:root { --bg:#080b12; --ink:#e9eef6; --mute:#8d98a8; --line:#222a38; --acc:#f0b441; --card:#121826; --ok:#4cd694; --mid:#e9d34c; --warm:#f0a03c; --panel:#0d121d; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin:0; height:100%; background:var(--bg); color:var(--ink); font:16px/1.35 system-ui,-apple-system,"Segoe UI",Roboto,sans-serif; overscroll-behavior:none; touch-action:manipulation; }
#app { height:100vh; height:100dvh; display:flex; flex-direction:column; margin:0 auto; position:relative; max-width:100%; }
.hidden { display:none !important; }
.screen { flex:1; display:flex; flex-direction:column; align-items:center; justify-content:center; padding:24px 22px calc(24px + env(safe-area-inset-bottom)); text-align:center; gap:14px; max-width:560px; margin:0 auto; width:100%; }
.brand { font-weight:700; letter-spacing:.04em; color:var(--acc); font-size:15px; }
h1 { font-size:38px; line-height:1.08; margin:6px 0 0; font-weight:800; }
h2 { font-size:26px; margin:6px 0 4px; font-weight:800; }
.lead { color:var(--mute); margin:0 0 14px; max-width:30ch; font-size:17px; }
.small { color:var(--mute); font-size:14px; margin:6px 0 0; }
button, .btn { font:inherit; color:var(--ink); background:#1a2233; border:1px solid #2b3550; border-radius:14px; min-height:48px; padding:0 16px; display:inline-flex; align-items:center; justify-content:center; gap:6px; cursor:pointer; text-decoration:none; user-select:none; -webkit-user-select:none; font-weight:600; }
button:active, .btn:active { background:#243050; }
.big { background:var(--acc); color:#1a1405; border:0; font-size:26px; font-weight:800; min-height:76px; padding:0 44px; border-radius:22px; box-shadow:0 8px 30px rgba(240,180,65,.28); }
.big:active { background:#d99b2c; }
.big3 { background:var(--acc); color:#1a1405; border:0; font-size:20px; font-weight:800; min-height:56px; padding:0 32px; border-radius:18px; margin-top:12px; }
#menu { overflow-y:auto; justify-content:flex-start; -webkit-overflow-scrolling:touch; }
#cards { width:100%; display:flex; flex-direction:column; gap:12px; }
@media (min-width: 820px) { #menu { max-width:1180px; } #cards { display:grid; grid-template-columns:repeat(auto-fill, minmax(330px, 1fr)); gap:16px; align-items:start; } }
.card { width:100%; display:flex; flex-direction:column; gap:6px; text-align:left; padding:18px 18px 20px; background:var(--card); border:1px solid #2b3550; border-radius:20px; color:var(--ink); text-decoration:none; min-height:96px; }
.card:active { background:#1a2438; }
.card-t { font-size:22px; font-weight:800; }
.card-img { width:100%; height:auto; aspect-ratio:480 / 600; object-fit:cover; border-radius:14px; background:#05070c; display:block; margin-bottom:6px; }
.card-vt { color:var(--acc); font-size:14px; font-weight:600; line-height:1.3; }
.card-s { color:var(--mute); font-size:15px; }

/* ---- the play screen: phone = stage on top, a dock and a pull-up menu below; wide = stage left, menu right */
#play { flex:1; display:flex; flex-direction:column; min-height:0; }
header { display:flex; align-items:center; gap:8px; padding:calc(6px + env(safe-area-inset-top)) 10px 6px; }
#titlebox { flex:1; text-align:center; min-width:0; }
#title { font-weight:800; font-size:16px; }
#rule { color:var(--mute); font-size:12px; line-height:1.2; display:-webkit-box; -webkit-line-clamp:3; -webkit-box-orient:vertical; overflow:hidden; }
.btn.icon { width:48px; padding:0; }
#snd .off { display:none; } #snd[aria-pressed="true"] .on { display:none; } #snd[aria-pressed="true"] .off { display:inline; } #snd[aria-pressed="true"] { color:var(--mute); }
#stage { position:relative; flex:1; min-height:160px; }
#cv { position:absolute; inset:0; width:100%; height:100%; display:block; touch-action:none; cursor:crosshair; }
#toast { position:absolute; left:10px; right:10px; top:10px; background:rgba(18,24,38,.95); border:1px solid #2b3550; border-radius:14px; padding:12px 14px; font-size:15px; }
#toast.warn { border-color:var(--warm); }
#hint { position:absolute; left:50%; transform:translateX(-50%); bottom:44px; width:min(92%, 440px); text-align:center; background:rgba(240,180,65,.96); color:#1a1405; font-weight:700; font-size:16px; padding:10px 14px; border-radius:14px; box-shadow:0 6px 24px rgba(0,0,0,.4); pointer-events:none; }
#strainbox { position:absolute; left:50%; transform:translateX(-50%); top:64px; display:flex; align-items:center; gap:8px; font-size:14px; font-weight:700; color:#ffb48a; background:rgba(30,12,8,.8); padding:6px 12px; border-radius:12px; pointer-events:none; }
#strainbox i { display:inline-block; width:90px; height:8px; border-radius:5px; background:#3a1d12; overflow:hidden; } #strainbox u { display:block; height:100%; width:0; background:linear-gradient(90deg,#f0a03c,#ff4a2b); }
#end { position:absolute; inset:0; display:flex; align-items:center; justify-content:center; background:rgba(5,7,12,.55); }
.endcard { background:#10162a; border:1px solid #2b3550; border-radius:22px; padding:22px 24px; text-align:center; max-width:86%; }
#endtitle { font-size:26px; font-weight:800; } #endsub { color:var(--mute); margin-top:6px; }
#side { display:flex; flex-direction:column-reverse; background:var(--panel); border-top:1px solid var(--line); padding-bottom:env(safe-area-inset-bottom); }
#dock { display:flex; flex-wrap:wrap; align-items:center; gap:8px; padding:8px 10px; }
.big2 { flex:1 1 0; min-width:0; min-height:52px; font-size:17px; padding:0 6px; }
#pause[aria-pressed="true"] { background:var(--acc); color:#1a1405; }
#stats { flex:1 1 100%; order:5; display:flex; justify-content:space-between; gap:8px; color:var(--mute); font-size:14px; padding:0 2px; }
#menuBtn { margin-left:0; } #menuBtn[aria-expanded="true"] { background:#243050; border-color:var(--acc); }
.stat b { color:var(--ink); font-variant-numeric:tabular-nums; }
#bar { display:inline-block; width:44px; height:8px; border-radius:5px; background:#1b2333; margin-left:6px; vertical-align:middle; overflow:hidden; }
#barfill { display:block; height:100%; width:100%; background:var(--ok); border-radius:5px; transition:width .3s, background .3s; }
#panel { display:none; max-height:40dvh; overflow-y:auto; padding:6px 12px 14px; border-bottom:1px solid var(--line); overscroll-behavior:contain; touch-action:pan-y; }
#side.open #panel { display:block; }
#menuBtn.pulse { animation:pulse 1.1s ease-in-out 4; }
@keyframes pulse { 0%,100% { box-shadow:0 0 0 0 rgba(240,180,65,0); } 50% { box-shadow:0 0 0 8px rgba(240,180,65,.5); } }

.ctl { padding:8px 0 6px; border-bottom:1px solid #161d2b; }
.ctl .lr { display:flex; align-items:baseline; gap:8px; font-size:15px; } .ctl .lr .lb { font-weight:700; } .ctl .lr b { color:var(--acc); font-variant-numeric:tabular-nums; margin-left:auto; }
.ctl .vb { font-size:12px; color:var(--mute); min-height:0; padding:0 6px; border:1px solid #2b3550; border-radius:8px; background:transparent; font-weight:600; min-height:24px; }
.ctl .vb.same { color:var(--ok); border-color:#1f4a38; }
.rng { position:relative; }
input[type=range] { width:100%; height:44px; margin:0; background:transparent; accent-color:var(--acc); position:relative; z-index:1; }
input[type=range]::-webkit-slider-thumb { width:32px; height:32px; }
.vm { position:absolute; bottom:2px; width:2px; height:9px; background:var(--ok); transform:translateX(-1px); pointer-events:none; }
.sw { display:grid; grid-template-columns:repeat(6, 1fr); gap:8px; padding-top:6px; }
.sw button { min-height:36px; padding:0; border-radius:12px; border:2px solid transparent; font-size:13px; font-weight:800; color:#10121a; text-shadow:0 0 3px rgba(255,255,255,.6); }
.sw button[aria-pressed="true"] { border-color:#fff; box-shadow:0 0 0 2px rgba(0,0,0,.5) inset; }
.seg { display:flex; flex-wrap:wrap; gap:8px; padding-top:6px; } .seg button { flex:1 1 auto; min-width:64px; min-height:46px; } .seg button[aria-pressed="true"] { background:var(--acc); color:#1a1405; border-color:var(--acc); }
.wide { width:100%; margin-top:12px; min-height:52px; }

/* ---- the Lab: numbers, read-outs, a graph; monospace */
#labBtn[aria-pressed="true"] { background:#243050; border-color:var(--acc); color:var(--acc); }
#side.lab #panel { max-height:50dvh; }
#labbox { font:13px/1.4 ui-monospace,SFMono-Regular,Consolas,"Liberation Mono",monospace; padding-top:6px; }
.lab-h { font-weight:700; letter-spacing:.08em; color:var(--acc); } .lab-h span { color:var(--mute); font-weight:400; letter-spacing:0; margin-left:6px; }
.lab-h2 { margin-top:10px; color:var(--mute); font-size:12px; letter-spacing:.06em; }
#lab-read { display:grid; grid-template-columns:repeat(2, 1fr); gap:2px 14px; margin:6px 0; }
#lab-read div { display:flex; justify-content:space-between; border-bottom:1px dotted #222a38; padding:2px 0; } #lab-read b { color:var(--ink); font-weight:600; font-variant-numeric:tabular-nums; } #lab-read span { color:var(--mute); }
#lab-graph { margin:6px 0; border:1px solid #222a38; border-radius:8px; padding:4px 6px 2px; }
.lab-gt { display:flex; justify-content:space-between; align-items:center; color:var(--mute); font-size:12px; } .lab-b { min-height:26px; font:inherit; font-size:12px; padding:0 8px; border-radius:8px; background:transparent; } .lab-b[aria-pressed="true"] { color:var(--acc); border-color:var(--acc); }
#lab-cv { width:100%; height:112px; display:block; }
.lab-f { display:grid; grid-template-columns:minmax(0,1fr) 92px 64px; gap:6px; align-items:center; padding:4px 0; border-bottom:1px dotted #1a2130; }
.lab-f .nm { color:var(--ink); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; } .lab-f .rg { grid-column:1 / 4; color:var(--mute); font-size:11.5px; margin-top:-2px; }
.lab-f input { font:inherit; font-size:15px; color:var(--acc); background:#0a0f19; border:1px solid #2b3550; border-radius:8px; height:38px; padding:0 8px; text-align:right; width:100%; }
.lab-f input:focus { outline:2px solid var(--acc); outline-offset:0; } .lab-f input.clamped { border-color:var(--warm); }
.lab-f .un { color:var(--mute); font-size:12px; } .lab-f .vd { color:var(--ok); }
.lab-btns { display:flex; gap:8px; margin-top:10px; } .lab-btns .btn { flex:1; min-height:46px; font:inherit; font-size:14px; padding:0 6px; }
.lab-n { color:var(--mute); font-size:12px; margin-top:6px; min-height:16px; }

@media (min-width: 820px) and (min-height: 420px) {
  #play { display:grid; grid-template-columns:minmax(0,1fr) 360px; grid-template-rows:auto minmax(0,1fr); }
  header { grid-column:1 / 3; }
  #stage { grid-column:1; grid-row:2; }
  #side { grid-column:2; grid-row:2; border-top:0; border-left:1px solid var(--line); overflow:hidden; flex-direction:column; }
  #panel { display:block !important; max-height:none; flex:1; border-bottom:0; border-top:1px solid var(--line); }
  #menuBtn { display:none; }
  #app { max-width:1100px; }
  /* the Lab on a wide screen: a wider panel, the number fields in two columns, the read-outs in three, so the numbers are in reach without scrolling */
  #side.lab #panel { max-height:none; }
  #play.lab-on { grid-template-columns:minmax(0,1fr) 660px; }
  #app:has(#play.lab-on) { max-width:1500px; }
  #play.lab-on #lab-read { grid-template-columns:repeat(3, 1fr); }
  #play.lab-on #lab-fields { display:grid; grid-template-columns:1fr 1fr; gap:0 18px; }
  #play.lab-on .lab-f { grid-template-columns:minmax(0,1fr) 84px 44px; }
}
