:root {
  --bg: #04121f;
  --text: #071a33;
  --muted: #4a5878;
  --accent: #19b5ff;
  --accent-2: #6fdcff;
  --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%, #12395e 0%, #071d33 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: drop-shadow(0 0 6px rgba(25,181,255,.6)); }
.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(62%) sepia(83%) saturate(2400%) hue-rotate(172deg) 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: #0a8fd6;
  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(4,18,31,.35), rgba(4,18,31,.85)),
    repeating-linear-gradient(90deg, rgba(255,255,255,.03) 0 2px, transparent 2px 120px),
    radial-gradient(ellipse at center, #dfeef8 0%, #9cc3dd 38%, #2a5578 75%, #0b2238 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.stage::before, .stage::after {
  content: "";
  position: absolute;
  top: 0; bottom: 0;
  width: 6px;
  background: rgba(227,38,47,.75);
  left: 50%;
  transform: translateX(-50%);
  pointer-events: none;
}
.stage::after { width: 160px; height: 160px; top: 50%; border-radius: 50%; background: transparent; border: 4px solid rgba(25,120,220,.45); transform: translate(-50%, -50%); }
.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 .abbr { font-size: 12px; opacity: .85; font-weight: 700; }
.team-block .pct {
  width: 50px; height: 50px; border-radius: 50%; border: 3px solid var(--accent);
  display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 800;
  background: rgba(0,0,0,.45);
}
.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-table { width: min(640px, 100%); display: flex; flex-direction: column; gap: 3px; }
.ft-row {
  display: grid; grid-template-columns: 26px 1fr 70px 1fr minmax(0, 1.3fr); align-items: center; gap: 8px;
  background: #0d2740; padding: 4px 8px; border-radius: 2px; font-weight: 700; font-size: 14px;
  font-family: "Roboto Condensed", sans-serif;
}
.ft-row:nth-child(odd) { background: #10304e; }
.ft-row.mine { outline: 1px solid var(--accent); }
.ft-row .num { color: #8fb4d4; font-size: 12px; }
.ft-row .team { display: flex; align-items: center; gap: 6px; opacity: .75; }
.ft-row .team.home { justify-content: flex-end; }
.ft-row .team.w { opacity: 1; color: #ffe066; }
.ft-row .team img { width: 20px; height: 20px; }
.ft-row .score { text-align: center; background: #fff; color: var(--text); border-radius: 2px; font-weight: 900; }
.ft-row .bets { display: flex; flex-wrap: wrap; gap: 3px; justify-content: flex-end; }
.ft-row .tag { font-size: 10px; padding: 1px 6px; border-radius: 8px; white-space: nowrap; }
.ft-row .tag.won { background: var(--win); }
.ft-row .tag.lost { background: var(--danger); }

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

.markets { background: #c9d7e8; padding: 8px 10px 12px; max-height: 300px; overflow-y: auto; }
.markets-head {
  display: grid; grid-template-columns: minmax(120px, 150px) 1fr 1fr 1fr; gap: 6px;
  color: #fff; background: #0d2238; font-size: 12px; font-weight: 700; padding: 6px;
}
.markets-head span { text-align: center; }
.markets-head span:first-child { grid-column: 2; }
.market-row {
  display: grid; grid-template-columns: minmax(120px, 150px) 1fr 1fr 1fr; gap: 6px; align-items: center;
  background: #fff; margin-top: 4px; padding: 5px 6px; border-radius: 2px; cursor: pointer;
}
.market-row.active-match { outline: 2px solid var(--accent); }
.pair {
  display: flex; align-items: center; gap: 4px; color: var(--text); font-weight: 800; font-size: 12px;
  font-family: "Roboto Condensed", sans-serif; min-width: 0;
}
.pair img { height: 20px; width: 20px; object-fit: contain; flex: 0 0 auto; }
.pair .vs { font-size: 10px; opacity: .55; }
.pair .num {
  flex: 0 0 18px; height: 18px; border-radius: 50%; background: var(--red); color: #fff; font-size: 10px;
  display: flex; align-items: center; justify-content: center;
}
.odds { display: flex; gap: 4px; min-width: 0; }
.odd-btn {
  flex: 1 1 0; min-width: 0; border: 1px solid #d0d8e4; background: #f5f9ff; height: 40px; 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), #0a8fd6); 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, #0d2238, #163a5c); 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: #0a8fd6; 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(25,181,255,.45); box-shadow: 0 0 0 1px rgba(25,181,255,.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; }
  .team-block img { width: 64px; height: 64px; }
  .team-block .name { font-size: 13px; }
  .markets-head, .market-row { grid-template-columns: 96px 1fr 1fr 1fr; }
  .pair img { display: none; }
  .ft-row { grid-template-columns: 22px 1fr 56px 1fr; }
  .ft-row .bets { grid-column: 1 / -1; justify-content: flex-start; }
}
@media (max-width: 600px) {
  .clock, .help-btn { display: none; }
  .match-tab img { display: none; }
  .fulltime h2 { font-size: 22px; }
}
