:root { color-scheme: dark; font-family: system-ui,sans-serif; color: #fff1ca; background: #202e30; }
* { box-sizing: border-box; }
body { margin: 0; height: 100dvh; overflow: hidden; display: grid; grid-template-rows: auto minmax(0,1fr) auto; }
header { padding: max(14px,env(safe-area-inset-top)) 18px 8px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
small { font-size: 9px; letter-spacing: .18em; color: #c0caa0; }
h1 { margin: 4px 0; font-size: clamp(17px,4.8vw,25px); font-weight: 650; }
output { color: #ffcf78; font-size: 23px; font-variant-numeric: tabular-nums; }
#stage { position: relative; min-height: 0; touch-action: none; outline-offset: -3px; }
canvas { display: block; width: 100%; height: 100%; touch-action: none; }
#chapter { position: absolute; inset: 8px 0 auto; text-align: center; font-size: 11px; color: #efcf94; pointer-events: none; }
footer { padding: 12px 18px max(14px,env(safe-area-inset-bottom)); background: #19282a; border-top: 1px solid #60634c; }
.breath { height: 5px; background: #3e4940; border-radius: 5px; overflow: hidden; }
#charge { display: block; width: 100%; height: 100%; background: #ffd17d; transform: scaleX(0); transform-origin: left; }
p { font-size: 12px; line-height: 1.5; min-height: 36px; margin: 10px 0; }
.controls { display: flex; align-items: center; gap: 8px; }
.controls span { flex: 1; font-size: 10px; line-height: 1.6; color: #bec8ac; }
button { min-width: 44px; min-height: 44px; border: 1px solid #9eaa7c; border-radius: 12px; padding: 8px 12px; color: #fff0c8; background: #384a40; font: inherit; font-size: 12px; touch-action: manipulation; cursor: pointer; }
button:focus-visible, #stage:focus-visible { outline: 2px solid #ffcf78; }
#veil { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; z-index: 2; background: #19282ae8; }
#veil[hidden] { display: none; }
@media (max-height: 450px) {
  body { grid-template-columns: minmax(0,1fr) 240px; grid-template-rows: auto minmax(0,1fr); }
  header { padding: 6px 16px; } #stage { grid-column: 1; }
  footer { grid-column: 2; grid-row: 1 / 3; align-content: center; padding: 16px; }
  h1 { font-size: 18px; }
}

[data-production] header { padding: max(8px,env(safe-area-inset-top)) 12px 6px; gap: 9px; }
[data-production] header > div { flex: 1; }
[data-production] h1 { font-size: clamp(15px,4.2vw,23px); }
.back { display: grid; place-items: center; min-width: 44px; min-height: 44px; border: 1px solid #9eaa7c; border-radius: 12px; color: #ffdf9b; text-decoration: none; }
[data-production] footer { padding: 8px 12px max(8px,env(safe-area-inset-bottom)); }
[data-production] .controls { flex-wrap: wrap; gap: 6px; }
[data-production] .controls button { flex: 1; padding: 6px 8px; }
#save-status { display: block; font-size: 10px; color: #c4c9b0; line-height: 1.3; margin-top: 6px; }
dialog { width: min(380px,calc(100vw - 24px)); max-height: calc(100dvh - 24px); overflow: auto; padding: 18px; border: 1px solid #d6b677; border-radius: 20px; color: #fff1ca; background: #243b36; }
dialog::backdrop { background: #101c23b8; }
dialog h2 { font-size: 20px; margin: 0 0 10px; } dialog p { min-height: 0; }
#constellation-preview { display: block; width: 100%; height: 120px; background: #19282a; border-radius: 14px; }
#reward-status { color: #ffdb88; }
@media (max-height: 450px) { [data-production] .controls button { flex-basis: 40%; } [data-production] header { padding: 4px 12px; } #constellation-preview { height: 80px; } }
