* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; overscroll-behavior: none; }
body { background: #17182c; color: #fff0cc; font-family: system-ui, sans-serif; }
main { height: 100dvh; max-width: 1000px; margin: auto; display: grid; grid-template-rows: 62px minmax(0, 1fr) 76px; 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 { font-size: 19px; line-height: 1.1; margin: 0; }
#clock { font-size: 25px; font-variant-numeric: tabular-nums; }
#stage { position: relative; min-height: 0; overflow: hidden; border-radius: 24px; touch-action: none; background: #252740; }
canvas { display: block; width: 100%; height: 100%; touch-action: none; }
#message { position: absolute; z-index: 2; top: 10px; left: 12px; right: 12px; margin: 0; text-align: center; font-size: 12px; pointer-events: none; }
#upper, #lower { position: absolute; right: 14px; pointer-events: none; font-size: 11px; letter-spacing: 2px; opacity: .65; }
#upper { top: 24%; } #lower { bottom: 24%; }
#stage[data-face="1"] #upper, #stage[data-face="-1"] #lower { opacity: 1; color: #ffce63; text-shadow: 0 0 9px #ffcc55; }
footer p { font-size: 10px; line-height: 1.6; flex: 1; }
button { min-height: 46px; min-width: 56px; border: 1px solid #b5ae99; border-radius: 12px; background: #353855; color: inherit; cursor: pointer; }
:focus-visible { outline: 3px solid #ffce63; outline-offset: -3px; }
[hidden] { display: none !important; }
@media (orientation: landscape) and (max-height: 500px) {
 main { grid-template-columns: 190px 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%; }
}

body[data-production] { background: #171e30; color: #f9e8c3; }
body[data-production] main { grid-template-rows: 76px minmax(0, 1fr) 154px; gap: 6px; }
body[data-production] header { justify-content: initial; }
body[data-production] header a { display: grid; place-items: center; min-width: 44px; height: 44px; border: 1px solid #8c929e; border-radius: 50%; color: #f5dbac; text-decoration: none; font-size: 24px; }
body[data-production] header small { display: block; font: 7px system-ui; letter-spacing: 1.1px; color: #aeb9cc; margin-bottom: 5px; }
body[data-production] h1 { font: 25px/.95 Georgia, serif; }
body[data-production] #clock { margin-left: auto; color: #eac078; }
body[data-production] #stage { border: 1px solid #748294; background: radial-gradient(ellipse at 55% 30%, #586078, #232b40 75%); box-shadow: inset 0 0 50px #10182a; }
body[data-production] #message { font-size: 11px; line-height: 1.45; text-shadow: 0 1px 3px #101b2c; }
body[data-production] #upper, body[data-production] #lower { font-size: 9px; right: 10px; letter-spacing: 1px; }
body[data-production] footer { display: block; }
body[data-production] footer p { font-size: 10px; text-align: center; line-height: 1.55; margin: 0 0 7px; }
body[data-production] footer p span { color: #bdc5d3; font-size: 9px; }
nav { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
nav button { grid-column: span 2; } nav button:nth-last-child(-n+2) { grid-column: span 3; }
body[data-production] button { min-width: 44px; min-height: 44px; font: 600 12px system-ui; background: #303f55; border-color: #8391a4; }
body[data-production] button:hover { background: #43536b; }
body[data-production] button[aria-pressed="true"] { background: #665331; border-color: #dfbc7d; }
#veil, #graphics-error, #loading { position: absolute; inset: 0; z-index: 3; display: flex; flex-direction: column; gap: 8px; align-items: center; justify-content: center; text-align: center; background: #253047ed; padding: 10px; font-size: 13px; }
#veil button, #graphics-error button, #loading button { padding: 0 18px; }
#graphics-error { z-index: 5; } #loading { z-index: 6; }
.paper-mark { display: block; font: 36px Georgia, serif; color: #e9bf7e; }
#completion { position: absolute; bottom: 12px; left: 8px; right: 8px; pointer-events: none; text-align: center; text-shadow: 0 2px 4px #172338; }
#completion strong { display: block; font: 24px Georgia, serif; color: #ffdda1; } #completion span { font-size: 11px; }
dialog { max-width: min(350px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); padding: 20px; color: #fff0cf; background: #29374f; border: 1px solid #b6aa8a; border-radius: 20px; text-align: center; }
dialog::backdrop { background: #10192cc9; } dialog h2 { font: 27px Georgia, serif; margin: 6px 0; } dialog p { font-size: 13px; line-height: 1.5; }
dialog div { display: flex; gap: 8px; } dialog button { flex: 1; padding: 8px; }
@media (max-width: 340px) { body[data-production] h1 { font-size: 23px; } body[data-production] header small { font-size: 6px; letter-spacing: .5px; } body[data-production] main { padding-left: 8px; padding-right: 8px; } }
@media (orientation: landscape) and (max-height: 500px) {
 body[data-production] main { grid-template-columns: 220px minmax(0, 1fr); grid-template-rows: 82px minmax(0, 1fr); }
 body[data-production] header { flex-wrap: nowrap; gap: 8px; } body[data-production] h1 { font-size: 23px; } body[data-production] header small { font-size: 6px; letter-spacing: .5px; }
 body[data-production] footer { align-self: center; } body[data-production] #stage { grid-column: 2; grid-row: 1 / 3; }
}
