* { box-sizing: border-box; }
:root { font-family: system-ui, sans-serif; color: #e0ecff; background: #0c1932; }
body { margin: 0; height: 100dvh; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; overflow: hidden; }
header { display: flex; align-items: center; justify-content: space-between; padding: max(12px, env(safe-area-inset-top)) 18px 8px; }
small { color: #9bb4d5; font-size: 10px; letter-spacing: .18em; }
h1 { margin: 3px 0; font-size: clamp(18px, 5vw, 25px); font-weight: 600; }
output { color: #ffd78e; font-size: 23px; font-variant-numeric: tabular-nums; }
#stage { min-height: 0; position: relative; touch-action: none; }
canvas { display: block; width: 100%; height: 100%; touch-action: none; }
footer { padding: 8px 14px max(12px, env(safe-area-inset-bottom)); background: #162841; }
footer p { min-height: 32px; margin: 0 0 6px; font-size: 13px; }
footer div { display: flex; gap: 8px; align-items: center; }
footer span { flex: 1; font-size: 11px; color: #a8bfd9; }
button { min-width: 44px; min-height: 44px; padding: 8px 12px; border: 1px solid #8ba7ca; border-radius: 8px; background: #263e5c; color: inherit; font: inherit; font-size: 13px; }
:focus-visible { outline: 2px solid #ffc979; outline-offset: -2px; }
@media (max-height: 450px) { header { padding: 4px 14px; } small { display: none; } h1 { font-size: 18px; } footer { padding: 4px 12px; } footer p { min-height: 16px; margin-bottom: 2px; } }

body[data-production] header { gap: 8px; }
.back { display: grid; place-items: center; min-width: 44px; min-height: 44px; color: #ffd78e; text-decoration: none; }
body[data-production] header > div { flex: 1; }
.controls { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; }
.controls button { padding: 5px; font-size: 12px; }
#chapter { position: absolute; top: 4px; left: 10px; right: 10px; text-align: center; font-size: 12px; pointer-events: none; }
.marker { position: absolute; transform: translate(-50%, -50%); pointer-events: none; color: #fff3c9; font-size: 10px; text-shadow: 0 1px 3px #000; }
#save-status { display: block; font-size: 10px; min-height: 14px; margin-top: 4px; color: #bdcfe4; }
dialog { max-width: min(350px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); overflow: auto; color: #e0ecff; background: #162841; border: 1px solid #d7b784; border-radius: 14px; padding: 18px; }
dialog::backdrop { background: #071326ba; }
dialog h2 { font-size: 20px; margin-top: 0; }
dialog button { margin: 3px; }
body[data-motion="reduced"] * { scroll-behavior: auto; }
@media (min-width: 600px) { .controls { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
