/* guki.si: dark, quiet, mobile-first. Layout budget per docs/design.md (360x740 reference). */
:root {
  --bg: #121417;
  --panel: #191c20;
  --line: #262a30;
  --text: #e7e4de;
  --muted: #8f949b;
  --accent: #d6b46a;
  --warn: #e5a54b;
  --sq-light: #a4aa9f;
  --sq-dark: #6d766e;
  --header-h: 40px;
  --row-h: 28px;
  --sync-h: 48px;
  /* Board shrinks first: whatever height is left after header, 16:9 embed, 2 player rows, sync. */
  --board: min(100vw, max(220px, calc(100svh - var(--header-h) - 56.25vw - 2 * var(--row-h) - var(--sync-h))));
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font-family: "Noto Sans", "Noto Sans Devanagari", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.4;
  -webkit-text-size-adjust: 100%;
}
a { color: var(--accent); }
button { font: inherit; }

/* Header */
.top {
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; letter-spacing: 0.01em; }
.sep { color: var(--muted); }
.unofficial { color: var(--muted); font-size: 13px; }

/* Page: one column on mobile */
.page { display: flex; flex-direction: column; }

/* Stream: always 16:9, never shrinks */
.stream {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  flex: none;
  background: #000;
  overflow: hidden;
}
.stream iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.stream-failed {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: #0b0c0e;
  color: var(--muted);
  text-align: center;
  padding: 16px;
}
.stream-failed p { margin: 0; color: var(--text); }
.stream-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.btn {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 16px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
}
.btn:hover { border-color: #3a4048; }

/* Live column: players, board, sync */
.col-live { display: flex; flex-direction: column; align-items: center; }
.player, .board-wrap, .sync { width: var(--board); }
.player {
  height: var(--row-h);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 6px;
  color: var(--muted);
}
.player .turn { width: 1em; font-size: 10px; text-align: center; }
.player .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player .clock {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
  font-weight: 600;
  font-size: 15px;
  padding: 1px 8px;
  border-radius: 4px;
}
.player.active { color: var(--text); }
.player.active .turn { color: var(--accent); }
.player.active .clock { background: #2a2f36; color: #fff; }

.board-wrap { aspect-ratio: 1; flex: none; }
.board-svg { display: block; width: 100%; height: 100%; }
.sq.l { fill: var(--sq-light); }
.sq.d { fill: var(--sq-dark); }
.hl { fill: rgba(226, 204, 120, 0.38); }
.chk { fill: url(#chk-grad); }
.coord { font-size: 18px; fill: rgba(18, 20, 23, 0.55); font-family: inherit; pointer-events: none; }
.pc {
  font-family: "Noto Sans Symbols 2", "Segoe UI Symbol", "DejaVu Sans", "Apple Symbols", sans-serif;
  font-size: 80px;
  text-anchor: middle;
  dominant-baseline: central;
  paint-order: stroke;
  pointer-events: none;
}
.pc.w { fill: #f4f1ea; stroke: #1b1c1e; stroke-width: 4px; }
.pc.b { fill: #18191b; stroke: #d9d4c8; stroke-width: 2px; }

.sync {
  height: var(--sync-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 6px;
  border-top: 1px solid var(--line);
}
.sync .last { flex: 1; min-width: 0; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip {
  display: inline-flex;
  align-items: center;
  height: 26px;
  padding: 0 10px;
  border-radius: 13px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.chip.live { background: #24302a; color: #9fd3a8; }
.chip.warn { background: #3a2c17; color: var(--warn); }

/* Below the fold */
.col-extra { padding: 12px; display: flex; flex-direction: column; gap: 12px; }
.moves summary { cursor: pointer; color: var(--muted); font-weight: 600; padding: 4px 0; }
.move-list {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
  font-variant-numeric: tabular-nums;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  column-gap: 12px;
}
.move-list li { display: grid; grid-template-columns: 2.6em 1fr 1fr; padding: 2px 0; }
.move-list .no { color: var(--muted); }
.mv.cur { color: var(--bg); background: var(--accent); border-radius: 3px; padding: 0 4px; justify-self: start; }

.health p { margin: 2px 0; color: var(--muted); font-size: 13px; }
.health .warn { color: var(--warn); }
.health .disclaimer { margin-top: 10px; font-size: 12px; opacity: 0.8; }

/* Desktop: stream left (~60%), live column right; same tree. */
@media (min-width: 960px) {
  .page {
    display: grid;
    grid-template-columns: minmax(0, 3fr) minmax(340px, 2fr);
    grid-template-areas:
      "stream live"
      "stream extra";
    grid-template-rows: auto 1fr;
    gap: 0 20px;
    padding: 16px 20px;
    max-width: 1600px;
    margin: 0 auto;
  }
  .col-stream { grid-area: stream; }
  .col-live { grid-area: live; --board: min(100%, calc(100svh - var(--header-h) - 32px - 2 * var(--row-h) - var(--sync-h) - 110px)); }
  .col-extra { grid-area: extra; padding: 8px 0 0; }
  .stream { border-radius: 8px; }
  .move-list { max-height: 30vh; overflow-y: auto; grid-template-columns: 1fr; }
}
