:root {
  --bg: #111216;
  --bg-2: #191b21;
  --panel: #1e2027;
  --panel-2: #282b34;
  --line: #3a3e4a;
  --text: #f6f6f8;
  --muted: #a6aab8;
  --accent: #f03445;
  --accent-2: #ff9099;
  --accent-deep: #a8182a;
  --accent-soft: #3d161b;
  --on-accent: #ffffff;
  --green: #3ccf7a;
  --red: #ff5c6c;
  --team-a: #1e5631;
  --team-a-accent: #f2a900;
  --team-b: #b9121b;
  --team-b-accent: #e8e8e8;
  --radius: 14px;
  --display: 'Bungee', 'Impact', system-ui, sans-serif;
  --body: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: radial-gradient(1200px 600px at 50% -10%, #5a121c 0%, var(--bg) 60%);
  color: var(--text);
  font-family: var(--body);
  line-height: 1.4;
  min-height: 100vh;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; }
input, select, textarea, a { touch-action: manipulation; }
a { color: var(--accent-2); }
h1, h2, h3 { margin: 0; }
.display { font-family: var(--display); letter-spacing: 0.02em; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.hidden { display: none !important; }

.wrap { max-width: 600px; margin: 0 auto; padding: 14px 14px 96px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 14px; }
.panel h2 { font-family: var(--display); font-size: 1.05rem; color: var(--accent); margin-bottom: 10px; }
.row { display: flex; gap: 10px; align-items: center; }
.row.between { justify-content: space-between; }
.stack { display: grid; gap: 10px; }

.btn {
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
  padding: 12px 16px; border-radius: 12px; font-weight: 600; min-height: 46px;
  transition: transform .05s ease, filter .15s ease;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.btn.danger { background: #4a1a22; border-color: #7a2a36; }
.btn.ghost { background: transparent; }
.btn.block { width: 100%; }
.btn.sm { padding: 7px 12px; min-height: 34px; font-size: .9rem; border-radius: 9px; }

.input {
  width: 100%; background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; min-height: 46px; outline: none;
}
.input:focus { border-color: var(--accent); }
label.field { display: grid; gap: 6px; font-size: .9rem; color: var(--muted); }

.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: .75rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; background: var(--panel-2); border: 1px solid var(--line); }
.badge.gold { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.badge.live { background: var(--red); color: #fff; border-color: var(--red); }
.badge.ok { background: #16423a; color: var(--green); border-color: #1f6a56; }

.toast {
  position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%);
  background: #2d1a1f; color: #fff; border: 1px solid var(--red); padding: 12px 16px; border-radius: 12px;
  max-width: 90vw; z-index: 50; box-shadow: 0 10px 30px rgba(0,0,0,.4); font-weight: 600;
}
.toast.ok { background: #16423a; border-color: var(--green); }

/* Header & matchup */
.hero { text-align: center; padding: 10px 0 6px; }
.hero .pub { color: var(--accent); font-weight: 700; letter-spacing: .14em; text-transform: uppercase; font-size: .78rem; }
.hero h1 { font-family: var(--display); font-size: clamp(1.7rem, 7vw, 2.4rem); line-height: 1; margin: 6px 0; }
.hero h1 span { color: var(--accent); }
.hero > .row.between { flex-wrap: wrap; justify-content: center; gap: 8px 12px; }
.hero > .row.between .btn { white-space: nowrap; }
.matchup { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: center; margin: 12px 0; }
.team-card { border-radius: var(--radius); padding: 12px 8px; text-align: center; border: 2px solid transparent; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.5); }
.team-card.a { background: linear-gradient(160deg, var(--team-a), color-mix(in srgb, var(--team-a) 60%, black)); }
.team-card.b { background: linear-gradient(160deg, var(--team-b), color-mix(in srgb, var(--team-b) 60%, black)); }
.team-card .key { font-family: var(--display); font-size: 1.6rem; line-height: 1; }
.team-card .name { font-size: .78rem; opacity: .9; }
.team-card .score { font-family: var(--display); font-size: 2.4rem; line-height: 1; margin-top: 4px; }
.vs { text-align: center; }
.vs .at { font-family: var(--display); color: var(--muted); font-size: .9rem; }
.vs .status { font-size: .8rem; color: var(--muted); margin-top: 4px; }
.countdown { font-family: var(--display); color: var(--accent); font-size: 1.1rem; }

/* Sponsor */
.sponsor { display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; }
.sponsor .sp-label { font-size: .72rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.sponsor .sp-link { display: inline-flex; align-items: center; gap: 7px; color: var(--text); text-decoration: none; font-family: 'Schibsted Grotesk', var(--body); font-weight: 800; font-size: 1.05rem; letter-spacing: -0.02em; }
.sponsor .sp-mark { width: 22px; height: 22px; flex: none; }
.sponsor .sp-tag { width: 100%; text-align: center; font-size: .78rem; color: var(--muted); }
.sponsor.lg .sp-link { font-size: 1.5rem; }
.sponsor.lg .sp-mark { width: 34px; height: 34px; }
.sponsor-strip { margin-top: 10px; padding: 8px 10px; border-radius: 10px; background: rgba(123,125,240,.08); border: 1px solid rgba(123,125,240,.25); }

/* Shouts */
.shout-fab { position: fixed; right: 14px; bottom: calc(84px + env(safe-area-inset-bottom)); width: 54px; height: 54px; border-radius: 50%; border: 2px solid var(--accent); background: var(--panel); font-size: 1.5rem; z-index: 25; box-shadow: 0 8px 24px rgba(0,0,0,.5); }
.sheet { position: fixed; inset: 0; background: rgba(5,8,18,.7); z-index: 45; display: flex; align-items: flex-end; }
.sheet-card { width: 100%; background: var(--panel); border-top: 1px solid var(--line); border-radius: 18px 18px 0 0; padding: 14px 14px calc(14px + env(safe-area-inset-bottom)); }
.shout-quick { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.shout-quick .btn { font-size: .9rem; padding: 10px 8px; min-height: 44px; }
.chat-form { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-top: 10px; }
.toast.shout { background: var(--panel-2); border-color: var(--accent); bottom: 150px; }
.toast.shout .who { color: var(--accent); font-size: .78rem; display: block; }

/* Budget */
.budget { position: sticky; top: 8px; z-index: 15; box-shadow: 0 8px 24px rgba(0,0,0,.45); margin: 12px 0 10px; padding: 12px 14px; border-radius: var(--radius); background: linear-gradient(135deg, var(--accent-soft), #1d0d10); border: 1px solid var(--accent); text-align: left; }
.budget .big { font-family: var(--display); font-size: 1.35rem; color: var(--accent); line-height: 1.1; }
.budget .big span { color: var(--text); }
.budget .hint { font-size: .85rem; color: var(--accent-2); margin-top: 4px; }
.budget .track { height: 8px; border-radius: 999px; background: rgba(0,0,0,.4); margin-top: 8px; overflow: hidden; }
.budget .fill { height: 100%; background: var(--accent); transition: width .3s ease; }
.budget.done { border-color: var(--green); background: linear-gradient(135deg, #16423a, #0f2a26); }
.budget.done .big, .budget.done .hint { color: var(--green); }
.budget.done .fill { background: var(--green); }
.wager-row { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: center; margin-top: 12px; }
.wager-row .lbl { font-weight: 700; }
.stake { font-size: .72rem; font-weight: 800; color: var(--accent); margin-left: 6px; }

/* Tabs */
.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; display: grid; grid-template-columns: repeat(4, 1fr);
  background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line); padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); z-index: 20;
}
.tabs button { background: var(--panel); border: 1px solid var(--line); color: var(--text); padding: 6px 2px 5px; margin: 0 3px; border-radius: 12px; font-size: .82rem; font-weight: 800; display: grid; gap: 1px; justify-items: center; }
.tabs button .n { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--panel-2); border: 1px solid var(--line); font-size: .85rem; line-height: 1; }
.tabs button .st { font-size: .68rem; font-weight: 700; color: var(--muted); min-height: .9em; }
.tabs button .st.todo { color: var(--accent-2); }
.tabs button .st.done { color: var(--green); }
.tabs button.active { border-color: var(--accent); background: var(--accent-soft); }
.tabs button.active .n { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }

.typo { background: var(--accent-soft); border: 1px solid var(--accent); border-radius: 12px; padding: 10px 12px; display: grid; gap: 8px; }
.typo .row { flex-wrap: wrap; }
.typo .btn { flex: 1; }

/* Plain-language instructions */
ul.how { margin: 0 0 10px; padding-left: 1.2em; display: grid; gap: 5px; }
ul.how li { line-height: 1.35; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--accent-2); text-decoration: underline; font-weight: 700; font-size: inherit; }
.step-h { font-weight: 800; font-size: 1.05rem; margin: 16px 0 8px; }
.step-h:first-of-type { margin-top: 4px; }
.chips { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.chips .btn { padding: 12px 0; font-size: 1.1rem; font-weight: 800; }
.chips .btn.selected { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.total-row { display: grid; grid-template-columns: 52px 52px 1fr 52px 52px; gap: 6px; align-items: center; }
.total-row .btn { padding: 12px 0; font-weight: 800; }
.total-row .val { text-align: center; font-family: var(--display); font-size: 2rem; line-height: 1; }
.total-row .val small { display: block; font-family: var(--body); font-size: .7rem; color: var(--muted); font-weight: 600; margin-top: 2px; }
.summary { background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; display: grid; gap: 4px; }
.summary .big { font-family: var(--display); font-size: 1.2rem; }
.budget .cta { margin-top: 10px; width: 100%; }
.gate { text-align: center; display: grid; gap: 10px; justify-items: center; padding: 22px 14px; }
.gate .emoji { font-size: 2.4rem; line-height: 1; }
.info-body { display: grid; gap: 10px; }
.info-body .lead { font-size: 1.05rem; font-weight: 700; }
.info-body .emoji { font-size: 2.6rem; line-height: 1; text-align: center; }
.dots { display: flex; gap: 6px; }
.dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.dots i.on { background: var(--accent); }
.mini { display: grid; grid-template-columns: repeat(6, 1fr); gap: 3px; max-width: 260px; margin: 0 auto; }
.mini div { aspect-ratio: 1; border-radius: 6px; background: var(--bg-2); border: 1px solid var(--line); display: grid; place-items: center; font-size: .7rem; font-weight: 800; position: relative; }
.mini .h { background: var(--panel-2); font-family: var(--display); font-size: .9rem; }
.mini .h.a { background: var(--team-a); color: #fff; } .mini .h.b { background: var(--team-b); color: #fff; }
.mini .c0 { background: transparent; border: 0; }
.mini .own { background: var(--panel-2); }
.mini .w { outline: 3px solid var(--green); outline-offset: -2px; }
.mini .near { outline: 2px dashed var(--accent); outline-offset: -2px; }
.mini .me { background: var(--accent); color: var(--on-accent); }

/* Winner pick */
.pick-teams { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pick-team { border-radius: var(--radius); padding: 18px 10px; border: 3px solid transparent; color: #fff; text-align: center; font-family: var(--display); font-size: 1.2rem; text-shadow: 0 1px 2px rgba(0,0,0,.5); opacity: .7; }
.pick-team.a { background: var(--team-a); }
.pick-team.b { background: var(--team-b); }
.pick-team.selected { opacity: 1; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(240,52,69,.3); }
.pick-team small { display: block; font-family: var(--body); font-size: .72rem; font-weight: 600; opacity: .9; }
.stepper { display: grid; grid-template-columns: 54px 1fr 54px; gap: 8px; }
.stepper input { text-align: center; font-family: var(--display); font-size: 1.5rem; }
.split { height: 14px; border-radius: 999px; overflow: hidden; display: flex; background: var(--bg-2); border: 1px solid var(--line); }
.split .a { background: var(--team-a); } .split .b { background: var(--team-b); }
.split-labels { display: flex; justify-content: space-between; font-size: .8rem; margin-top: 4px; }

/* Squares grid */
.grid-wrap { overflow-x: auto; }
.grid { display: grid; grid-template-columns: 22px repeat(10, 1fr); gap: 3px; min-width: 0; }
.grid .cell {
  aspect-ratio: 1; border-radius: 6px; background: var(--bg-2); border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center; font-size: .62rem; font-weight: 800;
  overflow: hidden; padding: 0; color: var(--text); position: relative;
}
.grid .cell.taken { background: var(--panel-2); color: #dfe2ea; }
.grid .cell.mine { background: var(--accent); color: var(--on-accent); border-color: var(--accent-2); }
.grid .cell.win { outline: 3px solid var(--green); outline-offset: -2px; }
.grid .cell.hot { box-shadow: 0 0 0 2px var(--green), 0 0 14px var(--green); animation: hot 1.2s ease-in-out infinite; z-index: 1; }
@keyframes hot { 0%, 100% { box-shadow: 0 0 0 2px var(--green), 0 0 6px var(--green); } 50% { box-shadow: 0 0 0 3px var(--green-2, #7ff0b0), 0 0 18px var(--green); } }
.grid .cell.win::after { content: attr(data-win); position: absolute; top: -1px; right: 1px; font-size: .5rem; color: var(--green); }
.grid .cell.near { outline: 2px dashed var(--accent); outline-offset: -2px; }
.grid .cell.near::before { content: '?'; position: absolute; top: -1px; left: 2px; font-size: .55rem; font-weight: 900; color: var(--accent); }
.near-line { color: var(--accent); }
.grid .hdr { aspect-ratio: auto; min-height: 22px; background: transparent; border: 0; font-family: var(--display); font-size: .9rem; }
.grid .hdr.a { color: var(--team-a-accent); background: var(--team-a); border-radius: 6px; }
.grid .hdr.b { color: var(--team-b-accent); background: var(--team-b); border-radius: 6px; }
.grid .corner { background: transparent; border: 0; }
.axis-label { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
.axis-label.a { color: var(--team-a-accent); } .axis-label.b { color: var(--team-b-accent); }
.axis-side { writing-mode: vertical-rl; transform: rotate(180deg); text-align: center; }
.grid-layout { display: grid; grid-template-columns: 16px 1fr; gap: 4px; align-items: stretch; }

/* Props */
.prop { border-top: 1px solid var(--line); padding: 12px 0; }
.prop:first-of-type { border-top: 0; padding-top: 0; }
.prop .q { font-weight: 700; margin-bottom: 8px; display: flex; justify-content: space-between; gap: 8px; }
.opts { display: grid; gap: 6px; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
.opt { position: relative; text-align: left; overflow: hidden; }
.opt.selected { border-color: var(--accent); background: var(--accent-soft); }
.opt.selected { box-shadow: inset 4px 0 0 var(--accent); }
.inbadge { display: inline-block; background: var(--green); color: #06251b; font-weight: 900; font-size: .72rem; letter-spacing: .04em; padding: 3px 8px; border-radius: 999px; }
.opt.correct { border-color: var(--green); background: #16423a; }
.opt.wrong { border-color: var(--red); background: #3a1a1f; }
.opt .pct { float: right; color: var(--muted); font-weight: 600; }
.opt .bar { position: absolute; left: 0; bottom: 0; height: 3px; background: var(--accent); opacity: .8; }

/* Leaderboard */
table.lb { width: 100%; border-collapse: collapse; }
table.lb th, table.lb td { padding: 8px 5px; text-align: left; border-bottom: 1px solid var(--line); }
table.lb th { color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; }
table.lb td.num, table.lb th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.lb tr.me td { background: var(--accent-soft); }
table.lb .rank { font-family: var(--display); color: var(--accent); width: 36px; }
.payout-list { display: grid; gap: 6px; }
.payout { display: flex; justify-content: space-between; gap: 8px; padding: 8px 10px; border-radius: 10px; background: var(--bg-2); border: 1px solid var(--line); }
.payout .who { font-weight: 700; }
.payout.pending { opacity: .8; }

/* Overlay */
.overlay { position: fixed; inset: 0; background: rgba(8,8,10,.92); display: flex; padding: max(12px, env(safe-area-inset-top)) 14px calc(env(safe-area-inset-bottom) + 110px); z-index: 40; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
/* margin:auto centres the card when it fits and lets the overlay scroll from the top when it does not */
.overlay .card { width: 100%; max-width: 420px; margin: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 18px; }
html:has(.overlay:not(.hidden)), html:has(.sheet:not(.hidden)), body:has(.overlay:not(.hidden)), body:has(.sheet:not(.hidden)) { overflow: hidden; }
@media (max-height: 700px) { .overlay .card { padding: 14px; } .overlay .card.stack { gap: 8px; } .overlay ul.how { gap: 3px; margin-bottom: 6px; } }

/* Check-your-email overlay and help popup */
.sent-to { display: flex; flex-wrap: wrap; justify-content: center; align-items: baseline; gap: 4px 10px; word-break: break-all; }
.sent-to strong { font-size: 1.05rem; }
.sent-to .linkbtn { font-size: .85rem; white-space: nowrap; }
.resend-note { background: var(--accent-soft); border: 1px solid var(--accent-deep); border-radius: 10px; padding: 8px 12px; font-size: .9rem; font-weight: 600; }
.resend-note.ok { background: #16423a; border-color: #1f6a56; color: var(--green); }
.btn:disabled { opacity: .6; cursor: default; }
#info { padding-bottom: max(14px, env(safe-area-inset-bottom)); }
#info .card { display: flex; flex-direction: column; gap: 12px; max-height: calc(100vh - 28px); max-height: calc(100dvh - 28px); overflow: hidden; }
#info .info-body { overflow-y: auto; -webkit-overflow-scrolling: touch; min-height: 0; flex: 1 1 auto; align-content: start; }
#info .card > .row { flex: none; }

/* Connection lost banner (phone) */
.conn-bar { position: fixed; top: 0; left: 0; right: 0; z-index: 60; padding: max(4px, env(safe-area-inset-top)) 12px 4px; text-align: center; font-size: .8rem; font-weight: 700; background: var(--accent-deep); color: #fff; pointer-events: none; }
