/* Isometric-paper palette: warm paper, ink type, hairline rules, one terracotta accent. */
:root {
  --paper: #f7f4ec;
  --paper-raised: #fffdf7;
  --ink: #1f1b16;
  --ink-soft: #5c554a;
  --ink-faint: #8b8375;
  --rule: #ded6c4;
  --accent: #c2622d;
  --accent-soft: #f0dccb;
  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --sans: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--paper); color: var(--ink); font-family: var(--sans); }
#app { position: relative; height: 100%; overflow: hidden; }
#stage { position: absolute; inset: 0; }
#stage canvas { display: block; width: 100%; height: 100%; touch-action: none; }

.hud-top {
  position: absolute; top: 0; left: 0; right: 0; display: flex; justify-content: space-between;
  align-items: flex-start; gap: 12px; padding: 14px 16px;
  background: linear-gradient(var(--paper) 30%, transparent); pointer-events: none;
}
.hud-top > * { pointer-events: auto; }
.brand h1 { margin: 0; font-family: var(--serif); font-size: 22px; font-weight: 600; }
.brand p { margin: 2px 0 0; font-size: 13px; color: var(--ink-soft); }
button {
  font: inherit; font-size: 13px; color: var(--ink); background: var(--paper-raised);
  border: 1px solid var(--rule); border-radius: 8px; padding: 6px 12px; cursor: pointer;
}
button:hover { border-color: var(--ink-faint); }

.progress {
  position: absolute; top: 70px; left: 16px; display: flex; gap: 6px; flex-wrap: wrap;
  font-size: 12px; color: var(--ink-soft);
}
.progress span {
  background: var(--paper-raised); border: 1px solid var(--rule); border-radius: 999px; padding: 3px 9px;
}
.progress span.done { border-color: var(--accent); color: var(--ink); }
.progress span.here { background: var(--accent-soft); border-color: var(--accent); color: var(--ink); }

.panel {
  position: absolute; right: 16px; top: 64px; bottom: 16px; width: min(360px, 40vw); overflow: auto;
  background: var(--paper-raised); border: 1px solid var(--rule); border-radius: 12px; padding: 18px;
  box-shadow: 0 2px 14px -6px rgb(31 27 22 / 0.22);
}
.panel-step { margin: 0; font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-faint); }
.panel h2 { margin: 4px 0 8px; font-family: var(--serif); font-size: 22px; font-weight: 600; }
.panel-lede { margin: 0 0 8px; font-weight: 600; }
.panel-body { margin: 0 0 14px; font-size: 14px; line-height: 1.5; color: var(--ink-soft); }
.control label { display: block; font-size: 13px; margin-bottom: 6px; }
.control input[type=range] { width: 100%; accent-color: var(--accent); }
.readout { margin-top: 12px; border-top: 1px solid var(--rule); padding-top: 10px; font-size: 14px; }
.readout dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0; }
.readout dt { color: var(--ink-faint); }
.readout dd { margin: 0; font-variant-numeric: tabular-nums; font-weight: 600; }

.hint {
  position: absolute; left: 16px; bottom: 16px; margin: 0; font-size: 12px; color: var(--ink-soft);
  background: var(--paper-raised); border: 1px solid var(--rule); border-radius: 8px; padding: 6px 10px;
}
.pad { position: absolute; left: 16px; bottom: 56px; display: none; grid-template: repeat(2, 48px) / repeat(3, 48px); gap: 6px; }
.pad button { font-size: 18px; padding: 0; }
.pad [data-dir=up] { grid-area: 1 / 2; }
.pad [data-dir=left] { grid-area: 2 / 1; }
.pad [data-dir=down] { grid-area: 2 / 2; }
.pad [data-dir=right] { grid-area: 2 / 3; }

dialog { max-width: 560px; border: 1px solid var(--rule); border-radius: 12px; background: var(--paper-raised); color: var(--ink); }
dialog h2, dialog h3 { font-family: var(--serif); }
.ledger { padding-left: 18px; font-size: 14px; line-height: 1.5; }
.ledger b { text-transform: capitalize; }

/* A phone: the panel becomes a sheet at the bottom and the pad appears. */
@media (max-width: 700px), (pointer: coarse) {
  .pad { display: grid; }
}
@media (max-width: 700px) {
  .panel { left: 8px; right: 8px; top: auto; bottom: 8px; width: auto; max-height: 45%; }
  .pad { bottom: calc(45% + 16px); }
  .hint { display: none; }
}
