:root {
  color-scheme: light;
  font-family: "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  font-weight: 600;
  color: #203d32;
  background: #eaf2df;
  -webkit-tap-highlight-color: transparent;
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 260px; min-height: 100vh; background: radial-gradient(#587b4525 1px, transparent 1px) 1px 1px / 19px 19px, #eaf2df; }
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
button:focus-visible { outline: 3px solid #12675a; outline-offset: 3px; }
[hidden] { display: none !important; }
.app { width: min(100% - 40px, 1024px); margin: auto; padding: 23px 0 24px; }
.masthead, .brand, .tools, .hud, .level-heading, .counters, .board-footer { display: flex; align-items: center; }
.masthead { justify-content: space-between; margin-bottom: 16px; }
.brand { gap: 12px; }
.brand-icon { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 15px; background: #21463a; color: #e2f4aa; box-shadow: 0 3px 0 #142f27; font-size: 29px; }
h1,h2,h3,p { margin: 0; }
h1 { font-size: clamp(24px, 4vw, 36px); font-weight: 950; letter-spacing: -.075em; }
.tools { gap: 8px; }
.icon-button { width: 44px; height: 44px; display: grid; place-items: center; border: 1px solid #aabf9f; border-radius: 13px; background: #f8faef; }
.icon-button:hover, .level:hover { background: #f0f5d9; }
.icon-button svg { width: 22px; height: 22px; }
.machine { background: #f9faee; border: 1px solid #a9bea0; border-radius: 24px; padding: 12px; box-shadow: 0 6px 0 #c6d8b9, 0 17px 40px #41685216; }
.hud { justify-content: space-between; gap: 10px; padding: 5px 7px 13px; }
.level-heading { gap: 11px; }
.stage-number { display: grid; place-items: center; min-width: 36px; min-height: 36px; padding: 0 5px; border-radius: 10px; color: #203d32; background: #deedaf; font-weight: 900; font-variant-numeric: tabular-nums; }
h2 { font-size: clamp(18px, 3.4vw, 27px); letter-spacing: -.055em; font-weight: 950; }
.counters { gap: 18px; flex-shrink: 0; }
.counter { display: flex; align-items: baseline; gap: 7px; }
.counter + .counter { border-left: 1px solid #cfdbbf; padding-left: 18px; }
.counter span { color: #526853; font-size: .83rem; }
.counter strong { min-width: 1ch; font-size: 1.43rem; font-weight: 950; font-variant-numeric: tabular-nums; }
#score { min-width: 4ch; text-align: right; }
.board { position: relative; border: 1px solid #52796b; overflow: hidden; border-radius: 15px; background: #a6d9bf; isolation: isolate; }
canvas { display: block; width: 100%; height: auto; aspect-ratio: 920 / 490; max-height: min(58vh, 530px); touch-action: none; user-select: none; cursor: grab; }
canvas.dragging { cursor: grabbing; }
.target-count { position: absolute; top: 13px; right: 13px; pointer-events: none; display: flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 10px; background: #f4fae6; color: #25473c; font-size: .82rem; box-shadow: 0 2px 0 #1e53442b; }
.target-count strong { font-size: 1rem; }
.board-footer { gap: 9px; padding: 12px 6px 3px; min-height: 42px; color: #405d4b; font-size: .92rem; }
.hint-icon { color: #276a52; }
.levels { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; margin-top: 16px; }
.level { display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 6px 10px; text-align: left; border: 1px solid #b5c8a7; border-radius: 12px; background: #f5f8ea; }
.level[aria-current="step"] { background: #24483c; color: #f6f9ec; border-color: #24483c; }
.level span:first-child { color: #3d5e4d; background: #e2ebcf; font-size: .79rem; padding: 4px 6px; border-radius: 6px; }
.level span:last-child { margin-left: auto; color: #587450; }
.level[aria-current="step"] span:last-child { color: #e2f4aa; }
.result { position: absolute; inset: 0; z-index: 1; background: #173c3975; display: grid; place-items: center; padding: 8px; }
.result-card { text-align: center; width: min(370px, 100%); padding: 18px 13px; border: 1px solid #9cb28a; border-radius: 19px; background: #fbfbed; box-shadow: 0 6px 0 #18372e58; }
.result-icon { font-size: 28px; line-height: 1; margin-bottom: 5px; }
.result h3 { font-size: clamp(21px, 4vw, 30px); line-height: 1.1; letter-spacing: -.045em; }
.result p { margin: 8px 0 12px; font-size: .88rem; color: #526853; }
.result-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 7px; }
.result-actions button { min-height: 42px; padding: 6px 14px; border-radius: 9px; }
.plain { border: 1px solid #abc0a2; background: #f5f8e9; }
.primary { border: 1px solid #21463a; background: #21463a; color: #f9faee; }
@media (max-width: 575px) {
  .app { width: calc(100% - 20px); padding: 12px 0 16px; }
  .masthead { margin-bottom: 12px; }
  .brand-icon { width: 39px; height: 39px; font-size: 24px; border-radius: 12px; }
  .brand { gap: 8px; }
  .machine { padding: 6px; border-radius: 18px; }
  .hud { padding: 6px 4px 10px; }
  .level-heading { gap: 6px; }
  .stage-number { min-width: 26px; min-height: 28px; font-size: .79rem; border-radius: 7px; }
  .counters { gap: 8px; }
  .counter { display: grid; gap: 0; justify-items: center; }
  .counter + .counter { padding-left: 8px; }
  .counter span { font-size: .69rem; }
  .counter strong { font-size: 1.13rem; text-align: center !important; }
  .board { border-radius: 11px; }
  canvas { aspect-ratio: 1.58; max-height: none; }
  .target-count { top: 6px; right: 6px; padding: 3px 6px; font-size: .68rem; }
  .board-footer { padding: 7px 4px 4px; min-height: 38px; font-size: .79rem; }
  .levels { gap: 5px; margin-top: 12px; }
  .level { display: grid; grid-template-columns: auto 1fr; gap: 3px 5px; padding: 5px; text-align: left; font-size: .73rem; }
  .level span:last-child { display: none; }
  .level span:first-child { font-size: .69rem; padding: 3px; }
  .result-card { padding: 9px 8px; }
}
@media (max-height: 510px) and (orientation: landscape) {
  .app { padding: 6px 0; width: min(100% - 16px, 750px); }
  .masthead { margin-bottom: 6px; }
  .brand-icon { width: 32px; height: 32px; font-size: 22px; }
  h1 { font-size: 25px; }
  .machine { padding: 6px; }
  .hud { padding: 2px 5px 5px; }
  canvas { height: 56vh; max-height: none; }
  .board-footer { min-height: 28px; padding: 3px; }
  .levels { margin-top: 8px; }
  .level { min-height: 44px; }
}
