:root {
  --bg: #0b1020;
  --text: #071a33;
  --muted: #4a5878;
  --accent: #ff7a1a;
  --accent-2: #ffb15c;
  --red: #e3262f;
  --red-2: #ff5a3c;
  --win: #00c166;
  --danger: #ea442e;
  --header: #03070d;
  --cyan: #7fe3ff;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  width: 100%;
  background: radial-gradient(ellipse at 50% 0%, #1d3a6e 0%, #101a36 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: 1280px;
  margin: 0 auto;
  position: relative;
}

/* ---------- top bar ---------- */

.topbar {
  height: 64px;
  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: 2px solid var(--accent);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand img.logo { height: 34px; width: 34px; filter: brightness(0) invert(1) drop-shadow(0 0 6px rgba(255,122,26,.7)); }
.brand .title {
  font-family: "Roboto Condensed", sans-serif;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 1px;
  font-style: italic;
}
.brand .sub {
  background: var(--red);
  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) saturate(100%) invert(58%) sepia(86%) saturate(2200%) hue-rotate(347deg) brightness(102%) contrast(101%);
}
.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: 12px;
  overflow: auto;
}
.main-col {
  grid-area: main;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: rgba(0,0,0,.25);
  border-radius: 4px;
  overflow: hidden;
}

.day-bar {
  height: 50px;
  background: #eef3f8;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  font-size: 18px;
  font-weight: 700;
  flex-shrink: 0;
}
.day-bar .phase-hint {
  font-size: 12px;
  font-weight: 700;
  color: #e0620a;
  text-transform: uppercase;
  letter-spacing: .3px;
}

.match-tabs-wrap { display: flex; align-items: center; gap: 6px; padding: 10px 8px; background: rgba(6,18,30,.7); }
.match-tabs-wrap .tab-nav {
  flex: 0 0 40px; height: 44px; border: 0; border-radius: 2px; background: #fff; color: var(--text);
  font-size: 28px; line-height: 1; cursor: pointer;
}
.match-tabs-wrap .tab-nav:disabled { opacity: .35; cursor: default; }
.match-tabs { display: flex; gap: 8px; flex: 1; min-width: 0; }
.match-tab {
  flex: 1; height: 44px; border: 0; border-radius: 2px; background: #fff; color: var(--text);
  display: flex; align-items: center; justify-content: center; gap: 7px; font-weight: 700;
  font-family: "Roboto Condensed", sans-serif; cursor: pointer; position: relative; min-width: 0;
}
.match-tab img { height: 24px; width: 24px; object-fit: contain; }
.match-tab .vs { font-size: 12px; opacity: .6; }
.match-tab .num { font-size: 11px; color: #fff; background: var(--red); border-radius: 50%; width: 18px; height: 18px; line-height: 18px; }
.match-tab.active { background: linear-gradient(90deg, var(--accent), var(--accent-2)); color: #021526; }
.match-tab .badge {
  position: absolute; top: -8px; right: 6px; background: #ffc700; color: #111; font-size: 10px;
  padding: 1px 6px; border-radius: 8px; font-weight: 800;
}

/* ---------- stage ---------- */

.stage {
  position: relative;
  flex: 0 0 auto;
  min-height: 340px;
  background:
    linear-gradient(180deg, rgba(8,14,30,.25), rgba(8,14,30,.8)),
    radial-gradient(ellipse at 50% 120%, #c4612a 0%, #6d3420 35%, transparent 70%),
    radial-gradient(ellipse at center, #2d63c8 0%, #1a3f8f 45%, #0d1f4a 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.stage::before, .stage::after {
  content: "";
  position: absolute;
  pointer-events: none;
}
.stage::before { top: 10%; bottom: 10%; left: 50%; width: 4px; transform: translateX(-50%); background: rgba(255,255,255,.55); }
.stage::after { left: 8%; right: 8%; top: 50%; height: 2px; transform: translateY(-50%); background: rgba(255,255,255,.35); }
.stage.broadcast { min-height: 0; aspect-ratio: 16 / 9; max-height: 62vh; }
.stage.broadcast::before, .stage.broadcast::after { display: none; }
.stage video {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; display: none; z-index: 1;
}
.stage.playing video { display: block; }

.live-badge {
  position: absolute; bottom: 12px; left: 12px; z-index: 5; display: none;
  background: var(--red); color: #fff; font-size: 12px; font-weight: 800; letter-spacing: 1px;
  padding: 4px 10px; border-radius: 2px; animation: pulse 1.4s ease-in-out infinite;
}
.stage.playing .live-badge { display: block; }
@keyframes pulse { 50% { opacity: .55; } }

.preview-board {
  position: relative;
  z-index: 2;
  width: min(680px, 94%);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 18px;
  align-items: center;
  text-align: center;
}
.preview-loading {
  grid-column: 1 / -1;
  font-size: 18px;
  font-weight: 700;
  text-shadow: 0 2px 8px rgba(0,0,0,.6);
}
.team-block { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.team-block img {
  width: 96px; height: 96px; object-fit: contain; border-radius: 50%;
  background: rgba(255,255,255,.15); padding: 6px;
  filter: drop-shadow(0 8px 18px rgba(0,0,0,.45));
}
.team-block .name {
  font-size: 17px; font-weight: 900; text-transform: uppercase; letter-spacing: .5px;
  text-shadow: 0 2px 8px rgba(0,0,0,.7);
}
.team-block .pct {
  font-size: 11px; font-weight: 800; letter-spacing: .5px; background: rgba(0,0,0,.5);
  padding: 3px 10px; border-radius: 10px; border: 1px solid var(--accent);
}
.avatar {
  position: relative; width: 96px; height: 96px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, rgba(255,255,255,.35), transparent 55%), var(--pc);
  border: 4px solid #fff; box-shadow: 0 8px 18px rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
}
.avatar .init { font-size: 44px; font-weight: 900; color: #fff; text-shadow: 0 2px 6px rgba(0,0,0,.45); }
.avatar .side {
  position: absolute; top: -6px; left: -6px; width: 28px; height: 28px; border-radius: 50%;
  background: #0b1020; border: 2px solid #fff; font-size: 13px; font-weight: 900;
  display: flex; align-items: center; justify-content: center;
}
.team-block .odd-pill {
  background: #fff; color: var(--text); font-weight: 900; font-size: 15px; padding: 3px 14px; border-radius: 12px;
}
.center-meta { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.center-meta .match-no {
  background: rgba(0,0,0,.55); padding: 4px 12px; border-radius: 2px; font-size: 12px; font-weight: 800; letter-spacing: 1px;
}
.center-meta .starts { font-size: 11px; font-weight: 700; opacity: .9; letter-spacing: 1px; text-shadow: 0 1px 4px #000; }
.countdown {
  background: #fff; color: var(--text); border-radius: 20px; padding: 6px 18px; font-weight: 900; font-size: 22px;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
}
.countdown.urgent { background: var(--red); color: #fff; animation: flicker 1s steps(1) infinite; }
@keyframes flicker { 50% { background: #fff; color: var(--red); } }
.ou-line {
  display: flex; gap: 8px; align-items: center; font-size: 12px; background: rgba(0,0,0,.5);
  padding: 4px 10px; border-radius: 2px; font-family: "Roboto Condensed", sans-serif;
}
.ou-line b { color: var(--accent-2); }

.fulltime {
  position: absolute; inset: 0; z-index: 8; display: none; flex-direction: column; align-items: center;
  justify-content: center; background: rgba(3,10,18,.78); backdrop-filter: blur(4px); gap: 12px; padding: 12px;
}
.fulltime.show { display: flex; }
.fulltime h2 {
  color: #fff; font-size: 30px; font-weight: 900; letter-spacing: 2px; font-style: italic;
  text-shadow: 0 2px 0 var(--red), 0 6px 14px rgba(227,38,47,.45);
}
.ft-body { display: flex; flex-direction: column; align-items: center; gap: 12px; width: min(560px, 100%); }
.ft-score { display: flex; align-items: center; justify-content: center; gap: 28px; }
.ft-player { display: flex; flex-direction: column; align-items: center; gap: 6px; opacity: .6; }
.ft-player.w { opacity: 1; }
.ft-player .avatar { width: 72px; height: 72px; }
.ft-player .avatar .init { font-size: 32px; }
.ft-player .name { font-weight: 900; font-size: 16px; text-transform: uppercase; }
.ft-player.w .name { color: #ffe066; }
.ft-score .score { font-size: 64px; font-weight: 900; letter-spacing: 2px; text-shadow: 0 4px 14px rgba(0,0,0,.6); }
.ft-winner { font-size: 22px; font-weight: 900; letter-spacing: 1px; color: var(--accent-2); text-transform: uppercase; }
.ft-bets { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.ft-bets .tag { font-size: 12px; padding: 3px 10px; 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: 18px; font-weight: 900; padding: 4px 16px; border-radius: 4px; }
.ft-total.won { background: var(--win); }
.ft-total.lost { background: rgba(234,68,46,.85); }

/* ---------- markets ---------- */

.markets {
  background: #c9d7e8; padding: 10px; display: grid; grid-template-columns: 1fr 2fr; gap: 10px;
}
.market-block { background: #fff; border-radius: 3px; overflow: hidden; }
.market-title {
  background: #10204a; color: #fff; font-size: 12px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .5px; padding: 7px 10px; text-align: center;
}
.odds { display: flex; gap: 6px; min-width: 0; padding: 8px; }
.odd-btn .lbl { font-weight: 900; color: var(--text); font-size: 12px; }
.odd-btn .who { font-size: 10px; opacity: .8; }
.odd-btn.selected .lbl { color: #fff; }
.odd-btn {
  flex: 1 1 0; min-width: 0; border: 1px solid #d0d8e4; background: #f5f9ff; height: 58px; border-radius: 5px;
  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:not(:disabled):hover { border-color: var(--accent); }
.odd-btn.selected { background: linear-gradient(180deg, var(--accent), #e0620a); color: #fff; border-color: transparent; }
.odd-btn.selected b { color: #fff; }
.odd-btn:disabled { opacity: .5; cursor: default; }

.panel-head {
  min-height: 46px; background: linear-gradient(90deg, #10204a, #1d3a6e); display: flex; align-items: center;
  padding: 0 14px; gap: 8px; font-size: 17px; font-weight: 500;
}
.panel-head .count {
  width: 21px; height: 21px; border-radius: 50%; background: var(--accent); color: #021526; font-size: 13px;
  font-weight: 800; display: flex; align-items: center; justify-content: center;
}
.matchday-bets { margin-top: 8px; background: #fff; border-radius: 2px; 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: #e0620a; 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;
  transition: box-shadow .35s ease, border-color .35s ease;
}
.ticket.has-bets { border-color: rgba(255,122,26,.45); box-shadow: 0 0 0 1px rgba(255,122,26,.15); }
.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:hover { background: rgba(255,255,255,.03); }
.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); 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); transition: transform .35s ease; 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 .45s cubic-bezier(.22,.61,.36,1); }
.ticket:not(.is-collapsed) .ticket-panel { grid-template-rows: 1fr; }
.ticket-panel-inner {
  overflow: hidden; min-height: 0; padding: 0 10px; opacity: 0; transform: translateY(-6px);
  transition: opacity .3s ease, transform .35s ease, padding .35s ease;
}
.ticket:not(.is-collapsed) .ticket-panel-inner { padding: 0 10px 10px; opacity: 1; transform: translateY(0); }
.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; min-height: 0; max-height: 0; transition: max-height .35s ease; position: relative; }
.ticket:not(.is-collapsed) .slip-body { max-height: 160px; min-height: 48px; }
.ticket.ticket--grow:not(.is-collapsed) .slip-body { max-height: 240px; }
.ticket.ticket--grow2:not(.is-collapsed) .slip-body { max-height: 320px; }
.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; position: relative; animation: slipIn .28s ease;
}
@keyframes slipIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }
.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: 32px; 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: 48px; border: 0; border-radius: 6px;
  background: linear-gradient(180deg, var(--red-2), var(--red)); color: #fff; font-size: 15px; font-weight: 800;
  text-transform: uppercase; letter-spacing: .04em; cursor: pointer;
}
.submit-btn:disabled { opacity: .5; cursor: default; }

.toast {
  position: fixed; top: 80px; 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 var(--accent);
}
.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: 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; }
  .avatar { width: 64px; height: 64px; }
  .avatar .init { font-size: 30px; }
  .team-block .name { font-size: 13px; }
  .markets { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .clock, .help-btn { display: none; }
  .fulltime h2 { font-size: 22px; }
  .ft-score { gap: 14px; }
  .ft-score .score { font-size: 40px; }
  .preview-board { gap: 8px; }
  .ou-line { font-size: 10px; }
}
