/* nonsens — gruvbox (dark medium default, light via prefers-color-scheme).
   Mono carries the chrome: brand, nav, labels, meta, numbers, buttons.
   Public Sans carries body copy and board phrases, which get long. */

/* Both faces are self-hosted: the CSP admits no third-party origin, so a
   webfont has to come from /static. See static/fonts/README.md. Nothing sets
   font-style: italic, so only the upright cuts are shipped. */
@font-face {
  font-family: "Commit Mono";
  src: url("/static/fonts/CommitMonoV143-VF.woff2") format("woff2");
  font-weight: 200 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Public Sans";
  src: url("/static/fonts/PublicSans-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Public Sans";
  src: url("/static/fonts/PublicSans-Bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: dark light;

  --mono: "Commit Mono", ui-monospace, SFMono-Regular, "SF Mono", Menlo,
    Consolas, monospace;
  --sans: "Public Sans", system-ui, -apple-system, "Segoe UI", sans-serif;

  /* Sharper corners, thinner rules: one radius scale, used everywhere. */
  --r: 3px;
  --r-sm: 2px;

  /* gruvbox dark, medium background. */
  --bg: #282828;
  --bg-deep: #1d2021;
  --fg: #ebdbb2;
  --muted: #a89984;
  --line: #3c3836;
  --line-strong: #504945;
  --accent: #8ec07c;
  --accent-dim: #689d6a;
  --on-accent: #1d2021;
  --surface: #32302f;
  --surface-raised: #3c3836;
  --red: #fb4934;
  --yellow: #fabd2f;
  --raster-ink: color-mix(in srgb, #ebdbb2 9.5%, transparent);

  --seat-0: #83a598;
  --seat-1: #fe8019;
  --seat-2: #b8bb26;
  --seat-3: #d3869b;
  --seat-4: #fabd2f;
  --seat-5: #fb4934;
  --seat-6: #8ec07c;
  --seat-7: #d5c4a1;
}

@media (prefers-color-scheme: light) {
  :root {
    /* gruvbox light, medium background. */
    --bg: #fbf1c7;
    --bg-deep: #f2e5bc;
    --fg: #3c3836;
    --muted: #7c6f64;
    --line: #e0d3ab;
    --line-strong: #d5c4a1;
    --accent: #427b58;
    --accent-dim: #4c7a5d;
    --on-accent: #fbf1c7;
    --surface: #fbf7e4;
    --surface-raised: #f2e5bc;
    --red: #9d0006;
    --yellow: #b57614;
    --raster-ink: color-mix(in srgb, #3c3836 15.3%, transparent);

    --seat-0: #076678;
    --seat-1: #af3a03;
    --seat-2: #79740e;
    --seat-3: #8f3f71;
    --seat-4: #b57614;
    --seat-5: #9d0006;
    --seat-6: #427b58;
    --seat-7: #7c6f64;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background-color: var(--bg);
  color: var(--fg);
  font: 15px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
}

/* One visible ring everywhere, since the whole app is keyboard-reachable. */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

a {
  color: var(--accent);
  text-decoration-color: color-mix(in srgb, var(--accent) 45%, transparent);
  text-underline-offset: 0.2em;
}

a:hover {
  color: var(--fg);
  text-decoration-color: currentColor;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.6rem 1.25rem;
  border-bottom: 1px solid var(--line);
  background: var(--bg-deep);
  font-family: var(--mono);
  font-size: 0.86rem;
}

.brand {
  font-family: var(--mono);
  font-weight: 700;
  letter-spacing: 0.02em;
  text-decoration: none;
  color: var(--fg);
}

/* A prompt mark, the one terminal flourish in the chrome. */
.brand::before {
  content: "~/";
  color: var(--accent);
  font-weight: 400;
}

.topbar nav {
  display: flex;
  gap: 1.1rem;
}

.topbar nav a {
  color: var(--muted);
  text-decoration: none;
}

.topbar nav a:hover {
  color: var(--fg);
}

main {
  max-width: 62rem;
  margin: 0 auto;
  padding: 1.75rem 1.25rem 4rem;
}

h1 {
  font-family: var(--mono);
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.empty {
  color: var(--muted);
  border: 1px dashed var(--line-strong);
  border-radius: var(--r);
  padding: 2rem;
  text-align: center;
  font-family: var(--mono);
  font-size: 0.86rem;
  background: color-mix(in srgb, var(--surface) 55%, transparent);
}

.session {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.whoami {
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.signin {
  font-family: var(--mono);
  color: var(--accent);
  text-decoration: none;
}

.signin:hover {
  color: var(--fg);
}

.badge {
  background: var(--accent);
  color: var(--on-accent);
  border-radius: var(--r-sm);
  padding: 0.05rem 0.4rem;
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.linkish {
  background: none;
  border: 0;
  padding: 0;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-family: var(--mono);
  font-size: 0.86rem;
}

.linkish:hover {
  color: var(--fg);
}

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.button {
  display: inline-block;
  background: var(--accent);
  color: var(--on-accent);
  border: 1px solid var(--accent);
  border-radius: var(--r);
  padding: 0.4rem 0.85rem;
  font-family: var(--mono);
  font-size: 0.86rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  text-decoration: none;
  cursor: pointer;
}

.button:hover {
  background: var(--accent-dim);
  border-color: var(--accent-dim);
  color: var(--on-accent);
}

.button:disabled {
  background: var(--surface-raised);
  border-color: var(--line-strong);
  color: var(--muted);
  cursor: default;
}

.cards {
  list-style: none;
  padding: 0;
  display: grid;
  gap: 0.6rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 0.9rem 1rem;
}

.card:hover {
  border-color: var(--line-strong);
}

.card-head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.card h2 {
  font-family: var(--mono);
  font-size: 1rem;
  font-weight: 700;
  margin: 0;
}

.card h2 a {
  text-decoration: none;
}

.desc {
  margin: 0.4rem 0 0;
}

.meta {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.78rem;
  margin: 0.5rem 0 0;
}

.actions {
  display: flex;
  gap: 0.9rem;
  align-items: center;
  margin-top: 0.7rem;
  padding-top: 0.7rem;
  border-top: 1px dotted var(--line-strong);
  font-family: var(--mono);
  font-size: 0.86rem;
}

.actions form {
  display: inline;
}

.actions a {
  text-decoration: none;
}

.danger {
  color: var(--red);
}

.warn {
  background: color-mix(in srgb, var(--yellow) 16%, transparent);
  border: 1px solid color-mix(in srgb, var(--yellow) 45%, transparent);
  color: var(--yellow);
  border-radius: var(--r-sm);
  padding: 0.05rem 0.4rem;
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 700;
}

.error {
  background: color-mix(in srgb, var(--red) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--red) 45%, transparent);
  border-left: 2px solid var(--red);
  color: var(--red);
  border-radius: var(--r);
  padding: 0.7rem 0.9rem;
  font-family: var(--mono);
  font-size: 0.86rem;
}

.stack {
  display: grid;
  gap: 1rem;
  max-width: 42rem;
}

.stack label {
  display: grid;
  gap: 0.3rem;
  font-family: var(--mono);
  font-size: 0.86rem;
  font-weight: 700;
}

.stack .check {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-weight: 400;
  margin-bottom: 0.45rem;
}

.hint {
  color: var(--muted);
  font-family: var(--sans);
  font-weight: 400;
  font-size: 0.85rem;
}

input:not([type="checkbox"], [type="radio"]),
select,
textarea {
  font: inherit;
  font-family: var(--mono);
  font-size: 0.86rem;
  font-weight: 400;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--r);
  background: var(--bg-deep);
  color: var(--fg);
  width: 100%;
}

input:not([type="checkbox"], [type="radio"]):hover,
select:hover,
textarea:hover {
  border-color: var(--muted);
}

::placeholder {
  color: var(--muted);
  opacity: 0.7;
}

input[type="checkbox"],
input[type="radio"] {
  accent-color: var(--accent);
  width: 0.95rem;
  height: 0.95rem;
  flex: none;
}

textarea {
  resize: vertical;
  font-family: var(--mono);
  font-size: 0.86rem;
}

.row {
  display: flex;
  gap: 1.2rem;
  align-items: end;
  flex-wrap: wrap;
}

.row > label {
  flex: 1 1 12rem;
}

.stack fieldset {
  display: grid;
  gap: 0.4rem;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.stack fieldset > :not(legend),
.stack fieldset > .check {
  margin-block: 0;
}

.stack legend {
  width: 100%;
  margin: 0 0 0.35rem;
}

.phrase-table {
  width: 100%;
  border-collapse: collapse;
}

.phrase-table th {
  padding: 0 0.25rem 0.3rem;
  text-align: left;
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.phrase-table td {
  padding: 0.2rem 0.25rem;
}

.phrase-table .weight {
  width: 5.5rem;
}

.phrase-table .group {
  width: 9rem;
}

.phrase-table .remove {
  width: 1%;
}

.add-row {
  justify-self: start;
  color: var(--accent);
}

/* The board types are tabs: the `layout` radios, with the labels drawn as the
   tab bar. The radio stays focusable, so the keyboard still moves between
   them. */
.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  border-bottom: 1px solid var(--line-strong);
}

.stack .tab {
  display: block;
  margin-bottom: -1px;
  padding: 0.4rem 0.85rem;
  border: 1px solid transparent;
  border-bottom-color: var(--line-strong);
  border-radius: var(--r) var(--r) 0 0;
  color: var(--muted);
  cursor: pointer;
}

.stack .tab:hover {
  color: var(--fg);
}

.stack .tab:has(input:checked) {
  border-color: var(--line-strong);
  border-bottom-color: var(--bg);
  color: var(--fg);
}

.stack .tab:has(input:focus-visible) {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* A panel follows the tab bar through :has(), so it needs no script. The
   server ignores whatever is hidden. */
.board-form:has(input[name="layout"][value="shuffled"]:checked)
  [data-layout]:not([data-layout~="shuffled"]),
.board-form:has(input[name="layout"][value="custom"]:checked)
  [data-layout]:not([data-layout~="custom"]),
.board-form:has(input[name="layout"][value="fixed"]:checked)
  [data-layout]:not([data-layout~="fixed"]) {
  display: none;
}

.layout-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.35rem;
}

.board-form:has(select[name="default_size"] option[value="3"]:checked) .layout-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.board-form:has(select[name="default_size"] option[value="4"]:checked) .layout-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.board-form:has(select[name="default_size"] option[value="3"]:checked)
  .slot:is([data-row="3"], [data-row="4"], [data-col="3"], [data-col="4"]),
.board-form:has(select[name="default_size"] option[value="4"]:checked)
  .slot:is([data-row="4"], [data-col="4"]) {
  display: none;
}

.slot {
  position: relative;
}

/* The free centre keeps its input, hidden and ignored, so turning the free
   square off again gives back whatever was typed there. */
.board-form:has(input[name="free_space"]:checked):has(select[name="default_size"] option[value="3"]:checked)
  .slot[data-row="1"][data-col="1"] > input,
.board-form:has(input[name="free_space"]:checked):has(select[name="default_size"] option[value="5"]:checked)
  .slot[data-row="2"][data-col="2"] > input {
  visibility: hidden;
}

.board-form:has(input[name="free_space"]:checked):has(select[name="default_size"] option[value="3"]:checked)
  .slot[data-row="1"][data-col="1"]::after,
.board-form:has(input[name="free_space"]:checked):has(select[name="default_size"] option[value="5"]:checked)
  .slot[data-row="2"][data-col="2"]::after {
  content: "FREE";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border: 1px dashed var(--line-strong);
  border-radius: var(--r);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

/* Raster panel. Two stacked layers on one pseudo-element -- a dot grid over a
   line grid, both on the same 28px pitch as the page -- masked to fade out at
   the edges so the panel has no hard border. Pure CSS: no image asset, and it
   costs nothing on a page that scrolls. Applies to `.hero` automatically, or
   put `.raster` on any block that should sit on it. */
.hero,
.raster {
  position: relative;
  isolation: isolate;
}

.hero::before,
.raster::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    radial-gradient(circle at center, var(--raster-ink) 0 1.1px, transparent 1.2px),
    linear-gradient(to right, var(--raster-ink) 0 1px, transparent 1px),
    linear-gradient(to bottom, var(--raster-ink) 0 1px, transparent 1px);
  background-size: 28px 28px, 112px 112px, 112px 112px;
  background-position: center;
  /* Fades to nothing well before the edges, so the raster never collides with
     the cards below it. */
  -webkit-mask-image: radial-gradient(120% 90% at 50% 35%, #000 0%, transparent 72%);
  mask-image: radial-gradient(120% 90% at 50% 35%, #000 0%, transparent 72%);
}

.hero {
  text-align: center;
  padding: 4.5rem 1rem 3.5rem;
}

.hero h1 {
  font-size: 2rem;
  margin: 0 0 0.4rem;
}

.hero p {
  color: var(--muted);
  margin: 0 0 1.4rem;
}

.section,
.stack legend {
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  padding: 0 0 0.5rem;
  border-bottom: 1px dotted var(--line-strong);
}

.section {
  margin-top: 2.2rem;
}

.start-room {
  align-items: end;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 1rem;
}

.room {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 16rem;
  gap: 1.25rem;
  align-items: start;
}

@media (max-width: 44rem) {
  .room {
    grid-template-columns: 1fr;
  }
}

.grid {
  --gap: 0.35rem;
  display: grid;
  gap: var(--gap);
  container-type: inline-size;
  padding: var(--gap);
  border: 1px solid var(--line-strong);
  border-radius: var(--r);
  background: var(--bg-deep);
}

.grid.size-3 { grid-template-columns: repeat(3, 1fr); }
.grid.size-4 { grid-template-columns: repeat(4, 1fr); }
.grid.size-5 { grid-template-columns: repeat(5, 1fr); }

/* Square, unless the phrase needs more room -- then the whole row grows.
   The container is the padded board, so a cell's share is the inline size
   minus the gaps between cells. */
.grid.size-3 .cell { min-height: calc((100cqi - 2 * var(--gap)) / 3); }
.grid.size-4 .cell { min-height: calc((100cqi - 3 * var(--gap)) / 4); }
.grid.size-5 .cell { min-height: calc((100cqi - 4 * var(--gap)) / 5); }

.cell {
  /* Inset and height of the stripe strip; the bottom padding clears it. */
  --marks-inset: 0.3rem;
  --marks-height: 5px;

  /* The positioning context for the stripe strip below. */
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0.45rem;
  padding-bottom: calc(var(--marks-inset) + var(--marks-height) + 0.3rem);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--fg);
  font: inherit;
  font-family: var(--sans);
  font-size: 0.8rem;
  line-height: 1.3;
  cursor: pointer;
  overflow-wrap: break-word;
  overflow-wrap: anywhere;
  -webkit-hyphens: auto;
  hyphens: auto;
  transition: background-color 90ms linear, border-color 90ms linear;
}

.cell > span {
  min-width: 0;
}

.cell:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--surface-raised);
}

.cell.marked {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
  font-weight: 700;
}

.cell.marked:hover:not(:disabled) {
  background: var(--accent-dim);
  border-color: var(--accent-dim);
}

.cell.free {
  font-family: var(--mono);
  font-weight: 700;
  letter-spacing: 0.06em;
}

.cell:disabled {
  cursor: default;
}

.grid.closed {
  opacity: 0.8;
}

/* The card a player builds before joining a custom room: the board's grid
   with a dropdown in every square. */
.pick-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.75rem;
  padding-top: 0.5rem;
  container: pick / inline-size;
}

.pick-form > p {
  margin: 0;
  overflow-wrap: anywhere;
}

.pick {
  display: grid;
  align-content: center;
  gap: 0.25rem;
  min-width: 0;
  padding: 0.35rem;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
}

/* Set like a square of the card it will become. */
.pick select {
  padding: 0.35rem 0.4rem;
  font-family: var(--sans);
  font-size: 0.8rem;
  line-height: 1.3;
}

.pick.free {
  justify-content: center;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.pick-at {
  display: none;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.78rem;
}

/* Where a dropdown can be restyled it wraps, so a square shows its whole
   phrase; elsewhere the phrase is cut at the square's edge. */
@supports (appearance: base-select) {
  .pick select,
  .pick select::picker(select) {
    appearance: base-select;
  }

  .pick select {
    align-items: center;
    min-height: 2.2rem;
    overflow-wrap: anywhere;
    -webkit-hyphens: auto;
    hyphens: auto;
  }

  .pick select::picker(select) {
    max-height: 60vh;
    border: 1px solid var(--line-strong);
    border-radius: var(--r);
    background: var(--bg-deep);
    color: var(--fg);
  }

  .pick option {
    padding: 0.3rem 0.5rem;
  }

  .pick option:checked {
    font-weight: 700;
  }
}

/* A dropdown narrower than this cannot show its phrase, so the card becomes a
   list in reading order and every square says where it sits. */
@container pick (max-width: 22rem) {
  .picker.size-3 { grid-template-columns: 1fr; }
  .picker.size-3 .pick-at { display: block; }
}

@container pick (max-width: 30rem) {
  .picker.size-4 { grid-template-columns: 1fr; }
  .picker.size-4 .pick-at { display: block; }
}

@container pick (max-width: 38rem) {
  .picker.size-5 { grid-template-columns: 1fr; }
  .picker.size-5 .pick-at { display: block; }
}

/* Who else has marked this phrase.
   The strip is an opaque plate the colour of the card, not a transparent band:
   a stripe then only ever has to contrast with --surface, and never with a
   marked cell's --accent. Marked and unmarked squares end up showing the same
   colours. */
.marks {
  position: absolute;
  left: var(--marks-inset);
  right: var(--marks-inset);
  bottom: var(--marks-inset);
  height: var(--marks-height);
  display: flex;
  gap: 1px;
  padding: 1px;
  border-radius: var(--r-sm);
  background: var(--surface);
}

.marks.empty {
  display: none;
}

.stripe {
  flex: 1 1 0;
  border-radius: 1px;
}

.swatch {
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 1px;
  flex: none;
}

.seat-0 { background: var(--seat-0); }
.seat-1 { background: var(--seat-1); }
.seat-2 { background: var(--seat-2); }
.seat-3 { background: var(--seat-3); }
.seat-4 { background: var(--seat-4); }
.seat-5 { background: var(--seat-5); }
.seat-6 { background: var(--seat-6); }
.seat-7 { background: var(--seat-7); }

/* A second, non-colour signal for the last four seats, so eight players do not
   rest on eight distinguishable hues alone. After the .seat-N backgrounds,
   which would otherwise reset it. */
.seat-4,
.seat-5,
.seat-6,
.seat-7 {
  background-image: repeating-linear-gradient(
    45deg,
    rgb(255 255 255 / 0.45) 0 2px,
    rgb(255 255 255 / 0) 2px 4px
  );
}

/* Announced by a screen reader, invisible on screen. Colour is never the only
   thing carrying a stripe's meaning. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 0.8rem 0.9rem;
  margin-bottom: 0.75rem;
}

.panel h2 {
  font-family: var(--mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 0 0 0.55rem;
  padding-bottom: 0.45rem;
  border-bottom: 1px dotted var(--line-strong);
}

.roster,
.placings {
  margin: 0;
  padding: 0;
  list-style: none;
}

.roster li,
.placings li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0;
  font-size: 0.88rem;
}

.roster li + li {
  border-top: 1px dotted var(--line);
}

.roster .name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.roster .progress {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
}

.place {
  background: var(--accent);
  color: var(--on-accent);
  border-radius: var(--r-sm);
  width: 1.15rem;
  height: 1.15rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 700;
  flex: none;
}

.placings li strong {
  font-family: var(--mono);
  color: var(--accent);
}

.muted {
  color: var(--muted);
}

.toasts {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  display: grid;
  gap: 0.5rem;
  z-index: 10;
}

.toast {
  background: var(--bg-deep);
  border: 1px solid var(--accent);
  border-left: 2px solid var(--accent);
  color: var(--fg);
  border-radius: var(--r);
  padding: 0.55rem 0.85rem;
  font-family: var(--mono);
  font-size: 0.82rem;
  font-weight: 400;
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.35);
}

.toast.failed {
  border-color: var(--red);
}

.scores {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: hidden;
  font-variant-numeric: tabular-nums;
}

.scores th,
.scores td {
  padding: 0.45rem 0.7rem;
  text-align: left;
  border-bottom: 1px dotted var(--line-strong);
}

.scores tbody tr:last-child td {
  border-bottom: 0;
}

.scores th {
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  border-bottom-style: solid;
  background: var(--bg-deep);
}

.scores .num {
  text-align: right;
  font-family: var(--mono);
  font-size: 0.86rem;
}

.scores .rank {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.78rem;
  width: 2.25rem;
}

.scores tr.me {
  background: color-mix(in srgb, var(--accent) 14%, transparent);
}

.scores tr.me .rank {
  color: var(--accent);
}

.avatar {
  border-radius: var(--r-sm);
  vertical-align: middle;
  flex: none;
  border: 1px solid var(--line-strong);
}

.scores .who {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Poker. Mobile first: the board and the pot at the top, a compact seat list,
   and your own cards with the buttons last, which is where a thumb is. */

.poker {
  display: grid;
  gap: 0.75rem;
}

.poker-board {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 0.9rem;
  text-align: center;
}

.poker-board .street {
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0.35rem 0;
}

.poker-board .pot {
  font-family: var(--mono);
  font-size: 1.1rem;
  margin: 0.5rem 0 0;
}

.cards-row {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  justify-content: center;
}

.card-face {
  font-family: var(--mono);
  font-size: 1.05rem;
  line-height: 1;
  padding: 0.4rem 0.45rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--surface-raised);
  /* The suit symbol is in the text, so the colour is never the only signal. */
  color: var(--fg);
}

.card-face.red {
  color: var(--red);
}

@keyframes card-flip {
  from {
    opacity: 0;
    transform: perspective(20rem) rotateY(90deg) translateY(-0.3rem);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.card-face.flip {
  animation: card-flip 280ms ease-out both;
}

.card-face.deal-2 {
  animation-delay: 90ms;
}

.card-face.deal-3 {
  animation-delay: 180ms;
}

.card-face.deal-4 {
  animation-delay: 270ms;
}

.card-face.deal-5 {
  animation-delay: 360ms;
}

@media (prefers-reduced-motion: reduce) {
  .card-face.flip {
    animation: none;
  }
}

.poker-seats {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.3rem;
}

.poker-seats li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding: 0.4rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
}

.poker-seats .acting {
  border-color: var(--accent);
}

.poker-seats .mine {
  background: color-mix(in srgb, var(--accent) 10%, var(--surface));
}

.poker-seats .name {
  flex: 1 1 6rem;
  min-width: 0;
}

.poker-seats .chips,
.poker-seats .bet {
  font-family: var(--mono);
  font-size: 0.85rem;
}

.poker-seats .bet {
  color: var(--accent);
}

.poker-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.poker-actions input {
  width: 6rem;
}

.table-scroll {
  overflow-x: auto;
}

.page-links {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.scores .who .meta {
  display: block;
  margin: 0.15rem 0 0;
}

.poker-hands {
  list-style: none;
  margin: 0.6rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.4rem;
  font-size: 0.85rem;
}

.poker-hands li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.poker-hands li + li {
  border-top: 1px dotted var(--line);
  padding-top: 0.4rem;
}

.poker-hands .hand-no {
  font-family: var(--mono);
  color: var(--muted);
  min-width: 1.5rem;
}

.poker-hands .card-face {
  font-size: 0.8rem;
  padding: 0.25rem 0.3rem;
}

.poker-step .cards-row {
  justify-content: flex-start;
  margin-bottom: 0.55rem;
}

.poker-sit {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.poker-sit p {
  margin: 0;
}

.poker-log {
  margin: 0;
  padding-left: 1.2rem;
  font-size: 0.85rem;
  color: var(--muted);
}

@media (min-width: 44rem) {
  .poker {
    grid-template-columns: minmax(0, 1fr) 18rem;
    align-items: start;
  }

  .poker-board,
  .poker-seats {
    grid-column: 1;
  }

  .poker > .panel {
    grid-column: 2;
  }
}

.clock {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--r-sm);
  background: var(--surface);
  font-size: 0.85rem;
}

.clock:empty,
.clock.idle {
  display: none;
}

.clock .left {
  font-family: var(--mono);
}

.clock.urgent {
  border-left-color: var(--yellow);
}

.clock.expired {
  border-left-color: var(--red);
  color: var(--muted);
}

.best-hand {
  margin-top: 0.6rem;
  padding-top: 0.5rem;
  border-top: 1px dashed var(--line);
}

.best-name {
  margin: 0 0 0.35rem;
  font-size: 0.85rem;
  color: var(--accent);
}

.best-name::first-letter {
  text-transform: uppercase;
}

.best-hand .card-face {
  font-size: 0.85rem;
  padding: 0.3rem 0.35rem;
}
