:root {
  --paper: #EEF2F4; --ground: #D3DCE2; --sq: #E4EAEE; --tile: #FCFCFA; --track: #8592A1; --casing: #FCFCFA;
  --text: #1D2733; --muted: #556373; --line: #C7D0D7;
  --p0: #E0473B; --p1: #2869D8; --p2: #179A56; --p3: #E3A000; --p4: #8B4FC0; --p5: #0A9898;
  --blend: multiply; --btn-bg: #1D2733; --btn-text: #FCFCFA;
  color-scheme: light; box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #11151B; --ground: #0A0D12; --sq: #161A21; --tile: #28303C; --track: #66737F; --casing: #28303C;
    --text: #E6EAF0; --muted: #9DA8B8; --line: #2A3341;
    --p0: #FF6257; --p1: #5590F2; --p2: #2DBF74; --p3: #FFBE2E; --p4: #A97BDD; --p5: #25C1C1;
    --blend: normal; --btn-bg: #E6EAF0; --btn-text: #11151B; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #11151B; --ground: #0A0D12; --sq: #161A21; --tile: #28303C; --track: #66737F; --casing: #28303C;
  --text: #E6EAF0; --muted: #9DA8B8; --line: #2A3341;
  --p0: #FF6257; --p1: #5590F2; --p2: #2DBF74; --p3: #FFBE2E; --p4: #A97BDD; --p5: #25C1C1;
  --blend: normal; --btn-bg: #E6EAF0; --btn-text: #11151B; color-scheme: dark;
}
*, *::before, *::after { box-sizing: border-box; }
html { scroll-padding-top: env(safe-area-inset-top, 0px); }
html, body { margin: 0; }
body {
  background: var(--paper); color: var(--text);
  font-family: "Overpass", "Helvetica Neue", Arial, system-ui, sans-serif;
  font-size: 16px; line-height: 1.5; -webkit-text-size-adjust: 100%;
}
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--paper); }
#app { max-width: 1080px; margin: 0 auto; padding: 14px 16px 0; }
.top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.wordmark { margin: 0; font-weight: 900; letter-spacing: -0.015em; line-height: .95; font-size: 1.6rem; }
body[data-view="landing"] .wordmark { font-size: clamp(3.4rem, 14vw, 6.5rem); margin-top: .2em; }
.status { color: var(--muted); font-size: .9375rem; font-weight: 600; text-align: right; }
h2 { font-size: 1.2rem; font-weight: 800; margin: 0 0 .5rem; line-height: 1.25; }
p { margin: 0 0 .75rem; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }

.intro { display: grid; gap: 8px 40px; padding-bottom: 48px; }
.hero { width: min(100%, 300px); margin: 18px 0 4px; }
@media (min-width: 820px) {
  .intro { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
  .hero { width: 100%; margin-top: 8px; grid-column: 2; grid-row: 1 / span 2; }
}
.lede { font-size: 1.1875rem; line-height: 1.45; margin: 1rem 0 1.25rem; max-width: 32em; }
.rules { padding-left: 1.4em; margin: 0 0 1.75rem; max-width: 38em; }
.rules li { margin-bottom: .45rem; padding-left: .2em; }
.rules li::marker { font-weight: 800; color: var(--muted); }
.starts { display: grid; border-top: 1.5px solid var(--line); }
.start { padding: 1.25rem 0; border-bottom: 1.5px solid var(--line); }
@media (min-width: 720px) {
  .starts { grid-template-columns: 1fr 1fr; }
  .start:first-child { padding-right: 1.5rem; }
  .start + .start { padding-left: 1.5rem; border-left: 1.5px solid var(--line); }
}
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.btn {
  font: inherit; font-weight: 700; line-height: 1.2; padding: .72em 1.25em; border-radius: 10px;
  border: 1.5px solid var(--btn-bg); background: var(--btn-bg); color: var(--btn-text); cursor: pointer; min-height: 44px;
}
.btn.quiet { background: transparent; color: var(--text); border-color: var(--line); }
.btn.warn { background: transparent; color: var(--text); border-color: var(--p0); }
.btn.icon { padding: 0; width: 44px; font-size: 1.25rem; }
.btn:disabled { opacity: .4; cursor: default; }
.btn:focus-visible, .seg-btn:focus-visible, .htile:focus-visible, input:focus-visible, summary:focus-visible { outline: 3px solid var(--p1); outline-offset: 2px; }
input[type="text"] {
  font: inherit; color: var(--text); background: var(--tile); border: 1.5px solid var(--line);
  border-radius: 10px; padding: .65em .9em; min-height: 44px; width: 13rem; max-width: 100%;
}
.seg { display: inline-flex; border: 1.5px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; }
.seg-btn { font: inherit; font-size: .9375rem; font-weight: 600; border: 0; border-radius: 7px; background: transparent; color: var(--text); padding: .45em .95em; cursor: pointer; min-height: 36px; }
.seg-btn[aria-pressed="true"] { background: var(--text); color: var(--paper); }
.field { display: block; margin: 0 0 1rem; }
.field > span { display: block; font-size: .875rem; color: var(--muted); margin-bottom: .3rem; font-weight: 600; }

.lobby { max-width: 34rem; padding: 1.25rem 0 48px; }
.roster { list-style: none; margin: 0 0 1.25rem; padding: 0; }
.roster li { display: flex; align-items: center; gap: 10px; padding: .5rem 0; border-bottom: 1px solid var(--line); }
.roster .name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.roster .tag { font-size: .8125rem; color: var(--muted); }
.roster .state { margin-left: auto; font-size: .8125rem; color: var(--muted); white-space: nowrap; }
.roster .state.ready { color: var(--text); font-weight: 700; }
.roster .score { font-weight: 900; font-variant-numeric: tabular-nums; min-width: 2ch; text-align: right; }
.roster .name + .score, .roster .tag + .score { margin-left: auto; }
.swatch { width: 18px; height: 6px; border-radius: 3px; background: var(--ink); flex: none; }

.game { display: grid; gap: 18px; padding-top: 12px; }
@media (min-width: 860px) { .game { grid-template-columns: minmax(0, 1fr) 300px; align-items: start; gap: 32px; } }
.board-slot { max-width: 620px; }
svg.tboard { display: block; width: 100%; height: auto; }
.tboard .ground { fill: var(--ground); }
.tboard .sq { fill: var(--sq); }
.tboard .tile { fill: var(--tile); }
.tboard .casing { fill: none; stroke: var(--casing); stroke-width: .13; stroke-linecap: butt; }
.tboard .track { fill: none; stroke: var(--track); stroke-width: .05; stroke-linecap: round; }
.tboard .trail { fill: none; stroke-width: .08; stroke-linecap: round; }
.tboard .piece { stroke: var(--tile); stroke-width: .035; }
.tboard .front { fill: none; stroke-width: .035; stroke-dasharray: .09 .06; }
.tboard .ghost-tile { opacity: .6; }
.tboard .proj { fill: none; stroke-width: .06; stroke-dasharray: .07 .07; stroke-linecap: round; }
.tboard .land { fill: none; stroke-width: .035; }
.tboard .xmark { stroke-width: .05; stroke-linecap: round; }
.tboard .pending { opacity: 0; }
.tboard .drop { animation: drop 360ms cubic-bezier(.2, .9, .3, 1.2) backwards; transform-box: fill-box; transform-origin: center; }
@keyframes drop { from { opacity: 0; transform: scale(1.25); } to { opacity: 1; transform: scale(1); } }
.tboard .burst { animation: burst 600ms ease-out forwards; transform-box: fill-box; transform-origin: center; }
@keyframes burst { 0% { transform: scale(1); opacity: 1; } 40% { transform: scale(2.2); opacity: .8; } 100% { transform: scale(2.8); opacity: 0; } }
.tboard .fadeout { transition: opacity 400ms; opacity: 0; }
.tboard .appear { animation: appear 500ms ease-out backwards; transform-box: fill-box; transform-origin: center; }
@keyframes appear { from { opacity: 0; transform: scale(.2); } to { opacity: 1; transform: scale(1); } }

.side section { margin-bottom: 1.25rem; }
.recap ul { list-style: none; padding: 0; margin: 0 0 .5rem; font-size: .9375rem; }
.recap li { display: flex; gap: 8px; align-items: baseline; padding: .3rem 0; border-top: 1px solid var(--line); }
.recap li .swatch { position: relative; top: -2px; }
.recap li .delta { margin-left: auto; font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.final { font-size: 1.125rem; }
details.howto { border-top: 1.5px solid var(--line); padding-top: .75rem; }
details.howto summary { cursor: pointer; font-weight: 700; }
details.howto .rules { margin: .75rem 0 0; font-size: .9375rem; }
.host-tools { border-top: 1.5px solid var(--line); padding-top: .75rem; }

.actionbar {
  position: sticky; bottom: 0; z-index: 5; margin: 18px -16px 0;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
  background: var(--paper); border-top: 1.5px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; gap: 10px 14px; flex-wrap: wrap;
}
.actionbar p { margin: 0; }
.actionbar .row { margin-left: auto; }
.hand { display: flex; gap: 8px; }
.htile { width: 64px; height: 64px; padding: 4px; border-radius: 10px; border: 2px solid var(--line); background: var(--tile); cursor: pointer; }
.htile[aria-pressed="true"] { border-color: var(--ink); box-shadow: 0 0 0 2px var(--ink); }
.htile svg { width: 100%; height: 100%; display: block; }
/* Picking controls: the tiles with their turn buttons, then Quit and Lock in
   on the right. The hint always has its own line, so its length never moves
   the controls. On narrow screens, where the hint can wrap, it keeps room for
   two lines, so the bar's height stays the same too. */
.picker { flex: 1 1 100%; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; }
.picker .turn { display: flex; gap: 8px; }
.picker .row { margin-left: auto; }
.picker .hint { flex-basis: 100%; min-height: 2.625rem; }
@media (min-width: 720px) { .picker .hint { min-height: 0; } }
.hint { font-size: .875rem; color: var(--muted); }
.hint.danger { color: var(--text); font-weight: 700; }

.toast {
  position: fixed; left: 50%; bottom: calc(110px + env(safe-area-inset-bottom, 0px)); z-index: 20;
  transform: translate(-50%, 8px); opacity: 0; pointer-events: none; background: var(--text); color: var(--paper);
  padding: .6em 1.1em; border-radius: 10px; font-size: .9375rem; max-width: min(92vw, 30rem); text-align: center; transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.loading { padding: 3rem 0; color: var(--muted); }
@media (prefers-reduced-motion: reduce) {
  .tboard .drop, .tboard .burst, .tboard .appear { animation: none; }
}


/* ---------- new for the online build ---------- */
a { color: inherit; }
.linkbox { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 0 0 1rem; }
.linkbox input[type="text"] { flex: 1 1 14rem; width: auto; font-size: .875rem; color: var(--muted); }
input[type="url"], input[type="password"] {
  font: inherit; color: var(--text); background: var(--tile); border: 1.5px solid var(--line);
  border-radius: 10px; padding: .65em .9em; min-height: 44px; width: 100%; max-width: 26rem;
}
input[type="url"]:focus-visible, input[type="password"]:focus-visible, details > summary:focus-visible { outline: 3px solid var(--p1); outline-offset: 2px; }
.block { border-top: 1.5px solid var(--line); padding-top: 1rem; margin-top: 1.25rem; }
details.fold { border-top: 1.5px solid var(--line); padding-top: .75rem; margin-top: 1.25rem; }
details.fold summary { cursor: pointer; font-weight: 700; }
details.fold[open] summary { margin-bottom: .6rem; }
.roster .rm { margin-left: auto; font: inherit; font-size: .8125rem; font-weight: 700; color: var(--muted); background: none; border: 1.5px solid var(--line); border-radius: 8px; padding: .25em .7em; min-height: 32px; cursor: pointer; }
.roster .rm.armed { color: var(--text); border-color: var(--p0); }
.roster .rm:focus-visible { outline: 3px solid var(--p1); outline-offset: 2px; }
.set-tag { font-size: .8125rem; font-weight: 800; padding: .15em .55em; border-radius: 6px; background: var(--line); }
.past { margin-top: 2rem; }
.thumbs { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 6px; }
.thumbs figure { margin: 0; flex: none; width: 128px; }
.thumbs figcaption { font-size: .8125rem; color: var(--muted); line-height: 1.3; margin-top: .3rem; }
.notice { border-left: 4px solid var(--line); padding: .25rem 0 .25rem .8rem; }
.mini-btn { font: inherit; font-size: .8125rem; font-weight: 700; color: var(--text); background: none; border: 1.5px solid var(--line); border-radius: 8px; padding: .2em .7em; min-height: 32px; cursor: pointer; }
.mini-btn:focus-visible { outline: 3px solid var(--p1); outline-offset: 2px; }

/* Game log */
details.log .log-round { margin-top: .9rem; }
.log-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: .35rem; }
.log-head h3 { font-size: 1rem; font-weight: 800; margin: 0; }
details.log .log-round ul { margin-bottom: .25rem; }

/* End-of-game stats */
.stats { margin-top: 1.5rem; }
.highlights { list-style: none; padding: 0; margin: 0 0 1rem; }
.highlights li { padding: .4rem 0; border-top: 1px solid var(--line); }
.table-wrap { overflow-x: auto; margin-bottom: .5rem; }
.stats-table { width: 100%; border-collapse: collapse; font-size: .9375rem; font-variant-numeric: tabular-nums; }
.stats-table th, .stats-table td { padding: .45rem .5rem; text-align: right; border-top: 1px solid var(--line); white-space: nowrap; }
.stats-table th:first-child { text-align: left; padding-left: 0; }
.stats-table thead th { font-size: .8125rem; font-weight: 700; color: var(--muted); border-top: 0; white-space: normal; vertical-align: bottom; }
.stats-table tbody th { font-weight: 700; }
.stats-table .who { display: inline-flex; align-items: center; gap: 8px; max-width: 10rem; }
.stats-table .who .name { overflow: hidden; text-overflow: ellipsis; }
.stats-narrow .stats { margin-top: 0; margin-bottom: 1.25rem; }
@media (min-width: 860px) { .stats-narrow { display: none; } }
@media (max-width: 859px) { .stats-wide { display: none; } }
.record { margin-top: 2rem; }
.over .highlights { font-size: .9375rem; margin: .6rem 0 .6rem; }
.over .highlights li { padding: .3rem 0; }

/* Players in the game roster open their stats so far. */
.roster.players li { flex-wrap: wrap; padding: 0; }
.roster .prow {
  display: flex; align-items: center; gap: 10px; flex: 1 1 100%; min-width: 0; min-height: 44px; padding: .2rem 0;
  font: inherit; color: inherit; text-align: left; background: none; border: 0; cursor: pointer;
}
.roster .prow:focus-visible { outline: 3px solid var(--p1); outline-offset: 2px; }
.roster .chev { color: var(--muted); font-size: .75rem; width: 1em; text-align: center; transition: transform .15s; }
.roster .prow[aria-expanded="true"] .chev { transform: rotate(180deg); }
.pstats { flex: 1 1 100%; margin: 0 0 .6rem; padding: .5rem .75rem .6rem; border-radius: 10px; background: var(--sq); }
.pstats p { margin: 0 0 .3rem; }
.pstats dl { display: grid; grid-template-columns: 1fr auto; gap: .15rem 1rem; margin: 0; font-size: .875rem; }
.pstats dt { color: var(--muted); }
.pstats dd { margin: 0; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
