* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #111e33; color: #f7e6c8; font: 14px system-ui; overscroll-behavior: none; }
main { height: 100dvh; max-width: 760px; margin: auto; padding: 10px; display: grid; grid-template-rows: auto minmax(0,1fr) auto; gap: 8px; }
header { position: relative; padding-right: 48px; }
small { font-size: 9px; letter-spacing: 1px; color: #a6c8db; }
h1 { font-size: clamp(20px,5vw,28px); margin: 4px 0; }
p { margin: 6px 0; }
#message { font-size: 12px; min-height: 30px; }
#clock { position: absolute; top: 24px; right: 0; font-size: 24px; color: #ffbe68; }
#stage { position: relative; min-height: 0; overflow: hidden; border: 1px solid #52657b; border-radius: 20px; background: radial-gradient(ellipse at top,#354560,#142239); }
canvas { display: block; width: 100%; height: 100%; touch-action: none; }
#silk, #banner { position: absolute; top: 8px; left: 0; right: 0; text-align: center; font-size: 11px; pointer-events: none; }
#banner { top: auto; bottom: 12px; color: #ffd48b; font-size: 18px; }
.controls { display: flex; gap: 6px; }
button { min-width: 44px; min-height: 44px; flex: 1; border: 0; border-radius: 12px; background: #c1dcdf; color: #152c42; font: 700 13px system-ui; touch-action: manipulation; }
button:focus-visible, canvas:focus-visible { outline: 3px solid #ffbe68; outline-offset: -3px; }
button:disabled { opacity: .5; }
#help { color: #b9cad9; font-size: 11px; line-height: 1.4; }
#count, #payoff { font-size: 12px; color: #ffcf7e; }
#payoff:empty { display: none; }
@media (orientation:landscape) {
  main { max-width: none; grid-template-columns: 164px minmax(0,1fr) 176px; grid-template-rows: minmax(0,1fr); }
  header, footer { align-self: center; } header { padding: 0; } #clock { position: static; }
  h1 { font-size: 23px; } .controls { flex-direction: column; }
}
@media (max-width:350px) { main { padding: 6px; gap: 4px; } small { display:none; } #help { font-size:10px; line-height:1.25; } }
.catalog { display:inline-flex; align-items:center; min-width:44px; min-height:44px; color:#ffd48b; }
:focus-visible { outline:3px solid #ffbe68; outline-offset:-3px; }
body[data-production] header small { display:block; }
body[data-production] .controls { flex-flow:row wrap; gap:4px; }
body[data-production] .controls button { flex:1 1 28%; font-size:12px; }
#storage { font-size:11px; }
dialog { max-width:min(360px,calc(100vw - 24px)); max-height:calc(100dvh - 24px); overflow:auto; border:1px solid #ffcf7e; border-radius:18px; background:#142239; color:#f7e6c8; }
dialog::backdrop { background:#071321b0; }
dialog button { display:block; width:100%; margin:8px 0; }
#fallback:not([hidden]) { position:fixed; inset:10%; z-index:10; overflow:auto; background:#142239; padding:20px; border:1px solid #ffcf7e; border-radius:18px; }
#fallback button { display:block; width:100%; margin-top:12px; }
@media (max-height:600px) and (orientation:portrait) {
  body[data-production] header .catalog { float:left; margin-right:8px; }
  body[data-production] header small { display:none; }
  body[data-production] #help { line-height:1.2; font-size:10px; }
}
