:root { --bg:#0a1420; --fg:#eef3f8; --mut:#9fb0c3; --g:#22e07a; --y:#ffd23f; --r:#ff4b4b; --b:#4fb3ff; --safe-t: env(safe-area-inset-top); --safe-b: env(safe-area-inset-bottom); }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg); font: 15px/1.35 -apple-system, system-ui, "Segoe UI", Roboto, sans-serif; overflow: hidden; overscroll-behavior: none; }
button { font: inherit; color: var(--fg); background: #1c2c40; border: 1px solid #2f4560; border-radius: 10px; padding: 8px 12px; }
button.on { background: #2f6db3; border-color: #4f8fd6; }
button.big { font-size: 17px; padding: 12px 18px; background: #2f6db3; width: 100%; margin-top: 8px; }
.iconbtn { font-size: 22px; padding: 2px 10px; background: transparent; border: 0; }
.hidden { display: none !important; }
.small { font-size: 12.5px; color: var(--mut); }
.mono { font-family: ui-monospace, Menlo, monospace; }
#top { position: fixed; top: 0; left: 0; right: 0; z-index: 20; display: flex; align-items: center; gap: 8px; padding: calc(6px + var(--safe-t)) 8px 6px; background: linear-gradient(#0a1420ee, #0a142000); }
#top .title { font-weight: 800; letter-spacing: .5px; flex: 1; }
#modeTag { font-weight: 600; font-size: 11px; margin-left: 8px; padding: 2px 6px; border-radius: 6px; background: #3a1d1d; color: #ffb4b4; }
#tabs button { padding: 6px 12px; margin-left: 2px; }
#stage { position: fixed; inset: 0; }
#cam { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: none; }
#view { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }
#hud { position: absolute; top: calc(50px + var(--safe-t)); left: 6px; right: 6px; z-index: 5; display: grid; grid-template-columns: repeat(4, 1fr); gap: 3px 8px; padding: 6px 8px; background: rgba(0,0,0,.5); border-radius: 12px; font: 600 12px/1.2 ui-monospace, Menlo, monospace; pointer-events: none; }
#hud .k { color: var(--mut); font-weight: 500; font-size: 9.5px; display: block; white-space: nowrap; overflow: hidden; }
#hud .warn { color: var(--r); }
#banner { position: absolute; top: calc(160px + var(--safe-t)); right: 8px; z-index: 6; max-width: 36vw; font-size: 12px; text-align: right; pointer-events: none; }
#banner div { background: rgba(0,0,0,.55); border-radius: 8px; padding: 4px 8px; margin-bottom: 4px; }
#banner .stall { background: #b00020; color: #fff; font-weight: 800; font-size: 15px; }
.center { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 24px; text-align: center; z-index: 8; }
.zoom { position: absolute; right: 8px; bottom: calc(180px + var(--safe-b)); z-index: 6; display: flex; flex-direction: column; gap: 6px; }
.zoom button { width: 44px; height: 40px; padding: 0; font-size: 18px; }
#list { position: absolute; left: 0; right: 0; bottom: 0; z-index: 7; max-height: 30vh; overflow: auto; background: rgba(6,12,20,.86); border-top: 1px solid #22344a; padding: 6px 10px calc(6px + var(--safe-b)); -webkit-overflow-scrolling: touch; }
#listHead { font-size: 12px; color: var(--mut); }
#listItems { list-style: none; margin: 4px 0 0; padding: 0; }
#listItems li { display: grid; grid-template-columns: 12px 1fr auto; gap: 8px; align-items: center; padding: 5px 0; border-bottom: 1px solid #16263a; font-size: 13px; }
#listItems .sw { width: 12px; height: 12px; border-radius: 50%; }
#listItems .sw.water { border-radius: 2px; transform: rotate(45deg); }
#listItems .sub { font-size: 11.5px; color: var(--mut); }
#listItems .r { text-align: right; font-family: ui-monospace, Menlo, monospace; font-size: 12px; }
#menu { position: fixed; z-index: 30; top: 0; left: 0; bottom: 0; width: min(92vw, 380px); overflow-y: auto; background: #0e1a28; border-right: 1px solid #22344a; padding: calc(8px + var(--safe-t)) 12px calc(20px + var(--safe-b)); -webkit-overflow-scrolling: touch; }
.menuhead { display: flex; justify-content: space-between; align-items: center; font-size: 18px; }
fieldset { border: 1px solid #22344a; border-radius: 12px; margin: 10px 0; padding: 8px 10px; }
legend { color: var(--mut); font-size: 12px; padding: 0 4px; }
#menu label { display: block; margin: 7px 0; }
#menu small { color: var(--mut); }
input[type=checkbox], input[type=radio] { transform: scale(1.25); margin-right: 8px; accent-color: #2f8fff; }
input, select { font: inherit; font-size: 16px; color: var(--fg); background: #15243a; border: 1px solid #2f4560; border-radius: 8px; padding: 5px 7px; }
select { width: 100%; }
#menu label select { width: auto; }
.num { width: 84px; } .num.w { width: 120px; } .code { width: 80px; text-transform: uppercase; }
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.7); display: flex; align-items: center; justify-content: center; padding: 16px; }
.card { background: #0e1a28; border: 1px solid #2f4560; border-radius: 16px; padding: 16px; max-width: 460px; width: 100%; max-height: 90vh; overflow: auto; }
.card h2 { margin: 0 0 8px; }
#scList button { display: block; width: 100%; text-align: left; margin: 6px 0; }
#resBody .score { font-size: 44px; font-weight: 800; }
#resBody ul { padding-left: 18px; }
#simctl { position: absolute; inset: 0; z-index: 6; pointer-events: none; }
#pad { pointer-events: auto; position: absolute; left: 14px; bottom: calc(30vh + 90px + var(--safe-b)); width: 130px; height: 130px; border-radius: 50%; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.25); touch-action: none; }
#knob { position: absolute; left: 45px; top: 45px; width: 40px; height: 40px; border-radius: 50%; background: rgba(255,255,255,.4); }
#thrWrap { pointer-events: auto; position: absolute; right: 14px; bottom: calc(30vh + 90px + var(--safe-b)); display: flex; flex-direction: column; align-items: center; font-size: 11px; }
#thr { writing-mode: vertical-lr; direction: rtl; width: 34px; height: 130px; }
#simBtns { pointer-events: auto; position: absolute; left: 6px; right: 6px; bottom: calc(30vh + 6px + var(--safe-b)); display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; }
#simBtns button { font-size: 11.5px; padding: 7px 4px; background: rgba(28,44,64,.85); }
#simBtns button.on { background: #2f6db3; }
body.sim .zoom { bottom: calc(30vh + 240px + var(--safe-b)); }
@media (orientation: landscape) {
  #list { left: auto; width: 42vw; max-height: 60vh; border-left: 1px solid #22344a; border-top-left-radius: 12px; }
  #hud { grid-template-columns: repeat(7, auto); right: auto; max-width: calc(100vw - 12px); }
  #banner { top: calc(110px + var(--safe-t)); }
  #simBtns { left: auto; right: calc(42vw + 8px); bottom: calc(8px + var(--safe-b)); width: 300px; }
  #pad { bottom: calc(8px + var(--safe-b)); }
  #thrWrap { right: calc(42vw + 316px); bottom: calc(8px + var(--safe-b)); }
  #thr { height: 100px; }
  .zoom, body.sim .zoom { bottom: auto; top: calc(110px + var(--safe-t)); right: calc(42vw + 8px); }
}
