:root {
  color-scheme: dark;
  font: 16px/1.5 system-ui, sans-serif;
  --background: #191b18;
  --panel: #22251f;
  --line: #3d4136;
  --ink: #f7f0df;
  --muted: #c2bca9;
  --amber: #edba70;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: radial-gradient(ellipse at top, #2e3024, transparent 72%), var(--background);
  color: var(--ink);
}

.sprites { position: absolute; width: 0; height: 0; overflow: hidden; }
.shell, .footer-shell { width: min(100% - 32px, 900px); margin-inline: auto; }
.shell { padding: clamp(18px, 4vw, 42px) 0 22px; }
.masthead { display: flex; align-items: center; gap: 14px; margin-bottom: clamp(18px, 3vw, 28px); }
.logo { width: clamp(44px, 8vw, 68px); flex: none; color: #d78e43; }
h1, h2, p, dl, dd { margin: 0; }
h1 { font: 700 clamp(2.5rem, 6vw, 4.2rem)/.96 Georgia, serif; letter-spacing: -.055em; }
h2 { font: 700 1.5rem/1.2 Georgia, serif; }
.eyebrow { display: block; color: var(--amber); font-size: .72rem; font-weight: 750; letter-spacing: .15em; text-transform: uppercase; }
.masthead .eyebrow { margin-bottom: .4rem; }
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 310px; gap: 16px; align-items: start; }
.playfield, .console { border: 1px solid var(--line); background: var(--panel); border-radius: 14px; }
.playfield { padding: clamp(12px, 2.2vw, 20px); }
.field-header { display: flex; align-items: end; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.field-header .eyebrow { margin-bottom: 2px; }
.board-size { color: var(--muted); font: .8rem ui-monospace, monospace; white-space: nowrap; }
.board-frame {
  display: grid;
  place-items: center;
  padding: clamp(8px, 2vw, 18px);
  border: 1px solid #53513a;
  border-radius: 8px;
  background: repeating-linear-gradient(135deg, #2b2d24 0 6px, #303127 6px 12px);
}
#board {
  display: block;
  width: 100%;
  height: auto;
  max-width: 384px;
  touch-action: none;
  user-select: none;
}
.crate { color: #d48a42; }
.crate.parked { color: #a46932; }
.status { min-height: 1.5em; margin-top: 10px; color: var(--muted); font-size: .85rem; }
.status.solved { color: #c7dfa9; font-weight: 700; }

.console { padding: 18px; }
button, select {
  min-height: 44px;
  border: 1px solid #535749;
  border-radius: 7px;
  background: #2d3028;
  color: var(--ink);
  font: inherit;
}
button { cursor: pointer; padding: 6px 8px; font-size: .85rem; font-weight: 650; }
button:hover:not(:disabled), select:hover { background: #383c30; border-color: var(--amber); }
button:active:not(:disabled) { background: #484131; }
button:disabled { color: #aaa698; opacity: .55; cursor: default; }
:focus-visible { outline: 2px solid var(--amber); outline-offset: 3px; }
select { width: 100%; margin-top: 7px; padding: 6px 10px; }
.stats, .actions { display: grid; gap: 7px; }
.stats { grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 15px 0 10px; }
.stats div { padding: 8px 3px; text-align: center; background: #1b1e19; border: 1px solid var(--line); border-radius: 7px; }
.stats dt { color: var(--muted); font-size: .74rem; }
.stats dd { color: var(--amber); font: 700 1.22rem/1.4 ui-monospace, monospace; }
.actions { grid-template-columns: 1.15fr 1fr; }
.next { width: 100%; margin-top: 9px; color: #1a1b16; background: #e6bc79; border-color: #e6bc79; }
.next:hover:not(:disabled), .next:active:not(:disabled) { background: #f4d69b; }
.controls { margin-top: 18px; }
.dpad { display: grid; grid-template-columns: repeat(3, 48px); justify-content: center; gap: 5px; margin-top: 8px; }
.dpad button { font-size: 1.35rem; }
.dpad button:first-child { grid-column: 2; }
.dpad button:nth-child(2) { grid-column: 1; }
.key-hint { margin-top: 8px; text-align: center; font-size: .74rem; }
.key-hint, .rules p, .credits, .site-footer { color: var(--muted); }
.rules { border-top: 1px solid var(--line); margin-top: 15px; padding-top: 12px; }
.rules h2 { font-size: 1.15rem; }
.rules p { font-size: .85rem; margin-top: 5px; }
kbd { padding: 1px 4px; border: 1px solid #6c6b5e; border-radius: 3px; color: var(--ink); }
.credits { margin-top: 14px; font-size: .75rem; }
a { color: var(--amber); text-underline-offset: 2px; }
.site-footer { display: grid; gap: 16px; padding-bottom: 22px; font-size: .8rem; line-height: 1.7; overflow-wrap: anywhere; }
.site-footer > div { padding: clamp(14px, 2.5vw, 22px); border: 1px solid var(--line); border-radius: 14px; background: var(--panel); }
.site-footer h2 { margin-bottom: 10px; color: var(--ink); }
.site-footer > div p + p { margin-top: 10px; }
.site-footer > p { text-align: center; }
.site-footer > p:first-of-type { padding-bottom: 12px; border-bottom: 1px dotted var(--line); }
.site-footer nav { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 18px; }
.site-footer .more-games { line-height: 2; }

@media (max-width: 660px) {
  .shell, .footer-shell { width: min(100% - 20px, 465px); }
  .layout { grid-template-columns: 1fr; gap: 8px; }
  #board { max-width: min(100%, 36svh); }
  .console { padding: 12px; }
  .console .controls { margin-top: 12px; }
}
