/* HALMA//ATELIER
 *
 * One stylesheet for all five pages. The board itself is barely styled: it is
 * an SVG drawn in the board picture's own coordinates, so its geometry comes
 * from src/board-geometry.js and only its colours are here.
 */

:root {
  --ink: #05070f;
  --panel: #0d1430cc;
  --panel-edge: #6d7bc433;
  --text: #dfe6ff;
  --muted: #8e9cc9;
  --gold: #f0c964;
  --gold-deep: #a8761f;
  --azure: #55d8f0;
  --azure-deep: #1b7f9c;
  --magenta: #d95bf0;
  --font-sans: "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --font-display: "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: var(--font-sans);
  background:
    linear-gradient(#05070fcc, #05070fee),
    url('assets/arcade-room.webp') center top / cover no-repeat,
    var(--ink);
  background-attachment: fixed;
}

.app-shell {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 1500px;
  margin: 0 auto;
  padding: 16px clamp(12px, 2vw, 28px) 28px;
}

/* ------------------------------------------------------------- top bar --- */

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
  border: 1px solid var(--panel-edge);
  border-radius: 3px;
  background: var(--panel);
  backdrop-filter: blur(8px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  color: var(--text);
  font: 600 16px var(--font-sans);
  letter-spacing: .12em;
  text-decoration: none;
}
.brand em { color: var(--magenta); font-style: normal; }
.brand-gem {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  color: #1b1206;
  font: 700 13px var(--font-display);
  background: linear-gradient(145deg, #f7dc93, #b9821f);
  border: 1px solid #ffe7a3;
  transform: rotate(45deg);
  box-shadow: 0 0 22px #d6a84a45;
}
.brand-gem { transform: rotate(45deg); }
.brand span:last-child { white-space: nowrap; }

.site-nav { display: flex; flex: 1; gap: 4px; justify-content: center; flex-wrap: wrap; }
.site-nav a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border: 1px solid transparent;
  border-radius: 2px;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: .17em;
  text-decoration: none;
}
.site-nav a:hover { color: var(--text); border-color: var(--panel-edge); }
.site-nav a[aria-current="page"] { color: var(--gold); border-color: #f0c96455; background: #f0c9640f; }
.site-nav span { opacity: .7; }

.arcade-tag { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 9px; letter-spacing: .2em; white-space: nowrap; }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: #45f0a8; box-shadow: 0 0 10px #45f0a8; }

/* ----------------------------------------------------------------- hud --- */

.hud { display: grid; grid-template-columns: 1fr minmax(240px, 1.2fr) 1fr; gap: 12px; align-items: stretch; }

.house-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border: 1px solid var(--panel-edge);
  border-radius: 3px;
  background: var(--panel);
}
.house-card--blue { justify-content: flex-end; text-align: right; }
.house-card .label { display: block; color: var(--muted); font-size: 8px; letter-spacing: .2em; }
.house-card strong { font-size: 13px; letter-spacing: .08em; }
.home-readout { margin-inline-start: auto; font: 400 26px var(--font-display); }
.house-card--blue .home-readout { margin-inline: 0 auto; }
.home-readout span { color: var(--muted); font-size: 10px; font-family: var(--font-sans); }

.marble-chip { width: 30px; height: 30px; border-radius: 50%; background: center / contain no-repeat; }
.marble-chip--gold { background-image: url('assets/marble-gold.webp'); }
.marble-chip--blue { background-image: url('assets/marble-blue.webp'); }

.mission-panel {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 2px;
  padding: 8px 14px;
  border: 1px solid var(--panel-edge);
  border-radius: 3px;
  background: var(--panel);
  text-align: center;
}
.mission-panel .label { color: var(--muted); font-size: 8px; letter-spacing: .22em; }
.turn-house { font: 400 22px var(--font-display); letter-spacing: .06em; }
.turn-house--gold { color: var(--gold); }
.turn-house--blue { color: var(--azure); }
.sub-status { color: var(--muted); font-size: 11px; }
.turn-state { color: var(--magenta); font-size: 8px; letter-spacing: .22em; }

/* --------------------------------------------------------------- table --- */

.table-layout { display: grid; grid-template-columns: 250px minmax(0, 1fr) 210px; gap: 16px; align-items: start; }

.side-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--panel-edge);
  border-radius: 3px;
  background: var(--panel);
}

.objective-title { margin: 0; font: 400 30px/1.05 var(--font-display); }
.objective-copy { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.55; }
.objective-list { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.objective-list li { display: flex; gap: 10px; align-items: baseline; padding-top: 10px; border-top: 1px solid var(--panel-edge); }
.objective-list b { color: var(--magenta); font: 400 15px var(--font-display); }
.objective-list span { display: grid; gap: 2px; color: var(--muted); font-size: 11px; }
.objective-list strong { color: var(--text); font-size: 10px; letter-spacing: .16em; }

.ledger { display: grid; gap: 8px; margin-top: auto; }
.ledger-head { display: flex; justify-content: space-between; }
.label { color: var(--muted); font-size: 8px; letter-spacing: .2em; }
.ledger-list { display: grid; gap: 5px; margin: 0; padding: 0; list-style: none; max-height: 210px; overflow: auto; }
.ledger-list li { display: flex; gap: 8px; align-items: center; padding: 5px 7px; border: 1px solid var(--panel-edge); border-radius: 2px; font-size: 11px; }
.ledger-list b { display: grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; font-size: 9px; }
.ledger-list b.gold { color: #21180a; background: var(--gold); }
.ledger-list b.blue { color: #05202a; background: var(--azure); }
.ledger-list span { display: flex; gap: 8px; align-items: baseline; }
.ledger-list i { color: var(--muted); font-size: 9px; font-style: normal; letter-spacing: .1em; }
.ledger-empty { color: var(--muted); font-size: 11px; }

.board-stage { display: grid; gap: 6px; }
.board-plaque, .board-caption { display: flex; justify-content: space-between; align-items: center; padding: 0 6px; color: var(--muted); font-size: 8px; letter-spacing: .16em; }
.board-plaque b { color: var(--gold); font: 400 12px var(--font-display); letter-spacing: .16em; }
.board-caption i { font-family: var(--font-display); font-size: 10px; }

/* The picture and the drawing share one box and one aspect ratio, which is
   what keeps the grid on the table at every size. */
.board-frame {
  position: relative;
  aspect-ratio: 1536 / 1024;
  background: url('assets/board.webp') center / 100% 100% no-repeat;
}
.board-layer { position: absolute; inset: 0; width: 100%; height: 100%; display: block; overflow: visible; }
/* The marbles and the marks, painted by the brain (brain/src/table.rs) and
   laid between the grid and the squares. A canvas is a replaced element:
   inset:0 does not size it, so it is given a width and a height as well --
   without those it draws at its own pixel size and, on a screen with two
   device pixels to the CSS pixel, runs off the board. */
.board-art { position: absolute; inset: 0; width: 100%; height: 100%; display: block; pointer-events: none; }

/* The flat board: the same squares seen from above, for a phone. A square
   drawing in a square box, every cell the same size, so a marble in the far
   camp is as easy to tap as one in the near. */
.board-frame--flat {
  aspect-ratio: 1;
  background: radial-gradient(circle at 50% 40%, #1b2b3a, #0d1620 70%);
  border: 1px solid #f0c96455;
  border-radius: 6px;
  box-shadow: 0 8px 24px #0009, inset 0 0 0 1px #ffffff0a;
}
.board-frame--flat .board-layer { overflow: hidden; border-radius: 5px; }
.square--light { fill: #182a37; }
.square--dark { fill: #142230; }
.square.camp--gold { fill: #3a3118; }
.square.camp--blue { fill: #16323d; }
.board-layer--flat .grid-line { stroke: #f0c96433; }
/* A square that can be reached is tinted on the flat board; the tint is in
   the picture now, because which squares those are is the position. */

.halma-board-tools { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.board-view-toggle {
  flex: none; min-height: 32px; padding: 6px 10px;
  border: 1px solid #f0c96455; border-radius: 4px;
  color: var(--gold); background: #0d1620cc;
  font: 600 9px var(--font-sans); letter-spacing: .14em; cursor: pointer;
}
.board-view-toggle[aria-pressed="true"] { background: #f0c96422; }

.camp { fill: #ffffff05; }
.camp--gold { fill: #f0c96412; }
.camp--blue { fill: #55d8f012; }

.grid-line { stroke: #f0c96455; stroke-width: 1; fill: none; vector-effect: non-scaling-stroke; }

/* The marks a move leaves, the square a marble is picked up from and the
   squares it can reach were all drawn here, in classes a reader could count
   without ever looking at the board. They are painted into .board-art now.

   What is left is the square as a place to tap: a hit area with a number on
   it and nothing else. It lights under the pointer whenever it is this
   player's turn -- every square alike, which says nothing about any of
   them. */
.cell { fill: transparent; }
.board-frame--playable .cell { cursor: pointer; }
.board-frame--playable .cell:hover { fill: #ffffff10; }

/* ------------------------------------------------------------ controls --- */

.mode-switch { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px; border: 1px solid var(--panel-edge); border-radius: 3px; }
.mode-switch button {
  padding: 8px 4px;
  border: 0;
  border-radius: 2px;
  color: var(--muted);
  background: transparent;
  font: 500 9px var(--font-sans);
  letter-spacing: .12em;
  cursor: pointer;
}
.mode-switch button.active { color: #1b1206; background: linear-gradient(145deg, #f7dc93, #d9a441); }
/* The word stays whole: in a narrow column the mark may sit on its own line
 * above it, but 'เจ้ามือ' must not break into 'เจ้า' and 'มือ'. Thai has no
 * letters to space out, so the tracking that suits the English capitals is
 * dropped there. */
.mode-switch button > span:last-child { white-space: nowrap; }
html[lang="th"] .mode-switch button { letter-spacing: 0; font-size: 11px; }

.primary-button, .ghost-button, .mini-button {
  padding: 11px 14px;
  border-radius: 2px;
  font: 600 10px var(--font-sans);
  letter-spacing: .16em;
  cursor: pointer;
}
.primary-button { border: 0; color: #1b1206; background: linear-gradient(120deg, #f7dc93, #e0952f); }
.ghost-button, .mini-button { border: 1px solid var(--panel-edge); color: var(--text); background: #ffffff08; }
.ghost-button:hover, .mini-button:hover { border-color: #f0c96466; color: var(--gold); }
.primary-button:disabled, .ghost-button:disabled { opacity: .38; cursor: not-allowed; }

.field { display: grid; gap: 5px; }
.field input, .field select {
  padding: 9px 10px;
  border: 1px solid var(--panel-edge);
  border-radius: 2px;
  color: var(--text);
  background: #05070f99;
  font: 400 12px var(--font-sans);
}
.field-help { margin: 0; color: var(--muted); font-size: 10px; }
.check { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 11px; }

/* ------------------------------------------------------- other pages --- */

.page-head { display: grid; gap: 6px; padding: 6px 2px; }
.page-head h1 { margin: 0; font: 400 34px var(--font-display); }
.page-head p { margin: 0; max-width: 62ch; color: var(--muted); font-size: 13px; line-height: 1.6; }

.lobby-layout { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; align-items: start; }
.panel { display: grid; gap: 12px; padding: 18px; border: 1px solid var(--panel-edge); border-radius: 3px; background: var(--panel); }
.panel h2 { margin: 0; font: 400 20px var(--font-display); }
.panel-status { margin: 0; color: var(--muted); font-size: 11px; }
.panel--wide { max-width: 900px; }
.rule { width: 100%; height: 1px; border: 0; background: var(--panel-edge); }

.room-list { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.room-list li { display: flex; gap: 12px; align-items: center; justify-content: space-between; padding: 10px 12px; border: 1px solid var(--panel-edge); border-radius: 2px; }
.room-list div { display: grid; gap: 3px; min-width: 0; }
.room-list strong { font-size: 12px; letter-spacing: .08em; }
.room-list small { color: var(--muted); font-size: 10px; }
.room-list code { color: var(--gold); font-size: 11px; letter-spacing: .18em; }

.score-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.score-table th { padding: 8px 10px; border-bottom: 1px solid var(--panel-edge); color: var(--muted); font-size: 9px; letter-spacing: .18em; text-align: left; }
.score-table td { padding: 9px 10px; border-bottom: 1px solid #6d7bc41c; }

.record { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 0; }
.record div { display: grid; gap: 3px; padding: 12px; border: 1px solid var(--panel-edge); border-radius: 2px; text-align: center; }
.record dt { color: var(--muted); font-size: 8px; letter-spacing: .2em; }
.record dd { margin: 0; font: 400 22px var(--font-display); }

.rules-body h2 { margin: 6px 0 0; color: var(--gold); font: 400 17px var(--font-display); }
.rules-body p, .rules-body li { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.65; }
.rules-body ul { display: grid; gap: 7px; margin: 0; padding-inline-start: 18px; }
.rules-body b { color: var(--text); }

.page-footer { display: flex; justify-content: space-between; color: var(--muted); font-size: 8px; letter-spacing: .2em; padding: 4px 2px; }

/* ---------------------------------------------------------- narrower --- */

@media (max-width: 1100px) {
  .table-layout { grid-template-columns: minmax(0, 1fr) 200px; }
  .side-panel--story { display: none; }
}
@media (max-width: 820px) {
  .hud { grid-template-columns: 1fr; }
  .table-layout { grid-template-columns: 1fr; }
  .side-panel--controls { display: grid; grid-template-columns: 1fr 1fr; }
  .mode-switch, .field, .field-help { grid-column: 1 / -1; }
  .site-nav { order: 3; width: 100%; justify-content: flex-start; }
  .page-head h1 { font-size: 26px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
