    * { margin: 0; padding: 0; box-sizing: border-box; }
    body { background: #000; color: #fff; overflow: hidden; font-family: 'Exo 2', sans-serif; }

    #bg-canvas {
      position: fixed; inset: 0; z-index: 0;
      width: 100%; height: 100%;
    }

    #fw-canvas {
      position: fixed; inset: 0; z-index: 21;
      width: 100%; height: 100%;
      pointer-events: none;
    }

    #vfx-canvas {
      position: fixed; inset: 0; z-index: 40;
      width: 100%; height: 100%;
      pointer-events: none;
    }

    /* ── Math equation ───────────────────────────────────────────────────────── */
    #math-wrap {
      position: fixed;
      top: 80px; left: 0; right: 0;
      height: 77vh;
      display: flex; align-items: center; justify-content: center;
      z-index: 1; pointer-events: none;
      font-size: clamp(2rem, 6vw, 6.5rem);
    }
    #math-display { color: #fff; }

    /* ── Answer zones ───────────────────────────────────────────────────────── */
    .answer-zone {
      position: fixed;
      top: 60%; transform: translateY(-50%) scale(1);
      padding: 1em 2em;
      border-radius: 999px;
      overflow: hidden;
      display: flex; align-items: center; justify-content: center;
      z-index: 2;
      cursor: pointer; user-select: none;
      transition: background 0.15s, box-shadow 0.15s, border-color 0.4s,
                  opacity 0.25s, transform 0.25s cubic-bezier(0.34,1.4,0.64,1);
    }
    .answer-zone.zones-hidden {
      opacity: 0; pointer-events: none;
      transform: translateY(-50%) scale(0.88);
    }

    /* Dwell fill — width driven by --fill (0→1) */
    .answer-zone::before {
      content: '';
      position: absolute; top: 0; left: 0; height: 100%;
      width: calc(var(--fill, 0) * 100%);
      border-radius: inherit;
      pointer-events: none;
    }
    #zone-false::before { background: rgba(220, 60, 60, 0.60); }
    #zone-true::before  { background: rgba(60, 210, 110, 0.60); }

    .zone-label {
      position: relative;
      font-family: 'Orbitron', sans-serif;
      font-size: clamp(1rem, 2vw, 1.6rem);
      font-weight: 700;
      letter-spacing: 0.1em;
    }
    #zone-false {
      left: 20px;
      background: rgba(220, 60, 60, 0.18);
      border: 3px solid rgba(220, 60, 60, 0.60);
    }
    #zone-true {
      right: 20px;
      background: rgba(60, 210, 110, 0.18);
      border: 3px solid rgba(60, 210, 110, 0.60);
    }
    .answer-zone.glow-false {
      background: rgba(220, 60, 60, 0.70);
      box-shadow: 0 0 80px rgba(220, 60, 60, 1), 0 0 160px rgba(220, 60, 60, 0.6);
    }
    .answer-zone.glow-true {
      background: rgba(60, 210, 110, 0.70);
      box-shadow: 0 0 80px rgba(60, 210, 110, 1), 0 0 160px rgba(60, 210, 110, 0.6);
    }
    /* In topic-select, zones float above the overlay (z-index 25) */
    .answer-zone.zone-ts-mode { z-index: 27; }

    /* ── HUD ────────────────────────────────────────────────────────────────── */
    #hud-row {
      position: fixed; top: 16px; left: 50%; transform: translateX(-50%);
      display: flex; align-items: center; gap: 10px;
      z-index: 8;
    }
    #hud {
      position: relative;
      display: flex; align-items: center; gap: 28px;
      background: rgba(0,0,0,0.50);
      border: 1px solid rgba(255,255,255,0.42);
      border-radius: 999px;
      padding: 10px 28px;
      white-space: nowrap; overflow: hidden;
    }
    #hud-timer-bar {
      position: absolute; top: 0; left: 0; height: 100%;
      width: calc(var(--timer, 1) * 100%);
      background: rgba(255,255,255,0.33);
      border-radius: inherit;
      pointer-events: none; z-index: 0;
    }
    #hud-timer-bar.danger { background: rgba(220,60,60,0.55); }
    #hud { font-family: 'Orbitron', sans-serif; }
    #lives-display, #score-display, #planet-display, #progress-display {
      position: relative; z-index: 1; font-size: 1.1rem;
    }
    #lives-display    { color: #f77; }
    #score-display    { color: #ff0; }
    #planet-display   { color: #adf; font-weight: 900; letter-spacing: 0.05em; }
    #progress-display { color: rgba(255,255,255,0.55); font-size: 0.85rem; }
    #hud-sep { color: rgba(255,255,255,0.2); position: relative; z-index: 1; }

    /* ── Result symbol — appears on the side that was triggered ────────────── */
    #result-overlay {
      position: fixed;
      top: 60%;
      transform: translateY(-50%) scale(0.4);
      z-index: 10; pointer-events: none;
      font-size: clamp(8rem, 28vw, 22rem);
      font-weight: 700;
      line-height: 1;
      opacity: 0;
      transition: opacity 0.12s, transform 0.12s;
    }
    #result-overlay.show   { opacity: 1; transform: translateY(-50%) scale(1); }
    #result-overlay.side-left  { left: 30px; right: auto; }
    #result-overlay.side-right { right: 30px; left: auto; }

    /* ── Screen flash on answer ─────────────────────────────────────────────── */
    #screen-flash {
      position: fixed; inset: 0;
      z-index: 9; pointer-events: none;
      opacity: 0;
    }
    @keyframes flash-anim  { 0% { opacity: 1; } 100% { opacity: 0; } }
    #screen-flash.flash-on { animation: flash-anim 0.55s ease-out forwards; }

    /* ── Score pop animation ────────────────────────────────────────────────── */
    @keyframes score-pop {
      0%   { transform: scale(1); }
      40%  { transform: scale(1.45); }
      70%  { transform: scale(0.95); }
      100% { transform: scale(1); }
    }
    .score-pop { animation: score-pop 0.38s cubic-bezier(0.34,1.4,0.64,1); }

    /* ── Level complete + Victory ───────────────────────────────────────────── */
    #levelup-overlay, #victory-overlay {
      position: fixed; inset: 0;
      display: flex; flex-direction: column;
      align-items: center; justify-content: center; gap: 16px;
      z-index: 20; opacity: 0; pointer-events: none;
      transition: opacity 0.5s;
    }
    #levelup-overlay.show, #victory-overlay.show { opacity: 1; pointer-events: auto; }
    #levelup-overlay { background: rgba(0,0,0,0.82); }
    #victory-overlay { background: rgba(10,4,0,0.92); }

    .overlay-title {
      font-family: 'Orbitron', sans-serif;
      font-size: clamp(2.5rem, 6vw, 5rem); font-weight: 900; letter-spacing: 0.06em;
    }
    .overlay-sub {
      font-family: 'Exo 2', sans-serif;
      font-size: clamp(1.4rem, 3vw, 2.4rem); font-weight: 600;
      color: rgba(255,255,255,0.80);
    }
    .overlay-next {
      font-family: 'Exo 2', sans-serif;
      font-size: clamp(1rem, 2vw, 1.4rem); color: rgba(255,255,255,0.38);
      letter-spacing: 0.1em; margin-top: 8px;
    }
    #levelup-planet { color: #ffd700; }
    #levelup-next   { color: #adf; font-weight: 700; }
    #victory-title  { color: #ffd700; }

    /* ── Game over ──────────────────────────────────────────────────────────── */
    #gameover-overlay {
      position: fixed; inset: 0;
      display: flex; flex-direction: column;
      align-items: center; justify-content: center; gap: 20px;
      background: rgba(0,0,0,0.92);
      z-index: 20; opacity: 0; pointer-events: none;
      transition: opacity 0.5s;
    }
    #gameover-overlay.show { opacity: 1; pointer-events: auto; }
    #gameover-msg   { font-family: 'Orbitron', sans-serif; font-size: clamp(2.5rem, 6vw, 5rem); font-weight: 900; color: #ff0; }
    #gameover-score { font-family: 'Orbitron', sans-serif; font-size: clamp(3rem, 8vw, 7rem); font-weight: 700; color: #fff; }
    #gameover-countdown { font-family: 'Exo 2', sans-serif; font-size: 1.1rem; color: rgba(255,255,255,0.4); letter-spacing: 0.1em; }

    /* ── Ready screen ───────────────────────────────────────────────────────── */
    #ready-overlay {
      position: fixed; inset: 0;
      display: flex; align-items: center; justify-content: center;
      z-index: 22; pointer-events: none;
      opacity: 0; transition: opacity 0.22s;
    }
    #ready-overlay.show { opacity: 1; }
    #ready-text {
      font-family: 'Orbitron', sans-serif;
      font-size: clamp(4rem, 14vw, 10rem); font-weight: 900; letter-spacing: 0.14em;
      color: #fff;
      text-shadow: 0 0 60px rgba(255,255,255,0.55), 0 0 120px rgba(100,200,255,0.35);
    }

    /* ── Webcam preview — bigger so kicks are visible ───────────────────────── */
    #cam-preview {
      position: fixed; bottom: 10px;
      left: 50%; transform: translateX(-50%);
      width: 304px;
      border: 1px solid rgba(255,255,255,0.22);
      border-radius: 8px; overflow: hidden;
      z-index: 5;
    }
    #cam-video {
      display: block; width: 100%; aspect-ratio: 4/3;
      transform: scaleX(-1);
    }
    #cam-canvas {
      position: absolute; top: 0; left: 0;
      width: 100%; height: 100%;
      transform: scaleX(-1);
      pointer-events: none;
    }
    #cam-status {
      position: absolute; bottom: 4px; left: 6px;
      font-size: 9px; color: rgba(255,255,255,0.55);
    }

    /* ── Multiplayer HUD switching ──────────────────────────────────────────── */
    .hud-2p { display: none; }
    #hud.mode-multi .hud-1p { display: none; }

    /* ── Team hearts block (right of camera, 2P) ────────────────────────────── */
    #team-status {
      position: fixed;
      bottom: 10px;
      left: calc(50vw + 168px);
      display: none; flex-direction: column; gap: 14px;
      z-index: 6; pointer-events: none;
    }
    body.mode-multi #team-status { display: flex; }

    .ts-row {
      display: flex; align-items: center; gap: 12px;
      opacity: 0.18;
      transition: opacity 0.3s, filter 0.3s;
    }
    .ts-row.sb-active { opacity: 1; }

    .ts-emoji { font-size: clamp(2rem, 3.5vw, 2.8rem); line-height: 1; }
    .ts-hearts { font-size: clamp(1.2rem, 2vw, 1.6rem); letter-spacing: 0.08em; }

    .hrt-full { color: #ff3355; }
    .hrt-gone { color: rgba(255,255,255,0.18); }

    /* ── In-position screen ─────────────────────────────────────────────────── */
    #inpos-overlay {
      position: fixed; inset: 0;
      display: flex; flex-direction: column;
      align-items: center; justify-content: flex-start;
      padding-top: 11vh; gap: 18px;
      z-index: 23; pointer-events: none;
      background: rgba(0,0,0,0.88);
      opacity: 0; transition: opacity 0.3s;
    }
    #inpos-overlay.show { opacity: 1; }
    #inpos-team {
      position: fixed; top: 11vh; left: 50%; transform: translateX(-50%);
      display: flex; flex-direction: column; align-items: center; gap: 6px;
      z-index: 27; pointer-events: none;
      opacity: 0; transition: opacity 0.3s;
    }
    #inpos-overlay.show + #inpos-team { opacity: 1; }
    #inpos-emoji {
      font-size: clamp(4rem, 10vw, 8rem); line-height: 1;
      filter: drop-shadow(0 0 24px var(--team-color, #fff));
    }
    #inpos-name {
      font-family: 'Orbitron', sans-serif;
      font-size: clamp(1.2rem, 3vw, 2.2rem); font-weight: 900; letter-spacing: 0.10em;
      color: var(--team-color, #fff);
      text-shadow: 0 0 30px var(--team-color, #fff);
    }

    /* ── Active team indicator (beside cam during gameplay, below cam during in-position) */
    #inpos-instruction {
      font-family: 'Exo 2', sans-serif;
      font-size: clamp(1rem, 2.5vw, 1.5rem); font-weight: 600;
      color: rgba(255,255,255,0.52); letter-spacing: 0.06em; text-align: center;
    }
    #inpos-hint {
      font-family: 'Exo 2', sans-serif;
      font-size: clamp(0.75rem, 1.5vw, 1rem);
      color: rgba(255,255,255,0.28); letter-spacing: 0.05em; text-align: center;
    }
    #inpos-status {
      font-family: 'Orbitron', sans-serif;
      font-size: clamp(1.1rem, 2.8vw, 2rem); font-weight: 700; letter-spacing: 0.12em;
      color: rgba(255,255,255,0.32); margin-top: 10px;
      transition: color 0.2s, font-size 0.25s;
    }
    #inpos-status.detected { color: #00ccff; font-size: clamp(3.5rem, 9vw, 7rem); }

    #inpos-redo {
      position: fixed; bottom: 8vh; left: 50%; transform: translateX(-50%);
      z-index: 27;
      font-family: 'Exo 2', sans-serif;
      font-size: 0.78rem; font-weight: 600; letter-spacing: 0.04em;
      background: rgba(0,0,0,0.50);
      border: 1px solid rgba(255,255,255,0.18);
      color: rgba(255,255,255,0.45);
      border-radius: 999px; padding: 8px 20px;
      cursor: pointer;
      opacity: 0; pointer-events: none;
      transition: background 0.15s, color 0.15s, border-color 0.15s, opacity 0.3s;
      display: none;
    }
    body.mode-multi #inpos-redo { display: block; }
    #inpos-overlay.show ~ #inpos-redo { opacity: 1; pointer-events: auto; }
    #inpos-redo:hover { background: rgba(255,200,60,0.12); border-color: rgba(255,200,60,0.40); color: rgba(255,210,80,0.90); }

    #cam-preview.inpos-mode {
      z-index: 26;
      width: min(68vw, 580px);
      bottom: auto;
      top: 57%;
      transform: translate(-50%, -50%);
      border-width: 2px;
      border-color: var(--inpos-border, rgba(255,255,255,0.5));
      box-shadow: 0 0 60px var(--inpos-border, rgba(255,255,255,0.18));
    }

    /* ── Turn banner ─────────────────────────────────────────────────────────── */
    #turn-banner {
      position: fixed; inset: 0;
      display: flex; flex-direction: column;
      align-items: center; justify-content: center;
      z-index: 25;
      background: rgba(0,0,0,0.80);
      opacity: 0; pointer-events: none;
      transition: opacity 0.28s;
    }
    #turn-banner.show { opacity: 1; }

    @keyframes banner-slide-in {
      from { opacity: 0; transform: translateY(-55px) scale(0.90); }
      to   { opacity: 1; transform: translateY(0)     scale(1); }
    }
    #turn-banner-content {
      display: flex; flex-direction: column;
      align-items: center; gap: 16px;
    }
    #turn-banner.show #turn-banner-content {
      animation: banner-slide-in 0.42s cubic-bezier(0.34,1.3,0.64,1) forwards;
    }
    #turn-banner-emoji {
      font-size: clamp(5rem, 16vw, 12rem);
      line-height: 1;
      filter: drop-shadow(0 0 32px var(--team-color, #fff));
    }
    #turn-banner-name {
      font-family: 'Orbitron', sans-serif;
      font-size: clamp(2rem, 6vw, 5rem);
      font-weight: 900; letter-spacing: 0.08em;
      color: var(--team-color, #fff);
      text-shadow: 0 0 40px var(--team-color, #fff);
    }
    #turn-banner-sub {
      font-family: 'Exo 2', sans-serif;
      font-size: clamp(1rem, 2.5vw, 2rem);
      font-weight: 600; letter-spacing: 0.12em;
      color: rgba(255,255,255,0.60);
    }
    #turn-banner-hearts { font-size: 1.8rem; letter-spacing: 0.12em; margin-top: 4px; }

    /* ── Gesture hints ──────────────────────────────────────────────────────── */

    /* ── Mode select screen ─────────────────────────────────────────────────── */
    #mode-select {
      position: fixed; inset: 0;
      display: flex; flex-direction: column;
      align-items: center; justify-content: center; gap: 48px;
      z-index: 30;
      background: rgba(0,0,0,0.75);
      backdrop-filter: blur(3px);
      transition: opacity 0.45s;
    }
    #mode-select.dismissed { opacity: 0; pointer-events: none; }

    .ko-feedback-link {
      font-size: 0.65rem;
      letter-spacing: 0.10em;
      text-transform: uppercase;
      color: rgba(255, 255, 255, 0.28);
      text-decoration: none;
      transition: color 0.2s ease;
    }
    .ko-feedback-link:hover { color: rgba(255, 255, 255, 0.65); }

    @keyframes ms-enter {
      from { opacity: 0; transform: translateY(28px) scale(0.96); }
      to   { opacity: 1; transform: translateY(0)    scale(1); }
    }
    .ms-title-wrap { text-align: center; line-height: 1.1;
      animation: ms-enter 0.55s 0.05s cubic-bezier(0.34,1.2,0.64,1) both; }
    #ms-1p { animation: ms-enter 0.50s 0.20s cubic-bezier(0.34,1.2,0.64,1) both; }
    #ms-2p { animation: ms-enter 0.50s 0.32s cubic-bezier(0.34,1.2,0.64,1) both; }
    #ms-hint { animation: ms-enter 0.45s 0.42s ease-out both; }
    .ms-eyebrow {
      font-family: 'Exo 2', sans-serif;
      font-size: clamp(0.85rem, 2vw, 1.4rem);
      font-weight: 600; letter-spacing: 0.35em;
      color: rgba(255,255,255,0.40);
      text-transform: uppercase; margin-bottom: 8px;
    }
    .ms-logo-math {
      font-family: 'Orbitron', sans-serif;
      font-size: clamp(3.5rem, 10vw, 8.5rem);
      font-weight: 900; letter-spacing: 0.06em;
      background: linear-gradient(135deg, #ffffff 0%, #ffd060 45%, #ff8800 100%);
      -webkit-background-clip: text; -webkit-text-fill-color: transparent;
      background-clip: text;
      filter: drop-shadow(0 0 28px rgba(255,190,40,0.45));
      line-height: 1;
    }
    .ms-logo-ko {
      font-family: 'Orbitron', sans-serif;
      font-size: clamp(1.6rem, 4vw, 3.2rem);
      font-weight: 700; letter-spacing: 0.22em;
      color: rgba(180,210,255,0.80);
      margin-top: 2px;
    }

    #ms-cards {
      display: flex; gap: 36px; align-items: stretch;
    }
    .ms-card {
      position: relative; overflow: hidden;
      display: flex; flex-direction: column;
      align-items: center; justify-content: center; gap: 16px;
      padding: 38px 56px; min-width: 230px;
      background: rgba(255,255,255,0.06);
      border: 2px solid rgba(255,255,255,0.14);
      border-radius: 24px;
      cursor: pointer; user-select: none;
      transition: background 0.2s, border-color 0.2s, transform 0.18s, box-shadow 0.2s;
    }
    /* Dwell fill bar — driven by --dwell (0→1) via gesture hold */
    .ms-card::after {
      content: '';
      position: absolute; bottom: 0; left: 0;
      height: 5px; width: calc(var(--dwell, 0) * 100%);
      border-radius: 0 0 22px 22px;
      pointer-events: none;
    }
    #ms-1p::after { background: linear-gradient(90deg, rgba(60,160,255,0.6), rgba(120,210,255,1)); }
    #ms-2p::after { background: linear-gradient(90deg, rgba(220,150,20,0.6), rgba(255,210,60,1)); }
    .ms-card:hover, .ms-card.hovered {
      background: rgba(255,255,255,0.12);
      transform: translateY(-5px) scale(1.03);
    }
    #ms-1p:hover, #ms-1p.hovered {
      border-color: rgba(80,190,255,0.75);
      box-shadow: 0 10px 48px rgba(40,140,255,0.28);
    }
    #ms-2p:hover, #ms-2p.hovered {
      border-color: rgba(255,200,60,0.75);
      box-shadow: 0 10px 48px rgba(255,150,20,0.28);
    }
    .ms-card-icon { font-size: clamp(2.8rem, 5.5vw, 4.5rem); line-height: 1; }
    .ms-card-label {
      font-family: 'Orbitron', sans-serif;
      font-size: clamp(1.1rem, 2.2vw, 1.8rem);
      font-weight: 900; letter-spacing: 0.08em; color: #fff;
    }
    .ms-card-sub {
      font-family: 'Exo 2', sans-serif;
      font-size: clamp(0.8rem, 1.4vw, 1rem);
      color: rgba(255,255,255,0.48); text-align: center; letter-spacing: 0.04em;
    }

    #ms-hint {
      font-family: 'Exo 2', sans-serif;
      font-size: clamp(0.7rem, 1.1vw, 0.9rem);
      color: rgba(255,255,255,0.26); letter-spacing: 0.08em; text-align: center;
    }

    /* ── Topic select screen ────────────────────────────────────────────────── */
    #topic-select {
      position: fixed; inset: 0;
      display: flex; flex-direction: column;
      align-items: center; justify-content: flex-start; gap: 8px;
      z-index: 25;
      background: rgba(0,0,0,0.82);
      backdrop-filter: blur(4px);
      opacity: 0; pointer-events: none;
      transition: opacity 0.4s;
      padding: 70px 24px 20px;
      overflow-y: auto;
    }
    #topic-select.visible { opacity: 1; pointer-events: auto; }

    @keyframes ts-enter {
      from { opacity: 0; transform: translateY(20px) scale(0.97); }
      to   { opacity: 1; transform: translateY(0)    scale(1); }
    }
    .ts-title {
      font-family: 'Orbitron', sans-serif;
      font-size: clamp(1.2rem, 2.4vw, 1.8rem);
      font-weight: 900; letter-spacing: 0.06em; color: #fff;
      margin: 0;
    }

    #ts-columns {
      display: flex; gap: 18px; align-items: flex-start;
      animation: ts-enter 0.5s 0.15s cubic-bezier(0.34,1.2,0.64,1) both;
    }

    .ts-group {
      background: rgba(255,255,255,0.05);
      border: 1px solid rgba(255,255,255,0.12);
      border-radius: 18px;
      padding: 14px 18px;
      min-width: 200px;
      display: flex; flex-direction: column; gap: 4px;
    }
    .ts-group-heading {
      font-family: 'Orbitron', sans-serif;
      font-size: clamp(0.7rem, 1.2vw, 0.9rem);
      font-weight: 700; letter-spacing: 0.25em;
      text-transform: uppercase;
      color: rgba(255,255,255,0.38);
      margin-bottom: 6px;
      border-bottom: 1px solid rgba(255,255,255,0.08);
      padding-bottom: 10px;
    }

    .ts-item {
      display: flex; align-items: center; gap: 10px;
      cursor: pointer; user-select: none;
      padding: 4px 8px; border-radius: 10px;
      transition: background 0.15s;
    }
    .ts-item:hover { background: rgba(255,255,255,0.07); }

    .ts-item input[type="checkbox"] {
      appearance: none; -webkit-appearance: none;
      width: 22px; height: 22px; flex-shrink: 0;
      border: 2px solid rgba(255,255,255,0.30);
      border-radius: 6px;
      background: transparent;
      cursor: pointer;
      position: relative;
      transition: border-color 0.15s, background 0.15s;
    }
    .ts-item input[type="checkbox"]:checked {
      background: rgba(60,210,110,0.85);
      border-color: rgba(60,210,110,1);
    }
    .ts-item input[type="checkbox"]:checked::after {
      content: '';
      position: absolute; top: 3px; left: 6px;
      width: 6px; height: 11px;
      border: 2px solid #000;
      border-top: none; border-left: none;
      transform: rotate(45deg);
    }

    .ts-label {
      font-family: 'Exo 2', sans-serif;
      font-size: clamp(0.85rem, 1.4vw, 1.05rem);
      font-weight: 600; color: rgba(255,255,255,0.88);
      display: flex; align-items: center; gap: 8px;
      flex-wrap: wrap;
    }
    .ts-sub {
      font-weight: 400; font-size: 0.8em;
      color: rgba(255,255,255,0.42);
    }
    .ts-badge {
      font-family: 'Exo 2', sans-serif;
      font-size: 0.68em; font-weight: 700;
      letter-spacing: 0.06em; text-transform: uppercase;
      background: rgba(255,160,40,0.18);
      border: 1px solid rgba(255,160,40,0.45);
      color: rgba(255,180,60,0.95);
      border-radius: 4px; padding: 1px 6px;
    }

    #ts-footer {
      display: flex; align-items: center; justify-content: space-between;
      width: 100%; max-width: 860px;
      animation: ts-enter 0.45s 0.05s ease-out both;
    }
    #ts-toggle {
      font-family: 'Exo 2', sans-serif;
      font-size: clamp(0.8rem, 1.2vw, 0.95rem);
      font-weight: 600; letter-spacing: 0.04em;
      background: transparent;
      border: 1px solid rgba(255,255,255,0.22);
      color: rgba(255,255,255,0.55);
      border-radius: 999px; padding: 10px 24px;
      cursor: pointer;
      transition: border-color 0.2s, color 0.2s;
    }
    #ts-toggle:hover { border-color: rgba(255,255,255,0.5); color: #fff; }

    #ts-start {
      font-family: 'Orbitron', sans-serif;
      font-size: clamp(1rem, 1.8vw, 1.4rem);
      font-weight: 900; letter-spacing: 0.08em;
      background: linear-gradient(135deg, #3cd26e 0%, #20a855 100%);
      border: none; color: #000;
      border-radius: 999px; padding: 14px 48px;
      cursor: pointer;
      box-shadow: 0 0 32px rgba(60,210,110,0.35);
      transition: transform 0.15s, box-shadow 0.15s, opacity 0.2s;
    }
    #ts-start:hover:not(:disabled) {
      transform: translateY(-3px) scale(1.03);
      box-shadow: 0 0 52px rgba(60,210,110,0.55);
    }
    #ts-start:disabled {
      opacity: 0.3; cursor: not-allowed;
      box-shadow: none;
    }

    #ts-empty-hint {
      font-family: 'Exo 2', sans-serif;
      font-size: clamp(0.7rem, 1vw, 0.85rem);
      color: rgba(255,100,100,0.7);
      letter-spacing: 0.05em;
      opacity: 0; transition: opacity 0.25s;
      pointer-events: none;
    }
    #ts-empty-hint.visible { opacity: 1; }

    /* ── Correction display ─────────────────────────────────────────────────── */
    #correction-display {
      position: absolute; top: 2rem; left: 0; right: 0;
      display: flex; align-items: center; justify-content: center; gap: 12px;
      opacity: 0;
      transform: translateY(8px);
      transition: opacity 0.35s ease, transform 0.35s ease;
      pointer-events: none;
    }
    #correction-display.visible {
      opacity: 1;
      transform: translateY(0);
    }
    #correction-label {
      font-family: 'Exo 2', sans-serif;
      font-size: clamp(0.85rem, 1.4vw, 1.1rem);
      font-weight: 700;
      letter-spacing: 0.06em;
      color: rgba(80, 220, 130, 0.85);
      white-space: nowrap;
    }
    #correction-eq {
      font-size: clamp(1.2rem, 2.5vw, 2.2rem);
      color: rgba(80, 220, 130, 0.95);
    }

    /* ── Detection zone shade ───────────────────────────────────────────────── */
    #zone-shade {
      position: fixed; inset: 0;
      pointer-events: none;
      z-index: 2;
      background: linear-gradient(to right,
        rgba(0,0,0,0.42) 0%,
        rgba(0,0,0,0.42) 14%,
        rgba(0,0,0,0.00) 19%,
        rgba(0,0,0,0.00) 81%,
        rgba(0,0,0,0.42) 86%,
        rgba(0,0,0,0.42) 100%
      );
      opacity: 0;
      transition: opacity 0.5s ease;
    }
    #zone-shade.active { opacity: 1; }

    /* ── Instructor bar (top-left: pause · home · gear) ────────────────────── */
    #instructor-bar {
      position: fixed; top: 14px; left: 20px;
      display: flex; gap: 8px; align-items: center;
      z-index: 35;
      opacity: 0; pointer-events: none;
      transition: opacity 0.3s;
    }
    #instructor-bar.active { opacity: 1; pointer-events: auto; }

    .ibar-btn {
      width: 44px; height: 44px;
      border-radius: 50%;
      border: 2px solid rgba(255,255,255,0.20);
      background: rgba(0,0,0,0.50);
      color: rgba(255,255,255,0.85);
      font-size: 1.2rem; line-height: 1;
      cursor: pointer;
      display: flex; align-items: center; justify-content: center;
      transition: background 0.2s, border-color 0.2s, transform 0.15s;
    }
    .ibar-btn:hover { background: rgba(0,0,0,0.72); border-color: rgba(255,255,255,0.40); transform: scale(1.05); }

    #pause-btn {
      opacity: 0; pointer-events: none;
      transition: background 0.2s, border-color 0.2s, transform 0.15s, opacity 0.3s;
    }
    #pause-btn.visible  { opacity: 1; pointer-events: auto; }
    #pause-btn.paused   { border-color: rgba(255,200,60,0.55); background: rgba(40,30,0,0.65); color: rgba(255,210,80,0.95); }

    #home-btn { border-color: rgba(255,255,255,0.20); background: rgba(0,0,0,0.50); }
    #home-btn:hover { background: rgba(0,0,0,0.72); border-color: rgba(255,255,255,0.40); }

    /* ── Gear panel ─────────────────────────────────────────────────────────── */
    #gear-panel {
      position: fixed; top: 70px; left: 20px;
      background: rgba(8,8,18,0.94);
      border: 1px solid rgba(255,255,255,0.14);
      border-radius: 14px;
      padding: 16px 18px;
      z-index: 34;
      display: none;
      min-width: 190px;
      backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
    }
    #gear-panel.open { display: flex; flex-direction: column; gap: 16px; }

    .gear-section { display: flex; flex-direction: column; gap: 8px; }
    .gear-label {
      font-family: 'Orbitron', sans-serif;
      font-size: 0.58rem; font-weight: 700; letter-spacing: 0.14em;
      color: rgba(255,255,255,0.28);
    }

    #skip-btn, #debug-toggle {
      font-family: 'Exo 2', sans-serif;
      font-size: 0.78rem; font-weight: 600;
      background: rgba(255,255,255,0.07);
      border: 1px solid rgba(255,255,255,0.14);
      color: rgba(255,255,255,0.70);
      border-radius: 8px; padding: 7px 14px;
      cursor: pointer; text-align: left; width: 100%;
      transition: background 0.15s, color 0.15s, border-color 0.15s;
    }
    #skip-btn:hover, #debug-toggle:hover { background: rgba(255,255,255,0.13); color: #fff; }
    #debug-toggle.on { color: rgba(255,255,100,0.9); border-color: rgba(255,255,100,0.35); background: rgba(255,255,0,0.07); }

    #debug-pill {
      display: none;
      position: fixed; bottom: 16px; right: 16px;
      z-index: 999;
      background: rgba(0,0,0,0.80);
      border: 1px solid rgba(255,255,100,0.25);
      border-radius: 10px;
      padding: 8px 12px 8px 12px;
      font-family: monospace; font-size: 11px; line-height: 1.7;
      color: rgba(255,255,160,0.85);
      pointer-events: auto;
      max-width: 280px;
    }
    #debug-pill b { color: rgba(255,255,255,0.5); font-weight: normal; }
    #debug-pill-close {
      float: right; margin-left: 10px;
      background: none; border: none;
      color: rgba(255,255,100,0.5); font-size: 11px;
      cursor: pointer; padding: 0 0 0 4px; line-height: 1;
    }
    #debug-pill-close:hover { color: rgba(255,255,100,1); }

    /* ── Timer dial (lives inside gear panel) ──────────────────────────────── */
    #timer-dial {
      display: flex; gap: 2px;
      background: rgba(0,0,0,0.40);
      border: 1px solid rgba(255,255,255,0.18);
      border-radius: 999px;
      padding: 3px;
    }
    .td-btn {
      font-family: 'Exo 2', sans-serif;
      font-size: 0.72rem; font-weight: 600; letter-spacing: 0.04em;
      background: transparent;
      border: none; color: rgba(255,255,255,0.45);
      border-radius: 999px; padding: 5px 13px;
      cursor: pointer;
      transition: background 0.15s, color 0.15s;
    }
    .td-btn:hover   { color: rgba(255,255,255,0.80); }
    .td-btn.td-active {
      background: rgba(255,255,255,0.18);
      color: #fff;
    }

    #redo-btn {
      font-family: 'Exo 2', sans-serif;
      font-size: 0.72rem; font-weight: 600; letter-spacing: 0.04em;
      background: rgba(0,0,0,0.40);
      border: 1px solid rgba(255,255,255,0.18);
      color: rgba(255,255,255,0.55);
      border-radius: 999px; padding: 10px 16px;
      cursor: pointer;
      opacity: 0; pointer-events: none;
      transition: background 0.15s, color 0.15s, border-color 0.15s, opacity 0.3s;
    }
    #redo-btn.active { opacity: 1; pointer-events: auto; }
    #redo-btn:hover {
      background: rgba(255,200,60,0.15);
      border-color: rgba(255,200,60,0.45);
      color: rgba(255,210,80,0.95);
    }

    /* ── In-game back link (SXR logo, top-right) ───────────────────────────── */
    #ko-back-link {
      position: fixed;
      top: 0.65rem;
      right: 0.75rem;
      z-index: 9990;
      opacity: 0;
      pointer-events: none;
      text-decoration: none;
      transition: opacity 0.3s ease;
    }
    #ko-back-link img {
      display: block;
      width: 2rem;
      height: 2rem;
      object-fit: contain;
      filter: brightness(0) invert(1);
      opacity: 0.35;
      transition: opacity 0.2s ease;
    }
    #ko-back-link:hover img { opacity: 0.75; }

