:root {
  color-scheme: light;
  --paper: #f4f1e7;
  --ink: #222824;
  --muted: #60675d;
  --line: #d9d9c9;
  --accent: #bd391f;
  --green: #cce56b;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "PingFang SC", "Noto Sans CJK SC", sans-serif;
  background: var(--paper);
  color: var(--ink);
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-width: 280px; }
button { color: inherit; font: inherit; cursor: pointer; }
button:focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; }
button:disabled { opacity: .42; cursor: default; }
[hidden] { display: none !important; }
.site { width: min(1112px, calc(100% - 88px)); margin: 0 auto; }
.site-header {
  min-height: 78px; display: flex; flex-wrap: wrap; align-items: center;
  justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; align-items: center; font: 900 21px/1 var(--mono); letter-spacing: -.095em; }
.brand-dot { color: var(--accent); padding: 0 2px; }
.site-progress {
  display: inline-flex; align-items: center; gap: 9px; padding: 7px 11px;
  border: 1px solid var(--line); border-radius: 100px; font-size: 12px; font-weight: 700;
}
.site-progress i { width: 8px; height: 8px; background: #749720; border-radius: 50%; }
.layout { display: grid; grid-template-columns: minmax(230px, 1fr) minmax(0, 2.55fr); gap: clamp(35px,5vw,74px); margin: 65px 0 54px; }
.sidebar { padding-top: 17px; }
.intro h1 { font-size: clamp(44px,5.4vw,74px); line-height: 1.1; font-weight: 900; margin: 0 0 22px; letter-spacing: -.09em; white-space: nowrap; }
.intro h1 span { color: var(--accent); padding-left: 4px; }
.intro p { margin: 0; color: var(--muted); font-size: 15px; line-height: 1.8; }
.levels { margin: 42px 0 27px; padding-top: 22px; border-top: 1px solid var(--line); }
.levels h2 { margin: 0 0 14px; font-size: 13px; }
.level-buttons { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 8px; }
.level-buttons button {
  min-height: 42px; position: relative; border: 1px solid var(--line);
  background: #faf8ef; border-radius: 7px; font: 750 15px var(--mono);
}
.level-buttons button:hover { border-color: var(--ink); }
.level-buttons button[aria-current] { background: var(--ink); color: #fffdf3; border-color: var(--ink); }
.level-buttons button[data-cleared]::after { content: ""; position: absolute; right: 5px; top: 5px; width: 5px; height: 5px; border-radius: 50%; background: #6d8e20; }
.level-buttons button[aria-current][data-cleared]::after { background: var(--green); }
.legend { display: flex; flex-wrap: wrap; gap: 11px 14px; color: var(--muted); font-size: 12px; }
.legend > span { display: inline-flex; align-items: center; gap: 5px; }
.game { min-width: 0; border: 1px solid var(--line); border-radius: 17px; background: #faf8ef; box-shadow: 0 7px 0 #e5e1d2; padding: 0 13px; }
.game-header, .controls {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 8px; min-height: 67px;
}
.level-title { display: flex; align-items: center; gap: 10px; }
.level-title > span {
  display: grid; place-items: center; width: 33px; height: 33px;
  border: 1px solid #f0cfbd; background: #fae7d8; color: #9b2c19; border-radius: 7px; font: 800 13px var(--mono);
}
.level-title h2 { margin: 0; font-size: 17px; white-space: nowrap; }
.stats { display: flex; gap: clamp(9px,1.8vw,22px); white-space: nowrap; }
.stats > span { display: inline-flex; align-items: baseline; gap: 6px; }
.stat-label { color: var(--muted); font-size: 12px; }
.stats strong { min-width: 2ch; font: 800 16px var(--mono); }
.stage {
  display: grid; place-items: center; position: relative; min-height: 420px;
  padding: 20px 13px; border-radius: 11px; overflow: hidden; isolation: isolate;
  background-color: #202c25;
  background-image: radial-gradient(circle, #39463e 1px, transparent 1.2px);
  background-size: 16px 16px;
}
.board {
  display: grid; grid-template-columns: repeat(var(--cols), minmax(0,1fr));
  width: min(100%, 510px); gap: 2px; touch-action: none; user-select: none;
}
.cell { position: relative; display: grid; place-items: center; aspect-ratio: 1; border-radius: 3px; background: #344339; }
.cell.wall {
  border: 1px solid #56695a; background: #475a4d;
  box-shadow: inset 0 2px #576c5d, inset 0 -4px #3a4a40;
}
.cell.wall::after { content: ""; position: absolute; inset: 44% 0 auto; height: 1px; background: #63766655; }
.cell.void { background: transparent; }
.cell.goal { background: #3d4e3e; }
.target {
  display: block; width: 39%; aspect-ratio: 1; border-radius: 50%;
  border: 2px dashed #d0e797; background: #96b06923;
}
.cell > .target, .cell > .crate, .player { grid-area: 1 / 1; }
.crate {
  display: block; position: relative; width: 81%; aspect-ratio: 1; border: 2px solid #61331c;
  border-radius: 18%; background: linear-gradient(155deg,#ffb262,#ee8844);
  box-shadow: inset 0 2px #ffd4a5, inset 0 -3px #9f4b2780, 0 2px #17201980; z-index: 1;
}
.crate::before, .crate::after { position: absolute; content: ""; }
.crate::before { inset: 15%; border: 1px solid #9b4b2e; border-radius: 12%; }
.crate::after { inset: 45% 10%; background: #a9552e; transform: rotate(-45deg); border-radius: 100px; }
.crate.placed {
  background: linear-gradient(155deg,#def47d,#9ebd50); border-color: #475c22;
  box-shadow: inset 0 2px #edfcb0, inset 0 -3px #55742390, 0 2px #17201980;
}
.crate.placed::before { border-color: #5d742c; }
.crate.placed::after { background: #6c8832; }
.brand-icon { width: 25px; margin-right: 10px; box-shadow: 0 1px #69382065; }
.legend-crate { width: 14px; border-width: 1px; box-shadow: none !important; }
.legend-crate::before { display: none; }
.legend-target { width: 13px; border-color: #5e752d; border-width: 1.5px; background: #d9e3c2; }
.player {
  width: 74%; height: 78%; z-index: 2; border-radius: 35% 35% 31% 31%;
  border: 2px solid #25332b; background: #f7f1dc;
  box-shadow: inset 0 -5px #c9c9a7, 0 3px #141e17a0;
  position: relative;
}
.player::before {
  content: ""; position: absolute; inset: 31% 18% auto; height: 26%;
  background: radial-gradient(circle at 26% 50%, #29362b 0 19%, transparent 21%),
              radial-gradient(circle at 74% 50%, #29362b 0 19%, transparent 21%);
}
.player::after {
  content: ""; position: absolute; top: 65%; left: 33%; right: 33%; height: 10%;
  border-radius: 10px; background: #e9a76b;
}
.controls { min-height: 65px; }
.actions, .keyboard { display: flex; align-items: center; gap: 7px; }
.actions button, .dpad button {
  border: 1px solid #d7d7c9; border-radius: 7px; background: #f3f0e5; min-height: 39px;
  font-size: 13px; font-weight: 750; padding: 0 11px;
}
.actions button:hover:not(:disabled), .dpad button:hover { border-color: #727a64; background: #efecd9; }
.actions button span { font-size: 18px; margin-right: 2px; vertical-align: -1px; }
.keyboard { margin: 0; color: var(--muted); font-size: 12px; gap: 4px; }
.keyboard span { margin-left: 3px; }
kbd { min-width: 23px; padding: 3px 5px; border: 1px solid var(--line); border-radius: 4px; text-align: center; font: 700 13px var(--mono); }
.dpad { display: none; gap: 5px; grid-template-columns: repeat(3, minmax(0,53px)); grid-template-areas: ". up ." "left down right"; justify-content: center; padding: 0 0 14px; }
.dpad button { font: 800 22px var(--mono); min-height: 44px; touch-action: manipulation; }
.up { grid-area: up; } .left { grid-area: left; } .down { grid-area: down; } .right { grid-area: right; }
.win { position: absolute; inset: 0; display: grid; place-items: center; z-index: 3; background: #17221bcd; padding: 12px; }
.win-card { width: min(100%, 285px); border-radius: 13px; padding: 23px; background: var(--paper); text-align: center; }
.win-crate { width: 40px; margin: 0 auto 13px; }
.win h3 { margin: 0 0 7px; font-size: 24px; }
.win p { margin: 0 0 16px; font-size: 13px; color: var(--muted); }
.next, .review { display: block; min-height: 38px; width: 100%; border: 0; border-radius: 6px; font-weight: 750; font-size: 13px; }
.next { background: var(--ink); color: #fffdf3; }
.next:hover { background: #3e493f; }
.review { background: transparent; margin-top: 4px; }
.review:hover { background: #e9e7d9; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; clip-path: inset(50%); overflow: hidden; white-space: nowrap; }
@media (max-width: 900px) {
  .site { width: calc(100% - 54px); }
  .layout { gap: 28px; margin-top: 50px; }
  .stage { min-height: 360px; }
}
@media (max-width: 680px) {
  .site { width: calc(100% - 28px); }
  .site-header { min-height: 58px; }
  .brand { font-size: 18px; }
  .brand-icon { width: 21px; margin-right: 8px; }
  .layout { display: flex; flex-direction: column; gap: 16px; margin: 20px 0 24px; }
  .sidebar { display: contents; }
  .intro { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 6px 12px; }
  .intro h1 { font-size: clamp(34px,10vw,52px); margin: 0; }
  .intro p { font-size: 12px; line-height: 1.55; }
  .levels { order: 2; margin: 7px 0 0; padding-top: 14px; }
  .level-buttons { grid-template-columns: repeat(7,minmax(0,1fr)); gap: 4px; }
  .level-buttons button { min-height: 36px; padding: 0; font-size: 13px; }
  .legend { order: 3; }
  .game { padding: 0 8px; border-radius: 13px; }
  .game-header, .controls { min-height: 52px; padding: 8px 3px; }
  .level-title { gap: 6px; }
  .level-title > span { width: 28px; height: 28px; }
  .level-title h2 { font-size: 14px; }
  .stats > span { gap: 3px; }
  .stats strong { font-size: 13px; }
  .stage { min-height: clamp(230px,74vw,420px); padding: 10px 8px; }
  .board { gap: 1px; }
}
@media (pointer: coarse), (max-width: 680px) {
  .dpad { display: grid; }
  .keyboard { display: none; }
  .actions { width: 100%; justify-content: space-between; }
}
