* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #14202b; font-family: system-ui, sans-serif; color: #1d2a1d; -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; }
#stage { position: fixed; inset: 0; }
#stage canvas { display: block; width: 100%; height: 100%; touch-action: none; }
#top { position: fixed; top: max(6px, env(safe-area-inset-top)); left: max(6px, env(safe-area-inset-left)); right: max(6px, env(safe-area-inset-right)); display: flex; flex-wrap: wrap; gap: 6px; pointer-events: none; z-index: 3; }
.chip { background: rgba(255,255,255,.92); padding: 5px 10px; border-radius: 10px; font-size: 16px; min-height: 34px; display: inline-flex; align-items: center; gap: 10px; white-space: nowrap; font-variant-numeric: tabular-nums; }
#bag { flex: 1 1 auto; justify-content: space-between; }
#cue { flex: 1 1 100%; font-weight: 600; background: rgba(255,248,214,.95); }
#quick { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 6px; }
#quick button { min-height: 48px; font-size: 14px; font-weight: 700; }
#bWeapon { background: #4a3f8a; }
#bFirst { background: #8a4a1a; }
#bFirst.gather { background: #2f6b3a; }
#cue.rest { background: #d8ecff; }
#cue.pause { background: #ffd3c9; }
#error[hidden] { display: none; }
#flyers { position: fixed; inset: 0; pointer-events: none; z-index: 4; }
.fly { position: absolute; left: 0; top: 0; padding: 2px 8px; border-radius: 10px; background: #ffe14a; color: #1d2a1d; font-size: 15px; font-weight: 700; white-space: nowrap; will-change: transform; }
#dock { position: fixed; left: max(6px, env(safe-area-inset-left)); right: max(6px, env(safe-area-inset-right)); bottom: max(6px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 6px; z-index: 3; }
#slots { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; pointer-events: none; }
.slot { background: rgba(255,255,255,.82); border-radius: 10px; padding: 3px 2px; text-align: center; font-size: clamp(12px, 3.4vw, 15px); min-height: 30px; overflow: hidden; display: flex; align-items: center; justify-content: center; border: 3px solid transparent; --p: 0%; background-image: linear-gradient(90deg, rgba(255,225,74,.85) var(--p), transparent var(--p)); }
.slot.on { border-color: #ffe14a; font-weight: 700; }
/* the choices stand behind the Settings button: three across, so they take three rows */
#panel { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
#bSettings { background: #3a4a5a; }
button { font: inherit; font-size: 17px; min-height: 52px; padding: 6px 8px; border: 0; border-radius: 10px; background: #2f6b3a; color: #fff; cursor: pointer; touch-action: manipulation; line-height: 1.15; }
button:active { background: #25552e; }
button.off { background: #6b5a3a; }
#bPause { background: #8a3a2a; }
#bPause.on { background: #2a5a8a; }
#error { position: fixed; left: 16px; right: 16px; bottom: 16px; background: #fff0f0; color: #7a1010; padding: 12px; border-radius: 10px; white-space: pre-wrap; font-size: 14px; z-index: 9; }
#clock { font-weight: 700; }
#over { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(10, 14, 10, .55); z-index: 8; }
#over[hidden] { display: none; }
#overCard { display: flex; flex-direction: column; gap: 12px; align-items: center; background: rgba(255, 255, 255, .95); border-radius: 14px; padding: 18px 22px; max-width: 80vw; }
#overText { font-size: 20px; font-weight: 700; color: #1d2a1d; text-align: center; }
#bRestart { min-width: 160px; }
#panel[hidden], #timing[hidden], #timing [hidden], #bSettings[hidden] { display: none; }
/* the Timing panel stands where the choices stood and is no taller */
#timing { display: flex; flex-direction: column; gap: 6px; }
.tunegrid { height: 102px; }
.tunegrid { display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; gap: 6px; }
.tunegrid label { display: flex; flex-direction: column; justify-content: center; min-width: 0; padding: 2px 8px; border-radius: 10px; background: rgba(255,255,255,.92); }
.tunegrid span { font-size: 13px; font-weight: 600; line-height: 16px; white-space: nowrap; overflow: hidden; }
.tunegrid input { width: 100%; height: 28px; margin: 0; accent-color: #2f6b3a; }
.tunetext { height: 86px; width: 100%; resize: none; padding: 1px 6px; border: 0; border-radius: 10px; font: 12px/14px ui-monospace, Consolas, monospace; color: #1d2a1d; background: #fff; -webkit-user-select: text; user-select: text; }
.tuneacts { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.tuneacts button { min-height: 48px; }
#timing output { order: 1; align-self: flex-end; margin-top: -6px; padding: 0 6px; font: 700 12px/16px system-ui, sans-serif; color: #2f6b3a; background: #fff; border-radius: 6px; }
.tuneacts { order: 2; }
#timing output:empty { display: none; }
@media (max-height: 700px) { #panel button { min-height: 48px; font-size: 15px; } }
