  :root { --fg: #f2f5f7; --dim: rgba(242,245,247,.62); --line: rgba(255,255,255,.22); --accent: #ffb35c; --ok: #7fe3a0; --bad: #ff6b5e; }
  * { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
  html, body { margin: 0; height: 100%; height: 100dvh; background: #05070a; overflow: hidden; overscroll-behavior: none; color: var(--fg);
    font: 14px/1.35 ui-sans-serif, system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif; user-select: none; -webkit-user-select: none; }
  canvas#c { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
  .hud { position: fixed; pointer-events: none; text-shadow: 0 1px 6px rgba(0,0,0,.65); }
  .mono { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
  #clock { top: max(14px, env(safe-area-inset-top)); left: max(16px, env(safe-area-inset-left)); }
  #clock .t { font-size: 30px; font-weight: 600; letter-spacing: .04em; }
  #clock .s { font-size: 11px; letter-spacing: .22em; color: var(--dim); margin-top: 2px; }
  #phase { top: max(14px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); text-align: center; white-space: nowrap; }
  #phase .p { font-size: 11px; letter-spacing: .28em; color: var(--dim); }
  #prompt { margin-top: 8px; display: inline-block; padding: 7px 14px; border: 1px solid var(--line); border-radius: 999px; background: rgba(5,8,12,.42);
    backdrop-filter: blur(6px); font-size: 12.5px; letter-spacing: .08em; }
  #prompt:empty { display: none; }
  #prompt b { color: var(--accent); font-weight: 600; }
  #prompt.alert { border-color: var(--accent); color: var(--accent); animation: pulse .7s ease-in-out infinite alternate; }
  @keyframes pulse { from { opacity: .55; } to { opacity: 1; } }
  #topright { top: max(14px, env(safe-area-inset-top)); right: max(16px, env(safe-area-inset-right)); text-align: right; font-size: 11px; letter-spacing: .16em; color: var(--dim); }
  #topright span { display: block; margin-bottom: 3px; }
  #telemetry { left: 0; right: 0; bottom: 0; padding: 30px max(18px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
    background: linear-gradient(to top, rgba(3,5,8,.72), rgba(3,5,8,0)); display: grid; grid-template-columns: 1fr auto 1fr; align-items: end; gap: 18px; }
  .gauge .v { font-size: 34px; font-weight: 600; line-height: 1; }
  .gauge .l { font-size: 10.5px; letter-spacing: .24em; color: var(--dim); margin-top: 5px; }
  .gauge .x { font-size: 11px; color: var(--dim); margin-top: 3px; letter-spacing: .06em; }
  #gR { text-align: right; }
  #mid { display: flex; align-items: flex-end; gap: 16px; }
  .bars { display: grid; gap: 6px; width: 190px; }
  .bar { display: grid; grid-template-columns: 62px 1fr; align-items: center; gap: 8px; font-size: 10px; letter-spacing: .16em; color: var(--dim); }
  .bar i { display: block; height: 5px; border-radius: 3px; background: rgba(255,255,255,.16); overflow: hidden; position: relative; }
  .bar i b { position: absolute; left: 0; top: 0; bottom: 0; width: 100%; background: var(--fg); transform-origin: left; }
  .bar.thr i b { background: var(--accent); }
  .bar .res { position: absolute; top: -2px; bottom: -2px; width: 1px; background: var(--accent); }
  #att { width: 64px; height: 64px; border: 1px solid var(--line); border-radius: 50%; position: relative; background: rgba(5,8,12,.35); }
  #att svg { position: absolute; inset: 0; }
  #caption { left: 50%; bottom: 118px; transform: translateX(-50%); max-width: min(720px, 86vw); text-align: center; font-size: 15px; padding: 7px 14px; border-radius: 8px;
    background: rgba(3,5,8,.5); backdrop-filter: blur(6px); opacity: 0; transition: opacity .25s; }
  #caption.on { opacity: 1; }
  #help { right: max(16px, env(safe-area-inset-right)); top: 70px; font-size: 11.5px; line-height: 1.75; color: var(--dim); text-align: right; }
  #help kbd { font: inherit; color: var(--fg); border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; margin-left: 6px; background: rgba(5,8,12,.4); }
  .overlay { position: fixed; inset: 0; display: grid; place-items: center; padding: 24px; background: radial-gradient(ellipse at 50% 40%, rgba(3,5,8,.25), rgba(3,5,8,.78)); z-index: 5; transition: opacity .6s; }
  .overlay.hide { opacity: 0; pointer-events: none; }
  .card { max-width: 620px; width: 100%; text-align: center; }
  .card h1 { font-size: clamp(34px, 7vw, 68px); font-weight: 200; letter-spacing: .28em; margin: 0 0 4px; padding-left: .28em; }
  .card h2 { font-size: 12px; font-weight: 400; letter-spacing: .42em; color: var(--dim); margin: 0 0 30px; padding-left: .42em; }
  .card p { color: var(--dim); margin: 0 auto 22px; max-width: 480px; }
  .btn { pointer-events: auto; cursor: pointer; font: inherit; color: #05070a; background: var(--fg); border: 0; border-radius: 999px; padding: 13px 34px; font-size: 13px; font-weight: 600; letter-spacing: .22em; }
  .btn:disabled { opacity: .45; cursor: default; }
  .btn.ghost { color: var(--fg); background: transparent; border: 1px solid var(--line); }
  .keys { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 22px; text-align: left; margin: 0 auto 28px; max-width: 470px; font-size: 12.5px; color: var(--dim); }
  .keys kbd { font: inherit; color: var(--fg); border: 1px solid var(--line); border-radius: 4px; padding: 0 6px; margin-right: 7px; }
  #loadbar { height: 2px; width: 220px; margin: 18px auto 0; background: rgba(255,255,255,.14); overflow: hidden; border-radius: 2px; }
  #loadbar b { display: block; height: 100%; width: 0; background: var(--fg); transition: width .3s; }
  #note { font-size: 10.5px; letter-spacing: .08em; color: rgba(242,245,247,.4); margin-top: 22px; }
  #result .big { font-size: clamp(26px, 5vw, 46px); font-weight: 200; letter-spacing: .2em; margin: 0 0 6px; padding-left: .2em; }
  #result .big.ok { color: var(--ok); } #result .big.bad { color: var(--bad); }
  #result table { margin: 20px auto 26px; border-collapse: collapse; font-size: 13px; }
  #result td { padding: 5px 14px; border-bottom: 1px solid rgba(255,255,255,.1); text-align: left; color: var(--dim); }
  #result td:last-child { text-align: right; color: var(--fg); }
  /* touch controls */
  body.intro .hud, body.intro #touch { opacity: 0; }
  .hud, #touch { transition: opacity .6s; }
  body.ended .hud, body.ended #touch { opacity: 0; }
  #touch { display: none; }
  body.touch #touch { display: block; }
  body.touch #help { display: none; }
  body.touch #telemetry { padding-bottom: calc(max(22px, env(safe-area-inset-bottom)) + 166px); }
  body.touch .gauge .l { letter-spacing: .12em; font-size: 9.5px; } body.touch .gauge .x { font-size: 10px; }
  body.touch #caption { bottom: calc(max(22px, env(safe-area-inset-bottom)) + 262px); font-size: 13px; }
  body.touch .gauge .v { font-size: 24px; }
  body.touch .bars { width: 130px; }
  body.touch #att { display: none; }
  #stick { position: fixed; left: max(18px, env(safe-area-inset-left)); bottom: max(22px, env(safe-area-inset-bottom)); width: 118px; height: 118px; border-radius: 50%; border: 1px solid var(--line); background: rgba(5,8,12,.3); touch-action: none; }
  #stick b { position: absolute; left: 50%; top: 50%; width: 46px; height: 46px; margin: -23px; border-radius: 50%; background: rgba(255,255,255,.55); }
  #thr { position: fixed; right: max(18px, env(safe-area-inset-right)); bottom: max(22px, env(safe-area-inset-bottom)); width: 46px; height: 150px; border-radius: 23px; border: 1px solid var(--line); background: rgba(5,8,12,.3); touch-action: none; overflow: hidden; }
  #thr b { position: absolute; left: 0; right: 0; bottom: 0; height: 0; background: rgba(255,179,92,.7); }
  #tcenter { position: fixed; left: calc(max(18px, env(safe-area-inset-left)) + 130px); right: calc(max(18px, env(safe-area-inset-right)) + 58px); bottom: max(22px, env(safe-area-inset-bottom)); display: grid; gap: 8px; max-width: 420px; margin: 0 auto; }
  #tbtns { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
  #tbtns button, #tmain { pointer-events: auto; font: inherit; font-size: 10.5px; letter-spacing: .12em; color: var(--fg); background: rgba(5,8,12,.38); border: 1px solid var(--line); border-radius: 10px; height: 38px; touch-action: manipulation; }
  #tmain { height: 46px; border-color: var(--accent); color: var(--accent); font-weight: 600; }
  .keys.t { display: none; grid-template-columns: 1fr; text-align: center; }
  body.touch .keys { display: none; } body.touch .keys.t { display: grid; }
  @media (max-width: 640px) { #topright, #phase .p { display: none; } #clock .t { font-size: 22px; } #phase { top: 52px; } #prompt { white-space: normal; max-width: 86vw; } }
  #help .pro, body.pro #help .easy { display: none; }
  body.pro #help .pro { display: inline; }
  .card p.fine { font-size: 12px; margin-top: -14px; }
  .card p.fine kbd { font: inherit; color: var(--fg); border: 1px solid var(--line); border-radius: 4px; padding: 0 6px; }
  body.touch .card p.fine { display: none; }
  body.touch:not(.pro) #stick, body.touch:not(.pro) #thr, body.touch:not(.pro) #tbtns button[data-k="KeyB"], body.touch:not(.pro) #tbtns button[data-k="KeyX"] { display: none; }
  body.touch:not(.pro) #tcenter { left: max(18px, env(safe-area-inset-left)); right: max(18px, env(safe-area-inset-right)); }
  body.touch:not(.pro) #telemetry { padding-bottom: calc(max(22px, env(safe-area-inset-bottom)) + 110px); }
  body.touch:not(.pro) #caption { bottom: calc(max(22px, env(safe-area-inset-bottom)) + 200px); }
  #wash { position: fixed; inset: 0; pointer-events: none; opacity: 0; }
  #wash.go { animation: wash 6s ease-out forwards; }
  @keyframes wash { 0% { opacity: 0; background: #ffb21e; } 6% { opacity: .95; background: radial-gradient(ellipse at 50% 45%, #ffd24a, #e07a05 60%, #5a2400); }
    35% { opacity: .95; background: radial-gradient(ellipse at 50% 30%, #9a8a1c, #55701f 60%, #23401c); } 70% { opacity: .9; background: radial-gradient(ellipse at 50% 30%, #6e7a22, #3f6426 60%, #1c3a1e); } 100% { opacity: 0; background: #2f5a2a; } }
  .steps { list-style: none; counter-reset: st; margin: 0 auto 18px; padding: 0; max-width: 460px; text-align: left; display: grid; gap: 9px; }
  .steps li { counter-increment: st; display: grid; grid-template-columns: 30px 1fr; column-gap: 12px; align-items: start; font-size: 13.5px; color: var(--dim); }
  .steps li::before { content: counter(st); grid-row: span 2; width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--accent); color: var(--accent); display: grid; place-items: center; font-weight: 600; font-size: 13px; }
  .steps li b { color: var(--fg); font-weight: 600; letter-spacing: .04em; }
  .steps kbd, #prompt kbd { font: inherit; font-weight: 600; color: var(--fg); border: 1px solid var(--line); border-radius: 5px; padding: 0 7px; background: rgba(255,255,255,.08); }
  .steps .t, body.touch .steps .k, body.touch .fine .k { display: none; }
  body.touch .steps .t { display: inline; }
  .card p.fine { margin-top: 0; display: block !important; }
  .card h2 { margin-bottom: 20px; }
  #prompt { font-size: 15px; padding: 10px 20px; letter-spacing: .03em; }
  #prompt i { font-style: normal; font-size: 10.5px; letter-spacing: .18em; color: var(--accent); margin-right: 10px; }
  #prompt kbd { border-color: var(--accent); color: var(--accent); }
  #prompt.alert { color: var(--fg); background: rgba(255,179,92,.22); }
  @media (max-width: 640px) { #prompt { font-size: 13.5px; padding: 8px 14px; } .steps li { font-size: 12.5px; } }
  /* broadcast-style telemetry bar */
  #telemetry { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: end; gap: 26px; padding: 46px max(22px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(22px, env(safe-area-inset-left));
    background: linear-gradient(to top, rgba(0,0,0,.86), rgba(0,0,0,.6) 55%, rgba(0,0,0,0)); }
  #hl { display: flex; align-items: center; gap: 14px; }
  #engines { width: 86px; height: 86px; }
  #engines .ring { fill: none; stroke: #fff; stroke-width: 2.4; }
  #engines circle.e { fill: rgba(255,255,255,.16); transition: fill .15s; }
  #engines circle.e.on { fill: #fff; }
  #att { width: 78px; height: 78px; border-color: rgba(255,255,255,.3); background: rgba(255,255,255,.06); }
  #hl .bars { width: 120px; gap: 8px; }
  #hl .bar { grid-template-columns: 1fr; gap: 3px; font-size: 9px; }
  #hc { text-align: center; padding-bottom: 2px; min-width: 0; }
  #hc .t { font-size: 34px; font-weight: 600; letter-spacing: .03em; line-height: 1.05; }
  #hc .s { font-size: 10.5px; letter-spacing: .24em; color: var(--dim); margin-top: 3px; }
  #hc .x { font-size: 10.5px; color: var(--dim); margin-top: 4px; letter-spacing: .05em; }
  #tl { position: relative; height: 2px; margin: 0 auto 26px; max-width: 620px; background: rgba(255,255,255,.28); border-radius: 2px; }
  #tlp { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: #fff; border-radius: 2px; }
  #tld { position: absolute; top: 50%; left: 0; width: 9px; height: 9px; margin: -4.5px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 3px rgba(255,255,255,.25); }
  #tl span { position: absolute; bottom: 9px; transform: translateX(-50%); font-size: 9.5px; font-weight: 600; letter-spacing: .12em; color: var(--dim); white-space: nowrap; }
  #tl span.lo { bottom: auto; top: 9px; }
  #tl span::after { content: ""; position: absolute; left: 50%; width: 5px; height: 5px; margin-left: -2.5px; border-radius: 50%; background: rgba(255,255,255,.55); bottom: -11.5px; }
  #tl span.lo::after { bottom: auto; top: -11.5px; }
  #tl span.done { color: var(--fg); }
  #hr { display: flex; gap: 14px; }
  .dial { position: relative; width: 104px; height: 104px; text-align: center; }
  .dial svg { position: absolute; inset: 0; transform: rotate(135deg); }
  .dial circle { fill: none; stroke-width: 3; stroke-linecap: round; stroke-dasharray: 207.3 276.5; }
  .dial .bg { stroke: rgba(255,255,255,.22); }
  .dial .fg { stroke: #fff; stroke-dashoffset: 207.3; transition: stroke-dashoffset .12s linear; }
  .dial .dl { position: absolute; left: 0; right: 0; top: 22px; font-size: 9.5px; font-weight: 600; letter-spacing: .12em; }
  .dial .dv { position: absolute; left: 0; right: 0; top: 36px; font-size: 27px; font-weight: 600; line-height: 1.1; }
  .dial .du { position: absolute; left: 0; right: 0; top: 70px; font-size: 9px; letter-spacing: .14em; color: var(--dim); }
  #caption { bottom: 176px; }
  body.touch #telemetry { gap: 10px; }
  body.touch #engines { width: 56px; height: 56px; } body.touch #hl .bars { display: none; }
  body.touch .dial { width: 74px; height: 74px; } body.touch .dial .dl { top: 14px; font-size: 7.5px; } body.touch .dial .dv { top: 25px; font-size: 18px; } body.touch .dial .du { top: 48px; font-size: 7px; }
  body.touch #hc .t { font-size: 20px; } body.touch #hc .x, body.touch #tl span { display: none; } body.touch #tl { margin-bottom: 10px; }
  @media (max-width: 760px) { #att, #hl .bars { display: none; } #tl span { font-size: 8px; letter-spacing: .04em; } #hc .t { font-size: 24px; } .dial { width: 84px; height: 84px; } .dial .dl { top: 16px; font-size: 8px; } .dial .dv { top: 28px; font-size: 21px; } .dial .du { top: 55px; } #engines { width: 64px; height: 64px; } }
  /* phone, assisted mode: one row of buttons, a slim telemetry strip above it */
  body.touch #hc .t { white-space: nowrap; font-size: 19px; } body.touch #hc .s { display: none; }
  body.touch #engines { width: 46px; height: 46px; } body.touch #att { display: none; }
  body.touch .dial { width: 64px; height: 64px; } body.touch .dial .dl { top: 11px; font-size: 7px; } body.touch .dial .dv { top: 21px; font-size: 16px; } body.touch .dial .du { top: 41px; font-size: 6.5px; }
  body.touch #hr { gap: 6px; } body.touch #tl { margin-bottom: 8px; }
  body.touch:not(.pro) #tcenter { left: max(12px, env(safe-area-inset-left)); right: max(12px, env(safe-area-inset-right)); grid-template-columns: 54px 1fr 54px 54px; gap: 8px; max-width: none; }
  body.touch:not(.pro) #tbtns { display: contents; }
  body.touch:not(.pro) #tbtns button, body.touch:not(.pro) #tmain { height: 48px; font-size: 9px; letter-spacing: .06em; padding: 0; }
  body.touch:not(.pro) #tmain { order: 2; font-size: 12px; letter-spacing: .12em; }
  body.touch:not(.pro) #tbtns button[data-k="KeyC"] { order: 1; } body.touch:not(.pro) #tbtns button[data-k="KeyT"] { order: 3; } body.touch:not(.pro) #tbtns button[data-k="KeyP"] { order: 4; }
  body.touch:not(.pro) #telemetry { padding: 26px 12px calc(max(22px, env(safe-area-inset-bottom)) + 58px); gap: 8px; }
  body.touch:not(.pro) #caption { bottom: calc(max(22px, env(safe-area-inset-bottom)) + 150px); }
  @media (max-width: 640px) { #phase { top: max(12px, env(safe-area-inset-top)); } }

/* on-screen problem report (errors, lost graphics context, restart after a crash) */
#diag{position:fixed;left:50%;top:max(10px,env(safe-area-inset-top));transform:translateX(-50%);z-index:60;max-width:min(92vw,560px);padding:8px 14px;border-radius:10px;
  background:rgba(20,10,6,.86);color:#ffd9b0;font:12px/1.4 ui-monospace,Menlo,monospace;border:1px solid rgba(255,170,90,.45);display:none;pointer-events:none;text-align:center}
#diag.on{display:block}
