:root {
  --ink: #173b46;
  --paper: #fff8e9;
  --coral: #ff836d;
  --lavender: #b8a1ef;
  --mint: #a6dfca;
  --line: #1d4b55;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { min-width: 320px; min-height: 100dvh; margin: 0; background: var(--paper); color: var(--ink); font: 18px/1.45 system-ui, sans-serif; }
button, a { min-height: 48px; font: inherit; }
button { padding: 9px 14px; border: 3px solid var(--line); border-radius: 15px; background: #fff; color: var(--ink); cursor: pointer; font-weight: 800; }
button:disabled { cursor: default; opacity: .55; }
.primary { background: #2457db; color: #fff; }
.game-bar { display: flex; min-height: 64px; align-items: center; justify-content: space-between; padding: 8px 16px; border-bottom: 3px solid var(--line); background: #fffdf6; }
.game-bar a { color: var(--ink); font-weight: 800; }
.game-bar p { font-weight: 900; letter-spacing: .08em; }
main { width: min(1050px, 100%); margin: auto; padding: 28px 18px; }
.card, .cabinet-card { border: 3px solid var(--line); border-radius: 25px; background: #fff; box-shadow: 0 7px 0 var(--line); }
.welcome { max-width: 650px; margin: 10vh auto; padding: clamp(24px, 7vw, 58px); text-align: center; }
.welcome h1, .round-head h1 { margin: .1em 0; font-size: clamp(2rem, 7vw, 4rem); line-height: 1.05; }
.eyebrow { margin: 0; color: #7959b6; font-size: .8rem; font-weight: 900; letter-spacing: .09em; }
.round-head { display: flex; align-items: start; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.support-status { min-height: 1.5em; margin: .4rem 0 0; font-weight: 700; }
.stamps { display: flex; flex-wrap: wrap; gap: 8px; }
.stamp { display: grid; width: 44px; height: 44px; place-items: center; border: 3px solid var(--line); border-radius: 50%; background: #fff; font-weight: 900; }
.stamp.done { background: var(--mint); }
.stamp.supported { box-shadow: inset 0 0 0 4px #7959b6; }
.layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(270px, .75fr); gap: 24px; }
.cabinet-card { position: relative; min-width: 0; padding: 12px; background: #f2d6a5; }
.board { position: relative; width: 100%; max-width: 510px; aspect-ratio: 1; border: 8px solid #744b36; border-radius: 18px; background: repeating-linear-gradient(90deg, #f9e7c2 0 calc(25% - 2px), #bf946a calc(25% - 2px) 25%), repeating-linear-gradient(0deg, transparent 0 calc(25% - 2px), #bf946a calc(25% - 2px) 25%); }
.piece { position: absolute; display: flex; align-items: center; justify-content: space-around; min-width: 48px; min-height: 48px; padding: 0; border-radius: 12px; background: var(--lavender); font-size: clamp(1rem, 4vw, 1.6rem); }
.piece[data-piece="B"], .piece[data-piece="D"], .piece[data-piece="F"] { background: var(--coral); }
.piece.parcel { background: #ffd360; }
.piece.selected { z-index: 2; outline: 5px solid #2457db; outline-offset: 2px; }
.piece span { font-size: .7em; }
.piece.x-0 { left: 4px; }
.piece.x-1 { left: calc(25% + 4px); }
.piece.x-2 { left: calc(50% + 4px); }
.piece.x-3 { left: calc(75% + 4px); }
.piece.y-0 { top: 4px; }
.piece.y-1 { top: calc(25% + 4px); }
.piece.y-2 { top: calc(50% + 4px); }
.piece.y-3 { top: calc(75% + 4px); }
.piece.horizontal.length-2 { width: calc(50% - 8px); height: calc(25% - 8px); }
.piece.horizontal.length-3 { width: calc(75% - 8px); height: calc(25% - 8px); }
.piece.vertical { flex-direction: column; width: calc(25% - 8px); }
.piece.vertical.length-2 { height: calc(50% - 8px); }
.piece.vertical.length-3 { height: calc(75% - 8px); }
.board-frame { position: relative; max-width: 534px; padding-right: 24px; margin-inline: auto; }
.door { position: absolute; top: calc(25% + 4px); right: 0; height: calc(25% - 8px); width: 24px; display: grid; place-items: center; border: 2px solid var(--line); background: #72bfa9; font-size: .65rem; font-weight: 900; writing-mode: vertical-rl; pointer-events: none; }
.board-key { font-size: .9rem; font-weight: 800; }
.controls { padding: 22px; }
.controls h2 { margin-top: 0; }
.move-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.actions { display: grid; gap: 10px; margin-top: 15px; }
.feedback { min-height: 3em; font-weight: 700; }
.feedback[data-kind="error"] { color: #a53c36; }
.help { margin-top: 24px; padding: 18px; border: 3px solid var(--line); border-radius: 18px; background: #fff; }
.mini-example { display: grid; grid-template-columns: minmax(180px, 320px) 1fr; gap: 18px; align-items: center; }
.mini-sequence { display: grid; grid-template-columns: 1fr auto 1fr; gap: 6px; align-items: center; }
.mini-step { display: grid; gap: 4px; color: var(--ink); font-size: .7rem; font-weight: 900; text-align: center; }
.mini-transition { color: var(--ink); font-size: 1.4rem; font-weight: 900; }
.mini-board { position: relative; width: 100%; aspect-ratio: 1; border: 3px solid var(--line); border-radius: 12px; background: repeating-linear-gradient(90deg, #f9e7c2 0 calc(25% - 1px), #bf946a calc(25% - 1px) 25%), repeating-linear-gradient(0deg, transparent 0 calc(25% - 1px), #bf946a calc(25% - 1px) 25%); }
.mini-piece, .mini-door, .mini-parcel-arrow { position: absolute; display: grid; place-items: center; font-size: .65rem; font-weight: 900; }
.mini-piece { border: 2px solid var(--line); border-radius: 7px; }
.mini-parcel { width: calc(50% - 6px); height: calc(25% - 6px); left: 3px; top: calc(25% + 3px); background: #ffd360; }
.mini-blocker { width: calc(25% - 6px); height: calc(50% - 6px); left: calc(50% + 3px); top: calc(25% + 3px); background: var(--coral); }
.mini-blocker-down { top: calc(50% + 3px); }
.mini-parcel-arrow { left: 38%; top: 27%; color: var(--ink); font-size: 1rem; }
.mini-door { right: 3px; top: calc(25% + 3px); width: calc(25% - 6px); height: calc(25% - 6px); border: 2px solid var(--line); background: #72bfa9; }
.hint-output { min-height: 1.5em; margin-bottom: 1rem; font-weight: 800; }
.completion-stamps { justify-content: center; margin: 1.5rem 0; }
:focus-visible { outline: 4px solid #2457db; outline-offset: 3px; }
@media (max-width: 850px) { .layout { grid-template-columns: 1fr; } .board { margin-inline: auto; } }
@media (max-width: 700px) { main { padding: 18px 12px; } .round-head { display: block; } .stamps { margin-top: 12px; } .mini-example { grid-template-columns: 1fr; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

.round-head h1 { font-size: clamp(1.75rem, 4vw, 2.5rem); }
.round-head p:not(.eyebrow) { margin: 8px 0; }
.help summary { min-height: 44px; padding-block: 10px; cursor: pointer; }
@media (max-height: 500px) and (min-width: 600px) { .round-head h1 { font-size: 1.75rem; } .round-head { margin-bottom: 10px; } .layout { grid-template-columns: minmax(0, 1fr) minmax(260px, 1fr); gap: 16px; } .stamps { flex-wrap: nowrap; } .support-status { font-size: .9rem; } }

.game-bar p { margin: 0; }
.game-bar a { display: inline-flex; align-items: center; }
@media (max-height: 500px) and (min-width: 600px) {
  .game-bar { min-height: 52px; padding: 2px 12px; }
  main { padding: 10px 12px; }
  .round-head h1 { font-size: 1.5rem; }
  .round-head p:not(.eyebrow) { font-size: .8rem; margin: 4px 0; }
}

@media (max-width: 700px) {
  .game-bar { min-height: 52px; padding: 2px 12px; }
  main { padding: 10px 12px; }
  .round-head { margin-bottom: 10px; }
  .round-head h1 { font-size: 1.5rem; }
  .round-head p:not(.eyebrow) { font-size: .8rem; margin: 4px 0; }
  .stamps { margin-top: 8px; }
  .stamp { width: 32px; height: 32px; border-width: 2px; }
  .board-key { font-size: .85rem; margin: 8px 0; }
  .move-controls button { font-size: .9rem; padding: 8px; }
}

.board-frame { max-width: clamp(264px, calc(100dvh - 350px), 534px); }

@media (max-height: 500px) and (min-width: 600px) {
  .welcome { margin: 4px auto; padding: 10px 20px; font-size: 1rem; }
  .welcome h1 { font-size: 2rem; }
  .welcome p { margin: 4px 0; }
  .welcome .completion-stamps { margin: 8px 0; }
}
