/* Backgammon - the whole interface. One dark room, one lit board.
   [hidden] is declared !important on purpose: an id rule that sets display would otherwise beat it
   and leave an invisible dialog swallowing every click. tools-harness-page.js asserts that no
   selector in this file sets `display` on any element that is toggled with `hidden`.            */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

:root {
  --ink: #eef1f4;
  --dim: #9aa4ae;
  --line: #2a3138;
  --panel: #151a1f;
  --panel2: #1c232a;
  --felt: #17251f;
  --accent: #63cf83;
  --warm: #e2a53a;
  --danger: #e5675c;
  --radius: 12px;
  --font: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --ui: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

html, body { height: 100%; margin: 0; }
body {
  background: radial-gradient(120% 90% at 50% 0%, #12181d 0%, #0b0e11 60%, #07090b 100%);
  color: var(--ink);
  font-family: var(--ui);
  overflow: hidden;
  -webkit-text-size-adjust: 100%;
}
.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;
}

#app { position: fixed; inset: 0; }
#gl { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: manipulation; }

/* ---- head-up readouts ---------------------------------------------------------------------- */
#hud {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 10px 14px;
  background: linear-gradient(#0b0e11ee, #0b0e1100);
  font-size: 14px; pointer-events: none;
}
.hud-side { display: flex; align-items: center; gap: 9px; min-width: 0; }
#hud-white { justify-content: flex-end; }
.dot { width: 13px; height: 13px; border-radius: 50%; display: inline-block; flex: none; }
.dot-white { background: #f2ede0; box-shadow: inset 0 0 0 2px #c9c2b0; }
.dot-black { background: #2b303a; box-shadow: inset 0 0 0 2px #4a515e; }
.who { color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pip { font-variant-numeric: tabular-nums; color: var(--dim); font-size: 12px; }
.pip::after { content: " pip"; opacity: .6; }
.score {
  font-variant-numeric: tabular-nums; font-weight: 700; font-size: 17px;
  min-width: 24px; text-align: center;
}
#hud-mid { text-align: center; color: var(--dim); font-size: 12px; line-height: 1.5; }
#hud-mid span { display: block; }
#cube-readout { color: var(--warm); font-weight: 600; }
.turn-me .who, .turn-me .score { color: var(--accent); }

#msg {
  position: absolute; left: 50%; transform: translateX(-50%); top: 62px;
  font-size: 15px; color: var(--ink); background: #0d1116cc; border: 1px solid var(--line);
  padding: 6px 14px; border-radius: 999px; pointer-events: none; max-width: 86vw;
  text-align: center; backdrop-filter: blur(3px);
}
#dice-readout {
  position: absolute; right: 14px; top: 62px; font-variant-numeric: tabular-nums;
  color: var(--warm); font-size: 14px; letter-spacing: .08em; pointer-events: none;
}
#movelog {
  position: absolute; left: 14px; bottom: 74px; font-size: 12px; color: var(--dim);
  font-variant-numeric: tabular-nums; max-width: 30vw; line-height: 1.7; pointer-events: none;
  white-space: pre-line;   /* the log is newline-separated text, not markup */
}

/* ---- buttons ------------------------------------------------------------------------------- */
button {
  font: inherit; color: var(--ink); background: var(--panel2);
  border: 1px solid var(--line); border-radius: 10px; padding: 9px 18px; cursor: pointer;
}
button:hover:not(:disabled) { background: #242c34; border-color: #3a444e; }
button:disabled { opacity: .38; cursor: default; }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#btn-roll, #btn-done, #btn-start, #btn-take, #btn-next-game {
  background: var(--accent); border-color: #79dc95; color: #08130c; font-weight: 700;
}
#btn-roll:hover:not(:disabled), #btn-done:hover, #btn-start:hover,
#btn-take:hover, #btn-next-game:hover { background: #74dd92; }
button.ghost { background: transparent; }
#btn-pass { background: var(--warm); border-color: #f0bc5c; color: #201603; font-weight: 700; }

#controls {
  position: absolute; left: 50%; transform: translateX(-50%); bottom: 16px;
  display: flex; gap: 10px; flex-wrap: wrap; justify-content: center;
}
#toolbar { position: absolute; right: 14px; bottom: 16px; display: flex; gap: 8px; }
#toolbar button { padding: 7px 12px; font-size: 13px; background: #131920cc; }

/* ---- sheets: the menu and the dialogs -------------------------------------------------------
   Every one of these is toggled with the `hidden` property. Note that none of them carries a
   `display` rule under its own id - `.sheet` owns the layout, and `[hidden]` above beats it.   */
.sheet {
  position: absolute; inset: 0; z-index: 20;
  display: flex; align-items: center; justify-content: center;
  padding: 20px; overflow: auto;
  background: #05070999; backdrop-filter: blur(5px);
}
.sheet-body {
  width: min(720px, 100%); max-height: 100%; overflow: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 26px 28px; box-shadow: 0 30px 80px #000a;
}
.sheet-body.narrow { width: min(420px, 100%); text-align: center; }
.sheet h2 { margin: 0 0 12px; font-family: var(--font); font-size: 24px; font-weight: 600; }
.sheet h3 { margin: 20px 0 6px; font-size: 15px; color: var(--accent); font-weight: 600; }
.sheet p, .sheet li { line-height: 1.62; color: #c8d0d8; font-size: 14px; margin: 8px 0; }
.sheet ul { padding-left: 20px; margin: 8px 0; }
.sheet b { color: var(--ink); }
.sheet em { color: var(--warm); font-style: normal; }
.callout {
  border-left: 3px solid var(--accent); background: #16221b; padding: 10px 14px;
  border-radius: 0 8px 8px 0;
}
.note, .hint { color: var(--dim); font-size: 12.5px; }
.sources li { font-size: 13px; }
.close { margin-top: 22px; }
.row { display: flex; gap: 10px; justify-content: center; margin-top: 16px; flex-wrap: wrap; }

#wordmark {
  font-family: var(--font); font-size: 40px; letter-spacing: .04em; line-height: 1;
  text-align: center; margin-bottom: 6px;
}
#wordmark span { color: var(--accent); }
.tagline { text-align: center; color: var(--dim); margin-bottom: 18px; }
.byline { text-align: center; color: #6d7883; font-size: 12px; margin-top: 16px; }

fieldset { border: 1px solid var(--line); border-radius: 10px; margin: 0 0 14px; padding: 12px 14px; }
legend { color: var(--dim); font-size: 12px; padding: 0 6px; letter-spacing: .06em; text-transform: uppercase; }
.pick { display: flex; gap: 8px; flex-wrap: wrap; }
.pick button { padding: 8px 14px; font-size: 13px; }
.pick button.on { background: var(--accent); border-color: #79dc95; color: #08130c; font-weight: 700; }
.sheet label { display: flex; gap: 10px; align-items: flex-start; margin: 9px 0; font-size: 13.5px; color: #c8d0d8; cursor: pointer; }
.sheet label input { margin-top: 2px; accent-color: var(--accent); }
#btn-start { width: 100%; padding: 13px; font-size: 16px; margin-top: 4px; }
#menu-record { text-align: center; }
.bigscore { font-family: var(--font); font-size: 52px; margin: 6px 0 2px; color: var(--warm); }

@media (max-width: 640px) {
  #hud { font-size: 12px; padding: 8px 10px; }
  .score { font-size: 15px; }
  #movelog { display: none; }
  #msg { font-size: 13px; }
  /* left:50% + translate caps an absolute box's shrink-to-fit width at half the viewport, which
     wrapped the controls onto two rows under the toolbar on every phone. Span the full width. */
  #controls { bottom: 12px; gap: 8px; left: 10px; right: 10px; transform: none; }
  #controls button { padding: 10px 14px; }
  #toolbar { bottom: 64px; left: 10px; right: 10px; justify-content: center; }
  #hud-mid { font-size: 11px; }
  #hud-mid span { white-space: nowrap; }
  #msg { top: 58px; }
  .sheet-body { padding: 20px 18px; }
  #wordmark { font-size: 30px; }
}
@media (max-width: 420px) {
  #hud { gap: 6px; padding: 8px 8px; }
  .hud-side { gap: 6px; }
  .pip::after { content: none; }
}
@media (max-width: 340px) {
  .score { min-width: 18px; }
  #hud-mid { font-size: 10.5px; }
}
@media (prefers-reduced-motion: reduce) {
  .sheet { backdrop-filter: none; }
}
