* { box-sizing: border-box; }
:root { font-family: system-ui, sans-serif; color: #e0f2fa; background: #101f36; }
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 8px; gap: 8px; }
small { font-size: 10px; letter-spacing: .16em; color: #9dbdd3; }
h1 { margin: 3px 0; font-size: clamp(17px, 4.7vw, 24px); font-weight: 650; }
#clock { border: 1px solid #86c9dc; border-radius: 50%; min-width: 44px; height: 44px; display: grid; place-items: center; font-variant-numeric: tabular-nums; }
#stage { position: relative; min-height: 0; touch-action: none; overflow: hidden; outline-offset: -3px; }
canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.label { position: absolute; top: 10px; width: 100%; text-align: center; font-size: 9px; letter-spacing: .17em; pointer-events: none; color: #9dbdd3; }
#veil { position: absolute; inset: 0; background: #101f36e8; display: grid; place-content: center; text-align: center; }
#veil[hidden] { display: none; }
footer { padding: 8px 12px max(12px, env(safe-area-inset-bottom)); background: #192c44; border-top: 1px solid #3c617a; }
#message { margin: 0 0 8px; font-size: 13px; min-height: 32px; }
.controls { display: flex; align-items: center; gap: 6px; }
.controls span { flex: 1; font-size: 10px; line-height: 1.5; }
button { min-height: 44px; min-width: 44px; padding: 8px; border: 1px solid #80b9cf; border-radius: 14px; background: #24445e; color: #e0f2fa; font: inherit; font-size: 12px; cursor: pointer; }
button:focus-visible, #stage:focus-visible { outline: 2px solid #ff9db3; }
@media (max-height: 450px) {
  body { grid-template-columns: 190px minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  header { flex-wrap: wrap; padding: 8px; } h1 { font-size: 18px; }
  #stage { grid-column: 2; grid-row: 1 / 3; } footer { padding: 8px; }
  .controls { flex-wrap: wrap; } .controls span { flex-basis: 100%; } .label { display: none; }
}
body[data-production] header { padding: 8px 10px; }
body[data-production] header > div { flex: 1; min-width: 0; }
body[data-production] h1 { font-size: clamp(16px, 4.4vw, 22px); }
.back { flex: 0 0 44px; height: 44px; display: grid; place-items: center; border: 1px solid #80b9cf; border-radius: 14px; text-decoration: none; color: #e0f2fa; }
#chapter { position: absolute; top: 8px; width: 100%; text-align: center; font-size: 11px; pointer-events: none; }
body[data-production] .controls { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px; }
#motion { grid-column: span 2; }
.storage { display: flex; align-items: center; gap: 5px; min-height: 30px; padding-top: 4px; }
#save-status { flex: 1; font-size: 10px; }
#save-retry { flex: 0 0 auto; }
dialog { width: min(340px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); overflow: auto; padding: 16px; border: 1px solid #80b9cf; border-radius: 20px; background: #192c44; color: #e0f2fa; }
dialog::backdrop { background: #071325aa; }
dialog h2 { font-size: 20px; margin: 0 0 8px; }
dialog p { font-size: 13px; line-height: 1.4; margin: 8px 0; }
#choir-preview { display: block; width: 100%; height: 115px; background: #101f36; border-radius: 14px; }
button[hidden] { display: none; }
#veil { gap: 6px; }
.back:focus-visible { outline: 2px solid #ff9db3; }
@media (max-height: 450px) {
  body[data-production] { grid-template-columns: 210px minmax(0, 1fr); }
  body[data-production] header { gap: 5px; padding: 6px 8px; }
  body[data-production] header > div { flex-basis: 130px; }
  body[data-production] header small { display: none; }
  body[data-production] .controls { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  body[data-production] #message { font-size: 11px; margin-bottom: 5px; min-height: 32px; }
  body[data-production] footer { padding: 4px 8px; }
  #choir-preview { height: 65px; }
  dialog { padding: 12px; }
}
