:root {
  --bg: #07101f;
  --text: #0b1f3f;
  --muted: #4a5878;
  --navy: #14306b;
  --navy-2: #1f4796;
  --accent: #f5c542;
  --accent-2: #ffe08a;
  --red: #d6182a;
  --red-2: #ff3b4d;
  --win: #00b862;
  --danger: #e3402e;
  --header: #050b16;
  --cyan: #7fd8ff;
  --away: #c8202f;
  --home: #1f4fb4;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  width: 100%;
  background: radial-gradient(ellipse at 50% 0%, #1d3a76 0%, #0e1d3c 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: 3px solid var(--red);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand img.logo { height: 42px; width: 36px; filter: drop-shadow(0 0 6px rgba(214,24,42,.6)); }
.brand .title { font-family: "Roboto Condensed", sans-serif; font-size: 24px; font-weight: 700; letter-spacing: 2px; font-style: italic; }
.brand .sub { background: var(--navy-2); 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); }
.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); opacity: .85; }
.help-btn:hover img { opacity: 1; }

.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: #12233f; 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 #2a4068; }
.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 #2a4068; }
.stats-clear { background: #1f3a65; border: 0; color: #fff; padding: 8px 12px; border-radius: 6px; font-weight: 700; cursor: pointer; }
.stats-row { padding: 8px 0; border-bottom: 1px solid #2a4068; 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; padding: 0 10px; text-align: center;
}
.day-bar .phase-hint { font-size: 12px; font-weight: 700; color: var(--red); text-transform: uppercase; letter-spacing: .3px; }

/* ---------- stage ---------- */

.stage {
  position: relative; flex: 0 0 auto; aspect-ratio: 16 / 9; width: 100%; max-height: 62vh; max-width: calc(62vh * 16 / 9);
  margin: 0 auto; background: #0a1a12; display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.stage video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; display: none; z-index: 2; }
.stage.playing video { display: block; }
.stage .promo { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: 1; }
.stage.playing .promo { display: none; }

.live-badge {
  position: absolute; top: 3%; left: 50%; transform: translateX(-50%); z-index: 5; display: none;
  background: var(--red); color: #fff; font-size: 11px; font-weight: 800; letter-spacing: 1px;
  padding: 3px 10px; border-radius: 2px; animation: pulse 1.4s ease-in-out infinite;
}
.stage.playing .live-badge { display: block; }
@keyframes pulse { 50% { opacity: .55; } }

.live-strip {
  position: absolute; bottom: 2%; right: 1.5%; z-index: 5; display: none; gap: 8px; align-items: center;
  background: rgba(3,7,13,.8); border-left: 3px solid var(--red); padding: 4px 10px; border-radius: 2px;
  font-size: 12px; letter-spacing: .5px;
}
.live-strip img { width: 26px; height: 26px; object-fit: contain; }
.live-strip span { opacity: .8; }
.stage.playing .live-strip { display: flex; }

/* pre-match board, modelled on the provider's intro card */
.preview-board { position: relative; z-index: 3; width: 94%; display: flex; flex-direction: column; align-items: center; gap: 2.2%; }
.stage.playing .preview-board { display: none; }
.preview-loading { font-size: 18px; font-weight: 700; text-shadow: 0 2px 8px rgba(0,0,0,.6); padding: 40px 0; }
.pb-top { width: 100%; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; }
.pb-team { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.pb-team img { width: clamp(60px, 11vw, 120px); height: auto; filter: drop-shadow(0 10px 18px rgba(0,0,0,.55)); }
.pb-team.home img { transform: scaleX(-1); }
.pb-team .nm {
  background: var(--navy); border: 2px solid rgba(255,255,255,.85); padding: 3px 12px; border-radius: 4px;
  font: 700 clamp(13px, 2.2vw, 24px)/1.1 "Roboto Condensed", sans-serif; text-transform: uppercase; letter-spacing: .5px;
  box-shadow: 0 4px 12px rgba(0,0,0,.45); white-space: nowrap;
}
.pb-team .tag { font-size: 11px; font-weight: 800; letter-spacing: 2px; opacity: .85; text-shadow: 0 1px 3px #000; }
.pb-logo { width: clamp(64px, 12vw, 130px); filter: drop-shadow(0 8px 16px rgba(0,0,0,.5)); }
.pb-card {
  width: min(760px, 100%); background: #fff; color: var(--text); border-radius: 8px; padding: 8px 14px;
  display: grid; grid-template-columns: 1.2fr 1fr 1.2fr 1fr; align-items: center; row-gap: 2px;
  box-shadow: 0 10px 26px rgba(0,0,0,.45);
}
.pb-card .h { font: 700 clamp(12px, 1.8vw, 20px)/1.2 "Roboto Condensed", sans-serif; color: var(--navy); text-align: center; letter-spacing: .5px; }
.pb-card .c { text-align: center; font: 700 clamp(13px, 2vw, 22px)/1.25 "Roboto Condensed", sans-serif; white-space: nowrap; }
.pb-card .c small { font-size: .65em; color: var(--muted); margin-right: 6px; }
.pb-card .ab { text-align: left; display: flex; align-items: center; gap: 6px; font: 700 clamp(12px, 1.7vw, 18px)/1.2 "Roboto Condensed", sans-serif; }
.pb-card .ab img { width: 30px; height: 30px; object-fit: contain; }
.pb-bar {
  display: flex; align-items: center; gap: 18px; background: linear-gradient(180deg, #1c3b7c, #0e2252);
  padding: 4px 26px; border-radius: 0 0 10px 10px; font: 700 clamp(12px, 1.8vw, 20px)/1.3 "Roboto Condensed", sans-serif;
  box-shadow: 0 6px 14px rgba(0,0,0,.4); margin-top: -1.2%;
}
.pb-card { padding-bottom: 12px; }
.pb-bar .id { font-style: italic; opacity: .9; }
.pb-bar .cd { font-size: 1.5em; letter-spacing: 1px; min-width: 3.6em; text-align: center; }
.pb-bar .cd.urgent { color: #ff5a5a; animation: pulse 1s steps(1) infinite; }

/* ---------- result overlay ---------- */

.fulltime {
  position: absolute; inset: 0; z-index: 8; display: none; flex-direction: column; align-items: center;
  justify-content: center; background: rgba(3,10,24,.8); backdrop-filter: blur(4px); gap: 10px; padding: 12px;
}
.fulltime.show { display: flex; }
.fulltime.won { background: radial-gradient(ellipse at center, rgba(120,84,10,.9), rgba(20,12,2,.92)); }
.fulltime h2 { color: #fff; font-size: 28px; font-weight: 900; letter-spacing: 3px; font-style: italic; text-shadow: 0 2px 0 var(--red), 0 6px 14px rgba(214,24,42,.45); }
.ft-body { display: flex; flex-direction: column; align-items: center; gap: 10px; width: min(620px, 100%); }
.ft-score { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 18px; width: 100%; }
.ft-team { display: flex; flex-direction: column; align-items: center; gap: 4px; opacity: .65; }
.ft-team.w { opacity: 1; }
.ft-team img { width: 92px; }
.ft-team.home img { transform: scaleX(-1); }
.ft-team .nm { font: 700 16px/1.1 "Roboto Condensed", sans-serif; text-transform: uppercase; }
.ft-team.w .nm { color: var(--accent); }
.ft-score .score { font: 900 56px/1 "Roboto Condensed", sans-serif; letter-spacing: 2px; text-shadow: 0 4px 14px rgba(0,0,0,.6); white-space: nowrap; }
.ft-stats { border-collapse: collapse; background: rgba(0,0,0,.3); border-radius: 6px; overflow: hidden; font-size: 13px; }
.ft-stats th, .ft-stats td { padding: 3px 14px; text-align: center; }
.ft-stats th { font-size: 11px; opacity: .75; letter-spacing: 1px; font-weight: 700; }
.ft-stats td { font-weight: 800; }
.ft-lines { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; font-size: 12px; }
.ft-lines span { background: rgba(255,255,255,.12); padding: 3px 10px; border-radius: 10px; font-weight: 700; }
.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(227,64,46,.85); }

/* ---------- markets (spread / moneyline / total table) ---------- */

.markets { background: #e9eef5; color: var(--text); padding: 6px 12px 10px; }
.mk-row { display: grid; grid-template-columns: minmax(120px, 1.1fr) 1fr 1fr 1fr; gap: 10px; align-items: center; padding: 5px 0; }
.mk-head { font-size: 12px; font-weight: 700; color: var(--muted); letter-spacing: .5px; text-transform: uppercase; text-align: center; padding: 4px 0 2px; }
.mk-head .no { text-align: left; color: var(--text); }
.mk-team { display: flex; align-items: center; gap: 8px; font-weight: 700; min-width: 0; }
.mk-team img { width: 34px; height: 34px; object-fit: contain; flex: 0 0 auto; }
.mk-team .ab { font: 700 20px/1 "Roboto Condensed", sans-serif; }
.mk-team .nm { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mk-team.home img { transform: scaleX(-1); }
.mk-at { grid-column: 1; font-size: 12px; color: var(--muted); padding-left: 12px; margin: -4px 0; }
.odd-btn {
  height: 44px; border: 1px solid #c3cddb; background: #fff; border-radius: 4px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 16px; color: var(--text);
  font: 700 17px/1 "Roboto Condensed", sans-serif; padding: 0 8px; white-space: nowrap; min-width: 0;
}
.odd-btn .ln { color: var(--muted); }
.odd-btn:not(:disabled):hover { border-color: var(--navy-2); background: #fffbe0; }
.odd-btn.selected { background: #fff59a; border-color: #9bbd2a; box-shadow: inset 0 0 0 1px #9bbd2a; }
.odd-btn.selected .ln { color: var(--text); }
.odd-btn:disabled { opacity: .55; cursor: default; }
.odd-btn.won { background: #c9f5d9; border-color: var(--win); }

.panel-head {
  min-height: 46px; background: linear-gradient(90deg, var(--navy), var(--navy-2)); 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: var(--navy-2); font-weight: 700; }
.md-item.won .right { color: var(--win); }
.md-item.lost .right { color: var(--danger); }

/* ---------- order ticket ---------- */

.ticket {
  grid-area: slip; background: #0c1828; 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(245,197,66,.5); box-shadow: 0 0 0 1px rgba(245,197,66,.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: 260px; }
.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; }

.last-results { margin-top: 10px; 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; align-items: center; gap: 6px; padding: 4px 0; border-bottom: 1px solid rgba(255,255,255,.06); font-size: 12px; }
.lr-no { color: var(--accent); font-weight: 800; min-width: 40px; }
.lr-tm { display: flex; align-items: center; gap: 4px; flex: 1; justify-content: flex-end; font-weight: 700; }
.lr-tm.h { justify-content: flex-start; }
.lr-tm img { width: 20px; height: 20px; object-fit: contain; }
.lr-tm.h img { transform: scaleX(-1); }
.lr-tm.w { color: var(--accent); }
.lr-sc { font: 700 13px/1 "Roboto Condensed", sans-serif; background: rgba(255,255,255,.1); padding: 3px 6px; border-radius: 3px; white-space: nowrap; }

.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(--red);
}
.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; }
  .stage { max-height: none; max-width: none; }
}
@media (max-width: 720px) {
  .layout { padding: 6px; }
  .brand .title { font-size: 18px; }
  .brand .sub, .clock, .help-btn { display: none; }
  .day-bar { font-size: 14px; flex-direction: column; gap: 0; height: auto; padding: 6px; }
  .stage { aspect-ratio: auto; min-height: 300px; }
  .pb-card { padding: 6px 8px; grid-template-columns: 1fr 1fr 1.2fr 1fr; }
  .pb-card .ab img { display: none; }
  .pb-bar { gap: 10px; padding: 3px 14px; }
  .mk-row { grid-template-columns: 74px 1fr 1fr 1fr; gap: 5px; }
  .mk-team .nm { display: none; }
  .mk-team img { width: 26px; height: 26px; }
  .mk-team .ab { font-size: 16px; }
  .odd-btn { font-size: 14px; gap: 6px; height: 40px; padding: 0 4px; }
  .fulltime h2 { font-size: 20px; }
  .ft-team img { width: 56px; }
  .ft-score .score { font-size: 36px; }
  .ft-stats th, .ft-stats td { padding: 2px 6px; }
}
