/* Palette and type follow Gemini: near-black, the orange of their developer platform mark, their green and red. Type is Barlow, a sign-lettering grotesque with a sports-broadcast feel. */
:root {
  --bg0: #010304;
  --bg1: #140b06;
  --accent: #f95e01;
  --accent-rgb: 249 94 1;
  --glass: rgb(255 255 255 / .055);
  --glass-strong: rgb(255 255 255 / .09);
  --edge: rgb(255 255 255 / .14);
  --ink: #ffffff;
  --muted: #9aa3a6;
  --win: #4ade80;
  --loss: #fc4848;
  --warn: #ffd166;
  font-family: "Barlow Semi Condensed", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 17px;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; color: var(--ink); overflow: hidden; height: 100dvh;
  background:
    radial-gradient(1000px 640px at 28% 48%, rgb(var(--accent-rgb) / .10), transparent 70%),
    radial-gradient(760px 520px at 92% 0%, rgb(var(--accent-rgb) / .06), transparent 70%),
    linear-gradient(180deg, var(--bg1), var(--bg0) 62%);
  display: grid; grid-template-rows: auto auto auto 1fr auto; grid-template-columns: minmax(0, 1fr);
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Glass: translucent fill, hairline edge, a lit top edge and a soft cast shadow. */
.glass {
  background: linear-gradient(180deg, var(--glass-strong), var(--glass));
  border: 1px solid var(--edge);
  backdrop-filter: blur(18px) saturate(1.4); -webkit-backdrop-filter: blur(18px) saturate(1.4);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / .22), inset 0 -1px 0 rgb(0 0 0 / .25), 0 10px 28px rgb(0 0 0 / .4);
}

.top { display: flex; align-items: center; gap: 12px; padding: 12px 16px 6px; min-width: 0; position: relative; z-index: 2; }
.brand { display: flex; align-items: center; gap: 9px; font-family: "Barlow Condensed", "Barlow Semi Condensed", sans-serif; font-style: italic; font-weight: 700; font-size: 27px; letter-spacing: .01em; text-transform: uppercase; line-height: 1; }
.mark { width: 24px; height: 24px; flex: none; display: block; }
.game-btn { display: flex; align-items: center; gap: 8px; padding: 9px 15px; border-radius: 999px; min-width: 0; flex: 0 1 auto; font-weight: 600; transition: transform .12s; }
.game-btn:active, .pos-btn:active, .icon-btn:active { transform: scale(.96); }
#gameTitle { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.live { width: 8px; height: 8px; border-radius: 50%; background: var(--loss); box-shadow: 0 0 10px var(--loss); flex: none; animation: pulse 1.4s infinite; transition: transform .18s; }
@keyframes pulse { 50% { opacity: .35; } }
.caret { color: var(--muted); }
.spacer { flex: 1; }
.wallet { position: relative; display: flex; align-items: center; gap: 8px; padding: 9px 15px; border-radius: 999px; font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; }
.mode { font-size: 10px; font-weight: 700; letter-spacing: .08em; color: var(--muted); }
.delta { position: absolute; right: 14px; top: 100%; margin-top: 4px; font-size: 13px; font-weight: 700; opacity: 0; pointer-events: none; }
.delta.show { animation: delta 1.8s ease-out; }
.delta.up { color: var(--win); } .delta.down { color: var(--loss); }
@keyframes delta { 0% { opacity: 0; transform: translateY(8px); } 15% { opacity: 1; transform: none; } 75% { opacity: 1; } 100% { opacity: 0; transform: translateY(-6px); } }
.wallet.bump { animation: bump .22s ease-out; }
@keyframes bump { 40% { transform: scale(1.08); box-shadow: 0 0 26px rgb(74 222 128 / .55); border-color: rgb(74 222 128 / .7); } }
.wallet.bump #balance { color: var(--win); }

/* overflow-x: auto also clips vertically, so leave padding for shadows and pull the rows back with margin. */
.markets, .contracts { display: flex; gap: 8px; padding: 10px 16px; margin: -4px 0 -10px; overflow-x: auto; scrollbar-width: none; position: relative; z-index: 2; }
.contracts { margin-bottom: -2px; }
.markets::-webkit-scrollbar, .contracts::-webkit-scrollbar, .controls::-webkit-scrollbar { display: none; }
.tab, .chip { white-space: nowrap; padding: 7px 14px; border-radius: 999px; border: 1px solid transparent; color: var(--muted); font-size: 16px; font-weight: 500; letter-spacing: .01em; transition: color .15s, transform .12s; }
.tab:hover, .chip:hover { color: var(--ink); }
.tab:active, .chip:active { transform: scale(.96); }
.tab[aria-pressed="true"] { color: var(--ink); background: var(--glass-strong); border-color: var(--edge); box-shadow: inset 0 1px 0 rgb(255 255 255 / .2), inset 0 -2px 0 var(--accent); }
.tab.hot { color: var(--ink); animation: hot 1.4s ease-out; }
@keyframes hot { 0%, 30% { background: rgb(var(--accent-rgb) / .22); } }
.chip { display: flex; gap: 8px; align-items: center; border-color: var(--edge); background: var(--glass); }
.chip b { font-variant-numeric: tabular-nums; color: var(--ink); font-weight: 700; }
.chip[aria-pressed="true"] { color: var(--ink); background: rgb(var(--accent-rgb) / .12); border-color: var(--accent); box-shadow: inset 0 1px 0 rgb(255 255 255 / .2); }
.chip .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--c, var(--accent)); box-shadow: 0 0 0 1px rgb(255 255 255 / .5), 0 0 8px var(--c, var(--accent)); }

.stage { position: relative; min-height: 0; }
#grid { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: pointer; }
#fx { position: fixed; inset: 0; width: 100vw; height: 100dvh; pointer-events: none; z-index: 50; }
.empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); padding: 24px; text-align: center; pointer-events: none; }
.empty[hidden] { display: none; }

.toasts { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; pointer-events: none; width: min(300px, calc(100% - 24px)); z-index: 3; }
.toast { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-radius: 14px; font-size: 16px; font-weight: 600; background: linear-gradient(180deg, rgb(255 255 255 / .12), rgb(255 255 255 / .06)); border: 1px solid var(--edge); backdrop-filter: blur(18px) saturate(1.4); -webkit-backdrop-filter: blur(18px) saturate(1.4); box-shadow: inset 0 1px 0 rgb(255 255 255 / .22), 0 12px 30px rgb(0 0 0 / .45); animation: toast .28s cubic-bezier(.2, 1.4, .4, 1); }
.toast::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex: none; }
.toast.win { border-color: rgb(74 222 128 / .55); } .toast.win::before { background: var(--win); box-shadow: 0 0 10px var(--win); }
.toast.loss::before { background: var(--loss); }
.toast.err::before { background: var(--warn); }
.toast.out { animation: toastOut .3s ease-in forwards; }
@keyframes toast { from { opacity: 0; transform: translateY(-10px) scale(.96); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-6px); } }

.activity { position: absolute; left: 12px; bottom: 30px; display: flex; flex-direction: column-reverse; gap: 6px; z-index: 3; max-width: min(320px, calc(100% - 24px)); }
.move { display: flex; align-items: center; gap: 8px; padding: 7px 13px; border-radius: 999px; font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; background: linear-gradient(180deg, rgb(255 255 255 / .1), rgb(255 255 255 / .05)); border: 1px solid var(--edge); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); box-shadow: inset 0 1px 0 rgb(255 255 255 / .2), 0 8px 20px rgb(0 0 0 / .4); animation: slideIn .35s cubic-bezier(.2, 1.3, .4, 1); text-align: left; }
.move .arrow { font-size: 11px; }
.move.up .arrow, .move.up b { color: var(--win); }
.move.down .arrow, .move.down b { color: var(--loss); }
.move .what { color: #c9d1d3; overflow: hidden; text-overflow: ellipsis; }
.move.out { animation: fadeOut .4s ease-in forwards; }
@keyframes slideIn { from { opacity: 0; transform: translateX(-24px); } }
@keyframes fadeOut { to { opacity: 0; transform: translateX(-12px); } }

.streak { position: absolute; top: 14px; right: 56px; z-index: 3; font-family: "Barlow Condensed", sans-serif; font-style: italic; font-weight: 700; font-size: 19px; letter-spacing: .04em; padding: 6px 14px; border-radius: 999px; color: #1a1200; background: linear-gradient(180deg, #fff0c2, var(--warn)); box-shadow: inset 0 1px 0 rgb(255 255 255 / .6), 0 6px 16px rgb(0 0 0 / .4); opacity: 0; transform: scale(.6); transition: opacity .2s, transform .2s; pointer-events: none; }
.streak.on { opacity: 1; transform: scale(1); }
.streak.pop { animation: streakPop .45s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes streakPop { 0% { transform: scale(.5) rotate(-6deg); } 60% { transform: scale(1.25) rotate(3deg); } }

.coach { position: absolute; left: 50%; bottom: 84px; transform: translateX(-50%); z-index: 3; width: min(420px, calc(100% - 32px)); padding: 14px 18px; border-radius: 16px; font-size: 14px; line-height: 1.45; background: linear-gradient(180deg, rgb(255 255 255 / .12), rgb(255 255 255 / .06)); border: 1px solid rgb(var(--accent-rgb) / .5); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); box-shadow: inset 0 1px 0 rgb(255 255 255 / .22), 0 0 30px rgb(var(--accent-rgb) / .22); pointer-events: none; animation: toast .4s ease-out; }
.coach span { display: block; margin-top: 6px; color: var(--muted); font-size: 13px; }
.coach[hidden] { display: none; }

.controls { display: flex; align-items: center; gap: 12px; padding: 8px 16px calc(12px + env(safe-area-inset-bottom)); overflow-x: auto; scrollbar-width: none; position: relative; z-index: 2; }
.group { display: flex; align-items: center; gap: 8px; }
.lbl { color: var(--muted); font-size: 15px; white-space: nowrap; }
.seg { display: flex; border-radius: 999px; padding: 3px; }
.seg button { padding: 7px 13px; border-radius: 999px; font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 600; white-space: nowrap; transition: color .15s, background .15s, transform .12s; }
.seg button:active { transform: scale(.92); }
.seg button[aria-pressed="true"] { background: linear-gradient(180deg, #ff8a3d, var(--accent)); color: #fff; box-shadow: inset 0 1px 0 rgb(255 255 255 / .35); }
.zoom { align-items: center; }
.zoom button { padding: 7px 12px; font-size: 17px; line-height: 1; }
.zoom span { min-width: 44px; text-align: center; font-size: 13px; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; flex: none; display: grid; place-items: center; font-size: 16px; transition: transform .12s; }
.icon-btn[aria-pressed="false"] { color: var(--muted); text-decoration: line-through; }
.pos-btn { margin-left: auto; flex: none; padding: 9px 15px; border-radius: 999px; white-space: nowrap; font-weight: 600; transition: transform .12s; }
.pos-btn span { margin-left: 6px; padding: 1px 8px; border-radius: 999px; background: rgb(var(--accent-rgb) / .2); font-variant-numeric: tabular-nums; }

.sheet { width: min(520px, calc(100vw - 24px)); max-height: min(640px, calc(100dvh - 48px)); padding: 0; border: 1px solid var(--edge); border-radius: 22px; background: linear-gradient(180deg, rgb(38 27 20 / .96), rgb(14 10 8 / .97)); backdrop-filter: blur(24px) saturate(1.4); -webkit-backdrop-filter: blur(24px) saturate(1.4); color: var(--ink); box-shadow: inset 0 1px 0 rgb(255 255 255 / .2), 0 30px 80px rgb(0 0 0 / .7); }
.sheet::backdrop { background: rgb(1 3 4 / .65); backdrop-filter: blur(6px); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--edge); position: sticky; top: 0; background: rgb(30 21 16 / .98); }
.sheet-head h2 { margin: 0; font-size: 17px; letter-spacing: -.01em; }
.x { font-size: 22px; line-height: 1; color: var(--muted); padding: 0 6px; }
.list { overflow-y: auto; }
.row { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 13px 18px; border-bottom: 1px solid rgb(255 255 255 / .07); }
.row:last-child { border-bottom: 0; }
button.row:hover { background: rgb(var(--accent-rgb) / .07); }
.row .main { flex: 1; min-width: 0; }
.row .title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.row .sub { color: var(--muted); font-size: 13px; }
.row .num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; font-weight: 700; }
.pos { color: var(--win); } .neg { color: var(--loss); }
.close-btn { padding: 6px 12px; border: 1px solid var(--edge); border-radius: 999px; font-size: 13px; font-weight: 600; background: var(--glass); }
.none { padding: 30px 18px; color: var(--muted); text-align: center; }

@media (max-width: 560px) {
  .brand span:last-child { display: none; }
  .top { padding: 10px 12px 4px; gap: 8px; }
  .markets, .contracts { padding-left: 12px; padding-right: 12px; }
  .view-inner { padding: 8px 14px 120px; }
  .view h1 { font-size: 30px; }
  .cards { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr 1fr; }
  .joinbar { left: 10px; right: 10px; bottom: 10px; }
  .views button { padding: 7px 10px; font-size: 15px; }
  .views em { display: none; }
  body[data-view="game"] .views { display: none; }
  .custom input { width: 62px; }
  .controls { padding-left: 12px; padding-right: 12px; gap: 8px; flex-wrap: wrap; overflow: visible; }
  .lbl, .mode { display: none; }
  .seg button { padding: 7px 8px; font-size: 13px; }
  .zoom button { padding: 7px 10px; font-size: 16px; }
  .zoom span { min-width: 38px; }
  .controls { row-gap: 6px; }
  .icon-btn { width: 34px; height: 34px; }
  .pos-btn { padding: 7px 12px; font-size: 14px; }
  .streak { right: 12px; top: 10px; font-size: 13px; }
  /* Phones: one slim pill at the top, so the bottom rows stay tappable. */
  .activity { top: 8px; bottom: auto; left: 12px; right: 12px; max-width: none; }
  .move:not(:first-child) { display: none; }
  /* It overlaps the top row of squares here, so let taps pass through to the grid. */
  .move { pointer-events: none; }
  .toasts { top: 52px; }
  .coach { bottom: 60px; }
}
@media (prefers-reduced-motion: reduce) {
  .toast, .delta.show, .live, .move, .streak.pop, .wallet.bump, .tab.hot { animation: none; }
  .delta.show { opacity: 1; }
}

/* ---------- sections: lobby, summary, leaderboard ---------- */
.top { z-index: 30; }
.views { display: flex; gap: 4px; }
.views button { padding: 8px 14px; border-radius: 999px; color: var(--muted); font-weight: 600; font-size: 16px; white-space: nowrap; }
.views button:hover { color: var(--ink); }
.views button[aria-current="page"] { color: var(--ink); background: var(--glass-strong); box-shadow: inset 0 -2px 0 var(--accent); }
.views em { font-style: normal; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--accent); margin-left: 4px; }
body:not([data-view="game"]) #gameBtn { display: none; }
.game-btn .caret { font-size: 13px; font-weight: 600; padding-left: 4px; border-left: 1px solid var(--edge); margin-left: 4px; }

.view { display: none; position: fixed; inset: 0; z-index: 20; overflow-y: auto; padding-top: 66px;
  background:
    radial-gradient(1000px 640px at 28% 30%, rgb(var(--accent-rgb) / .10), transparent 70%),
    linear-gradient(180deg, var(--bg1), var(--bg0) 62%); }
body[data-view="lobby"] #lobby, body[data-view="summary"] #summary, body[data-view="leaderboard"] #leaderboard { display: block; }
.view-inner { max-width: 1080px; margin: 0 auto; padding: 18px 24px 130px; }
.view h1 { font-family: "Barlow Condensed", sans-serif; font-style: italic; font-weight: 700; text-transform: uppercase; font-size: 44px; line-height: 1; margin: 8px 0 8px; letter-spacing: .01em; text-wrap: balance; }
.view h2 { font-size: 19px; margin: 28px 0 10px; }
.lede { color: var(--muted); margin: 0 0 22px; max-width: 60ch; font-size: 18px; }
.soon { font-family: "Barlow Semi Condensed", sans-serif; font-style: normal; font-size: 14px; letter-spacing: .06em; vertical-align: middle; padding: 4px 10px; border-radius: 999px; background: rgb(var(--accent-rgb) / .16); color: var(--accent); border: 1px solid rgb(var(--accent-rgb) / .5); }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.card { text-align: left; padding: 16px 18px; border-radius: 18px; display: flex; flex-direction: column; gap: 12px; transition: transform .12s, border-color .12s; }
.card:hover { border-color: rgb(255 255 255 / .3); }
.card:active { transform: scale(.985); }
.card[aria-selected="true"] { border-color: var(--accent); box-shadow: inset 0 1px 0 rgb(255 255 255 / .22), inset 0 0 0 1px var(--accent), 0 10px 28px rgb(0 0 0 / .4); background: linear-gradient(180deg, rgb(var(--accent-rgb) / .16), rgb(var(--accent-rgb) / .05)); }
.card-top { display: flex; align-items: center; justify-content: space-between; font-size: 13px; font-weight: 700; letter-spacing: .08em; color: var(--muted); }
.livetag { display: flex; align-items: center; gap: 6px; color: var(--ink); }
.livetag i { width: 7px; height: 7px; border-radius: 50%; background: var(--loss); }
.livetag.quiet { color: var(--muted); } .livetag.quiet i { background: var(--muted); }
.card-title { font-size: 22px; font-weight: 700; line-height: 1.15; }
.teams { display: grid; gap: 8px; }
.team { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px; font-size: 17px; }
.team .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c, var(--accent)); box-shadow: 0 0 0 1px rgb(255 255 255 / .5); }
.team b { font-variant-numeric: tabular-nums; font-size: 19px; }
.team .bar { grid-column: 1 / -1; height: 4px; border-radius: 2px; background: rgb(255 255 255 / .1); overflow: hidden; }
.team .bar i { display: block; height: 100%; border-radius: 2px; background: var(--c, var(--accent)); }
.card-foot { display: flex; justify-content: space-between; color: var(--muted); font-size: 14px; }
.cards-note { grid-column: 1 / -1; padding: 40px 0; text-align: center; color: var(--muted); }

/* Solid fill, no backdrop blur: iOS draws a grey block under a blurred fixed bar inside a scroller. */
.joinbar { position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); transform: translateX(-50%); width: min(560px, calc(100% - 20px)); display: flex; align-items: center; gap: 14px; padding: 12px 12px 12px 20px; border-radius: 20px; z-index: 25; background: linear-gradient(180deg, #2a1c14, #120d0a); backdrop-filter: none; -webkit-backdrop-filter: none; }
/* Cards fade out behind the bar instead of being cut off by it. */
#lobby::after { content: ""; position: fixed; left: 0; right: 0; bottom: 0; height: 130px; pointer-events: none; z-index: 24; background: linear-gradient(180deg, transparent, var(--bg0) 70%); }
body:not([data-view="lobby"]) .joinbar { display: none; }
.join-info { flex: 1; min-width: 0; display: grid; }
.join-label { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.join-info b { font-size: 19px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cta { flex: none; padding: 13px 34px; border-radius: 14px; font-family: "Barlow Condensed", sans-serif; font-style: italic; font-weight: 700; font-size: 24px; text-transform: uppercase; letter-spacing: .03em; color: #fff; background: linear-gradient(180deg, #ff8a3d, var(--accent)); box-shadow: inset 0 1px 0 rgb(255 255 255 / .4), 0 8px 18px rgb(0 0 0 / .4); transition: transform .12s, opacity .12s; }
.cta:active { transform: scale(.96); }
.cta:disabled { opacity: .4; cursor: default; }
@media (max-width: 560px) { .joinbar { transform: none; width: auto; } }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.stat { padding: 16px 18px; border-radius: 16px; }
.stat span { display: block; color: var(--muted); font-size: 15px; }
.stat b { display: block; font-size: 32px; line-height: 1.15; font-variant-numeric: tabular-nums; margin-top: 2px; }
.stat small { color: var(--muted); font-size: 14px; }
.results { border-radius: 16px; overflow: hidden; }
.ghost-btn { margin-top: 22px; padding: 9px 16px; border-radius: 999px; border: 1px solid var(--edge); color: var(--muted); font-weight: 600; font-size: 15px; }
.ghost-btn:hover { color: var(--ink); border-color: rgb(255 255 255 / .3); }
.ghost-btn[hidden] { display: none; }

.board { position: relative; border-radius: 18px; padding: 8px 18px; max-width: 640px; }
.board-row { display: flex; align-items: center; gap: 14px; padding: 14px 0; border-bottom: 1px solid rgb(255 255 255 / .07); opacity: .5; }
.board-row:nth-last-child(2) { border-bottom: 0; }
.board-row span { width: 22px; color: var(--muted); font-weight: 700; font-variant-numeric: tabular-nums; }
.board-row i { height: 12px; border-radius: 6px; background: rgb(255 255 255 / .12); }
.board-row i.short { width: 64px; margin-left: auto; }
.board-cover { position: absolute; inset: 0; display: grid; place-items: center; font-family: "Barlow Condensed", sans-serif; font-style: italic; font-weight: 700; font-size: 34px; text-transform: uppercase; letter-spacing: .04em; background: rgb(8 6 5 / .55); border-radius: 18px; }

/* custom amount beside the quick amounts */
.custom { display: flex; align-items: center; gap: 2px; padding: 0 12px; height: 40px; border-radius: 999px; color: var(--muted); font-weight: 600; }
.custom input { width: 78px; border: 0; background: none; color: var(--ink); font: inherit; font-weight: 600; font-variant-numeric: tabular-nums; outline: none; -moz-appearance: textfield; }
.custom input::placeholder { color: var(--muted); }
.custom input::-webkit-outer-spin-button, .custom input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.custom:focus-within, .custom.on { border-color: var(--accent); color: var(--ink); }
.custom.on { background: rgb(var(--accent-rgb) / .16); }

/* Phones: section tabs get their own row under the header, and the section layouts tighten up.
   This block comes last so it wins over the desktop rules above. */
@media (max-width: 560px) {
  body:not([data-view="game"]) .top { flex-wrap: wrap; row-gap: 8px; }
  body:not([data-view="game"]) .views { order: 3; width: 100%; justify-content: space-between; }
  .views button { flex: 1; text-align: center; }
  .view { padding-top: 108px; }
  .view-inner { padding: 4px 14px 120px; }
  .view h1 { font-size: 32px; }
  .lede { font-size: 16px; margin-bottom: 16px; }
  .cards { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr 1fr; }
  .stat b { font-size: 26px; }
  .joinbar { left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom)); transform: none; width: auto; padding-left: 16px; }
  .session { display: none; }
  .max-btn { padding: 0 10px; font-size: 13px; }
  .cta { padding: 12px 26px; }
}

/* The page is an app surface: no pull-to-refresh, double-tap zoom, text selection or tap flash. */
html, body { overscroll-behavior: none; }
body { -webkit-tap-highlight-color: transparent; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
button, .seg, .chip, .tab, .card { touch-action: manipulation; }
input { -webkit-user-select: text; user-select: text; }
/* Blurring whatever is behind a panel is costly when that is a canvas repainting every frame,
   so panels that float over the grid use a plain translucent fill on phones. */
@media (max-width: 560px) {
  .toast, .move, .coach { backdrop-filter: none; -webkit-backdrop-filter: none; }
  .toast, .move { background: rgb(22 16 13 / .94); }
  .coach { background: rgb(22 16 13 / .96); }
}

/* amount mode, max per square, session result */
.max-btn { height: 40px; padding: 0 14px; border-radius: 999px; color: var(--muted); font-weight: 600; white-space: nowrap; flex: none; }
.max-btn b { color: var(--ink); font-variant-numeric: tabular-nums; margin-left: 4px; }
.max-btn:hover { color: var(--ink); }
.session { font-weight: 700; font-size: 15px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.session[hidden] { display: none; }
.sheet-body { padding: 16px 18px 20px; }
.sheet-body p { margin: 0 0 14px; color: #d7dcde; line-height: 1.45; }
.sheet-body .fine { margin: 14px 0 0; color: var(--muted); font-size: 15px; }
.seg.wrap { flex-wrap: wrap; border-radius: 18px; }
.seg.wrap button { flex: 1 0 30%; }
.toast.badge { border-color: rgb(255 209 102 / .6); }
.toast.badge::before { background: var(--warn); box-shadow: 0 0 10px var(--warn); }

/* lobby cards that can't be joined right now */
.card.off { opacity: .55; }
.card.off .team b { color: var(--muted); font-weight: 600; }

/* summary badges */
.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.badge { padding: 12px 14px; border-radius: 14px; border: 1px dashed rgb(255 255 255 / .16); color: var(--muted); }
.badge b { display: block; font-size: 17px; }
.badge span { font-size: 14px; }
.badge.on { border: 1px solid rgb(255 209 102 / .55); background: rgb(255 209 102 / .1); color: #f3e3bd; }
.badge.on b { color: var(--warn); }

/* "Entering <game>" card shown for a moment when joining */
.enter { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; pointer-events: none; background: rgb(6 4 3 / .86); opacity: 0; }
.enter[hidden] { display: none; }
.enter.go { animation: enter .9s ease-out forwards; }
.enter div { text-align: center; padding: 0 24px; }
.enter span { display: block; font-size: 15px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--accent); }
.enter b { display: block; font-family: "Barlow Condensed", sans-serif; font-style: italic; font-weight: 700; text-transform: uppercase; font-size: clamp(34px, 7vw, 64px); line-height: 1.05; margin-top: 6px; }
.enter.go div { animation: enterText .9s cubic-bezier(.2, 1.2, .3, 1) forwards; }
@keyframes enter { 0% { opacity: 0; } 18% { opacity: 1; } 70% { opacity: 1; } 100% { opacity: 0; } }
@keyframes enterText { 0% { transform: scale(.86); } 30% { transform: scale(1); } 100% { transform: scale(1.06); } }
@media (prefers-reduced-motion: reduce) { .enter.go, .enter.go div { animation: none; } }

@media (min-width: 561px) {
  .toasts { left: 14px; transform: none; top: 12px; width: min(300px, 26%); }
}

/* Phones: the amount controls take their own rows so nothing runs off the side. */
@media (max-width: 560px) {
  /* groups dissolve so every control packs into as few rows as possible */
  .controls .group { display: contents; }
  .zoom span { min-width: 34px; }
  .zoom button { padding: 7px 8px; }
  .custom { height: 36px; padding: 0 10px; }
  .custom input { width: 58px; }
  .max-btn { height: 36px; }
}

/* live game chat: a panel over the right side of the chart */
.chat-btn { margin-left: auto; }
.chat-btn + .pos-btn { margin-left: 0; }
.chat-btn span { background: var(--accent); color: #fff; }
.chat-btn span[hidden] { display: none; }
.chat-btn[aria-expanded="true"] { border-color: var(--accent); }
.chat { position: absolute; top: 10px; right: 12px; bottom: 10px; width: min(330px, 40%); z-index: 4; display: flex; flex-direction: column; border-radius: 18px; border: 1px solid var(--edge); background: linear-gradient(180deg, rgb(38 27 20 / .97), rgb(14 10 8 / .97)); box-shadow: inset 0 1px 0 rgb(255 255 255 / .18), 0 24px 60px rgb(0 0 0 / .6); overflow: hidden; animation: chatIn .22s cubic-bezier(.2, 1.2, .4, 1); }
.chat[hidden] { display: none; }
@keyframes chatIn { from { opacity: 0; transform: translateX(16px); } }
.chat-head { display: flex; align-items: center; gap: 8px; padding: 10px 10px 10px 14px; border-bottom: 1px solid var(--edge); }
.chat-title { display: flex; flex-direction: column; flex: 1 1 auto; min-width: 0; }
.chat-title b { font-size: 16px; }
.chat-people { white-space: nowrap; display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; font-weight: 600; }
.chat-people i { flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.chat-people.live i { background: var(--win); box-shadow: 0 0 8px var(--win); }
.chat-name { max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 5px 10px; border-radius: 999px; border: 1px solid var(--edge); font-size: 13px; font-weight: 600; color: var(--muted); }
.chat-name:hover { color: var(--ink); }
.chat-list { flex: 1; overflow-y: auto; padding: 10px 14px; display: flex; flex-direction: column; gap: 7px; overscroll-behavior: contain; scrollbar-width: thin; }
.chat-empty { margin: auto; color: var(--muted); text-align: center; font-size: 14px; line-height: 1.4; padding: 0 10px; }
.msg { font-size: 15px; line-height: 1.35; overflow-wrap: anywhere; animation: msgIn .2s ease-out; }
.msg b { color: #ffb27d; font-weight: 700; margin-right: 6px; }
.msg.mine b { color: var(--accent); }
.msg.hit { padding: 6px 10px; border-radius: 10px; background: rgb(74 222 128 / .1); border: 1px solid rgb(74 222 128 / .3); }
.msg.hit span { color: var(--win); font-weight: 700; }
.msg.old { opacity: .62; }
@keyframes msgIn { from { opacity: 0; transform: translateY(4px); } }
.chat-share { display: flex; align-items: center; gap: 8px; padding: 6px 14px; color: var(--muted); font-size: 13px; font-weight: 600; border-top: 1px solid var(--edge); cursor: pointer; }
.chat-share input { accent-color: var(--accent); width: 15px; height: 15px; margin: 0; }
.chat-form { display: flex; gap: 8px; padding: 8px 10px calc(10px + env(safe-area-inset-bottom)); }
.chat-form input { flex: 1; min-width: 0; height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--edge); background: rgb(255 255 255 / .06); color: var(--ink); font: inherit; font-size: 16px; outline: none; }
.chat-form input:focus { border-color: var(--accent); }
.chat-form .cta { height: 40px; padding: 0 16px; font-size: 15px; }
.toast.social::before { background: var(--accent); box-shadow: 0 0 10px var(--accent); }
@media (max-width: 560px) {
  .chat { top: auto; left: 8px; right: 8px; bottom: 8px; width: auto; height: min(52%, 400px); }
  @keyframes chatIn { from { opacity: 0; transform: translateY(20px); } }
}
