:root { color-scheme: dark; font-family: system-ui, sans-serif; color: #f3e4cb; background: #15182c; }
* { box-sizing: border-box; }
body { margin: 0; height: 100dvh; overflow: hidden; display: grid; grid-template-rows: auto minmax(0,1fr) auto; grid-template-columns: minmax(0,1fr); }
header { padding: max(16px,env(safe-area-inset-top)) 18px 8px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
small { font-size: 9px; letter-spacing: .16em; color: #b8b4d0; }
h1 { font-size: clamp(18px,5vw,25px); margin: 5px 0; }
output { font-size: 24px; color: #ffd27f; font-variant-numeric: tabular-nums; }
#stage { position: relative; min-width: 0; min-height: 0; touch-action: none; }
canvas { display: block; max-width: 100%; max-height: 100%; width: 100%; height: 100%; touch-action: none; }
.directions { position: absolute; inset: auto 18px 12px; display: flex; justify-content: space-between; pointer-events: none; color: #b8b4d0; font-size: 9px; letter-spacing: .1em; }
footer { padding: 8px 16px max(16px,env(safe-area-inset-bottom)); background: #1d2038; border-top: 1px solid #44425b; }
p { font-size: 13px; line-height: 1.5; min-height: 39px; margin: 6px 0 12px; }
.controls { display: flex; align-items: center; gap: 8px; }
.controls span { flex: 1; font-size: 10px; line-height: 1.6; color: #c1b9ce; }
button { min-height: 44px; padding: 8px 12px; border: 1px solid #8f7b72; border-radius: 10px; background: #383047; color: #ffedcc; cursor: pointer; touch-action: manipulation; }
button:focus-visible, #stage:focus-visible { outline: 2px solid #ffd27f; outline-offset: -2px; }
#veil { position: absolute; inset: 0; background: #15182cdd; display: grid; place-content: center; text-align: center; }
#veil[hidden] { display: none; }

.production header { padding: max(10px,env(safe-area-inset-top)) 12px 6px; gap: 8px; }
.production header > div { flex: 1; }
.production h1 { font-size: clamp(16px,4.5vw,23px); }
.back { display: grid; place-items: center; min-width: 44px; min-height: 44px; border: 1px solid #8f7b72; border-radius: 10px; text-decoration: none; color: #ffedcc; }
#chapter { position: absolute; top: 8px; left: 0; width: 100%; text-align: center; font-size: 12px; color: #e5c9a4; pointer-events: none; }
.production footer { padding: 6px 12px max(10px,env(safe-area-inset-bottom)); }
.production .controls button { flex: 1; min-width: 44px; }
.preferences { margin-top: 6px; }
#save-status { display: block; min-height: 14px; margin-top: 6px; font-size: 10px; color: #c1b9ce; }
dialog { width: min(410px,calc(100vw - 24px)); max-height: calc(100dvh - 24px); overflow: auto; padding: 14px; border: 1px solid #c8a57a; border-radius: 16px; background: #25233e; color: #ffedcc; }
dialog::backdrop { background: #090b1bbf; }
dialog h2 { margin: 0 0 8px; font-size: 19px; }
dialog p { min-height: 0; margin: 8px 0; font-size: 12px; }
#seam-preview { display: block; width: 100%; height: 150px; }
#reward-status { color: #ffd27f; }
@media (max-height: 450px) {
  .production { grid-template-columns: minmax(0,1fr) 250px; grid-template-rows: auto minmax(0,1fr); }
  .production header { padding: 5px 12px; } .production #stage { grid-column: 1; }
  .production footer { grid-column: 2; grid-row: 1 / 3; align-content: center; padding: 12px; }
  .production h1 { font-size: 18px; } #seam-preview { height: 110px; }
}
