* { box-sizing: border-box; }
:root { font-family: system-ui, sans-serif; color: #372d50; background: #eee0cf; }
body { margin: 0; height: 100dvh; overflow: hidden; display: grid; grid-template-rows: auto minmax(0,1fr) auto; }
header { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; }
h1 { font-size: clamp(16px,4.5vw,22px); margin: 0; line-height: 1.1; }
#clock { font-variant-numeric: tabular-nums; font-size: 20px; }
#stage { position: relative; min-height: 0; overflow: hidden; touch-action: none; }
canvas { display: block; width: 100%; height: 100%; touch-action: none; }
#chapter { position: absolute; top: 8px; text-align: center; width: 100%; pointer-events: none; font-size: 13px; }
#veil { position: absolute; inset: 0; display: grid; place-content: center; gap: 12px; text-align: center; background: #eee0cfed; }
[hidden] { display: none !important; }
footer { padding: 10px 12px max(10px,env(safe-area-inset-bottom)); background: #fff4dd; }
p { font-size: 13px; margin: 0 0 8px; }
#message { min-height: 32px; }
.controls { display: flex; gap: 8px; }
button { min-width: 44px; min-height: 44px; flex: 1; border: 1px solid #766384; border-radius: 10px; padding: 8px; color: inherit; background: #fffaf0; font: inherit; font-size: 13px; touch-action: manipulation; }
.hint { font-size: 10px; margin: 8px 0 0; }
:focus-visible { outline: 3px solid #764c9d; outline-offset: -3px; }
@media (max-height: 450px) { body { grid-template-columns: 220px 1fr; grid-template-rows: auto 1fr; } #stage { grid-column: 2; grid-row: 1 / 3; } footer { padding: 8px; } }

body[data-production] { background: #eee0cf; }
body[data-production] header { position: relative; border-bottom: 1px solid #cfb6c5; }
body[data-production] .controls { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 6px; }
body[data-production] h1 { letter-spacing: -.5px; }
#chapter { color: #493652; background: #fff4ddd9; border-radius: 20px; padding: 6px; }
dialog { color: #372d50; background: #fff4dd; border: 2px solid #94709c; border-radius: 18px; max-width: min(350px,calc(100vw - 24px)); padding: 18px; }
dialog h2 { font-size: 19px; margin: 0 0 10px; }
dialog button { margin-top: 8px; }
dialog::backdrop { background: #372d5077; }
#finish { position: fixed; top: auto; bottom: 235px; margin: 0 auto; text-align: center; padding: 12px; }
#storage { font-size: 10px; display: block; margin-top: 5px; }
#reward-status { font-size: 11px; margin: 3px 0 0; }
@media (max-height: 450px) {
  body[data-production] { grid-template-columns: 235px 1fr; }
  body[data-production] header { padding: 7px 10px; }
  body[data-production] footer { padding: 6px; }
  body[data-production] .hint { margin-top: 4px; }
  #finish { left: 240px; bottom: 12px; max-width: calc(100vw - 255px); }
}

#finish[open] { animation: stamp-arrive .2s ease-out; }
body[data-reduced-motion="true"] #finish { animation: none; }
@keyframes stamp-arrive { from { transform: translateY(6px); } to { transform: none; } }
@media (prefers-reduced-motion: reduce) { body[data-production]:not([data-reduced-motion="false"]) #finish { animation: none; } }
