:root {
  color-scheme: light;
  font-family: system-ui, sans-serif;
  background: #f4f6f5;
  color: #18232b;
  --acid: #d0ff69;
  --ink-blue: #173b59;
}
* { box-sizing: border-box; }
body { margin: 0; }
main { width: min(100% - 24px, 560px, 77dvh); margin: 14px auto; }
header, .hud { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
header { margin-bottom: 8px; }
h1 { color: #264722; font-size: clamp(24px, 6vw, 36px); line-height: 1; margin: 0; letter-spacing: -.06em; }
small, .keys { color: var(--ink-blue); font: 11px ui-monospace, monospace; letter-spacing: .09em; }
.hud { color: var(--ink-blue); align-items: center; min-height: 54px; border-top: 1px solid #aab8b2; }
.hud strong, small { display: block; }
.hud strong { margin-top: 4px; color: var(--ink-blue); font: 700 16px ui-monospace, monospace; }
.hud p { margin: 0; font-size: 13px; text-align: center; }
.next { display: flex; align-items: center; gap: 4px; }
.next canvas { width: 54px; height: auto; }
.next[hidden], .puzzle-preview[hidden] { display: none; }
.puzzle-preview { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; color: var(--ink-blue); }
.puzzle-preview small { flex: none; }
.puzzle-preview ol { display: flex; flex-wrap: wrap; gap: 4px; margin: 0; padding: 0; list-style: none; }
.puzzle-preview canvas { display: block; width: 46px; height: auto; background: #273632; border-radius: 4px; }
.puzzle-preview span { font-size: 12px; }
.field { position: relative; border: 1px solid #405048; border-radius: 9px; overflow: hidden; }
#game { width: 100%; height: auto; display: block; }
.controls { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 8px; }
button { color: #eef4eb; background: #1b2924; border: 1px solid #41564b; border-radius: 7px; min-height: 44px; font: inherit; font-weight: 650; cursor: pointer; touch-action: none; user-select: none; }
button:hover, button:active, button.is-held { background: #334739; }
button:focus-visible { outline: 2px solid #537724; outline-offset: 2px; }
.controls button { font-size: 20px; }
.controls span { font-size: 13px; margin-left: 3px; }
.keys { text-align: center; margin: 8px 0 0; }
.overlay { position: absolute; inset: 0; display: grid; place-items: center; background: #080d10a8; padding: 16px; }
.overlay[hidden] { display: none; }
.overlay.victory { background: #080d1040; }
.card { color: #eef4eb; width: min(100%, 300px); background: #13201c; border: 1px solid #526a56; padding: 22px; border-radius: 10px; text-align: center; }
.card h2 { margin: 0; }
.card button { padding: 0 20px; background: var(--acid); color: #172010; }
@media (pointer: coarse) { .keys { display: none; } }
.level { display: flex; align-items: center; gap: 6px; color: var(--ink-blue); font-size: 12px; }
.level select { font: inherit; color: #eef4eb; background: #1b2924; border: 1px solid #41564b; border-radius: 6px; padding: 6px; }
.mascot { display: flex; align-items: center; gap: 9px; margin-top: 8px; padding: 6px 9px; background: #e9eef0; color: var(--ink-blue); border: 1px solid #b3c1c8; border-radius: 7px; }
.mascot canvas { flex: 0 0 32px; width: 32px; height: 32px; image-rendering: pixelated; }
.mascot p { margin: 0; font-size: 14px; line-height: 1.4; }
.mascot strong { color: var(--ink-blue); margin-right: 3px; }
#restart { padding: 0 9px; min-height: 34px; font-size: 12px; }
#game:focus { outline: none; }
@media (max-width: 530px) {
  header h1 { white-space: nowrap; }
  .hud { display: grid; grid-template-columns: repeat(4, auto); gap: 5px; padding: 6px 0; }
  .hud p { grid-column: 1 / -1; grid-row: 2; }
  .controls span { margin-left: 0; font-size: 11px; }
}
.audio-controls { display: flex; justify-content: center; gap: 16px; margin-top: 7px; color: var(--ink-blue); font-size: 12px; }
.audio-controls label { display: flex; align-items: center; gap: 4px; cursor: pointer; }
.audio-controls input { accent-color: #537724; }

.start-keys { margin: 12px 0 0; color: #b8c9bf; font-size: 12px; }
#restart:disabled { opacity: .5; cursor: default; }
@media (pointer: coarse) { .start-keys { display: none; } }
.high-scores { display: grid; gap: 4px; margin: 14px 0; font-size: 13px; text-align: left; }
.high-scores div { display: flex; justify-content: space-between; gap: 10px; }
.high-scores dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }
#result-best { font-weight: 700; }
