* { box-sizing: border-box; }
:root { font-family: system-ui, sans-serif; background: #141426; color: #ffdfac; }
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: 12px 16px; gap: 8px; }
h1 { font-size: clamp(17px, 4.6vw, 25px); margin: 4px 0; }
small { font-size: 10px; letter-spacing: .18em; }
#clock { min-width: 44px; font-variant-numeric: tabular-nums; }
#stage { position: relative; min-height: 0; overflow: hidden; touch-action: none; }
canvas { display: block; width: 100%; height: 100%; touch-action: none; }
#veil { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; background: #141426dc; }
#veil[hidden] { display: none; }
footer { padding: 10px 14px max(12px, env(safe-area-inset-bottom)); background: #232038; }
#message { margin: 0 0 8px; min-height: 34px; font-size: 13px; }
.controls { display: flex; gap: 8px; align-items: center; }
.controls span { flex: 1; font-size: 10px; line-height: 1.5; }
button { min-width: 44px; min-height: 44px; border: 1px solid #a28b83; border-radius: 10px; padding: 8px 12px; background: #36304a; color: #ffdfac; font: inherit; font-size: 12px; }
:focus-visible { outline: 2px solid #ffc661; outline-offset: -2px; }
@media (max-height: 450px) { body { grid-template-columns: 190px 1fr; grid-template-rows: auto 1fr; } #stage { grid-column: 2; grid-row: 1 / 3; } header, footer { padding: 8px; } h1 { font-size: 17px; } .controls { flex-wrap: wrap; } .controls span { flex-basis: 100%; } }

/* The production frame keeps the silk stage clear, including short landscape screens. */
body[data-production] { background: radial-gradient(ellipse at top, #29223f, #141426 70%); }
body[data-production] header { padding: 9px 12px; border-bottom: 1px solid #554361; }
body[data-production] header > div { flex: 1; min-width: 0; }
body[data-production] h1 { font-family: Georgia, serif; font-weight: 500; font-size: clamp(18px, 4.6vw, 24px); line-height: 1.05; }
body[data-production] header small { font-size: 8px; letter-spacing: .14em; color: #cbb7db; }
.back { display: grid; place-items: center; min-width: 44px; height: 44px; border: 1px solid #796283; border-radius: 50%; color: #ffdfac; text-decoration: none; }
body[data-production] #clock { border: 1px solid #796283; border-radius: 50%; width: 44px; height: 44px; display: grid; place-items: center; }
#chapter { position: absolute; top: 10px; width: 100%; text-align: center; font-size: 11px; color: #e6c6ef; pointer-events: none; letter-spacing: .05em; }
body[data-production] footer { border-top: 1px solid #65506b; background: linear-gradient(#292239, #201b30); padding: 8px 12px max(8px, env(safe-area-inset-bottom)); }
.objective { color: #ffc776; font-size: 10px; letter-spacing: .1em; margin: 0 0 5px; }
body[data-production] #message { min-height: 34px; margin-bottom: 4px; font-size: 12px; line-height: 1.4; }
#showline { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 6px; font-size: 10px; color: #c7b9d9; }
body[data-production] .controls { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px; }
body[data-production] button { padding: 6px 8px; border-color: #796283; background: #37304d; }
body[data-production] button[aria-pressed="true"] { background: #5a425e; border-color: #ffc776; }
#motion { grid-column: span 2; }
#storage { display: block; min-height: 18px; padding-top: 5px; font-size: 9px; letter-spacing: 0; color: #c7b9d9; }
#reward-status { font-size: 11px; min-height: 15px; margin: 2px 0 0; color: #ffd789; }
dialog { width: min(330px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); overflow: auto; padding: 18px; border: 1px solid #b8908f; border-radius: 18px; color: #ffdfac; background: #292239; }
dialog::backdrop { background: #100d22bc; } dialog h2 { font: 23px Georgia, serif; margin: 0 0 10px; } dialog p { font-size: 13px; line-height: 1.5; }
@media (max-height: 450px) {
  body[data-production] { grid-template-columns: 210px minmax(0, 1fr); }
  body[data-production] header { gap: 6px; padding: 6px; flex-wrap: wrap; }
  body[data-production] header > div { flex: 1; } body[data-production] header small { display: none; }
  body[data-production] h1 { font-size: 16px; }
  body[data-production] #clock { position: static; }
  body[data-production] footer { padding: 7px 8px; }
  body[data-production] .objective { font-size: 9px; letter-spacing: .03em; }
  body[data-production] #message { min-height: 48px; margin-top: 0; }
  #showline { margin-bottom: 5px; } #showline span { display: none; }
  body[data-production] .controls { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  #motion { grid-column: span 2; }
  #storage { min-height: 26px; } #reward-status { font-size: 10px; }
}
