:root {
  --bg: #f4f1ec; --fg: #1d1b19; --muted: #6b655d; --card: #ffffff; --line: #d6d0c6;
  --accent: #2f6f4e; --accent-fg: #ffffff; --warn: #9a3412;
  --sq-light: #f0d9b5; --sq-dark: #b58863; --sq-last: rgba(255, 221, 51, 0.55); --sq-sel: rgba(20, 130, 90, 0.55);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1a18; --fg: #ece8e1; --muted: #a39b8f; --card: #262421; --line: #3d3a35;
    --accent: #4fae81; --accent-fg: #0d1a13; --warn: #fb923c;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow-x: hidden;
}
#app { max-width: 520px; margin: 0 auto; padding: 8px 16px calc(24px + env(safe-area-inset-bottom)); }
.top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
h1 { font-size: 1.15rem; margin: 6px 0; }
h2 { font-size: 1.05rem; margin: 8px 0; }
.meter { color: var(--muted); font-variant-numeric: tabular-nums; display: flex; gap: 12px; }
.status { min-height: 2.8em; margin: 4px 0; }
.status.bad { color: var(--warn); font-weight: 600; }
.status.good { color: var(--accent); font-weight: 600; }
.board-wrap { position: relative; width: 100%; aspect-ratio: 1; touch-action: manipulation; }
#boardHost, .board { width: 100%; height: 100%; display: block; }
.board { user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; }
.sq-light { fill: var(--sq-light); } .sq-dark { fill: var(--sq-dark); }
.hl-last { fill: var(--sq-last); pointer-events: none; }
.hl-sel { fill: var(--sq-sel); pointer-events: none; }
.sq-hidden { fill: var(--card); }
.coord { font: 2.4px sans-serif; fill: #000; opacity: 0.45; pointer-events: none; }
.target { fill: rgba(20, 85, 30, 0.5); pointer-events: none; }
.target-cap { fill: none; stroke: rgba(20, 85, 30, 0.5); stroke-width: 1; pointer-events: none; }
image { pointer-events: none; }
.row { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
button {
  font: inherit; min-height: 44px; padding: 8px 14px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--line); background: var(--card); color: var(--fg);
}
button.primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); font-weight: 600; }
button.link { border: 0; background: none; min-height: 44px; padding: 0 4px; color: var(--muted); text-decoration: underline; }
button:disabled { opacity: 0.5; }
.info { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; overflow-wrap: anywhere; }
.info a { color: var(--accent); display: inline-block; min-height: 40px; min-width: 40px; line-height: 40px; padding: 0 8px; }
.warn { color: var(--warn); font-size: 0.9rem; }
.veil {
  position: absolute; inset: 0; display: grid; place-items: center; font-size: 1.4rem;
  background: var(--card); border-radius: 4px; color: var(--muted);
}
.promo {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); display: flex; gap: 8px;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35); z-index: 2;
}
.promo button { width: 18vw; max-width: 84px; height: 18vw; max-height: 84px; padding: 4px; }
.promo img { width: 100%; height: 100%; display: block; }
[hidden] { display: none !important; }
#sumList { list-style: none; padding: 0; margin: 0 0 8px; }
#sumList li { padding: 4px 0; border-bottom: 1px solid var(--line); }
.hist { margin-top: 12px; }
.hist summary { cursor: pointer; padding: 8px 0; min-height: 44px; display: flex; align-items: center; }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; font-size: 0.92rem; }
th, td { text-align: left; padding: 4px 6px; border-bottom: 1px solid var(--line); }
footer { margin-top: 18px; color: var(--muted); }
.stamp { font-size: 0.85rem; margin: 4px 0; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
