/* Hexaequo — layout and components. Colours all come from tokens.css. */

*, *::before, *::after { box-sizing: border-box; }

/*
 * Tell the browser which way round the page is.
 *
 * A native dropdown list is drawn by the operating system, not by us: no rule
 * of ours reaches inside it. Without this it paints a light menu with light
 * text over our dark chrome, and the options are unreadable. color-scheme is
 * the one thing that reaches native widgets, and it also fixes scrollbars,
 * date pickers and the caret in the same stroke.
 */
:root[data-theme="dark"] { color-scheme: dark; }
:root[data-theme="light"] { color-scheme: light; }
/* 'auto' never reaches the attribute: settings.js resolves it first. */

html, body {
  height: 100%;
  margin: 0;
  overscroll-behavior: none;
}

body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font-sans);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  -webkit-text-size-adjust: 100%;
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
           env(safe-area-inset-bottom) env(safe-area-inset-left);
}

button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .35; cursor: not-allowed; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ── Site header ─────────────────────────────────────────────────────────── */

.site-header {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  flex: none;
}
.site-header .logo { flex: none; }
.site-header .spacer { flex: 1; }
:root[data-route="home"] .site-header { display: none; }

.btn {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 7px 12px;
  min-height: 36px;
  transition: background .15s var(--ease), border-color .15s var(--ease);
}
.btn:hover:not(:disabled) { background: var(--accent-soft); border-color: var(--accent); }
.btn.is-active, .btn.is-on { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.btn--icon { width: 38px; min-width: 38px; padding: 7px 0; text-align: center; line-height: 1.2; }
.btn--primary {
  background: var(--accent); color: var(--accent-ink);
  border-color: var(--accent); font-weight: 600;
}
.btn--primary:hover:not(:disabled) { filter: brightness(1.08); }

select.btn { padding-right: 8px; }
select.btn option {
  background: var(--surface);
  color: var(--text);
}

/* ── Logo ────────────────────────────────────────────────────────────────── */

.logo { display: flex; align-items: center; gap: .7em; }
.logo-mark { display: block; height: 1.9em; width: auto; }
.logo-word {
  font-weight: 300;
  letter-spacing: .27em;
  text-indent: .27em;      /* balance the trailing letter-space */
  white-space: nowrap;
}
.logo--sm { font-size: 15px; }
.logo--lg { font-size: clamp(30px, 8vw, 58px); flex-direction: column; gap: .5em; }
.logo--lg .logo-mark { height: 2.9em; }

/* ── Views ───────────────────────────────────────────────────────────────── */

#view { flex: 1; display: flex; flex-direction: column; min-height: 0; position: relative; }
.view-container { flex: 1; display: flex; flex-direction: column; min-height: 0; }

.page {
  flex: 1; overflow-y: auto; min-height: 0;
  padding: clamp(18px, 4vw, 40px);
  -webkit-overflow-scrolling: touch;
}
.page-inner { max-width: 780px; margin: 0 auto; }
.page h1 { font-size: 22px; margin: 0 0 6px; font-weight: 600; }
.page h2 {
  font-size: 12px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--muted); margin: 28px 0 10px; font-weight: 600;
}
.page p { margin: 0 0 10px; }
.page ul { margin: 0 0 12px; padding-left: 20px; }
.page li { margin-bottom: 5px; }
.lede { color: var(--muted); margin-bottom: 4px; }

/* ── Home ────────────────────────────────────────────────────────────────── */

/*
 * The home screen centres its content until the content is taller than the
 * screen, and then stops centring.
 *
 * justify-content: center on a scrolling flex container overflows equally at
 * both ends, and the top end cannot be scrolled to — the logo was cut off with
 * no way to reach it. An auto margin on a single child centres the same way
 * while collapsing to zero once there is no room, which leaves the top
 * reachable.
 */
.home {
  flex: 1; display: flex; flex-direction: column;
  padding: clamp(16px, 4vh, 32px) 20px; text-align: center; overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.home-inner {
  margin: auto; width: 100%;
  display: flex; flex-direction: column; align-items: center;
  gap: clamp(16px, 4.5vh, 44px);
}
.home-credit {
  color: var(--muted); font-size: 12px; margin: 0;
}
.home-menu { display: flex; flex-direction: column; gap: 10px; width: min(320px, 86vw); }
.home-menu .btn {
  min-height: var(--tap); font-size: 16px;
  display: flex; align-items: center; justify-content: center; gap: 10px;
}
.home-foot { color: var(--muted); font-size: 12px; display: flex; gap: 14px; align-items: center; }
.home-foot button {
  background: none; border: 0; color: var(--muted); text-decoration: underline;
  text-underline-offset: 3px; padding: 6px;
}

/* ── Game ────────────────────────────────────────────────────────────────── */

.game { flex: 1; display: flex; min-height: 0; position: relative; }
/* overflow:hidden matters: without it a panel parked outside this box by a
   transform stays visible and covers the reserve rail next to it. */
.board-area { flex: 1; position: relative; min-width: 0; display: flex; overflow: hidden; }
.board { flex: 1; width: 100%; height: 100%; display: block; touch-action: none; background: var(--board-bg); }
.board-fx { pointer-events: none; }
.cell { cursor: default; }
.cell.is-clickable { cursor: pointer; }
[data-fx], .fx-ghost, .fx-flyer { transform-box: fill-box; transform-origin: center; }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }
.pulse { animation: pulse 1.4s ease-in-out infinite; }

/* Reserves on either side of the board, shown as real pieces. */
.rail {
  width: 164px; flex: none; overflow-y: auto;
  background: var(--surface);
  border-left: 1px solid transparent; border-right: 1px solid transparent;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 12px 7px;
  transition: border-color .3s var(--ease), box-shadow .3s var(--ease);
}
.rail.is-turn { border-color: var(--accent); box-shadow: inset 0 0 30px var(--spot-fill-strong); }
.player-dot {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--piece-dark-edge); background: var(--piece-dark);
  box-shadow: 0 0 0 1px var(--line);
}
.player-dot.is-white { background: var(--piece-light); border-color: var(--piece-light-edge); }
.rail.is-thinking .player-dot { animation: pulse 1s ease-in-out infinite; }
.stack { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; width: 100%; }
.token {
  width: 36px; height: 36px; display: block; padding: 2px; border-radius: var(--radius-sm);
  background: var(--accent-soft); background: rgba(128, 128, 128, .1);
  transition: transform .14s var(--ease), background .14s var(--ease);
}
.token svg { width: 100%; height: 100%; display: block; overflow: visible; }
.token.is-usable { cursor: pointer; }
.token.is-usable:hover { transform: translateY(-3px) scale(1.12); background: var(--accent-soft); }
.token.is-armed { filter: drop-shadow(0 0 4px var(--accent)) drop-shadow(0 0 2px var(--accent)); }
.rail-sep { width: 78%; height: 0; border-top: 1px dashed var(--line); margin: 5px 0 3px; }

.chain-bar {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 5;
  background: var(--surface); border: 1px solid var(--accent); border-radius: var(--radius-md);
  padding: 5px 7px; display: none; align-items: center; gap: 6px; box-shadow: var(--shadow-md);
}
.chain-bar.is-on { display: flex; }
.chain-bar .taken { display: flex; gap: 3px; padding: 0 4px; }

.result-overlay {
  position: absolute; inset: 0; z-index: 6; display: none;
  align-items: center; justify-content: center; padding: 20px;
  background: color-mix(in srgb, var(--bg) 78%, transparent);
}
.result-overlay.is-on { display: flex; }
.result-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 24px 30px; text-align: center; box-shadow: var(--shadow-lg); max-width: 340px;
}
.result-title {
  display: flex; align-items: center; justify-content: center; gap: 11px;
  font-size: 19px; font-weight: 600;
}
.result-why { color: var(--muted); font-size: 13px; margin: 7px 0 16px; }
.result-note { color: var(--accent); font-size: 13px; margin: -8px 0 14px; min-height: 0; }
.result-note:empty { display: none; }
.result-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

/*
 * Reading back through a game.
 *
 * The bar sits under the board and stays out of the way until there is
 * something to look back on. While the player is behind the live position the
 * board is tinted and a way back is offered, so nobody loses track of which
 * position is the real one.
 */
.review-bar {
  display: none; align-items: center; justify-content: center;
  gap: 6px; flex-wrap: wrap;      /* the way back appears late and must still fit */
  flex: none; padding: 6px 10px; border-top: 1px solid var(--line);
}
.review-bar.is-on { display: flex; }
.review-ply {
  font: 600 12px/1 var(--font-mono); color: var(--muted);
  min-width: 5.5em; text-align: center; font-variant-numeric: tabular-nums;
}
.review-live { display: none; font-size: 12px; margin-left: 6px; }
@media (max-width: 480px) {
  /* On a phone the arrows are the controls that matter; the words shrink. */
  .review-live { margin-left: 0; padding: 5px 9px; min-height: 32px; }
  .review-ply { min-width: 4.4em; }
}
.review-bar.is-back .review-live { display: inline-flex; }
.game.is-reviewing .board-host { background: color-mix(in srgb, var(--accent) 7%, transparent); }
.game.is-reviewing .board-host::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  box-shadow: inset 0 0 0 2px var(--accent); opacity: .35;
}
.board-host { position: relative; }

/*
 * The move list rises from the bottom of the board area rather than the side.
 * The sides belong to the reserves, which must stay readable at all times; the
 * bottom is also where the chat tab will live for online games.
 */
.drawer {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 9;
  height: min(240px, 45%);
  display: flex; flex-direction: column;
  background: var(--surface); border-top: 1px solid var(--line);
  transform: translateY(101%); transition: transform .3s var(--ease);
}
.drawer.is-on { transform: none; box-shadow: 0 -14px 40px rgba(0, 0, 0, .35); }
.drawer-tabs {
  display: flex; align-items: center; gap: 6px; flex: none;
  padding: 8px 12px; border-bottom: 1px solid var(--line);
}
.drawer-tab {
  background: none; border: 0; border-bottom: 2px solid transparent;
  padding: 5px 4px; color: var(--muted);
  font-size: 12px; letter-spacing: .1em; text-transform: uppercase; font-weight: 600;
}
.drawer-tab.is-active { color: var(--text); border-bottom-color: var(--accent); }
.drawer-body { flex: 1; overflow-y: auto; min-height: 0; padding: 10px 12px; }
.move-list {
  font: 12px/1.7 var(--font-mono);
  columns: 240px; column-gap: 22px;   /* a wide, short panel: use the width */
  flex: none;                          /* the drawer body scrolls, not the list */
}
.move-list > div { break-inside: avoid; }
.move-list div { display: flex; gap: 8px; white-space: nowrap; }
.move-list .n { color: var(--muted); width: 26px; flex: none; text-align: right; }
.move-list .black { width: 104px; flex: none; }
.move-list .took { color: var(--danger); }
/* Every half-move is a way into the review. */
.move-list .ply { cursor: pointer; border-radius: 3px; padding: 0 3px; margin: 0 -3px; }
.move-list .ply:hover { background: var(--surface-2); }
.move-list .ply.is-at { background: var(--accent-soft); color: var(--text); font-weight: 600; }

/* Chat lives in the same drawer, one tab over. */
.drawer-tab { position: relative; }
.tab-dot { display: none; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.drawer-tab.has-unread .tab-dot {
  display: block; position: absolute; top: 2px; right: -4px;
}
.drawer-body { display: flex; flex-direction: column; }
.chat-pane { display: flex; flex-direction: column; flex: 1; min-height: 0; gap: 8px; }
.chat-log { flex: 1; overflow-y: auto; min-height: 0; display: flex; flex-direction: column; gap: 5px; }
.chat-line { display: flex; gap: 8px; font-size: 13.5px; line-height: 1.45; }
.chat-who { color: var(--muted); flex: none; max-width: 9em; overflow: hidden; text-overflow: ellipsis; }
.chat-line.is-mine .chat-who { color: var(--accent); }
.chat-text { word-break: break-word; }
.chat-form { display: flex; gap: 6px; flex: none; }
.chat-input { flex: 1; text-align: left; font-weight: 400; background: var(--bg); }

/* ── Floating panels ─────────────────────────────────────────────────────── */

.overlay { position: fixed; inset: 0; z-index: 50; display: none; }
.overlay.is-on { display: block; }
.overlay-backdrop {
  position: absolute; inset: 0;
  background: color-mix(in srgb, var(--bg) 68%, transparent);
  animation: overlay-fade .18s var(--ease);
}
.overlay-panel {
  position: absolute; top: 0; right: 0; bottom: 0;
  width: min(560px, 100%);
  display: flex; flex-direction: column;
  background: var(--surface); border-left: 1px solid var(--line);
  box-shadow: -18px 0 50px rgba(0, 0, 0, .4);
  animation: overlay-slide .24s var(--ease);
  padding-bottom: env(safe-area-inset-bottom);
}
.overlay-head {
  display: flex; align-items: center; gap: 12px; flex: none;
  padding: 10px 12px 10px 18px; border-bottom: 1px solid var(--line);
}
.overlay-title {
  font-size: 12px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--muted); font-weight: 600; flex: 1;
}
.overlay-body { flex: 1; overflow-y: auto; min-height: 0; -webkit-overflow-scrolling: touch; }
.overlay-body .page { padding-top: 18px; }
.overlay-body .page h1 { display: none; }   /* the panel header already names it */

@keyframes overlay-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes overlay-slide { from { transform: translateX(18px); opacity: 0; } to { transform: none; opacity: 1; } }

@media (max-width: 640px) {
  .overlay-panel { top: auto; height: 88%; width: 100%; border-left: 0; border-top: 1px solid var(--line); }
  @keyframes overlay-slide { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
}

/* ── Online ──────────────────────────────────────────────────────────────── */

.net-strip {
  display: none; align-items: center; gap: 10px; flex: none;
  padding: 7px 12px; background: var(--surface); border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.net-strip.is-on { display: flex; }
.net-strip.is-warn { border-bottom-color: var(--danger); color: var(--danger); }
.net-strip .net-msg { color: var(--muted); }
.net-strip.is-warn .net-msg { color: var(--danger); }
.board-area { flex-direction: column; }
.board-area > .board-host { flex: 1; min-height: 0; }

.clock {
  font: 600 19px/1 var(--font-mono); letter-spacing: .04em;
  padding: 6px 8px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--line); color: var(--muted);
  font-variant-numeric: tabular-nums; min-width: 4.2em; text-align: center;
}
.clock.is-running { color: var(--text); border-color: var(--accent); background: var(--accent-soft); }
.clock.is-low { color: var(--danger); border-color: var(--danger); }

.cadence-grid { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 4px; }
.cadence-grid .cadence { flex: 1 1 auto; min-width: 9em; }

.room-code {
  font: 600 26px/1.2 var(--font-mono); letter-spacing: .22em;
  color: var(--accent); margin: 6px 0 12px;
}
.room-code--sm { font-size: 14px; margin: 0; letter-spacing: .16em; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.code-input {
  font: 600 17px/1 var(--font-mono); letter-spacing: .2em; text-transform: uppercase;
  width: 8em; text-align: center; background: var(--bg);
}
.net-error {
  border: 1px solid var(--danger); border-radius: var(--radius-sm);
  padding: 9px 12px; color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, transparent);
}

/* Two ways into the same page: find a game, or go and see who is around. */
.page-tabs { display: flex; gap: 4px; margin: 0 0 14px; border-bottom: 1px solid var(--line); }
.page-tab {
  background: none; border: 0; border-bottom: 2px solid transparent;
  padding: 8px 14px; color: var(--muted); font-size: 14px; font-weight: 600;
}
.page-tab.is-active { color: var(--text); border-bottom-color: var(--accent); }

/* ── Lobby ───────────────────────────────────────────────────────────────── */

.lobby-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.lobby-head h3 { margin: 0; }
.lobby-count { color: var(--muted); font-size: 12px; flex: 1; }
.btn--sm { padding: 4px 10px; font-size: 12px; min-height: 0; }
.lobby-list { margin-top: 10px; display: flex; flex-direction: column; }
.lobby-row {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 2px; border-top: 1px solid var(--line);
}
.lobby-row.is-me { color: var(--accent); }
.lobby-name { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lobby-elo { font: 600 13px/1 var(--font-mono); color: var(--muted); font-variant-numeric: tabular-nums; }
.lobby-status { font-size: 12px; color: var(--muted); min-width: 5.5em; text-align: right; }
.lobby-status.is-busy { color: var(--accent); }
.lobby-notice {
  border: 1px solid var(--accent); border-radius: var(--radius-sm);
  padding: 9px 12px; color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  margin-bottom: 12px;
}
.challenge-card { border-color: var(--accent); }
.chat-block { display: flex; flex-direction: column; gap: 10px; }
.lobby-chat { max-height: 210px; overflow-y: auto; }

/* Quick match: the search reads as one widening range, not a spinner. */
.rule-block.searching { border-color: var(--accent); }
.rule-block.searching h3::after {
  content: ''; display: inline-block; width: 7px; height: 7px; margin-left: 8px;
  border-radius: 50%; background: var(--accent); vertical-align: middle;
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: .25; } 50% { opacity: 1; } }
.search-band {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  font: 600 15px/1.2 var(--font-mono); font-variant-numeric: tabular-nums;
}
.search-range { color: var(--text); }
.search-timer { color: var(--muted); }
.search-bar {
  height: 5px; border-radius: 999px; background: var(--surface-2);
  overflow: hidden; margin-top: 8px;
}
.search-bar i { display: block; height: 100%; background: var(--accent); transition: width .4s linear; }

@media (prefers-reduced-motion: reduce) {
  .rule-block.searching h3::after { animation: none; opacity: .8; }
  .search-bar i { transition: none; }
}

/* ── Rules ───────────────────────────────────────────────────────────────── */

.rule-block {
  border: 1px solid var(--line); border-radius: var(--radius-md);
  background: var(--surface); padding: 14px 16px; margin-bottom: 14px;
}
.rule-block h3 { margin: 0 0 8px; font-size: 16px; font-weight: 600; }
.rule-figure { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.rule-figure .mini {
  flex: none; width: 200px; height: 170px;
  background: var(--board-bg); border: 1px solid var(--line); border-radius: var(--radius-sm);
}
.rule-figure .caption { flex: 1; min-width: 200px; color: var(--muted); font-size: 13.5px; }
.rule-figure .mini svg { width: 100%; height: 100%; display: block; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; margin: 10px 0 2px; }
.legend span { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--muted); }
.legend .token { cursor: default; }

/* ── Settings ────────────────────────────────────────────────────────────── */

.setting {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 13px 0; border-bottom: 1px solid var(--line);
}
.setting:last-child { border-bottom: 0; }
.setting-label { flex: 1; min-width: 170px; }
.setting-label b { display: block; font-weight: 600; }
.setting-label small { color: var(--muted); font-size: 12.5px; }
.segmented { display: flex; gap: 0; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; }
.segmented button {
  background: var(--surface-2); border: 0; padding: 9px 13px; min-height: var(--tap);
  border-right: 1px solid var(--line);
}
.segmented button:last-child { border-right: 0; }
.segmented button.is-active { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.switch {
  width: 50px; height: 29px; border-radius: 15px; border: 1px solid var(--line);
  background: var(--surface-2); position: relative; padding: 0; flex: none;
  transition: background .2s var(--ease), border-color .2s var(--ease);
}
.switch::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 21px; height: 21px;
  border-radius: 50%; background: var(--muted); transition: transform .2s var(--ease), background .2s var(--ease);
}
.switch[aria-checked="true"] { background: var(--accent); border-color: var(--accent); }
.switch[aria-checked="true"]::after { transform: translateX(21px); background: var(--accent-ink); }
input[type="range"] { accent-color: var(--accent); width: 150px; }
.preview-board {
  width: 100%; height: 190px; background: var(--board-bg);
  border: 1px solid var(--line); border-radius: var(--radius-md); margin-top: 6px;
}
.preview-board svg { width: 100%; height: 100%; display: block; }

/* ── Small screens ───────────────────────────────────────────────────────── */

@media (max-width: 820px) {
  .game { flex-wrap: wrap; }
  .board-area { order: 1; flex: 1 0 100%; min-height: 42vh; }
  .rail {
    order: 2; flex: 1 1 50%; width: auto; max-height: 34vh;
    flex-direction: row; flex-wrap: wrap; align-content: flex-start;
    border-top: 1px solid var(--line); border-left: 0; border-right: 0;
  }
  .rail.is-turn { border-color: var(--accent); }
  .stack { width: auto; }
  .site-header { padding: 6px 8px; gap: 6px; }
  .site-header .logo-word { display: none; }
  .drawer { height: min(200px, 55%); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ── Legal pages ─────────────────────────────────────────────────────────── */

.legal h2 { margin: 26px 0 8px; font-size: 13px; }
.legal p { max-width: 62ch; }
.legal-date { color: var(--muted); font-size: 12px; margin-bottom: 18px; }
.legal-foot { display: flex; align-items: center; gap: 16px; margin: 36px 0 8px; }
.legal-mark { height: 34px; opacity: .5; }
.legal-mark svg { height: 100%; width: auto; }

/* ── Account ─────────────────────────────────────────────────────────────── */

#account-chip { display: flex; align-items: center; gap: 8px; }
#account-chip .chip-elo { color: var(--accent); font-variant-numeric: tabular-nums; font-weight: 600; }
#account-chip.is-signed-in { border-color: var(--accent); }
.account-head { display: flex; align-items: center; gap: 14px; margin-bottom: 8px; }
.account-head .avatar { width: 56px; height: 56px; border-radius: 50%; border: 1px solid var(--line); }
.google-button { display: flex; justify-content: center; margin: 22px 0 8px; min-height: 44px; }
.nickname-input { font-size: 16px; width: 14em; }
.nickname-hint.is-bad { color: var(--danger); }

/* ── Pre-boot copy ───────────────────────────────────────────────────────── */

/*
 * Shown for the fraction of a second before the app mounts, and to anything
 * that never runs JavaScript. Styled to look deliberate rather than like a
 * flash of unstyled text.
 */
.boot-copy {
  max-width: 62ch; margin: auto; padding: clamp(24px, 6vw, 56px);
  color: var(--muted); font-size: 14px; line-height: 1.6;
}
.boot-copy h1 {
  color: var(--accent); font-weight: 300;
  letter-spacing: .27em; text-transform: uppercase;
  font-size: clamp(22px, 5vw, 34px); margin: 0 0 18px;
}
.boot-copy a { color: var(--accent); text-decoration: none; }
.boot-copy a:hover { text-decoration: underline; }
.home-purpose {
  color: var(--muted); font-size: 13.5px; line-height: 1.6;
  max-width: 46ch; margin: -8px auto 0;
}

/* ── Leaderboard ─────────────────────────────────────────────────────────── */

.board-table { width: 100%; border-collapse: collapse; font-size: 14px; margin-top: 10px; }
.board-table th {
  text-align: left; font-size: 11px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted); font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--line);
}
.board-table td { padding: 8px; border-bottom: 1px solid var(--line); }
.board-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.board-table .rank { color: var(--muted); width: 3em; }
.board-table .elo { color: var(--accent); font-weight: 600; }
.board-table tr.is-me { background: var(--accent-soft); }
.board-table tr.is-me td { font-weight: 600; }
.net-vs { display: flex; align-items: center; gap: 6px; color: var(--text); }
.net-vs .net-elo { color: var(--accent); font-variant-numeric: tabular-nums; font-size: 12px; }
.net-stake {
  font-size: 11px; letter-spacing: .08em; text-transform: uppercase;
  padding: 3px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted);
}
.net-stake.is-rated { border-color: var(--accent); color: var(--accent); }
.result-rating { font-variant-numeric: tabular-nums; font-weight: 600; margin: 0 0 14px; }
.result-rating.is-up { color: var(--green, #5cba7d); }
.result-rating.is-down { color: var(--danger); }

/* ── Signing in, and the profile ─────────────────────────────────────────── */

.auth-form { display: flex; flex-direction: column; gap: 8px; margin: 14px 0 4px; }
.auth-input {
  text-align: left; font-weight: 400; background: var(--bg);
  font-size: 15px; padding: 10px 12px;
}
.btn--link {
  background: none; border: 0; color: var(--muted); font-size: 13px;
  padding: 4px; text-decoration: underline; align-self: flex-start; min-height: 0;
}
.btn--link:hover { color: var(--text); }
/* A rule with the word "or" sitting in it, between the two doors. */
.auth-or {
  display: flex; align-items: center; gap: 12px;
  color: var(--muted); font-size: 12px; margin: 18px 0 14px;
}
.auth-or::before, .auth-or::after {
  content: ''; flex: 1; height: 1px; background: var(--line);
}

.profile-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 16px;
}
.profile-elo { text-align: right; }
.profile-elo b {
  display: block; font: 600 30px/1 var(--font-mono);
  color: var(--accent); font-variant-numeric: tabular-nums;
}
.muted-small { color: var(--muted); font-size: 12px; font-weight: 400; }

.curve { position: relative; margin: 4px 0 20px; }
.curve svg { width: 100%; height: 130px; display: block; }
.curve-scale {
  position: absolute; inset: 0 0 0 auto; display: flex; flex-direction: column;
  justify-content: space-between; padding: 2px 0; pointer-events: none;
}
.curve-scale span {
  font: 11px/1 var(--font-mono); color: var(--muted);
  background: var(--surface); padding: 1px 4px; border-radius: 3px;
}

.game-list { display: flex; flex-direction: column; }
.game-row {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 9px 4px; border: 0; border-top: 1px solid var(--line);
  background: none; color: var(--text); text-align: left; font-size: 13.5px;
}
.game-row:hover { background: var(--surface-2); }
.game-vs { flex: 1; display: flex; align-items: center; gap: 7px; min-width: 0; }
.game-vs > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.game-meta { color: var(--muted); font-size: 12px; white-space: nowrap; }
.outcome {
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em;
  padding: 3px 7px; border-radius: 4px; flex: none; min-width: 5.4em; text-align: center;
}
.outcome.is-win { background: color-mix(in srgb, var(--green, #5cba7d) 22%, transparent); color: var(--green, #5cba7d); }
.outcome.is-loss { background: color-mix(in srgb, var(--danger) 18%, transparent); color: var(--danger); }
.outcome.is-draw { background: var(--surface-2); color: var(--muted); }
.delta { font: 600 12px/1 var(--font-mono); font-variant-numeric: tabular-nums; min-width: 3em; text-align: right; }
.delta.is-up { color: var(--green, #5cba7d); }
.delta.is-down { color: var(--danger); }

@media (max-width: 560px) {
  /* On a phone the cadence and the move count are the first things to go. */
  .game-row .game-meta:nth-of-type(-n+2) { display: none; }
}

/* Whoever read to the end of the rules is the one who wants to know. */
.rules-colophon {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  margin: 40px 0 10px; opacity: .55;
}
.rules-mark { height: 52px; }
.rules-colophon p { margin: 0; font-size: 12.5px; color: var(--muted); }

/*
 * Choosing between a disk and a ring.
 *
 * In HTML above the board rather than inside it, so the targets are a real
 * size in real pixels whatever the board is scaled to. Two circles sized in
 * board units came out around thirteen pixels across on a phone.
 */
.piece-picker {
  position: absolute; z-index: 7; display: flex; gap: 6px;
  background: var(--surface); border: 1px solid var(--accent);
  border-radius: var(--radius-md); padding: 6px; box-shadow: var(--shadow-lg);
  animation: picker-in .14s var(--ease);
}
.piece-picker[hidden] { display: none; }
@keyframes picker-in { from { opacity: 0; transform: translateY(4px) scale(.96); } }
.piece-choice {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  min-width: 72px; min-height: 72px; padding: 8px 10px;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--radius-sm); color: var(--text);
  font-size: 12px; font-weight: 600;
  transition: background .13s var(--ease), border-color .13s var(--ease);
}
.piece-choice:hover, .piece-choice:active {
  background: var(--accent-soft); border-color: var(--accent);
}
.piece-choice-art { width: 40px; height: 40px; display: block; }
.piece-choice-art svg { width: 100%; height: 100%; display: block; overflow: visible; }

@media (pointer: coarse) {
  /* A finger needs more than a cursor does. */
  .piece-choice { min-width: 84px; min-height: 84px; }
  .piece-choice-art { width: 48px; height: 48px; }
}

.review-speed { padding: 3px 6px; min-height: 30px; font-size: 12px; }
