/* Adrena: night arcade, softened. One dark theme on purpose. */
:root {
  --bg: #08080F;
  --board: #0F0F18;
  --panel: #161630;
  --line: #262650;
  --text: #FFFFFF;
  --muted: #94A3B8;
  --indigo: #4F46E5;
  --lav: #9E9EFF;
  --cyan: #00F2FE;
  --purple: #9D4EDD;
  --amber: #F59E0B;
  --green: #53FC18;
  --danger: #FF5C7A;
  --display: "Space Grotesk", "Avenir Next", "Segoe UI", Roboto, system-ui, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: radial-gradient(120% 60% at 50% 0%, #17173a 0%, var(--bg) 60%) fixed, var(--bg);
  color: var(--text);
  font-family: var(--display);
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
.app {
  min-height: 100%;
  max-width: 520px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding: max(14px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) max(14px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
}
.screen { flex: 1; display: flex; flex-direction: column; gap: 16px; }
.screen.center { align-items: center; justify-content: center; text-align: center; }
.logo { width: 84px; height: 84px; filter: drop-shadow(0 10px 30px rgba(79, 70, 229, .55)); }
.mini-logo { width: 36px; height: 36px; }
.eyebrow { font-size: 12px; letter-spacing: .2em; text-transform: uppercase; color: var(--lav); font-weight: 500; }
.title { margin: 0; font-size: clamp(36px, 10vw, 52px); font-weight: 700; line-height: .95; text-wrap: balance; }
.title span { color: var(--cyan); }
.h2 { margin: 0; font-size: 26px; font-weight: 700; text-wrap: balance; }
.lede, .muted { margin: 0; color: var(--muted); font-size: 15px; line-height: 1.5; max-width: 34ch; text-wrap: balance; }
.label { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); font-weight: 500; }
.stack { display: flex; flex-direction: column; gap: 10px; width: min(300px, 100%); }
.row { display: flex; gap: 10px; }
.row .btn { flex: 1; }
.btn {
  font: inherit; font-size: 16px; font-weight: 700;
  padding: 13px 18px; border-radius: 14px;
  border: 1px solid var(--line); background: var(--panel); color: var(--text);
  cursor: pointer;
}
.btn.primary { background: var(--indigo); border-color: var(--indigo); box-shadow: 0 8px 30px -8px var(--indigo); }
.btn.big { font-size: 19px; padding: 16px 18px; }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: .5; cursor: default; }
.btn:focus-visible, .input:focus-visible, .name-btn:focus-visible, .match:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
.input {
  font: inherit; font-size: 16px; color: var(--text);
  background: var(--board); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; width: 100%; min-width: 0;
}
.input.code { text-transform: uppercase; letter-spacing: .2em; font-weight: 700; }
.error { margin: 0; color: var(--danger); font-size: 14px; }

/* Home */
.topbar { display: flex; align-items: center; gap: 10px; }
.who { display: flex; flex-direction: column; }
.name-btn { font: inherit; font-weight: 700; font-size: 17px; background: none; border: 0; color: var(--text); padding: 0; text-align: left; cursor: pointer; }
.record { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.hero-card {
  display: flex; flex-direction: column; gap: 12px;
  padding: 18px; border-radius: 20px;
  background: linear-gradient(160deg, rgba(79,70,229,.22), rgba(22,22,48,.9) 60%);
  border: 1px solid var(--line);
}
.join { display: flex; gap: 10px; }
.join .btn { flex: none; }
.section-label { margin: 6px 0 0; font-size: 12px; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); font-weight: 500; }
.matches { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.match {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px 12px;
  padding: 12px 14px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line);
  font: inherit; color: var(--text); text-align: left; width: 100%;
}
button.match { cursor: pointer; }
.match .opp { font-weight: 700; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.match .scores { grid-column: 1; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.chip { grid-row: 1 / span 2; grid-column: 2; font-size: 12px; font-weight: 700; padding: 5px 10px; border-radius: 999px; border: 1px solid var(--line); white-space: nowrap; }
.chip.turn { background: var(--indigo); border-color: var(--indigo); }
.chip.won { color: var(--green); border-color: rgba(83,252,24,.4); }
.chip.lost { color: var(--danger); border-color: rgba(255,92,122,.4); }
.chip.draw { color: var(--lav); }
.chip.wait { color: var(--muted); }
.empty { color: var(--muted); font-size: 14px; margin: 0; }

/* Invite */
.bigcode { font-size: 44px; font-weight: 700; letter-spacing: .18em; color: var(--cyan); font-variant-numeric: tabular-nums; }
.copyline { display: flex; gap: 8px; width: min(380px, 100%); }
.copyline .btn { flex: none; }

/* Pre-match */
.rules { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; color: var(--muted); font-size: 15px; max-width: 34ch; text-align: left; }
.rules b { color: var(--text); }

/* Game */
.game { gap: 8px; }
.hud { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; }
.stat { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.stat.right { align-items: flex-end; }
.value { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1; }
.timer { align-items: center; position: relative; }
.timer .value { font-size: 32px; }
.timer.low .value { color: var(--amber); }
.vs { font-weight: 700; font-size: 15px; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill {
  position: absolute; top: calc(100% + 5px); left: 50%; transform: translateX(-50%); z-index: 3;
  font-size: 12px; font-weight: 500; padding: 4px 10px; border-radius: 999px;
  background: rgba(245,158,11,.18); color: var(--amber); white-space: nowrap;
}
.stage { position: relative; flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; touch-action: none; }
.board { position: relative; }
canvas { display: block; width: 100%; height: 100%; border-radius: 20px; box-shadow: 0 0 0 1px var(--line), 0 20px 60px -20px rgba(79,70,229,.45); touch-action: none; }
.recall { position: absolute; right: 12px; bottom: 12px; font: inherit; font-size: 13px; font-weight: 700; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--text); cursor: pointer; }
.countdown { position: absolute; inset: 0; display: grid; place-items: center; font-size: 96px; font-weight: 700; color: var(--cyan); text-shadow: 0 0 40px rgba(0,242,254,.6); background: rgba(15,15,24,.55); border-radius: 20px; }
.toast {
  position: absolute; left: 50%; top: 40%; transform: translate(-50%, -50%);
  font-size: clamp(22px, 6vw, 30px); font-weight: 700; white-space: nowrap; pointer-events: none;
  text-shadow: 0 0 24px rgba(0,242,254,.6); animation: toast 1.4s ease-out forwards;
}
.toast.sticky { animation: none; font-size: 18px; top: 46%; color: var(--amber); text-shadow: none; }
@keyframes toast {
  0% { opacity: 0; transform: translate(-50%, -30%) scale(.9); }
  15% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  75% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -70%); }
}

/* Result */
.versus { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 14px; width: min(360px, 100%); }
.side { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 14px 8px; border-radius: 16px; background: var(--panel); border: 1px solid var(--line); min-width: 0; }
.side.win { border-color: var(--green); box-shadow: 0 0 24px -8px var(--green); }
.side .nm { font-size: 13px; color: var(--muted); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side .sc { font-size: 34px; font-weight: 700; font-variant-numeric: tabular-nums; }
.vsdot { color: var(--muted); font-weight: 700; }
.foot { margin: 14px 0 0; text-align: center; font-size: 12px; color: var(--muted); }
.game ~ .foot { display: none; }
@media (prefers-reduced-motion: reduce) { .toast { animation-duration: .01s; opacity: 1; } }

/* Wallet, games and stakes */
.gem { color: var(--cyan); }
.cash { color: var(--green); }
.warn { color: var(--amber); }
.small { font-size: 12px; }
.fine { margin: 6px 0 0; text-align: center; font-size: 11px; line-height: 1.45; color: var(--muted); opacity: .85; }
.h3 { margin: 0; font-size: 18px; font-weight: 700; }
.topbar .who { flex: 1; min-width: 0; }
.chips { font: inherit; display: flex; gap: 12px; align-items: center; padding: 7px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); color: var(--text); font-weight: 700; font-size: 14px; cursor: pointer; font-variant-numeric: tabular-nums; }
.back { font: inherit; align-self: flex-start; background: none; border: 0; color: var(--lav); font-weight: 500; padding: 0; cursor: pointer; }
.daily { font: inherit; display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 14px; border-radius: 16px; border: 1px solid rgba(0,242,254,.4); background: rgba(0,242,254,.12); color: var(--text); font-weight: 700; cursor: pointer; }
.daily b { color: var(--cyan); }
.games { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.game-tile { font: inherit; color: var(--text); text-align: left; display: flex; flex-direction: column; gap: 4px; aspect-ratio: .78; padding: 14px; border-radius: 20px; border: 1px solid rgba(79,70,229,.7); background: linear-gradient(180deg, #2A2470, var(--panel)); cursor: pointer; min-width: 0; }
.game-tile.soon { border-color: var(--line); background: rgba(22,22,48,.5); align-items: center; justify-content: center; text-align: center; cursor: default; }
.game-tile .plus { font-size: 40px; color: var(--muted); }
.tile-art { flex: 1; display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; align-content: start; position: relative; }
.tile-art i { height: 16px; border-radius: 4px; background: var(--indigo); }
.tile-art i:nth-child(4n+1) { background: var(--cyan); } .tile-art i:nth-child(4n+2) { background: var(--lav); } .tile-art i:nth-child(4n+3) { background: var(--purple); }
.tile-art i.gap { visibility: hidden; }
.tile-art em { position: absolute; left: 34%; bottom: 8px; width: 12px; height: 12px; border-radius: 50%; background: #fff; }
.tile-title { font-size: 18px; font-weight: 700; }
.tile-sub { font-size: 12px; color: var(--muted); line-height: 1.35; }
.tile-play { font-size: 12px; font-weight: 700; letter-spacing: .12em; color: var(--cyan); }
.stakes { display: flex; flex-direction: column; gap: 10px; }
.stake { display: flex; align-items: center; gap: 12px; padding: 16px 18px; border-radius: 20px; border: 1px solid var(--line); background: var(--panel); }
.stake.hl { background: linear-gradient(160deg, rgba(79,70,229,.22), rgba(22,22,48,.9) 60%); }
.stake > div { flex: 1; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.stake b { font-size: 18px; }
.stake span { font-size: 14px; font-weight: 500; color: var(--muted); }
.stake .btn { flex: none; width: 96px; }
.balances { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; width: 100%; }
.bal { display: flex; flex-direction: column; gap: 4px; padding: 16px; border-radius: 18px; border: 1px solid var(--line); background: var(--panel); text-align: left; }
.bal b { font-size: 26px; font-variant-numeric: tabular-nums; }
.earn { display: flex; align-items: center; gap: 12px; }
.earn > div { flex: 1; display: flex; flex-direction: column; }
.earn .btn { flex: none; width: 110px; }
.check { display: flex; gap: 10px; align-items: center; font-weight: 500; }
.check input { width: 18px; height: 18px; accent-color: var(--indigo); }
select.input { appearance: auto; }
.payout { margin: 0; font-weight: 700; font-size: 16px; }
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px; background: rgba(8,8,15,.75); }
.modal-card { width: min(360px, 100%); display: flex; flex-direction: column; gap: 12px; padding: 20px; border-radius: 20px; border: 1px solid var(--line); background: var(--panel); text-align: center; }
.ad-box { height: 140px; display: grid; place-items: center; border-radius: 12px; background: var(--bg); color: var(--muted); font-weight: 700; }

/* Top bar v2: logo + name (opens settings) | coin and cash wallets */
:root { --gold: #FFC93C; }
.coin { color: var(--gold); }
.ico { width: 18px; height: 18px; flex: none; display: inline-block; vertical-align: -3px; }
.ico.dollar { border-radius: 50%; background: var(--green); color: var(--bg); font-weight: 700; font-size: 12px; line-height: 18px; text-align: center; }
.profile { font: inherit; flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; background: none; border: 0; padding: 0; color: var(--text); cursor: pointer; text-align: left; }
.profile .meName { font-weight: 700; font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wallets { display: flex; gap: 8px; flex: none; }
.chip-bal { font: inherit; display: flex; align-items: center; gap: 6px; padding: 6px 12px 6px 6px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; font-size: 14px; font-variant-numeric: tabular-nums; }
.earn-card { gap: 14px; }
.earn-head { display: flex; justify-content: space-between; align-items: center; }
.link { font: inherit; background: none; border: 0; color: var(--lav); font-size: 13px; cursor: pointer; padding: 4px; }
.link.danger { color: var(--danger); }
.earn .reward { flex: none; display: flex; align-items: center; gap: 4px; color: var(--gold); font-weight: 700; font-size: 14px; }
.earn .btn { width: 92px; }
.earn > div b { display: block; }
.games .game-tile { aspect-ratio: .82; }
.profile-head { display: flex; gap: 14px; align-items: center; }
.logo-sm { width: 56px; height: 56px; border-radius: 14px; }
.setrow { display: flex; align-items: center; gap: 12px; cursor: pointer; }
.setrow > div { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.switch { width: 44px; height: 24px; accent-color: var(--indigo); }
.task-btn { grid-column: 1 / -1; margin-top: 8px; }

/* v3: the three ways to earn coins, side by side */
.earn-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.earn-tile { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; padding: 10px 6px; border: 1px solid var(--line, #262650); border-radius: 14px; background: rgba(8,8,15,.45); min-width: 0; }
.earn-tile .reward { display: inline-flex; align-items: center; gap: 4px; }
.earn-tile b { font-size: 13px; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.earn-tile .small { font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.earn-tile .btn { width: 100%; padding: 8px 4px; margin-top: 4px; font-size: 14px; }

/* v4: stake cards — win on the left, Play in the middle, entry on the right, every label on one line */
.stake { flex-direction: column; align-items: stretch; gap: 10px; }
.stake .stake-name { font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stake > .stake-row { display: grid; flex: none; grid-template-columns: minmax(0, 1fr) 88px minmax(0, 1fr); gap: 10px; align-items: center; }
.stake .stake-row .btn { width: 88px; padding: 10px 4px; }
.stake .stake-row > .stake-box { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px; border: 1px solid var(--line); border-radius: 12px; background: rgba(8,8,15,.45); min-width: 0; }
.stake .stake-box span { font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.stake .stake-box b { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.stake .stake-box b.muted { color: var(--muted); }
.stake .stake-box b.free { color: #00F2FE; }
.earn > div { min-width: 0; }
.earn > div b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stake[data-quick] { cursor: pointer; }
.stake[data-quick]:hover { border-color: #3a3a78; }

/* v5: results screen */
.result-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.result-stats > div { display: flex; flex-direction: column; align-items: center; padding: 10px 4px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); }
.result-stats b { font-size: 20px; }
.result-stats span { font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.result-stats .danger { color: #FF5C7A; } .result-stats .lav { color: #9E9EFF; } .result-stats .free { color: #00F2FE; }
.filters { display: flex; gap: 8px; }
.filters button { font: inherit; font-size: 13px; font-weight: 700; color: var(--muted); background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 7px 14px; cursor: pointer; }
.filters button.on { color: #fff; background: #4F46E5; border-color: #4F46E5; }

/* v6: more games, quit */
.tile-svg { flex: 1; display: flex; align-items: center; justify-content: center; }
.tile-svg svg { width: 100%; height: auto; max-height: 100%; }
.run-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.quit-btn, .quit-chip { font: inherit; font-size: 13px; font-weight: 700; color: var(--muted); background: transparent; border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; cursor: pointer; }
.quit-chip { font-size: 12px; padding: 4px 10px; }
.match-wrap { display: flex; gap: 8px; align-items: stretch; }
.match-wrap > .match { flex: 1; min-width: 0; }
.match-wrap > .quit-chip { align-self: center; }
