  html, body { margin: 0; padding: 0; overflow: hidden; background: #111; font-family: 'Segoe UI', Arial, sans-serif; }
  canvas { display: block; }

  #blocker {
    position: absolute; inset: 0; background: rgba(0,0,0,0.78);
    display: flex; align-items: safe center; justify-content: center; z-index: 30; overflow-y: auto;
  }
  #instructions {
    color: #fff; text-align: center; max-width: 660px; padding: 22px 30px; margin: 20px;
    background: rgba(20,20,25,0.94); border-radius: 10px; border: 1px solid #444;
  }
  #instructions h1 { margin: 0 0 8px; font-size: 26px; color: #ffd24a; }
  #instructions #touch-note {
    color: #ffd24a; font-size: 14px; font-weight: bold; margin: 12px 0 4px;
    padding: 10px; border: 1px solid #ffd24a; border-radius: 6px;
  }
  #instructions p { line-height: 1.6; font-size: 12.5px; color: #ccc; margin: 6px 0; }
  #instructions .key { color: #ffd24a; font-weight: bold; }
  #instructions .start {
    font-size: 18px; margin-top: 14px; color: #ffd24a; cursor: pointer;
    border: 1px solid #ffd24a; border-radius: 6px; padding: 10px; transition: background 0.15s;
  }
  #instructions .start { background: rgba(255,210,74,0.10); font-weight: bold; }
  #instructions .start:hover { background: rgba(255,210,74,0.22); }

  /* the trickshot list: a popup over everything */
  #glossary-open, #stats-open, #ach-open { margin-top: 10px; }
  #ach-count { color: #ffd24a; }
  #glossary, #stats, #achievements, #settings-popup {
    position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,0.7);
    display: flex; align-items: center; justify-content: center; padding: 16px;
  }
  #glossary[hidden], #stats[hidden], #achievements[hidden], #settings-popup[hidden] { display: none; }
  #settings-popup .g-panel { width: min(780px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; }
  #settings-popup #settings { margin: 0; padding: 0; border-top: 0; }
  #settings-open { margin-top: 10px; }
  #howto { margin: 6px 0 0; text-align: center; }
  #howto summary { cursor: pointer; color: #9a9aa3; font-size: 12px; list-style: none; }
  #howto summary::before { content: "\25B8  "; }
  #howto[open] summary::before { content: "\25BE  "; }
  #howto summary:hover { color: #ffd24a; }

  .ach-row { display: grid; grid-template-columns: 22px 1fr auto; gap: 8px; align-items: start; padding: 4px 0; border-bottom: 1px solid #2a2a31; text-align: left; break-inside: avoid; }
  .ach-mark { width: 20px; height: 20px; border-radius: 50%; border: 1px solid #44444c; color: #15161a; font-weight: bold; text-align: center; line-height: 19px; font-size: 12px; }
  .ach-row.done .ach-mark { background: #ffd24a; border-color: #ffd24a; }
  .ach-row b { display: block; font-size: 13px; color: #8d8d96; }
  .ach-row.done b { color: #ffd24a; }
  .ach-row span { display: block; font-size: 12px; color: #9a9aa3; }
  .ach-row small { font-size: 11px; color: #8d8d96; }
  .ach-bar { display: block; height: 4px; background: #2a2a31; border-radius: 2px; margin: 3px 0 1px; overflow: hidden; }
  @media (min-width: 1200px) { #achievements .g-panel { width: min(1320px, 100%); } #ach-list { columns: 3 !important; } }
  .ach-bar i { display: block; height: 100%; background: #ffd24a; }
  #ach-toast {
    position: absolute; top: 78px; left: 50%; transform: translate(-50%, -20px); opacity: 0; pointer-events: none;
    background: rgba(20,20,25,0.92); border: 1px solid #ffd24a; border-radius: 8px; padding: 8px 18px; text-align: center;
    transition: opacity 0.3s, transform 0.3s; min-width: 240px;
  }
  #ach-toast.show { opacity: 1; transform: translate(-50%, 0); }
  #ach-toast small { display: block; font-size: 10px; letter-spacing: 1.5px; text-transform: uppercase; color: #ffd24a; }
  #ach-toast b { display: block; font-size: 17px; color: #ffd24a; }
  #ach-toast span { display: block; font-size: 12px; color: #c8c8ce; }
  .st-foot { text-align: right; margin-top: 12px; }
  .g-panel {
    width: min(760px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; color: #fff;
    background: rgba(20,20,25,0.97); border: 1px solid #444; border-radius: 10px; padding: 16px 22px 20px;
  }
  .g-head { display: flex; align-items: center; justify-content: space-between; }
  .g-head h2 { margin: 0; font-size: 18px; color: #ffd24a; text-transform: uppercase; letter-spacing: 1px; }
  .g-close { background: none; border: 0; color: #aaa; font-size: 28px; line-height: 1; cursor: pointer; padding: 0 4px; }
  .g-close:hover { color: #fff; }
  .g-panel .g-note { font-size: 12.5px; color: #9a9aa3; margin: 6px 0 4px; text-align: left; }
  .g-panel h3 { font-size: 11px; color: #8d8d96; text-transform: uppercase; letter-spacing: 1px; margin: 12px 0 4px; text-align: left; }
  .g-row { display: grid; grid-template-columns: 170px 128px 1fr; gap: 10px; font-size: 12.5px; padding: 3px 0; border-bottom: 1px solid #2a2a31; text-align: left; }
  .g-row .g-name { color: #ff9d3b; font-weight: bold; }
  .g-row .g-val { color: #ffd24a; font-variant-numeric: tabular-nums; }
  .g-row .g-how { color: #c8c8ce; }
  .g-row.pen .g-name, .g-row.pen .g-val { color: #ff5a4f; }
  @media (max-width: 560px) { .g-row { grid-template-columns: 1fr auto; } .g-row .g-how { grid-column: 1 / -1; } }
  /* wide screens: two columns, so the whole list fits without scrolling */
  @media (min-width: 1000px) {
    .g-panel { width: min(1240px, 100%); }
    #glossary-list, #stats-list, #ach-list { columns: 2; column-gap: 30px; }
    #glossary-list h3, #stats-list h3, #ach-list h3 { break-after: avoid; }
    .g-row { grid-template-columns: 140px 96px 1fr; break-inside: avoid; font-size: 12px; }
  }

  #settings { margin-top: 12px; padding-top: 12px; border-top: 1px solid #3a3a42; text-align: left; }
  #settings h2 { font-size: 12px; color: #ffd24a; margin: 0 0 8px; text-transform: uppercase; letter-spacing: 1px; }
  .slider-row { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; font-size: 12.5px; color: #ccc; }
  .slider-row label { width: 104px; flex-shrink: 0; }
  .slider-row input[type=range] { flex: 1; accent-color: #ffd24a; cursor: pointer; }
  .slider-row input:disabled { opacity: 0.35; }
  .slider-row .val { width: 44px; text-align: right; color: #ffd24a; font-weight: bold; font-variant-numeric: tabular-nums; }
  .check-row { font-size: 12.5px; color: #aaa; margin-top: 6px; }
  .check-row input { accent-color: #ffd24a; cursor: pointer; vertical-align: middle; margin-right: 4px; }
  .check-row label { cursor: pointer; margin-right: 14px; white-space: nowrap; }

  /* settings tabs */
  .settings-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
  .settings-head h2 { margin: 0 !important; }
  .stabs { display: flex; gap: 4px; }
  .stab {
    background: transparent; color: #aaa; border: 1px solid #3a3a42; border-radius: 5px;
    padding: 3px 10px; font: 12px 'Segoe UI', Arial, sans-serif; cursor: pointer;
  }
  .stab:hover { color: #fff; border-color: #666; }
  .stab.active { color: #111; background: #ffd24a; border-color: #ffd24a; font-weight: bold; }
  .spanel { min-height: 150px; }
  .slider-row select {
    flex: 1; background: #26262c; color: #eee; border: 1px solid #44444c; border-radius: 4px;
    padding: 3px 6px; font: 12.5px 'Segoe UI', Arial, sans-serif; cursor: pointer;
  }
  .slider-row input[type=color] { width: 44px; height: 24px; padding: 0; border: 1px solid #44444c; border-radius: 4px; background: none; cursor: pointer; }
  .swatches { display: flex; gap: 5px; flex: 1; }
  .swatches button { width: 18px; height: 18px; border-radius: 50%; border: 1px solid #555; cursor: pointer; padding: 0; }
  .xh-preview {
    height: 70px; margin-bottom: 10px; border-radius: 6px; border: 1px solid #3a3a42;
    background: linear-gradient(90deg, #87b7d9 0 33%, #b4e77f 33% 66%, #6e6e78 66%);
    display: flex; align-items: center; justify-content: space-around;
  }
  .tdot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: 0; }
  #settings-reset { margin: 16px 0 0; display: block; }
  .set-hint { font-size: 11.5px; color: #8d8d96; margin: 2px 0 0; }
  .sens-import { margin-top: 12px; padding-top: 10px; border-top: 1px solid #2f2f37; }
  .si-title { font-size: 12px; color: #ccc; margin-bottom: 6px; }
  .si-row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
  .si-row select, .si-row input { background: #15161a; color: #e8e8ea; border: 1px solid #44444c; border-radius: 5px; padding: 4px 6px; font: 12.5px 'Segoe UI', Arial, sans-serif; }
  .si-row select { flex: 1 1 180px; }
  .si-row input { width: 118px; }
  .si-row .btn.small { margin-left: 0; }
  #best-clear { margin: 14px 0 0; }

  /* controls tab: two columns of action + two input boxes */
  #bind-list { display: grid; grid-template-columns: 1fr 1fr; gap: 3px 22px; margin-top: 8px; }
  .bind-row { display: flex; align-items: center; gap: 5px; font-size: 12.5px; color: #ccc; }
  .bind-name { flex: 1; min-width: 0; }
  .bind-slot {
    width: 86px; padding: 3px 4px; background: #26262c; color: #eee; border: 1px solid #44444c; border-radius: 4px;
    font: 12px 'Segoe UI', Arial, sans-serif; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .bind-slot:hover { border-color: #888; }
  .bind-slot.empty { color: #666; }
  .bind-slot.listening { border-color: #ffd24a; color: #ffd24a; background: #33301f; }
  #bind-note { min-height: 16px; margin-top: 6px; color: #ffd24a; }
  #bind-reset { margin: 6px 0 0; }
  @media (max-width: 640px) { #bind-list { grid-template-columns: 1fr; } }

  /* the crosshair is an SVG drawn from the settings; colour comes from `color` */
  #crosshair { color: #eee; }
  #crosshair.hit { color: #ff3b3b !important; }
  #crosshair svg, .xh-preview svg { display: block; overflow: visible; }

  #hud { position: absolute; inset: 0; pointer-events: none; z-index: 10; display: none; }

  #crosshair {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    transition: opacity 0.1s;
  }

  #scope {
    position: absolute; top: 50%; left: 50%; width: 78vh; height: 78vh; border-radius: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 0 100vmax rgba(0,0,0,0.97), inset 0 0 70px rgba(0,0,0,0.85);
    border: 2px solid #000; opacity: 0; pointer-events: none;
  }
  /* lens edge: darkening toward the rim with a faint colour fringe, drawn over the reticle */
  #scope::after {
    content: ""; position: absolute; inset: 0; border-radius: 50%; pointer-events: none;
    background: radial-gradient(circle, transparent 58%, rgba(0,0,0,0.22) 80%, rgba(0,0,0,0.75) 100%);
    box-shadow: inset 0 0 6px 2px rgba(255,140,60,0.16), inset 0 0 16px 5px rgba(60,120,255,0.12);
  }
  /* muzzle glow seen through the lens when firing scoped */
  #scope-flash {
    position: absolute; inset: 0; border-radius: 50%; opacity: 0; pointer-events: none;
    background: radial-gradient(ellipse 70% 55% at 50% 95%, rgba(255,180,90,0.9), rgba(255,140,60,0.25) 55%, transparent 80%);
  }
  #scope-lines { position: absolute; inset: 0; opacity: 0; pointer-events: none; }
  #scope-lines .l { position: absolute; background: rgba(10,10,10,0.85); }
  #scope-lines .lv { left: 50%; top: 0; width: 1px; height: 100%; transform: translateX(-50%); }
  #scope-lines .lh { top: 50%; left: 0; height: 1px; width: 100%; transform: translateY(-50%); }
  /* thick outer posts that stop short of the centre */
  #scope-lines .post { position: absolute; background: #0a0a0a; }
  #scope-lines .pt, #scope-lines .pb { left: 50%; width: 6px; height: 32%; transform: translateX(-50%); }
  #scope-lines .pt { top: 0; }
  #scope-lines .pb { bottom: 0; }
  #scope-lines .pl, #scope-lines .pr { top: 50%; height: 6px; width: 32%; transform: translateY(-50%); }
  #scope-lines .pl { left: 0; }
  #scope-lines .pr { right: 0; }
  /* range ticks across the thin centre lines: long every other step, short in between */
  #scope-lines .mils { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); }
  #scope-lines .mh {
    width: 36%; height: 14px;
    background:
      linear-gradient(to right, transparent calc(50% - 1px), #0a0a0a calc(50% - 1px), #0a0a0a calc(50% + 1px), transparent calc(50% + 1px)) center / 22.222% 100% repeat-x,
      linear-gradient(to right, transparent calc(50% - 0.5px), #0a0a0a calc(50% - 0.5px), #0a0a0a calc(50% + 0.5px), transparent calc(50% + 0.5px)) center / 11.111% 50% repeat-x;
  }
  #scope-lines .mv {
    width: 14px; height: 36%;
    background:
      linear-gradient(to bottom, transparent calc(50% - 1px), #0a0a0a calc(50% - 1px), #0a0a0a calc(50% + 1px), transparent calc(50% + 1px)) center / 100% 22.222% repeat-y,
      linear-gradient(to bottom, transparent calc(50% - 0.5px), #0a0a0a calc(50% - 0.5px), #0a0a0a calc(50% + 0.5px), transparent calc(50% + 0.5px)) center / 50% 11.111% repeat-y;
  }
  #scope-lines .dot {
    position: absolute; top: 50%; left: 50%; width: 4px; height: 4px; border-radius: 50%;
    background: #e02424; box-shadow: 0 0 4px rgba(255,40,40,0.8); transform: translate(-50%, -50%);
  }

  /* speed lines that streak in when you're moving fast */
  #speedlines {
    position: absolute; inset: 0; opacity: 0; pointer-events: none;
    background: radial-gradient(ellipse at center,
      rgba(255,255,255,0) 42%, rgba(255,255,255,0.09) 70%, rgba(160,200,255,0.20) 100%);
  }

  #speed {
    position: absolute; bottom: 18px; left: 18px; color: #fff;
    font-size: 14px; background: rgba(0,0,0,0.4); padding: 6px 10px; border-radius: 6px;
  }
  #speed span { color: #ffd24a; font-weight: bold; }
  #speed .state { color: #7CFC00; font-size: 12px; }
  #speedbar {
    width: 150px; height: 4px; background: rgba(255,255,255,0.14);
    border-radius: 2px; margin-top: 5px; overflow: hidden;
  }
  #speedbar-fill { height: 100%; width: 0%; background: #ffd24a; transition: width 0.08s linear; }
  /* the grappling hook's cooldown: fills up, and glows when it's ready */
  #grapplebar {
    width: 150px; height: 3px; background: rgba(255,255,255,0.14);
    border-radius: 2px; margin-top: 4px; overflow: hidden;
  }
  #grapplebar-fill { height: 100%; width: 100%; background: #ffd24a; }
  #grapplebar-fill.cooling { background: rgba(255,255,255,0.45); }
  /* deathmatch health: a fuller bar than the others, with the number on it */
  #hpbar { position: relative; width: 150px; height: 12px; background: rgba(255,255,255,0.14); border-radius: 3px; margin-top: 6px; overflow: hidden; }
  #hpbar[hidden] { display: none; }
  #hpbar-fill { height: 100%; width: 100%; background: #3ddc84; transition: width 0.15s linear; }
  #hpbar-text { position: absolute; inset: 0; text-align: center; font-size: 10px; line-height: 12px; font-weight: bold; color: #fff !important; text-shadow: 0 0 3px #000; }
  /* damage you deal: numbers floating up from the player you hit */
  #dmg-numbers { position: fixed; inset: 0; pointer-events: none; z-index: 5; overflow: hidden; }
  #dmg-numbers span { position: fixed; transform: translate(-50%, -50%); font: bold 20px 'Segoe UI', Arial, sans-serif; color: #fff;
    text-shadow: 0 0 4px #000, 0 1px 3px #000; white-space: nowrap; }
  #dmg-numbers span.head { color: #ffd24a; font-size: 27px; }
  #dmg-numbers span.kill { color: #ff5a4f; font-size: 30px; }
  /* getting hit: a red edge flash and an arrow toward the shooter */
  #dmg-flash { position: fixed; inset: 0; pointer-events: none; opacity: 0; z-index: 4;
    background: radial-gradient(ellipse at center, rgba(255,0,0,0) 45%, rgba(255,0,0,0.85) 100%); }
  #dmg-dir { position: fixed; left: 50%; top: 50%; width: 0; height: 0; pointer-events: none; opacity: 0; z-index: 4; }
  #dmg-dir i { position: absolute; left: -18px; top: -150px; width: 36px; height: 20px; background: rgba(255,60,60,0.9);
    clip-path: polygon(50% 0, 100% 100%, 0 100%); }

  /* top right: score, best trickshot, streak, then the multipliers of the last hit */
  #hud-right {
    position: absolute; top: 18px; right: 18px; display: flex; flex-direction: column;
    align-items: flex-end; gap: 8px;
  }
  #score {
    color: #fff; text-align: right;
    font-size: 14px; background: rgba(0,0,0,0.4); padding: 6px 10px; border-radius: 6px;
  }
  #score span { color: #ffd24a; font-weight: bold; font-size: 20px; }

  #best {
    color: #fff; text-align: right; font-size: 12px; background: rgba(0,0,0,0.4);
    padding: 6px 10px; border-radius: 6px; border: 1px solid rgba(255,210,74,0.35); max-width: 220px;
  }
  #best[hidden] { display: none; }
  #best span { color: #ffd24a; font-weight: bold; font-size: 17px; }
  #best-tags { color: #ff9d3b; font-size: 11px; font-weight: bold; line-height: 1.45; margin-top: 2px; }
  #best-tags .mult { color: #ffd24a; }
  #best.new { animation: best-new 1.2s ease-out; }
  @keyframes best-new {
    0% { box-shadow: 0 0 0 0 rgba(255,210,74,0.9); background: rgba(255,210,74,0.35); }
    100% { box-shadow: 0 0 0 10px rgba(255,210,74,0); background: rgba(0,0,0,0.4); }
  }

  #streak {
    color: #fff; text-align: right;
    font-size: 14px; background: rgba(0,0,0,0.4); padding: 6px 10px; border-radius: 6px;
  }
  #streak span { color: #7CFC00; font-weight: bold; font-size: 18px; }

  #bonus-tags {
    color: #ff9d3b; text-align: right;
    font-size: 13px; font-weight: bold; background: rgba(0,0,0,0.35); padding: 5px 10px;
    border-radius: 6px; opacity: 0; transition: opacity 0.6s; max-width: 320px; line-height: 1.55;
  }
  #bonus-tags .mult { color: #ffd24a; font-size: 15px; }
  /* penalties, and a multiplier dragged under 1 */
  #bonus-tags .pen, #best-tags .pen, #bonus-tags .mult.low, #best-tags .mult.low { color: #ff5a4f; }
  #bonus-tags.show { opacity: 1; transition: opacity 0.15s; }

  #feed {
    position: absolute; top: 38%; left: 50%; transform: translate(-50%, -50%);
    font-size: 30px; font-weight: bold; color: #ffd24a; text-shadow: 0 0 12px rgba(255,210,74,0.8);
    opacity: 0; transition: opacity 0.15s, transform 0.15s; white-space: nowrap;
  }
  #feed { transition: opacity 0.5s, transform 0.15s; }
  #feed.show { opacity: 1; transform: translate(-50%, -62%); transition: opacity 0.12s, transform 0.15s; }

  #ammo {
    position: absolute; bottom: 178px; right: 18px; text-align: right;
    background: rgba(0,0,0,0.42); padding: 6px 12px; border-radius: 6px;
  }
  #ammo .count { font-size: 26px; font-weight: bold; color: #fff; line-height: 1; font-variant-numeric: tabular-nums; }
  #ammo .count .max { font-size: 15px; color: #888; }
  #ammo .count.low { color: #ff6b3b; }
  #ammo .label { font-size: 10px; color: #888; letter-spacing: 1.5px; margin-top: 2px; }
  #ammo .label.reloading { color: #ffd24a; }

  /* loadout stack, bottom right: gun on top, knife below, each in its own box */
  #hotbar { position: absolute; bottom: 16px; right: 18px; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
  .slot {
    width: 170px; padding: 5px 10px 6px; border-radius: 8px; box-sizing: border-box;
    background: rgba(0,0,0,0.45); border: 2px solid rgba(255,255,255,0.15);
    color: #8b8b90; transition: all 0.12s;
  }
  .slot .head { display: flex; justify-content: space-between; align-items: baseline; }
  .slot .num { font-size: 11px; opacity: 0.65; }
  .slot .name { font-size: 12px; font-weight: bold; letter-spacing: 0.8px; }
  .slot .icon { height: 34px; margin-top: 2px; }
  .slot .icon svg { height: 100%; width: auto; display: block; margin: 0 auto; }
  .slot.active { background: rgba(255,210,74,0.16); border-color: #ffd24a; color: #fff; }
  .slot.active .name { color: #ffd24a; }

  /* loadout picker in the menu */
  #loadout { display: flex; align-items: center; gap: 8px; margin: 12px 0 2px; flex-wrap: wrap; justify-content: center; }
  #loadout .lo-label { font-size: 12px; color: #ffd24a; font-weight: bold; text-transform: uppercase; letter-spacing: 1px; margin-right: 4px; }
  #loadout button {
    width: 98px; padding: 5px 6px 4px; border-radius: 6px; cursor: pointer;
    background: rgba(255,255,255,0.04); border: 1px solid #44444c; color: #aaa; font: bold 11px 'Segoe UI', Arial, sans-serif; letter-spacing: 0.6px;
  }
  #loadout button svg { height: 22px; width: auto; display: block; margin: 0 auto 2px; }
  #loadout button:hover { border-color: #888; color: #fff; }
  #loadout button.active { border-color: #ffd24a; color: #ffd24a; background: rgba(255,210,74,0.12); }

  /* ---------------- free play / score attack ---------------- */
  #play-modes { display: flex; align-items: center; gap: 8px; margin: 14px 0 2px; flex-wrap: wrap; justify-content: center; }
  #play-modes .lo-label { font-size: 12px; color: #ffd24a; font-weight: bold; text-transform: uppercase; letter-spacing: 1px; margin-right: 4px; }
  #play-modes button {
    padding: 6px 12px; border-radius: 6px; cursor: pointer; background: rgba(255,255,255,0.04); border: 1px solid #44444c;
    color: #aaa; font: bold 12px 'Segoe UI', Arial, sans-serif; letter-spacing: 0.4px;
  }
  #play-modes button:hover { border-color: #888; color: #fff; }
  #play-modes button.active { border-color: #ffd24a; color: #ffd24a; background: rgba(255,210,74,0.12); }
  #mode-note { min-height: 18px; margin: 4px 0 0 !important; font-size: 12.5px; color: #9a9aa3 !important; }
  #run-quit { margin: 10px 0 0 8px; }
  #mp-timer.low #mp-timer-val { color: #ff5a4f; }
  #run-count {
    position: absolute; top: 34%; left: 50%; transform: translate(-50%, -50%); font: bold 84px 'Segoe UI', Arial, sans-serif;
    color: #fff; text-shadow: 0 0 24px rgba(0,0,0,0.6); pointer-events: none; opacity: 0;
  }
  #run-count.pop { animation: run-pop 0.9s ease-out forwards; }
  @keyframes run-pop { 0% { opacity: 1; transform: translate(-50%, -50%) scale(1.25); } 70% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -50%) scale(1); } }
  #results {
    position: fixed; inset: 0; z-index: 70; background: rgba(0,0,0,0.72);
    display: flex; align-items: center; justify-content: center; padding: 16px;
  }
  #results[hidden] { display: none; }
  .r-panel {
    width: min(720px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; color: #fff; text-align: center;
    background: rgba(20,20,25,0.97); border: 1px solid #444; border-radius: 10px; padding: 20px 26px 22px;
  }
  .r-title { font-size: 13px; letter-spacing: 3px; text-transform: uppercase; color: #9a9aa3; }
  .r-score { font-size: 54px; font-weight: bold; color: #ffd24a; line-height: 1.1; font-variant-numeric: tabular-nums; }
  .r-rank { min-height: 22px; font-weight: bold; color: #ffd24a; }
  .r-stats { display: flex; justify-content: center; gap: 22px; margin: 8px 0 4px; color: #c8c8ce; font-size: 13.5px; flex-wrap: wrap; }
  .r-stats b { color: #fff; font-size: 16px; display: block; }
  .r-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 12px; text-align: left; }
  .r-cols h3 { font-size: 11px; color: #8d8d96; text-transform: uppercase; letter-spacing: 1px; margin: 0 0 6px; }
  #r-best { color: #ff9d3b; font-size: 12.5px; font-weight: bold; line-height: 1.5; }
  #r-best .mult { color: #ffd24a; font-size: 15px; }
  #r-best .pen { color: #ff5a4f; }
  #r-best .none { color: #8d8d96; font-weight: normal; }
  #r-top { margin: 0; padding-left: 22px; font-size: 13px; color: #c8c8ce; line-height: 1.7; }
  #r-top li.me { color: #ffd24a; font-weight: bold; }
  #r-top small { color: #8d8d96; }
  .r-buttons { display: flex; gap: 10px; justify-content: center; margin-top: 18px; flex-wrap: wrap; }
  .r-again {
    padding: 10px 22px; font: bold 15px 'Segoe UI', Arial, sans-serif; background: transparent; color: #ffd24a;
    border: 2px solid #ffd24a; border-radius: 8px; cursor: pointer;
  }
  .r-again:hover { background: rgba(255,210,74,0.12); }
  @media (max-width: 560px) { .r-cols { grid-template-columns: 1fr; } }

  /* ---------------- tutorial ---------------- */
  #tutorial-btn { margin-top: 10px; }
  #tutorial-btn.glow { border-color: #ffd24a; color: #ffd24a; box-shadow: 0 0 12px rgba(255,210,74,0.35); }
  #tutorial {
    position: absolute; top: 70px; left: 50%; transform: translateX(-50%); width: min(520px, calc(100% - 32px));
    background: rgba(15,15,20,0.85); border: 1px solid #44444c; border-radius: 10px; padding: 10px 16px 12px; text-align: center;
    transition: border-color 0.2s;
  }
  #tutorial[hidden] { display: none; }
  #tutorial.done { border-color: #ffd24a; }
  .tut-head { display: flex; justify-content: space-between; font-size: 11px; color: #8d8d96; text-transform: uppercase; letter-spacing: 1px; }
  .tut-skip { text-transform: none; letter-spacing: 0; }
  .tut-title { font-size: 19px; font-weight: bold; color: #ffd24a; margin-top: 2px; }
  #tutorial.done .tut-title::before { content: "\2713  "; color: #ffd24a; }
  .tut-text { font-size: 13.5px; color: #e8e8ea; margin-top: 2px; }
  .tut-track { height: 4px; background: #2f2f37; border-radius: 2px; margin-top: 8px; overflow: hidden; }
  #tut-fill { height: 100%; width: 0; background: #ffd24a; transition: width 0.4s; }

  /* ---------------- replays ---------------- */
  #resume { position: fixed; inset: 0; z-index: 64; display: flex; align-items: center; justify-content: center; cursor: pointer; }
  #resume[hidden] { display: none; }
  #resume div { background: rgba(15,15,20,0.88); border: 1px solid #ffd24a; color: #ffd24a; font: bold 18px 'Segoe UI', Arial, sans-serif;
    padding: 14px 26px; border-radius: 10px; text-align: center; }
  #resume small { display: block; color: #9a9aa3; font-weight: normal; font-size: 12px; margin-top: 2px; }
  #watch-row { margin-top: 8px; display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
  #hud.replaying > *:not(#scope) { display: none !important; }
  #replay { position: fixed; inset: 0; z-index: 65; pointer-events: none; color: #fff; }
  #replay[hidden] { display: none; }
  .rp-top { position: absolute; top: 16px; left: 18px; font-size: 14px; text-shadow: 0 1px 3px rgba(0,0,0,0.8); }
  .rp-badge { background: #e02424; color: #fff; font-weight: bold; font-size: 11px; letter-spacing: 1.5px; text-transform: uppercase; padding: 2px 8px; border-radius: 4px; margin-right: 6px; }
  #replay-tags { position: absolute; top: 16px; right: 18px; text-align: right; font-weight: bold; color: #ff9d3b; font-size: 14px;
    background: rgba(0,0,0,0.45); padding: 8px 12px; border-radius: 6px; line-height: 1.5; opacity: 0; transition: opacity 0.3s; }
  #replay-tags.show { opacity: 1; }
  #replay-tags .mult { color: #ffd24a; font-size: 20px; }
  #replay-tags .pen, #replay-tags .mult.low { color: #ff5a4f; }
  .rp-bar { position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); width: min(760px, calc(100% - 32px));
    background: rgba(15,15,20,0.82); border: 1px solid #44444c; border-radius: 10px; padding: 10px 12px; pointer-events: auto; }
  .rp-track { height: 4px; background: #2f2f37; border-radius: 2px; overflow: hidden; margin-bottom: 8px; }
  #replay-progress { height: 100%; width: 0; background: #ffd24a; }
  .rp-buttons { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
  .rp-buttons button { background: rgba(255,255,255,0.05); color: #ddd; border: 1px solid #44444c; border-radius: 6px; padding: 5px 10px;
    font: 12.5px 'Segoe UI', Arial, sans-serif; cursor: pointer; }
  .rp-buttons button:hover { border-color: #ffd24a; color: #fff; }
  #rp-exit { color: #ff9d3b; }
  #replay-note { position: absolute; left: 50%; bottom: 96px; transform: translateX(-50%); background: rgba(15,15,20,0.85);
    border: 1px solid #ffd24a; color: #ffe9a8; padding: 6px 14px; border-radius: 6px; font-size: 13px; }
  #replay-note[hidden] { display: none; }
  .rp-rec { display: none; position: absolute; top: 16px; left: 50%; transform: translateX(-50%); color: #ff5a4f; font-weight: bold; font-size: 13px; }
  #replay.recording .rp-rec { display: block; }
  #replay.recording .rp-bar { display: none; }   /* the bar isn't in the video anyway; hide it while recording */


  /* ---------------- mode select + multiplayer ---------------- */
  [hidden] { display: none !important; }
  #mode-tabs { display: flex; gap: 8px; margin-top: 14px; justify-content: center; }
  .tab {
    background: transparent; color: #aaa; border: 1px solid #444; border-radius: 6px;
    padding: 8px 18px; font-size: 14px; cursor: pointer; font-family: inherit;
  }
  .tab:hover { color: #fff; border-color: #888; }
  .tab.active { color: #111; background: #ffd24a; border-color: #ffd24a; font-weight: bold; }
  .tab:disabled { opacity: 0.4; cursor: not-allowed; }

  #panel-mp { margin-top: 12px; text-align: left; }
  #panel-mp h3 { margin: 0 0 6px; font-size: 12px; color: #ffd24a; text-transform: uppercase; letter-spacing: 1px; }
  .mp-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; font-size: 12.5px; color: #ccc; }
  .mp-row input, #mp-code, #mp-next-sub {
    background: #1b1b21; color: #fff; border: 1px solid #555; border-radius: 5px;
    padding: 6px 8px; font-size: 13px; font-family: inherit;
  }
  .mp-row input { flex: 1; }
  .mp-cols { display: flex; gap: 12px; }
  .mp-box select { background: #202026; color: #e8e8ea; border: 1px solid #44444c; border-radius: 4px; padding: 2px 4px; font: inherit; margin-left: 4px; }
  .mp-box { flex: 1; border: 1px solid #3a3a42; border-radius: 8px; padding: 10px 12px; }
  #mp-code { width: 90px; text-transform: uppercase; letter-spacing: 3px; font-weight: bold; text-align: center; margin-right: 6px; }
  .mp-hint { font-size: 11.5px !important; color: #999 !important; min-height: 32px; margin: 4px 0 8px !important; line-height: 1.4 !important; }
  .btn {
    background: rgba(255,255,255,0.05); color: #d6d6dc; border: 1px solid #55555f; border-radius: 6px;
    padding: 7px 14px; font-size: 13px; cursor: pointer; font-family: inherit; transition: background 0.15s, border-color 0.15s, color 0.15s;
  }
  .btn:hover { background: rgba(255,210,74,0.10); border-color: #ffd24a; color: #ffd24a; }
  .btn:disabled { opacity: 0.4; cursor: wait; }
  .btn.danger { border-color: #7a3b3b; color: #ff9a9a; }
  .btn.danger:hover { background: rgba(255,90,90,0.12); border-color: #ff5a5a; color: #ff9a9a; }
  .btn.danger.armed { background: #7a1f1f; border-color: #ff5a5a; color: #fff; }

  .btn.small { padding: 3px 10px; font-size: 12px; margin-left: 8px; }
  .mp-status { min-height: 18px; color: #ff9d3b !important; text-align: center; margin: 10px 0 0 !important; }
  .mp-status.ok { color: #ffd24a !important; }
  .mp-codebar { font-size: 14px; color: #ccc; text-align: center; }
  .mp-codebar b { font-size: 30px; letter-spacing: 6px; color: #ffd24a; margin: 0 6px; user-select: all; }
  .mp-modeline { font-size: 12.5px; color: #aaa; text-align: center; margin-top: 4px; }
  .mp-modeline b { color: #fff; }
  #mp-players { list-style: none; padding: 0; margin: 10px 0 0; font-size: 13px; color: #ddd; }
  #mp-players li { display: flex; align-items: center; gap: 8px; padding: 3px 0; }
  #mp-players .dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
  #mp-players .tag { color: #ffd24a; font-size: 10px; border: 1px solid #ffd24a; border-radius: 3px; padding: 0 4px; }
  #mp-room .start { text-align: center; }
  #mp-room > .btn { display: block; margin: 12px auto 0; }

  #mp-timer {
    position: absolute; top: 18px; left: 50%; transform: translateX(-50%); text-align: center;
    color: #fff; background: rgba(0,0,0,0.4); padding: 5px 16px; border-radius: 6px;
  }
  #mp-timer-val { font-size: 24px; font-weight: bold; color: #ffd24a; font-variant-numeric: tabular-nums; }
  #mp-timer-mode { font-size: 10px; letter-spacing: 1.5px; color: #999; text-transform: uppercase; }
  #fps { position: absolute; top: 8px; left: 8px; font: 12px Consolas, monospace; color: #ffe9a8; background: rgba(0,0,0,0.45); padding: 2px 6px; border-radius: 4px; }
  #esc-hint { position: absolute; top: 8px; left: 14px; font-size: 12px; color: #f2f2f4; letter-spacing: 0.5px; pointer-events: none;
    background: rgba(0,0,0,0.6); border: 1px solid rgba(255,255,255,0.22); border-radius: 5px; padding: 3px 9px; }
  .replaying #esc-hint { display: none; }
  #killfeed { position: absolute; top: 40px; left: 18px; display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
  #killfeed div { background: rgba(0,0,0,0.45); color: #fff; font-size: 13px; padding: 4px 10px; border-radius: 5px; }
  #killfeed b { color: #ffd24a; }
  #killfeed i { color: #ff9d3b; font-style: normal; font-size: 11px; margin-left: 4px; }
  #dead-screen {
    position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
    background: rgba(120,0,0,0.35); color: #fff;
  }
  #dead-screen div { font-size: 44px; font-weight: bold; letter-spacing: 4px; text-shadow: 0 0 14px #000; }
  #dead-screen small { font-size: 16px; margin-top: 6px; color: #ddd; }

  #scoreboard {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 25;
    min-width: 440px; max-width: 90vw; padding: 16px 22px; color: #fff; pointer-events: none;
    background: rgba(15,15,20,0.9); border: 1px solid #555; border-radius: 10px;
  }
  #scoreboard h2 { margin: 0 0 10px; text-align: center; color: #ffd24a; font-size: 20px; }
  #scoreboard table { width: 100%; border-collapse: collapse; font-size: 14px; }
  #scoreboard th { text-align: right; color: #888; font-weight: normal; font-size: 11px; padding: 2px 8px; text-transform: uppercase; letter-spacing: 1px; }
  #scoreboard td { text-align: right; padding: 4px 8px; font-variant-numeric: tabular-nums; }
  #scoreboard th:nth-child(2), #scoreboard td:nth-child(2) { text-align: left; width: 100%; }
  #scoreboard th:first-child, #scoreboard td:first-child { text-align: left; color: #888; }
  #scoreboard tr.me td { color: #ffd24a; font-weight: bold; }
  #scoreboard .dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 8px; }
  #sb-foot { margin: 10px 0 0; text-align: center; color: #aaa; font-size: 13px; }
