/* Grip the Blip: a quiet dark theme with a single accent, the blip red.
   System fonts only, no network assets. */
:root {
  color-scheme: dark;
  --bg: #0a0c10;
  --bg-sunk: #0d1015;
  --panel: #12151b;
  --panel-2: #181c24;
  --line: #232935;
  --line-strong: #333b4b;
  --control: #5c6578; /* control borders: >= 3:1 against the surfaces */
  --text: #e8ebf1;
  --muted: #98a1b1;
  --blip: #ff5258; /* the one accent: text, dots, focus */
  --accent-strong: #c8353b; /* filled controls (white text, >= 5:1) */
  --accent-hover: #d0373d;
  --focus: #ff8a8e;
  --bad: #ff6b70;
  --glow: #86dfb5; /* functional: the grip signal (ring + arena border), kept distinct from the accent */
  --warn: #f2b84b;
  --radius: 14px;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset, 0 12px 28px -16px rgba(0, 0, 0, 0.75);
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Roboto, Arial, sans-serif;
  --mono: ui-monospace, 'SF Mono', SFMono-Regular, Menlo, Consolas, 'Liberation Mono', monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); font: 15px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
body { background: radial-gradient(1200px 520px at 50% -120px, #131820 0%, var(--bg) 70%) no-repeat, var(--bg); min-height: 100vh; }
h1 { font-size: 26px; margin: 0 0 6px; font-weight: 650; letter-spacing: 0.01em; }
h2 { font-size: 12px; margin: 0 0 14px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.14em; }
p { margin: 0 0 10px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
::selection { background: rgba(255, 82, 88, 0.35); }
a { color: var(--text); text-decoration-color: rgba(255, 82, 88, 0.7); text-underline-offset: 3px; transition: color 0.15s, text-decoration-color 0.15s; }
a:hover { color: #fff; text-decoration-color: var(--blip); }
a:visited { color: var(--text); }

/* ---- layout shells ------------------------------------------------------------- */
.center { max-width: 760px; margin: 0 auto; padding: 40px 20px; }
#waiting, #end { text-align: center; }
.stack { max-width: 640px; margin: 0 auto; padding: 0 20px 56px; }
.card { background: linear-gradient(180deg, var(--panel) 0%, #10131a 100%); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; margin-bottom: 16px; box-shadow: var(--shadow); text-align: left; }
.card > :last-child { margin-bottom: 0; }

/* ---- lobby ---------------------------------------------------------------------- */
.topbar { max-width: 1060px; margin: 0 auto; padding: 22px 24px 0; position: relative; z-index: 1; }
.brand { margin: 0; line-height: 0; }
.brand img { height: 30px; width: auto; display: block; }
.hero { margin-top: 6px; line-height: 0; -webkit-mask-image: linear-gradient(to bottom, transparent, #000 18%, #000 58%, transparent); mask-image: linear-gradient(to bottom, transparent, #000 18%, #000 58%, transparent); }
.hero img { width: 100%; height: clamp(150px, 20vw, 260px); object-fit: cover; object-position: 62% 50%; display: block; }
.tagline { text-align: center; color: var(--muted); font-size: 16px; margin: -6px 0 26px; letter-spacing: 0.01em; }
.brand-mini { display: inline-block; line-height: 0; margin-bottom: 14px; }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field.wide { grid-column: 1 / -1; }
.field label { font-size: 13px; }
.checks { display: flex; flex-direction: column; gap: 10px; margin: 18px 0 4px; }
.check { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; color: var(--text); line-height: 1.4; }
.check span { color: var(--muted); }
.check input:checked + span { color: var(--text); }
input[type=checkbox] { appearance: none; -webkit-appearance: none; flex: none; width: 18px; height: 18px; margin: 1px 0 0; border: 1px solid var(--control); border-radius: 5px; background: var(--bg-sunk); display: grid; place-content: center; cursor: pointer; transition: background 0.15s, border-color 0.15s; }
input[type=checkbox]::after { content: ''; width: 9px; height: 5px; border-left: 2px solid #fff; border-bottom: 2px solid #fff; transform: translateY(-1px) rotate(-45deg) scale(0); transition: transform 0.12s; }
input[type=checkbox]:checked { background: var(--accent-strong); border-color: var(--accent-strong); }
input[type=checkbox]:checked::after { transform: translateY(-1px) rotate(-45deg) scale(1); }
input[type=checkbox]:hover { border-color: #7b869b; }
.actions { margin-top: 18px; }
.center-actions { display: flex; justify-content: center; margin-top: 22px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 8px 0; }
.row:first-of-type { margin-top: 0; }
.grow { flex: 1 1 180px; min-width: 0; }
.full { width: 100%; }
.err { color: var(--bad); min-height: 1.5em; text-align: center; font-size: 14px; }

label { color: var(--muted); }
input[type=text], select { background: var(--bg-sunk); color: var(--text); border: 1px solid var(--control); border-radius: 10px; padding: 10px 12px; font: inherit; min-height: 42px; transition: border-color 0.15s, box-shadow 0.15s, background 0.15s; }
input[type=text]::placeholder { color: #7d8697; }
input[type=text]:hover, select:hover { border-color: #7b869b; }
input[type=text]:focus-visible, select:focus-visible { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px rgba(255, 82, 88, 0.22); }
input[readonly] { color: var(--muted); font: 13px/1.4 var(--mono); }
select { appearance: none; -webkit-appearance: none; padding-right: 34px; cursor: pointer; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%2398a1b1' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; }
input[type=text].code { text-transform: uppercase; letter-spacing: 0.32em; width: 8.5em; text-align: center; font: 600 20px/1 var(--mono); padding-left: 0.32em; }

button { background: var(--accent-strong); color: #fff; border: 1px solid transparent; border-radius: 10px; padding: 10px 18px; min-height: 42px; font: inherit; font-weight: 600; letter-spacing: 0.01em; cursor: pointer; transition: background 0.15s, border-color 0.15s, transform 0.08s, box-shadow 0.15s; }
button:hover { background: var(--accent-hover); }
button:active { transform: translateY(1px); }
button.secondary { background: transparent; color: var(--text); border-color: var(--control); }
button.secondary:hover { background: rgba(255, 255, 255, 0.05); border-color: #7b869b; }
button:disabled { opacity: 0.5; cursor: default; }

.bigcode { font: 600 56px/1 var(--mono); letter-spacing: 0.3em; padding-left: 0.3em; text-align: center; margin: 22px auto; padding-block: 18px; max-width: 420px; background: var(--bg-sunk); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: inset 0 2px 12px rgba(0, 0, 0, 0.5); }
.bigcode.small { font-size: 34px; padding-block: 10px; margin: 8px 0 14px; max-width: none; }
#waiting .card { max-width: 520px; margin-inline: auto; }
#waiting .row { justify-content: center; }

/* ---- game ------------------------------------------------------------------------- */
#game { display: grid; grid-template-columns: minmax(300px, 600px) minmax(260px, 380px); gap: 24px; padding: 18px 20px; max-width: 1080px; margin: 0 auto; align-items: start; }
@media (max-width: 800px) { #game { grid-template-columns: 1fr; } }
.hud { display: flex; justify-content: space-between; gap: 12px; margin: 0 2px 8px; color: var(--muted); min-height: 1.5em; font-size: 14px; }
.banner { font-weight: 500; color: var(--muted); }
.round { font-weight: 650; color: var(--text); letter-spacing: 0.12em; text-transform: uppercase; font-size: 12px; white-space: nowrap; align-self: center; }

.clockbar { display: flex; align-items: baseline; justify-content: center; gap: 16px; margin: 0 0 12px; padding: 6px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-sunk); box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.45); transition: border-color 0.25s, background 0.25s; }
.clock-label { font-size: 12px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--muted); }
.clock { font: 700 64px/1.05 var(--mono); font-variant-numeric: tabular-nums; color: #f4f6fa; letter-spacing: 0.02em; transition: color 0.25s; }
.clockbar.warn { border-color: #8a6a1c; background: #1a1507; }
.clockbar.warn .clock { color: var(--warn); }
.clockbar.crit { border-color: #b3332f; background: #220d0d; animation: clock-pulse 0.8s ease-in-out infinite; }
.clockbar.crit .clock { color: #ff625a; }
@keyframes clock-pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(255, 90, 77, 0); } 50% { box-shadow: 0 0 22px 3px rgba(255, 90, 77, 0.5); } }
@media (max-width: 500px) { .clock { font-size: 48px; } }

/* arena: a double frame, quiet until the grip glow lights the border */
.arena-wrap { position: relative; container-type: inline-size; aspect-ratio: 1; width: 100%; border: 1px solid var(--line-strong); border-radius: 10px; background: #080a0e; box-shadow: 0 0 0 6px var(--bg-sunk), 0 0 0 7px var(--line), 0 24px 40px -22px rgba(0, 0, 0, 0.9); transition: box-shadow 0.18s, border-color 0.18s; }
.arena-wrap.glow { border-color: var(--glow); box-shadow: 0 0 0 6px var(--bg-sunk), 0 0 0 7px rgba(134, 223, 181, 0.5), 0 0 26px 6px rgba(134, 223, 181, 0.45); }
canvas { width: 100%; height: 100%; display: block; border-radius: 9px; }
.overlay { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; background: rgba(8, 10, 14, 0.78); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); border-radius: 9px; z-index: 2; }
.cd-label { font-size: clamp(14px, 4.4cqw, 26px); font-weight: 600; letter-spacing: 0.2em; text-transform: uppercase; color: var(--text); opacity: 0.8; }
.cd-num { font-size: clamp(120px, 55cqw, 420px); line-height: 1; font-weight: 800; color: #fff; font-variant-numeric: tabular-nums; text-shadow: 0 0 44px rgba(255, 82, 88, 0.5); }
.cd-num.tick { animation: cd-pop 0.9s ease-out; }
@keyframes cd-pop { 0% { transform: scale(1.4); opacity: 0.2; } 25% { opacity: 1; } 100% { transform: scale(1); opacity: 1; } }

.pads { display: flex; gap: 16px; margin-top: 18px; }
.pad { flex: 1; font: 600 32px/1 var(--mono); padding: 18px 0 20px; border-radius: 16px; background: linear-gradient(180deg, #1d222c, #161a22); color: var(--text); border: 1px solid var(--line-strong); box-shadow: 0 4px 0 #07090c, 0 10px 18px -10px rgba(0, 0, 0, 0.8); user-select: none; -webkit-user-select: none; touch-action: none; transition: opacity 0.15s, background 0.1s, transform 0.06s, box-shadow 0.06s, border-color 0.15s; }
.pad:hover { background: linear-gradient(180deg, #232935, #1a1f28); }
.pad.active { background: var(--accent-strong); border-color: #e8575d; color: #fff; transform: translateY(3px); box-shadow: 0 1px 0 #07090c, 0 6px 14px -8px rgba(255, 82, 88, 0.6); }
.pad.dim { opacity: 0.32; }

.chat { display: flex; flex-direction: column; height: 460px; position: relative; }
.log { flex: 1; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: var(--bg-sunk); scrollbar-width: thin; scrollbar-color: #2f3746 transparent; }
.log.short { flex: none; height: 200px; }
.log.tall { flex: none; height: 240px; }
.msg { margin: 0 0 8px; word-break: break-word; line-height: 1.45; }
.msg .who { font-weight: 650; margin-right: 8px; }
.msg .who.you { color: var(--text); }
.msg .who.partner { color: #9db4d6; }
.msg .ts { color: var(--muted); font: 11px var(--mono); margin-left: 8px; }
.marker { color: var(--muted); font-style: italic; font-size: 13px; margin: 0 0 6px; }
.pill { position: absolute; left: 50%; transform: translateX(-50%); bottom: 66px; min-height: 0; background: var(--text); color: #0a0c10; border-radius: 999px; padding: 5px 14px; font-size: 13px; font-weight: 650; box-shadow: 0 6px 16px -6px rgba(0, 0, 0, 0.8); }
.pill:hover { background: #fff; }
.pill:active { transform: translateX(-50%) translateY(1px); }
.chat-form { display: flex; gap: 8px; margin-top: 10px; }
.chat-form input { flex: 1; min-width: 0; }
.notice { color: var(--bad); font-size: 13px; min-height: 1.3em; margin-top: 6px; }
.legend { font-size: 13px; color: var(--muted); margin-top: 14px; }

/* keep clock + arena + A/B pads on one screen: the board shrinks with the window height */
.board { width: 100%; max-width: max(300px, calc(100svh - 290px)); margin-inline: auto; }
@media (max-width: 800px) { .board { max-width: min(100%, max(300px, calc(100svh - 290px))); } }
.board .card { margin-top: 16px; }

/* ---- end ----------------------------------------------------------------------------- */
.end-card { max-width: 480px; margin: 8vh auto 0; text-align: center; padding: 30px 26px 28px; }
.end-mark { color: var(--text); display: block; margin: 0 auto 6px; overflow: visible; }
.end-dot { fill: var(--blip); transition: transform 0.9s cubic-bezier(0.3, 0.7, 0.2, 1); }
#end.lost .end-dot { transform: translate(40px, -14px); }
#end .big { font-size: 34px; line-height: 1.15; font-weight: 700; margin: 8px 0 18px; letter-spacing: -0.005em; }
#end.lost .big { color: var(--bad); }
.stats { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 14px 0; margin-bottom: 16px; }
.stat { font-size: 15px; color: var(--muted); margin: 5px 0; }
.stat:first-child { color: var(--text); }
.links { display: flex; justify-content: center; gap: 12px; color: var(--muted); }

/* leaderboard */
.lb-card { width: 100%; max-width: 760px; overflow-x: auto; }
.lb { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.lb th, .lb td { padding: 10px 8px; border-bottom: 1px solid var(--line); text-align: left; }
.lb thead th { color: var(--muted); font-size: 0.8rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.lb .num { text-align: right; white-space: nowrap; }
.lb th.pair { font-weight: 600; overflow-wrap: anywhere; }
.lb tbody tr:first-child td, .lb tbody tr:first-child th { color: var(--blip); }
.lb tr.prov td, .lb tr.prov th { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
