:root {
  --bg: #0a1626;
  --text: #071a33;
  --muted: #4a5878;
  --accent: #6cc4ff;
  --accent-2: #ffd34d;
  --red: #e3262f;
  --red-2: #ff5a3c;
  --win: #00c166;
  --danger: #ea442e;
  --header: #03070d;
  --cyan: #7fe3ff;
  --panel: #133a63;
  --panel-2: #0e2c4d;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  width: 100%;
  background: radial-gradient(ellipse at 50% 0%, #2a5d8f 0%, #14304f 45%, var(--bg) 100%) fixed;
  font-family: "Roboto", "Segoe UI", sans-serif;
  color: #fff;
  overflow: hidden;
  user-select: none;
}

#app { display: flex; flex-direction: column; height: 100%; max-width: 1320px; margin: 0 auto; position: relative; }

/* ---------- top bar ---------- */

.topbar {
  height: 60px; background: var(--header); display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px; flex-shrink: 0; position: relative; z-index: 100; border-bottom: 3px solid;
  border-image: linear-gradient(90deg, #74acdf 0 33%, #fff 33% 66%, #74acdf 66%) 1;
}
.brand { display: flex; align-items: center; gap: 10px; }
.ball-logo {
  width: 30px; height: 30px; border-radius: 50%;
  background: radial-gradient(circle at 50% 50%, #111 0 18%, transparent 19%), radial-gradient(circle at 50% 50%, #fff 0 100%);
  box-shadow: 0 0 0 2px #74acdf, 0 0 10px rgba(116,172,223,.7);
}
.brand .title { font-family: "Roboto Condensed", sans-serif; font-size: 20px; font-weight: 700; letter-spacing: 1px; font-style: italic; }
.brand .sub { background: #74acdf; color: #fff; font-size: 10px; font-weight: 700; padding: 2px 6px; border-radius: 2px; text-transform: uppercase; }
.top-right { display: flex; align-items: center; gap: 14px; font-weight: 700; position: relative; z-index: 110; }
.clock { font-size: 12px; opacity: .9; }
.balance { font-size: 14px; letter-spacing: .2px; color: var(--accent-2); }
.exit-btn {
  border: 0; background: var(--red); color: #fff; font-size: 12px; font-weight: 700; letter-spacing: .4px;
  padding: 8px 14px; border-radius: 2px; cursor: pointer; text-transform: uppercase;
}
.exit-btn:hover { background: var(--red-2); }
.help-btn {
  width: 34px; height: 34px; padding: 0; border: 0; background: transparent;
  display: flex; align-items: center; justify-content: center; border-radius: 50%; cursor: pointer;
}
.help-btn img { width: 26px; height: 26px; display: block; filter: brightness(0) invert(1); }
.help-btn:hover { opacity: .85; }

.lang-switch { position: relative; z-index: 120; }
.lang-btn { display: flex; align-items: center; gap: 6px; padding: 4px 8px; border: 0; border-radius: 6px; background: #102233; color: #fff; cursor: pointer; }
.lang-btn img { width: 22px; height: 16px; object-fit: cover; border-radius: 2px; }
.lang-btn #lang-code { font-size: 12px; font-weight: 700; }
.lang-menu {
  position: absolute; right: 0; top: calc(100% + 6px); max-height: 280px; overflow: auto; min-width: 180px;
  background: #0f1d2b; border: 1px solid #23384d; border-radius: 8px; box-shadow: 0 12px 28px rgba(0,0,0,.45); z-index: 130;
}
.lang-menu.hide { display: none; }
.lang-item { width: 100%; display: flex; align-items: center; gap: 8px; padding: 8px 10px; text-align: left; border: 0; background: transparent; color: #fff; cursor: pointer; font-size: 12px; }
.lang-item:hover, .lang-item.on { background: #1a3046; }
.lang-item img { width: 22px; height: 16px; object-fit: cover; }

/* ---------- modals ---------- */

.help-modal { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,.7); padding: 16px; }
.help-modal.hide { display: none; }
.help-modal-card {
  width: min(720px, 100%); max-height: min(86vh, 760px); display: flex; flex-direction: column;
  background: #14263a; border-radius: 10px; box-shadow: 0 20px 50px rgba(0,0,0,.55); overflow: hidden; color: #fff;
}
.help-modal-head { display: flex; align-items: center; justify-content: center; position: relative; padding: 14px; border-bottom: 1px solid #2a4058; }
.help-modal-head h2 { margin: 0; font-size: 16px; }
.help-close { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); font-size: 22px; width: 32px; height: 32px; border: 0; background: transparent; color: #fff; cursor: pointer; }
.help-modal-body { padding: 14px 16px; overflow: auto; flex: 1; font-size: 14px; line-height: 1.45; color: #e8eef5; }
.help-modal-body p { margin: 0 0 12px; }
.stats-footer { padding: 10px 16px; border-top: 1px solid #2a4058; }
.stats-clear { background: #1f3a55; border: 0; color: #fff; padding: 8px 12px; border-radius: 6px; font-weight: 700; cursor: pointer; }
.stats-row { padding: 8px 0; border-bottom: 1px solid #2a4058; font-size: 13px; }
.stats-row .sub { opacity: .75; font-size: 12px; margin-top: 2px; }

/* ---------- layout ---------- */

.layout {
  flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) 290px; grid-template-areas: "main slip";
  align-items: start; gap: 10px; min-height: 0; padding: 10px; overflow: auto;
}
.main-col { grid-area: main; display: flex; flex-direction: column; gap: 8px; min-width: 0; }

.tlogo { width: 26px; height: 26px; object-fit: contain; flex: 0 0 auto; }
.tlogo.sm { width: 20px; height: 20px; }
.tlogo.lg { width: 84px; height: 84px; filter: drop-shadow(0 6px 14px rgba(0,0,0,.5)); }

/* ---------- live: video + board ---------- */

.live-wrap { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); background: #0b2340; border-radius: 4px; overflow: hidden; }

.stage {
  position: relative; aspect-ratio: 16 / 9; background:
    linear-gradient(180deg, rgba(4,20,8,.25), rgba(4,20,8,.85)),
    repeating-linear-gradient(90deg, rgba(255,255,255,.05) 0 40px, transparent 40px 80px),
    radial-gradient(ellipse at center, #2f7d3a 0%, #1b5226 55%, #0b2a12 100%);
  overflow: hidden; display: flex; align-items: center; justify-content: center;
}
.stage video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #000; display: none; z-index: 1; }
.stage.playing video { display: block; }
.stage.novideo video { display: none; }

.scorebug {
  position: absolute; top: 8px; left: 8px; z-index: 4; display: none; align-items: center; gap: 6px;
  background: rgba(20,24,30,.85); padding: 4px 8px; border-radius: 3px; font-family: "Roboto Condensed", sans-serif; font-size: 15px;
}
.stage.playing .scorebug:not(:empty) { display: flex; }
.scorebug .sb-score { font-weight: 900; font-size: 17px; padding: 0 4px; }
.scorebug .sb-min { background: var(--red); padding: 2px 6px; margin-left: 4px; border-radius: 2px; font-size: 13px; }

.goal-flash {
  position: absolute; left: 0; right: 0; top: 38%; z-index: 4; text-align: center; pointer-events: none; opacity: 0;
  font-size: 64px; font-weight: 900; font-style: italic; letter-spacing: 4px; color: #fff; text-shadow: 0 4px 18px rgba(0,0,0,.7);
}
.goal-flash.show { animation: goal 2.6s ease; }
@keyframes goal { 0% { opacity: 0; transform: scale(.6); } 15% { opacity: 1; transform: scale(1.05); } 80% { opacity: 1; } 100% { opacity: 0; transform: scale(1); } }

.preview-board {
  position: relative; z-index: 3; display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: center;
  width: 94%; text-align: center; background: rgba(4,12,24,.55); border-radius: 6px; padding: 14px 10px;
}
.stage.playing .preview-board { display: none; }
.preview-loading { grid-column: 1 / -1; font-size: 16px; font-weight: 700; }
.pv-team { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.pv-team .nm { font-size: 14px; font-weight: 900; text-transform: uppercase; text-shadow: 0 2px 6px #000; }
.preview-board .od { font-size: 12px; font-weight: 800; background: #fff; color: var(--text); padding: 2px 10px; border-radius: 10px; }
.pv-mid { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.pv-league { font-size: 11px; font-weight: 700; opacity: .9; line-height: 1.3; }
.starts { font-size: 11px; font-weight: 700; letter-spacing: 1px; opacity: .9; }
.countdown { background: rgba(0,0,0,.6); border: 1px solid rgba(255,255,255,.3); border-radius: 6px; padding: 4px 14px; font-weight: 900; font-size: 26px; }
.countdown.urgent { background: var(--red); animation: flicker 1s steps(1) infinite; }
@keyframes flicker { 50% { background: #fff; color: var(--red); } }

.stage-bar {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
  padding: 6px 8px; background: linear-gradient(0deg, rgba(0,0,0,.75), transparent);
}
.stage-bar select {
  background: rgba(0,0,0,.6); color: #fff; border: 1px solid rgba(255,255,255,.3); border-radius: 3px; padding: 3px 6px;
  font-weight: 700; font-size: 13px; cursor: pointer;
}
.stage-bar select option { background: #0e2c4d; }
.live-badge { display: none; background: var(--red); color: #fff; font-size: 11px; font-weight: 800; letter-spacing: 1px; padding: 3px 8px; border-radius: 2px; animation: pulse 1.4s ease-in-out infinite; }
.stage.playing .live-badge { display: block; }
@keyframes pulse { 50% { opacity: .55; } }

.board { display: flex; flex-direction: column; min-width: 0; background: var(--panel-2); }
.board-head { display: flex; align-items: center; gap: 10px; height: 34px; background: var(--panel); padding-right: 10px; flex-shrink: 0; }
.board-live { background: #7a1b20; color: #fff; font-size: 12px; font-weight: 800; padding: 0 14px; height: 100%; display: flex; align-items: center; opacity: .55; }
.board-live.on { background: var(--red); opacity: 1; }
.board-title { font-size: 13px; font-weight: 700; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.phase-hint { font-size: 11px; font-weight: 700; color: var(--accent-2); text-transform: uppercase; white-space: nowrap; }
.board-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; padding: 2px; flex: 1; align-content: stretch; }
.brow {
  display: grid; grid-template-columns: 20px 20px minmax(0, 1fr) auto minmax(0, 1fr) 20px 30px; align-items: center; gap: 5px;
  background: #16406b; padding: 3px 6px; font-family: "Roboto Condensed", sans-serif; font-size: 13px; cursor: pointer; min-height: 28px;
  transition: background .3s;
}
.brow:hover { background: #1d4f82; }
.brow.feat { background: #3a2c5e; box-shadow: inset 3px 0 0 var(--accent-2); }
.brow.flash { background: #1c7a3c; }
.bno { font-size: 11px; opacity: .7; text-align: center; }
.bteam { font-weight: 700; text-align: center; }
.bscore { font-weight: 900; font-size: 14px; white-space: nowrap; }
.bmin { font-size: 11px; color: var(--accent-2); text-align: right; }

/* ---------- markets ---------- */

.markets-wrap { background: var(--panel-2); border-radius: 4px; overflow: hidden; }
.markets-head { font-size: 14px; font-weight: 700; padding: 10px 12px 6px; }
.market-tabs { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; padding: 0 10px 10px; }
.mtab { height: 34px; border: 0; border-radius: 3px; background: #0b2340; color: #cfe3f7; font-size: 13px; cursor: pointer; }
.mtab.on { background: #b9dcf5; color: var(--text); font-weight: 700; }
.markets { background: #e9f0f8; color: var(--text); }
.mrow { display: grid; align-items: center; gap: 6px; padding: 4px 10px; border-top: 1px solid #d5dfeb; }
.mrow.cols3 { grid-template-columns: 22px minmax(0, 1fr) repeat(3, 82px); }
.mrow.cols6 { grid-template-columns: 22px minmax(0, 1fr) repeat(6, 74px); }
.mrow.mhead { background: var(--panel); color: #fff; font-size: 12px; font-weight: 700; border-top: 0; padding: 7px 10px; }
.mrow.mhead span:nth-child(n+3) { text-align: center; font-size: 11px; }
.mrow:nth-child(odd):not(.mhead) { background: #f5f8fc; }
.mrow.feat { box-shadow: inset 3px 0 0 #6a4fd0; }
.mno { font-size: 12px; color: var(--muted); text-align: center; }
.mteams { display: flex; align-items: center; gap: 6px; min-width: 0; cursor: pointer; font-size: 13px; }
.mteams b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mteams i { font-style: normal; color: var(--muted); }
.mteams:hover b { text-decoration: underline; }

.odd-btn {
  min-width: 0; border: 1px solid #d0d8e4; background: #fff; height: 34px; border-radius: 4px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--muted); font-size: 11px;
  padding: 2px 4px; white-space: nowrap; overflow: hidden;
}
.odd-btn b { color: var(--text); font-size: 14px; }
.odd-btn .lbl { font-weight: 700; color: var(--muted); font-size: 11px; }
.odd-btn:not(:disabled):hover { border-color: #3a7bd5; }
.odd-btn.selected { background: linear-gradient(180deg, #2f7be0, #1957b0); border-color: transparent; }
.odd-btn.selected b, .odd-btn.selected .lbl { color: #fff; }
.odd-btn:disabled { opacity: .55; cursor: default; }

.cs-head { display: flex; align-items: center; gap: 8px; padding: 10px; flex-wrap: wrap; font-size: 14px; }
.cs-head select { margin-left: auto; padding: 4px 6px; border-radius: 3px; border: 1px solid #b8c6d8; font-weight: 700; }
.cs-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; padding: 0 10px 10px; }
.cs-grid .odd-btn { height: 46px; }
.cs-grid .odd-btn:last-child { grid-column: 1 / -1; }

/* ---------- full time ---------- */

.fulltime {
  position: absolute; inset: 0; z-index: 8; display: none; flex-direction: column; align-items: center; justify-content: safe center;
  background: rgba(3,10,18,.86); gap: 6px; padding: 6px; overflow: auto;
}
.fulltime.show { display: flex; }
.fulltime.won { background: radial-gradient(ellipse at center, rgba(10,90,40,.9), rgba(2,16,8,.94)); }
.fulltime h2 { font-size: 20px; font-weight: 900; letter-spacing: 2px; font-style: italic; }
.ft-body { display: flex; flex-direction: column; align-items: center; gap: 8px; width: 100%; }
.ft-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 10px; width: 100%; max-width: 560px; }
.ft-row { display: grid; grid-template-columns: 20px 1fr auto 1fr 20px; align-items: center; gap: 5px; font-family: "Roboto Condensed", sans-serif; font-size: 13px; padding: 1px 4px; border-radius: 2px; }
.ft-row span { text-align: center; }
.ft-row b { font-weight: 900; }
.ft-row.mine { background: rgba(255,211,77,.22); }
.ft-bets { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; }
.ft-bets .tag { font-size: 11px; padding: 2px 8px; border-radius: 10px; white-space: nowrap; font-weight: 700; }
.ft-bets .tag.won { background: var(--win); }
.ft-bets .tag.lost { background: var(--danger); }
.ft-total { font-size: 16px; font-weight: 900; padding: 3px 14px; border-radius: 4px; }
.ft-total.won { background: var(--win); }
.ft-total.lost { background: rgba(234,68,46,.85); }

/* ---------- my bets ---------- */

.panel-head { min-height: 42px; background: linear-gradient(90deg, var(--panel), #1d4f82); display: flex; align-items: center; padding: 0 14px; gap: 8px; font-size: 16px; font-weight: 500; }
.panel-head .count { width: 21px; height: 21px; border-radius: 50%; background: var(--accent-2); color: #021526; font-size: 13px; font-weight: 800; display: flex; align-items: center; justify-content: center; }
.matchday-bets { background: #fff; border-radius: 4px; overflow: hidden; }
.md-list { max-height: 140px; overflow: auto; color: var(--text); }
.md-item { padding: 10px 12px; border-top: 1px solid #dfe3ea; display: flex; justify-content: space-between; gap: 8px; font-size: 13px; }
.md-item .right { text-align: right; color: #1957b0; font-weight: 700; }
.md-item.won .right { color: var(--win); }
.md-item.lost .right { color: var(--danger); }

/* ---------- order ticket ---------- */

.ticket {
  grid-area: slip; background: #0c1824; border: 1px solid rgba(255,255,255,.12); border-radius: 8px;
  display: flex; flex-direction: column; align-self: start; overflow: hidden; color: #fff;
}
.ticket.has-bets { border-color: rgba(108,196,255,.5); }
.ticket-toggle { width: 100%; display: flex; align-items: center; gap: 8px; padding: 12px; text-align: left; background: transparent; border: 0; cursor: pointer; color: inherit; }
.ticket-toggle h2 { margin: 0; font-size: 14px; letter-spacing: .04em; flex: 1; font-weight: 700; }
.ticket-count { min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; background: var(--accent-2); color: #021526; font-size: 12px; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; }
.ticket-count.hide { display: none; }
.ticket-chevron { width: 10px; height: 10px; border-right: 2px solid #9ab; border-bottom: 2px solid #9ab; transform: rotate(45deg); margin-top: -4px; flex-shrink: 0; }
.ticket:not(.is-collapsed) .ticket-chevron { transform: rotate(225deg); margin-top: 4px; }
.ticket-panel { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .4s ease; }
.ticket:not(.is-collapsed) .ticket-panel { grid-template-rows: 1fr; }
.ticket-panel-inner { overflow: hidden; min-height: 0; padding: 0 10px; }
.ticket:not(.is-collapsed) .ticket-panel-inner { padding: 0 10px 10px; }
.ticket-tools { display: flex; justify-content: flex-end; margin-bottom: 6px; }
.linkish { background: none; border: 0; color: var(--cyan); font-size: 12px; cursor: pointer; padding: 0; }
.stake-row { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; font-size: 12px; font-weight: 700; color: #9aaabf; }
.stake-row input { width: 72px; text-align: center; background: #06101a; border: 1px solid rgba(255,255,255,.15); color: #fff; border-radius: 4px; padding: 6px; }
.stake-row button { width: 28px; height: 28px; background: #1c344c; border: 0; border-radius: 4px; color: #fff; cursor: pointer; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.chips button { min-width: 44px; height: 32px; padding: 0 8px; background: #142a3e; border: 1px solid transparent; border-radius: 999px; color: #fff; font-weight: 700; font-size: 12px; cursor: pointer; }
.chips button.active { background: #0b3552; border-color: var(--accent); }
.slip-body { overflow: auto; max-height: 200px; min-height: 48px; }
.ticket.ticket--grow .slip-body { max-height: 300px; }
.slip-empty { color: var(--cyan); font-size: 13px; padding: 12px 4px; }
.slip-item { background: #132536; border: 1px solid rgba(255,255,255,.08); border-radius: 6px; padding: 8px; margin-bottom: 6px; font-size: 12px; }
.slip-item .meta { font-size: 11px; color: #9aaabf; margin-bottom: 4px; }
.slip-item .sel { font-size: 13px; font-weight: 600; display: flex; justify-content: space-between; gap: 8px; }
.slip-item .est { color: var(--accent-2); font-size: 11px; text-align: right; margin-top: 4px; }
.slip-item input { width: 78px; height: 30px; border: 1px solid rgba(255,255,255,.2); border-radius: 2px; text-align: right; padding: 0 6px; font-weight: 700; margin-top: 6px; background: #06101a; color: #fff; }
.slip-item .remove { float: right; border: 0; background: transparent; color: #9aaabf; cursor: pointer; font-size: 16px; }
.ticket-totals { border-top: 1px solid rgba(255,255,255,.12); padding-top: 8px; margin-top: 6px; display: flex; flex-direction: column; gap: 4px; font-size: 12px; }
.ticket-totals strong { float: right; color: var(--accent-2); font-size: 15px; font-weight: 800; }
.submit-btn {
  width: 100%; margin-top: 10px; height: 46px; border: 0; border-radius: 6px; background: linear-gradient(180deg, #3b8cf0, #1957b0);
  color: #fff; font-size: 15px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; cursor: pointer;
}
.submit-btn:disabled { opacity: .5; cursor: default; }

.last-results { border-top: 1px solid rgba(255,255,255,.12); padding: 10px; }
.lr-head { font-size: 12px; font-weight: 800; letter-spacing: .5px; color: #9aaabf; margin-bottom: 6px; }
.lr-empty { font-size: 12px; color: var(--cyan); }
.lr-row { display: flex; flex-direction: column; gap: 2px; padding: 5px 0; border-bottom: 1px solid rgba(255,255,255,.06); font-size: 12px; }
.lr-no { color: var(--accent-2); font-weight: 800; }
.lr-res { display: grid; grid-template-columns: 1fr 1fr; gap: 1px 8px; font-family: "Roboto Condensed", sans-serif; }
.lr-res i { font-style: normal; opacity: .9; white-space: nowrap; }

.toast {
  position: fixed; top: 76px; right: 20px; background: rgba(255,255,255,.96); color: var(--text); padding: 12px 16px; border-radius: 4px;
  box-shadow: 0 8px 24px rgba(0,0,0,.2); z-index: 50; display: none; font-weight: 600; border-left: 4px solid #3b8cf0;
}
.toast.show { display: block; animation: slideIn .35s ease; }
@keyframes slideIn { from { opacity: 0; transform: translateY(-12px); } to { opacity: 1; transform: translateY(0); } }

@media (max-width: 1100px) {
  .live-wrap { grid-template-columns: 1fr; }
}
@media (max-width: 980px) {
  body { overflow: auto; }
  #app { height: auto; min-height: 100%; }
  .layout { grid-template-columns: 1fr; grid-template-areas: "main" "slip"; overflow: visible; }
  .brand .title { font-size: 15px; }
  .mrow.cols6 { grid-template-columns: 22px minmax(0, 1fr) repeat(6, 54px); }
}
@media (max-width: 640px) {
  .clock, .help-btn { display: none; }
  .market-tabs { grid-template-columns: repeat(3, 1fr); }
  .mrow.cols3 { grid-template-columns: 18px minmax(0, 1fr) repeat(3, 58px); }
  .mrow.cols6 { grid-template-columns: 1fr 1fr 1fr; }
  .mrow.cols6 .mno { display: none; }
  .mrow.cols6 .mteams, .mrow.cols6.mhead span:nth-child(2) { grid-column: 1 / -1; }
  .mteams b { font-size: 12px; }
  .board-grid { grid-template-columns: 1fr; }
  .tlogo.lg { width: 56px; height: 56px; }
  .ft-grid { grid-template-columns: 1fr; }
  .goal-flash { font-size: 40px; }
}
