* { box-sizing: border-box; }
html, body { margin: 0; width: 100%; height: 100%; overflow: hidden; overscroll-behavior: none; }
body { background: #101e3c; color: #ecfff5; font-family: system-ui, sans-serif; }
main { height: 100dvh; display: grid; grid-template-rows: 58px minmax(0, 1fr) 64px; gap: 8px; padding: max(8px, env(safe-area-inset-top)) 12px max(8px, env(safe-area-inset-bottom)); }
header, footer { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
h1 { margin: 0; font-size: 22px; letter-spacing: -.6px; }
header span { font-size: 12px; color: #a9d7da; }
#clock { font-size: 24px; font-variant-numeric: tabular-nums; }
#stage { position: relative; min-height: 0; overflow: hidden; border-radius: 22px; touch-action: none; background: #183969; }
canvas { display: block; width: 100%; height: 100%; touch-action: none; }
#message { position: absolute; top: 10px; left: 10px; right: 10px; text-align: center; pointer-events: none; font-size: 12px; text-shadow: 0 1px 4px #07152a; }
footer p { font-size: 11px; line-height: 1.5; flex: 1; }
button { min-width: 54px; min-height: 46px; padding: 8px 12px; border: 1px solid #89bfcd; border-radius: 14px; color: #ecfff5; background: #23486b; font: inherit; font-size: 13px; cursor: pointer; touch-action: manipulation; }
button:focus-visible, #stage:focus-visible { outline: 3px solid #ffdb87; outline-offset: -3px; }
#veil { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; flex-direction: column; background: #102544b8; padding: 25px; text-align: center; }
#veil[hidden] { display: none; }
@media (orientation: landscape) and (max-height: 500px) {
  main { grid-template-columns: 180px minmax(0, 1fr); grid-template-rows: 1fr 1fr; }
  #stage { grid-column: 2; grid-row: 1 / 3; }
  header, footer { flex-wrap: wrap; }
  footer p { flex-basis: 100%; }
}
/* Production chrome keeps the accepted canvas and controls in one viewport. */
body[data-production] main { grid-template-rows: 58px minmax(0, 1fr) 144px; }
.back { display: grid; place-items: center; min-width: 44px; height: 46px; border-radius: 14px; background: #23486b; color: inherit; text-decoration: none; }
body[data-production] h1 { font-size: 19px; }
body[data-production] header > div { min-width: 0; flex: 1; }
body[data-production] footer { display: block; }
body[data-production] footer p { margin: 0 0 4px; line-height: 1.4; }
nav { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; }
nav button { padding: 6px; }
#loading, #graphics-error { position: absolute; inset: 0; background: #102544ed; display: grid; place-content: center; text-align: center; padding: 18px; z-index: 3; }
#loading[hidden], #graphics-error[hidden] { display: none; }
dialog { width: min(340px, calc(100vw - 24px)); padding: 18px; border: 1px solid #89bfcd; border-radius: 18px; background: #183052; color: #ecfff5; }
dialog::backdrop { background: #07152ac9; }
dialog h2 { font-size: 21px; margin-top: 0; }
dialog div { display: flex; gap: 8px; }
dialog button { flex: 1; }
body[data-production] #veil { padding: 12px; }
@media (orientation: landscape) and (max-height: 500px) {
  body[data-production] main { grid-template-columns: 220px minmax(0, 1fr); grid-template-rows: 80px minmax(0, 1fr); }
  body[data-production] header { gap: 5px; flex-wrap: nowrap; }
  body[data-production] h1 { font-size: 16px; }
  body[data-production] header span { font-size: 10px; }
  body[data-production] footer { align-content: start; }
  body[data-production] nav { grid-template-columns: repeat(2, 1fr); }
}
body[data-production] #stage.finished #veil { top: auto; padding: 8px; background: #102544ba; }
body[data-production] #stage.finished #veil p { font-size: 15px; margin: 0 0 6px; }
