  html, body { margin: 0; padding: 0; overflow: hidden; height: 100%; background: #000;
    font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif; color: #fff; }
  canvas { display: block; }

  /* ---- Broadcast-style scoreboard ----
     The two panels (#hud > .panel left / .panel.right) take a team-color
     theme via CSS variables. Defaults: left=green (player), right=red
     (opponent) — covers vs-CPU and online-A. The .flip-colors modifier
     on #hud swaps the two for online-B, so each peer always sees their
     own side on the left in their team colour. */
  :root {
    --c-grn:    #2fcb7e;
    --c-grn-dk: #155a39;
    --c-grn-lt: #6df0a8;
    --c-red:    #e23146;
    --c-red-dk: #6a141f;
    --c-red-lt: #ff6a7c;
  }
  /* The scoreboard: a broadcast score bug, top left — two rows (flag,
     name, the serve ball, sets, games, the point), a header with the
     event's name, the event's colour down the edge and on the point of
     the side ahead (--ev / --ev2: hud.js setHudEvent). Each row keeps its
     side's team / country colour as a thin stripe (--side-c). */
  #hud {
    position: absolute; top: 18px; left: 18px;
    pointer-events: none;
    font-family: 'Oswald', 'Helvetica Neue', system-ui, sans-serif;
    --ev: #ffd84d; --ev2: #c9a018;
  }
  /* Hide the score HUD whenever the start menu is visible — the empty
     scoreboard reads as clutter behind the drone-camera + tile UI.
     Tied off #start's inline display attribute (which the engine flips
     to 'none' the moment a match begins and back to 'flex' on every
     return path), so we don't need a parallel body class to maintain.
     Initial state (no style attribute) also matches `:not(none)`, so
     the HUD is hidden on first boot before any JS runs.
     Second selector: while the World Tour career UI (#wt-root.show)
     is open, #start is forced to display:none so the first selector
     no longer applies — the empty match HUD would otherwise leak
     through the career screens. :has() pulls the body up when a
     `.show` World Tour root exists and hides #hud unconditionally. */
  #start:not([style*="none"]) ~ #hud,
  body:has(#wt-root.show) #hud,
  body:has(.wt-tut-root) #hud { display: none; }
  #hud .sb { display: grid; grid-template-columns: 5px auto; filter: drop-shadow(0 8px 18px rgba(0,0,0,0.45)); }
  #hud .sb-edge { background: linear-gradient(180deg, var(--ev), var(--ev2)); border-radius: 4px 0 0 4px; }
  #hud .sb-rows { background: rgba(8,13,20,0.72); backdrop-filter: blur(10px) saturate(130%); -webkit-backdrop-filter: blur(10px) saturate(130%);
    border-radius: 0 7px 7px 0; overflow: hidden; }
  #hud .sb-head { display: flex; justify-content: space-between; gap: 24px; padding: 5px 14px 5px 12px; font-size: 11px; letter-spacing: 4px; font-weight: 600;
    color: var(--ev); background: rgba(255,255,255,0.04); border-bottom: 1px solid rgba(255,255,255,0.08); }
  #hud .sb-head #sb-stage { color: rgba(255,255,255,0.55); }
  .panel {
    position: relative; display: grid; grid-template-columns: minmax(170px, auto) 34px 34px 56px; align-items: center; height: 40px;
  }
  .panel + .panel { border-top: 1px solid rgba(255,255,255,0.07); }
  /* Team-color tokens per side. Order matters: .flip-colors overrides
     pull below for online-B. */
  .panel:not(.right) { --side-c: var(--c-grn); --side-c-dk: var(--c-grn-dk); --side-c-lt: var(--c-grn-lt); }
  .panel.right       { --side-c: var(--c-red); --side-c-dk: var(--c-red-dk); --side-c-lt: var(--c-red-lt); }
  #hud.flip-colors .panel:not(.right) { --side-c: var(--c-red); --side-c-dk: var(--c-red-dk); --side-c-lt: var(--c-red-lt); }
  #hud.flip-colors .panel.right       { --side-c: var(--c-grn); --side-c-dk: var(--c-grn-dk); --side-c-lt: var(--c-grn-lt); }
  /* the side's colour: a thin stripe at the row's start */
  .panel::before { content: ''; position: absolute; left: 0; top: 7px; bottom: 7px; width: 3px; border-radius: 2px; background: var(--side-c); }
  .panel .name-col { display: flex; align-items: center; gap: 9px; padding: 0 12px 0 13px; min-width: 0; }
  .panel .name-col .label { font-size: 17px; letter-spacing: 1.5px; font-weight: 500; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 190px; }
  .panel .name-col.serving .label { font-weight: 700; }
  /* the flag: hidden until applyTeamColors has a country for the side */
  .panel .name-col .flag-img { display: none; width: 26px; height: 19px; object-fit: cover; border-radius: 3px; box-shadow: 0 0 0 1px rgba(255,255,255,0.35); flex: none; }
  .panel .name-col.with-flag .flag-img { display: block; }
  /* the serve: a tennis ball after the name */
  .panel .name-col .serve-dot { display: none; width: 10px; height: 10px; border-radius: 50%; margin-left: auto; flex: none;
    background: radial-gradient(circle at 35% 35%, #f4ff9a, #c9e33b 60%, #8fa61c); box-shadow: 0 0 9px rgba(214,240,80,0.8); }
  .panel .name-col.serving .serve-dot { display: block; }
  .panel .col { display: grid; place-items: center; height: 100%; }
  .panel .col-v { font-size: 18px; font-weight: 400; line-height: 1; font-variant-numeric: tabular-nums; color: rgba(255,255,255,0.6); }
  .panel .col.cur .col-v { color: #fff; font-weight: 600; }
  /* best of five: the sets played, one column each (hud.js pastSets) */
  #hud.long .panel .col.sets-col { display: none; }
  .panel .col.past .col-v { font-size: 16px; color: rgba(255,255,255,0.45); }
  .panel .col.past .col-v.won { color: rgba(255,255,255,0.92); font-weight: 600; }
  .panel .col.past .col-v sup { font-size: 9px; margin-left: 1px; vertical-align: 6px; }
  /* the point: in the event's colour, lit full on the side ahead */
  .panel .col.pt-col { background: color-mix(in srgb, var(--ev) 22%, transparent); }
  .panel .col-v.pt { font-size: 22px; font-weight: 700; color: color-mix(in srgb, var(--ev) 40%, #fff); }
  .panel.lead .col.pt-col { background: var(--ev); }
  .panel.lead .col-v.pt { color: var(--ev-on, #fff); text-shadow: 0 1px 4px rgba(0,0,0,0.35); }
  @media (max-width: 700px) { #hud { top: 8px; left: 8px; transform: scale(0.8); transform-origin: top left; } }

  #crosshair { display: none; }

  #message { position: absolute; top: 28%; left: 0; right: 0; text-align: center;
    font-size: 64px; font-weight: 800; letter-spacing: 6px;
    text-shadow: 0 6px 18px rgba(0,0,0,0.8);
    opacity: 0; transition: opacity 0.25s ease-out; pointer-events: none; }
  #message.show { opacity: 1; }
  #message .msg-sub { display: block; margin-top: 14px; font-size: 30px; font-weight: 600; letter-spacing: 8px; opacity: .9; }

  #power-meter { position: absolute; bottom: 26px; left: 50%; transform: translateX(-50%);
    width: 240px; height: 8px; background: rgba(255,255,255,0.15); border-radius: 4px;
    overflow: hidden; pointer-events: none; opacity: 0; transition: opacity 0.15s; }
  #power-meter.show { opacity: 1; }
  #power-meter > div { height: 100%; width: 0%;
    background: linear-gradient(90deg, #ffd84d, #ff5533); transition: width 0.05s linear; }
  #swing-badge { position: absolute; bottom: 44px; left: 50%; transform: translateX(-50%);
    color: #ffd84d; font-size: 12px; letter-spacing: 4px; font-weight: 700;
    text-shadow: 0 2px 6px rgba(0,0,0,0.7); pointer-events: none;
    opacity: 0; transition: opacity 0.15s; }
  #swing-badge.show { opacity: 1; }

  /* Hide the scoreboard panels during tutorial — score is irrelevant
     while the player is learning controls, and the panels just add
     visual noise. body.tutorial-on is toggled by tutorialBegin /
     completeTutorial. */
  body.tutorial-on #hud { display: none; }

  /* Tutorial band, praise, step clear, chapter cards, the finale banner: tutorial-flow.js (its own CSS).
     Hidden here too until it is shown, whatever the order the styles arrive in. */
  #tut-celebrate:not(.show), #tut-finale-banner:not(.show), #tut-chapter:not(.show) { display: none; }

  /* ===== Final TUTORIAL CLEAR finale ===================================
     Fires when the player clears step 21 — the full graduation. Two
     pieces:
       1. #tut-finale    — full-screen confetti rain. JS generates
                            ~60 small coloured rectangles with random
                            position / size / rotation / fall duration,
                            each animated to drift from top → past the
                            bottom of the viewport while spinning.
       2. #tut-finale-banner — big golden "TUTORIAL CLEAR!" with a
                            sub-line "全 21 ステップ完了！" pulsing in
                            the centre of the screen.
     Both fade away together after ~4 seconds, then returnToMenu fires.
     ====================================================================== */
  #tut-finale {
    position: fixed; inset: 0;
    pointer-events: none;
    z-index: 100;
    overflow: hidden;
    display: none;
  }
  #tut-finale.show { display: block; }
  .tut-confetti {
    position: absolute;
    top: -40px;
    animation-name: tut-confetti-fall;
    animation-timing-function: linear;
    animation-fill-mode: forwards;
    border-radius: 2px;
    opacity: 0.95;
    will-change: transform;
  }
  @keyframes tut-confetti-fall {
    0%   { transform: translateY(-40px) rotate(var(--rot-start, 0deg)); }
    100% { transform: translateY(110vh)  rotate(var(--rot-end, 360deg)); }
  }

  /* Ghost-swipe demo overlay — full-screen, sits OVER the canvas but
     UNDER #tutorial. Showcases the gesture for the current step. */
  #tut-ghost {
    position: absolute; inset: 0;
    pointer-events: none;
    display: flex; align-items: center; justify-content: center;
    opacity: 0;
    transition: opacity 0.25s ease-out;
    z-index: 25;
  }
  #tut-ghost.show { opacity: 1; }
  #tut-ghost svg { width: 60vmin; height: 60vmin; max-width: 540px; max-height: 540px; }
  #tut-ghost .gh-path {
    fill: none;
    stroke: #ffd84d;
    stroke-width: 6;
    stroke-linecap: round;
    stroke-linejoin: round;
    filter: drop-shadow(0 0 12px rgba(255,216,77,0.7));
    stroke-dasharray: 0 1000;
    animation: gh-draw 1.6s ease-in-out infinite;
  }
  #tut-ghost .gh-hint {
    position: absolute;
    bottom: 22%;
    font-size: 13px; letter-spacing: 4px; font-weight: 800;
    color: #ffd84d;
    text-shadow: 0 2px 8px rgba(0,0,0,0.85);
    text-align: center;
  }
  @keyframes gh-draw {
    0%   { stroke-dasharray: 0 1000; opacity: 0; }
    20%  { opacity: 1; }
    70%  { stroke-dasharray: 1000 0; opacity: 1; }
    100% { stroke-dasharray: 1000 0; opacity: 0; }
  }

  /* Side-edge pill — pulsing "FOREHAND" / "BACKHAND" label on the
     screen edge that matches the side the ball is heading to. Reads
     as "the side ↔ the swing name" tied directly. Vertical centre,
     in the player's peripheral vision, without occluding the court. */
  #tut-sidepill {
    position: absolute;
    top: 50%;
    pointer-events: none;
    opacity: 0;
    z-index: 28;
    font-family: Inter, sans-serif;
    font-size: 18px; letter-spacing: 6px; font-weight: 900;
    padding: 16px 22px;
    background: linear-gradient(180deg, rgba(255,216,77,0.18), rgba(255,138,90,0.18));
    border: 3px solid #ffd84d;
    border-radius: 14px;
    color: #ffe9a8;
    text-shadow: 0 2px 12px rgba(0,0,0,0.85), 0 0 24px rgba(255,216,77,0.55);
    box-shadow: 0 0 36px rgba(255,216,77,0.45), 0 0 0 1px rgba(255,255,255,0.12) inset;
    backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
    white-space: nowrap;
  }
  #tut-sidepill[data-side="right"] { right: 36px; transform: translateY(-50%); }
  #tut-sidepill[data-side="left"]  { left:  36px; transform: translateY(-50%); }
  #tut-sidepill.show {
    animation: tut-sp-pulse 1.0s ease-in-out infinite;
  }
  @keyframes tut-sp-pulse {
    0%, 100% { opacity: 0.80; box-shadow: 0 0 30px rgba(255,216,77,0.35); }
    50%      { opacity: 1;    box-shadow: 0 0 50px rgba(255,216,77,0.75); }
  }

  /* Persistent ghost-overlay variant — same SVG arc as the one-shot
     demo, but used by ghost-stay for the duration of a ball flight.
     Hide the hint text so it doesn't compete with the side-pill, and
     drop opacity slightly so the court reads through. */
  #tut-ghost.tg-persist { opacity: 0.55; }
  #tut-ghost.tg-persist .gh-hint { display: none; }

  /* The serve prompt: a broadcast lower third, bottom left — the matchup's
     type and gold accent, see-through so the court reads behind it */
  #serve-prompt { position: absolute; left: 3.2vw; bottom: 8vh; pointer-events: none;
    font-family: 'Oswald', 'Helvetica Neue', system-ui, sans-serif; color: #fff;
    filter: drop-shadow(0 8px 18px rgba(0,0,0,0.35)); animation: sp-in .35s ease-out; }
  @keyframes sp-in { from { opacity: 0; transform: translateX(-14px); } to { opacity: 1; transform: none; } }
  #serve-prompt .sp-band { display: flex; align-items: stretch; }
  #serve-prompt .sp-bar { width: 6px; background: #ffd84d; }
  #serve-prompt.second .sp-bar { background: #ff9f43; }
  #serve-prompt .sp-main { padding: 10px 26px 12px 18px;
    background: linear-gradient(90deg, rgba(8,14,22,0.62), rgba(8,14,22,0.34));
    backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
  #serve-prompt .sp-kicker { font-size: 11px; letter-spacing: 5px; font-weight: 600; color: #ffd84d; }
  #serve-prompt.second .sp-kicker { color: #ff9f43; }
  #serve-prompt .sp-title { font-size: 34px; font-weight: 700; letter-spacing: 2.5px; line-height: 1.05; text-shadow: 0 2px 10px rgba(0,0,0,0.35); }
  #serve-prompt .sp-hint { margin-top: 5px; font-size: 13px; letter-spacing: 2px; color: rgba(255,255,255,0.8); display: flex; align-items: center; gap: 8px; }
  #serve-prompt .key { display: inline-block; padding: 3px 8px 2px; border-radius: 5px; font-size: 12px; font-weight: 600; letter-spacing: 1px;
    background: rgba(255,255,255,0.14); border: 1px solid rgba(255,255,255,0.35); box-shadow: 0 2px 0 rgba(0,0,0,0.3); }
  @media (max-width: 700px) { #serve-prompt .sp-title { font-size: 24px; } }

  /* #start is now a transparent overlay — the 3D drone-camera flyaround
     (menu-bg.js) renders behind it on the WebGL canvas. A thin radial
     scrim sits on top of the scene to lift the menu type off bright
     midday-sky / clay-red backdrops without burying the venue. */
  #start { position: absolute; inset: 0; display: flex; flex-direction: column;
    align-items: stretch; justify-content: stretch; z-index: 10;
    overflow-y: auto;
    padding: 0;
    background: radial-gradient(ellipse at center, rgba(0,0,0,0.25), rgba(0,0,0,0.55)); }
  /* Legacy widgets — kept in the DOM as click-target sinks + as
     reparentable selector hosts for the new menu (menu-start.js
     mounts the new UI and moves the format/difficulty/court/practice
     panels into its CPU and Practice stages). #main-modes itself
     stays hidden permanently. */
  #start #main-modes { display: none !important; }
  #start .legacy-controls,
  #start .legacy-hints { display: none; }
  #start .modes { display: flex; gap: 18px; margin-top: 28px; }
  #start .mode-btn { background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.4);
    color: white; padding: 14px 28px; font-size: 14px; letter-spacing: 4px;
    font-weight: 600; cursor: pointer; border-radius: 6px; transition: all 0.15s;
    font-family: inherit; }
  #start .mode-btn:hover { background: rgba(255,255,255,0.18); border-color: white;
    transform: translateY(-2px); }
  #start .mode-btn:disabled { opacity: 0.4; cursor: wait; transform: none; }
  #start .practice-panel { display: none; flex-direction: column; gap: 14px; margin-top: 18px; align-items: center; }
  #start .practice-panel.show { display: flex; }
  #start .practice-panel .pp-title { font-size: 12px; letter-spacing: 5px; opacity: 0.65; margin-bottom: 4px; }
  #start .practice-panel .pp-grid { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; max-width: 720px; }
  #start .practice-panel .pp-btn { background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.32);
    color: white; padding: 14px 18px; min-width: 160px; max-width: 200px; cursor: pointer; border-radius: 6px;
    transition: all 0.15s; font-family: inherit; text-align: left; }
  #start .practice-panel .pp-btn:hover { background: rgba(255,255,255,0.14); border-color: white; transform: translateY(-2px); }
  #start .practice-panel .pp-btn .pp-h { font-size: 13px; font-weight: 700; letter-spacing: 2px; margin-bottom: 6px; color: #ffd84d; }
  #start .practice-panel .pp-btn .pp-d { font-size: 11px; opacity: 0.75; line-height: 1.4; }
  #start .practice-panel .pp-back { font-size: 11px; letter-spacing: 3px; opacity: 0.6; background: transparent;
    border: none; color: white; cursor: pointer; padding: 6px; margin-top: 4px; font-family: inherit; }
  #start .practice-panel .pp-back:hover { opacity: 1; }
  #start .practice-panel .pp-card { display: flex; flex-direction: column; gap: 6px; align-items: stretch; }
  #start .practice-panel .pp-toggle { display: inline-block; background: rgba(0,0,0,0.3); border: 1px solid rgba(255,255,255,0.25);
    color: white; padding: 6px 10px; font-size: 10px; letter-spacing: 1.5px; cursor: pointer; border-radius: 4px;
    transition: all 0.15s; font-family: inherit; text-align: center; }
  #start .practice-panel .pp-toggle:hover { background: rgba(255,255,255,0.18); border-color: white; }
  #start .practice-panel .pp-toggle[data-on="on"] { background: rgba(110,212,122,0.22); border-color: #6ed47a; }
  #start .practice-panel .pp-toggle[data-on="on"] .pp-toggle-state { color: #6ed47a; font-weight: 700; }
  #start .practice-panel .pp-levels { display: flex; align-items: center; gap: 6px; justify-content: center; padding: 4px; }
  #start .practice-panel .pp-level-label { font-size: 10px; letter-spacing: 1.5px; opacity: 0.65; margin-right: 4px; }
  #start .practice-panel .pp-level-btn { background: rgba(0,0,0,0.3); border: 1px solid rgba(255,255,255,0.22);
    color: white; padding: 4px 9px; font-size: 11px; font-weight: 700; cursor: pointer; border-radius: 4px;
    transition: all 0.15s; font-family: inherit; min-width: 24px; }
  #start .practice-panel .pp-level-btn:hover { background: rgba(255,255,255,0.18); border-color: white; }
  #start .practice-panel .pp-level-btn.selected { background: rgba(255,216,77,0.25); border-color: #ffd84d; color: #ffd84d; }

  #practice-hud { position: absolute; top: 90px; left: 50%; transform: translateX(-50%);
    background: rgba(0,0,0,0.55); border: 1px solid rgba(255,255,255,0.25);
    color: white; padding: 10px 22px; border-radius: 6px; z-index: 9;
    text-align: center; pointer-events: none; font-family: inherit; }
  #practice-hud .ph-mode { font-size: 11px; letter-spacing: 4px; color: #ffd84d; margin-bottom: 4px; }
  #practice-hud .ph-stats { font-size: 18px; font-weight: 700; letter-spacing: 2px; }
  #practice-hud .ph-speed { font-size: 22px; font-weight: 800; color: #6ed47a; letter-spacing: 3px;
    margin-top: 6px; text-shadow: 0 0 12px rgba(110,212,122,0.6); font-variant-numeric: tabular-nums; }
  #practice-hud .ph-speed .ph-speed-label { font-size: 10px; letter-spacing: 2px; color: rgba(255,255,255,0.65);
    margin-right: 6px; font-weight: 500; text-shadow: none; }
  #practice-hud .ph-keys { font-size: 11px; letter-spacing: 1px; color: #ffe89a; margin-top: 6px; }
  #practice-hud .ph-hint { font-size: 10px; letter-spacing: 2px; opacity: 0.55; margin-top: 4px; }

  #pause { position: absolute; inset: 0; display: flex; flex-direction: column;
    align-items: center; justify-content: center; cursor: pointer; z-index: 11;
    background: rgba(0,0,0,0.7); }
  #pause .p-title { font-size: 64px; letter-spacing: 12px; font-weight: 200;
    color: white; padding: 8px 32px;
    border-top: 1px solid rgba(255,255,255,0.4);
    border-bottom: 1px solid rgba(255,255,255,0.4); }
  #pause .p-hint { margin-top: 28px; font-size: 13px; letter-spacing: 4px;
    color: white; opacity: 0.75; animation: pulse 1.6s ease-in-out infinite; }

  /* ===== Pause overlay actions — CARD STACK button design ============
     Two stacked gradient cards under PAUSED:
       • skip-tutorial-step (mint gradient, ▸▸ icon) — advance to next step
       • skip-tutorial / exit-practice (orange gradient, house icon) —
         leave the lesson and go back to the main menu.
     Each card: 56px round icon emblem on the left + 2-line label
     (title + sub) in the middle + small dark arrow circle on the right.
     ================================================================ */
  #pause .pause-actions {
    margin-top: 40px;
    display: flex; flex-direction: column;
    gap: 14px;
    align-items: stretch;
    width: min(420px, 80vw);
  }
  #pause .pause-card {
    cursor: pointer;
    border: 1.5px solid rgba(255,255,255,0.4);
    border-radius: 18px;
    padding: 14px 18px;
    font-family: Inter, sans-serif;
    display: flex; align-items: center; gap: 14px;
    width: 100%;
    text-align: left;
    transition:
      transform 0.18s ease,
      box-shadow 0.18s ease,
      filter 0.18s ease;
    box-shadow: 0 8px 18px rgba(0,0,0,0.5);
  }
  #pause .pause-card--skip {
    background: linear-gradient(180deg, #7be3b3 0%, #2c8a3f 100%);
    color: #0a1410;
  }
  #pause .pause-card--exit {
    background: linear-gradient(180deg, #ff8a5a 0%, #c45c2f 100%);
    color: #1c0a05;
  }
  #pause .pause-card:hover {
    transform: translateY(-2px);
    filter: brightness(1.08);
    box-shadow: 0 12px 24px rgba(0,0,0,0.55);
  }
  #pause .pause-card:active {
    transform: translateY(0);
    filter: brightness(0.95);
  }
  #pause .pause-card-icon {
    flex-shrink: 0;
    width: 56px; height: 56px;
    border-radius: 999px;
    background: rgba(10,20,16,0.85);
    border: 1.5px solid rgba(255,255,255,0.35);
    display: flex; align-items: center; justify-content: center;
  }
  #pause .pause-card--skip .pause-card-icon { color: #7be3b3; }
  #pause .pause-card--exit .pause-card-icon { color: #ff8a5a; }
  #pause .pause-card-text {
    flex: 1 1 auto;
    display: flex; flex-direction: column; gap: 2px;
    min-width: 0;
  }
  #pause .pause-card-title {
    font-size: 17px; font-weight: 800;
    letter-spacing: 1px;
    line-height: 1.2;
  }
  #pause .pause-card-sub {
    font-size: 11px; font-weight: 600;
    letter-spacing: 1px;
  }
  #pause .pause-card--skip .pause-card-sub { color: #08321c; opacity: 0.85; }
  #pause .pause-card--exit .pause-card-sub { color: #3a1808; opacity: 0.85; }
  #pause .pause-card-arrow {
    flex-shrink: 0;
    width: 32px; height: 32px;
    border-radius: 999px;
    background: rgba(10,20,16,0.45);
    color: #ffffff;
    font-size: 18px; font-weight: 800;
    display: flex; align-items: center; justify-content: center;
    transition: transform 0.18s ease;
  }
  #pause .pause-card:hover .pause-card-arrow {
    transform: translateX(3px);
  }
  #start h1 { margin: 0; font-size: 88px; letter-spacing: 16px; font-weight: 200;
    border-top: 1px solid rgba(255,255,255,0.4); border-bottom: 1px solid rgba(255,255,255,0.4);
    padding: 8px 32px; }
  #start .sub { margin-top: 14px; font-size: 14px; letter-spacing: 8px; opacity: 0.75; }
  #start .controls { margin-top: 32px; display: flex; gap: 36px; opacity: 0.85; }
  #start .ctrl { display: flex; flex-direction: column; align-items: center; gap: 6px; }
  #start .key { display: inline-block; min-width: 36px; padding: 6px 10px;
    border: 1px solid rgba(255,255,255,0.5); border-radius: 5px; font-weight: 600; }
  #start .desc { font-size: 12px; opacity: 0.7; letter-spacing: 1px; }
  #start .pulse { margin-top: 56px; font-size: 13px; letter-spacing: 4px; opacity: 0.8;
    animation: pulse 1.6s ease-in-out infinite; }
  @keyframes pulse { 0%, 100% { opacity: 0.4; } 50% { opacity: 1; } }

  /* ---- Match format selector ---- */
  .format-selector {
    display: flex; flex-direction: column; align-items: center; gap: 12px;
    margin-top: 22px;
  }
  .format-selector .fs-title {
    font-size: 12px; letter-spacing: 6px; font-weight: 700;
    opacity: 0.7; color: #fff;
  }
  .format-selector .fs-row { display: flex; gap: 14px; }
  .fs-btn {
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.22);
    border-radius: 4px;
    padding: 10px 22px;
    color: #fff; font-family: inherit;
    cursor: pointer;
    text-align: center;
    transition: transform 0.15s ease-out, background 0.15s ease-out,
                border-color 0.15s ease-out, box-shadow 0.15s ease-out;
  }
  .fs-btn:hover {
    background: rgba(255,255,255,0.12);
    border-color: rgba(255,255,255,0.4);
    transform: translateY(-2px);
  }
  .fs-btn.selected {
    background: rgba(255,225,74,0.12);
    border-color: #ffe14a;
    box-shadow: 0 0 18px rgba(255,225,74,0.45), 0 6px 16px rgba(0,0,0,0.45);
  }
  .fs-btn.selected .fs-label { color: #ffe14a; text-shadow: 0 0 12px rgba(255,225,74,0.7); }
  .fs-btn .fs-label {
    font-size: 13px; letter-spacing: 4px; font-weight: 800;
  }
  .fs-btn .fs-tagline {
    margin-top: 5px;
    font-size: 9px; letter-spacing: 2.5px; opacity: 0.55;
  }

  /* (no tiebreak badge on the HUD: the scoreboard says enough) */

  /* ---- Broadcast-style instant-replay overlay ---- */
  #replay-hud {
    position: absolute; inset: 0; pointer-events: none; z-index: 6;
    opacity: 0; transition: opacity 0.35s ease-out;
  }
  #replay-hud.show { opacity: 1; }
  /* Cinematic letterbox bars slide in from top/bottom */
  #replay-hud .bar {
    position: absolute; left: 0; right: 0; height: 9vh;
    background: rgba(0,0,0,0.88);
    transition: transform 0.5s cubic-bezier(0.6, 0, 0.25, 1);
  }
  #replay-hud .bar.top    { top: 0;    transform: translateY(-100%); }
  #replay-hud .bar.bottom { bottom: 0; transform: translateY(100%); }
  #replay-hud.show .bar.top    { transform: translateY(0); }
  #replay-hud.show .bar.bottom { transform: translateY(0); }
  /* "INSTANT REPLAY" recording badge */
  #replay-hud .badge {
    position: absolute; top: 3vh; left: 4vw;
    display: flex; align-items: center; gap: 12px;
    font-size: 13px; letter-spacing: 6px; font-weight: 700;
    color: #ffffff; opacity: 0;
    transform: translateX(-12px);
    transition: opacity 0.4s 0.25s ease-out, transform 0.4s 0.25s ease-out;
    text-shadow: 0 2px 8px rgba(0,0,0,0.8);
  }
  #replay-hud.show .badge { opacity: 1; transform: translateX(0); }
  #replay-hud .badge .dot {
    width: 11px; height: 11px; border-radius: 50%; background: #ff2a2a;
    box-shadow: 0 0 14px #ff2a2a;
    animation: replay-rec 1.1s ease-in-out infinite;
  }
  @keyframes replay-rec { 0%, 100% { opacity: 1; } 50% { opacity: 0.2; } }
  /* "HAWK-EYE REVIEW" sub-label, right side */
  #replay-hud .sublabel {
    position: absolute; top: 3vh; right: 4vw;
    font-size: 11px; letter-spacing: 5px; font-weight: 600;
    color: rgba(255,255,255,0.7); opacity: 0;
    transition: opacity 0.4s 0.3s ease-out;
    text-shadow: 0 2px 8px rgba(0,0,0,0.8);
  }
  #replay-hud.show .sublabel { opacity: 1; }
  /* Verdict + distance caption at bottom */
  #replay-hud .call {
    position: absolute; bottom: 11vh; left: 0; right: 0; text-align: center;
    opacity: 0; transform: translateY(8px);
    transition: opacity 0.35s 0.4s ease-out, transform 0.35s 0.4s ease-out;
  }
  #replay-hud.show .call { opacity: 1; transform: translateY(0); }
  #replay-hud .verdict {
    font-size: 46px; font-weight: 900; letter-spacing: 12px; line-height: 1;
    color: #ffffff;
    text-shadow: 0 6px 18px rgba(0,0,0,0.85);
  }
  #replay-hud .verdict.in   { color: #6ee35a; text-shadow: 0 0 28px rgba(110,227,90,0.7), 0 6px 18px rgba(0,0,0,0.85); }
  #replay-hud .verdict.out  { color: #ff5050; text-shadow: 0 0 28px rgba(255,80,80,0.7), 0 6px 18px rgba(0,0,0,0.85); }
  #replay-hud .dist {
    display: block; margin-top: 10px; font-size: 16px; letter-spacing: 7px;
    font-weight: 600; opacity: 0.9; color: #ffffff;
    text-shadow: 0 2px 8px rgba(0,0,0,0.85);
  }

  /* ===== Boot splash / loading screen =====
     Inline DOM (top of <body>) so the browser paints it during HTML
     parse, BEFORE the module script runs — heavy Three.js boot work
     stays hidden behind a rich animated cover instead of a flash of
     unstyled canvas. Doubles as the autoplay-policy gate: dismissing
     the splash counts as the user gesture that authorises the menu
     BGM to start (see menu-loading.js / menu-music.js header notes). */
  #loading-screen {
    position: fixed; inset: 0;
    z-index: 10000;
    overflow: hidden;
    background: #050a0e;
    color: #eaf3ec;
    font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
    user-select: none;
    cursor: pointer;
    transition: opacity 0.7s ease-out;
  }
  #loading-screen.ls-fade-out { opacity: 0; pointer-events: none; }

  #loading-screen .ls-bg {
    position: absolute; inset: 0;
    background:
      radial-gradient(ellipse at 30% 22%, rgba(80,200,120,0.22), transparent 58%),
      radial-gradient(ellipse at 78% 88%, rgba(255,210,80,0.12), transparent 55%),
      radial-gradient(ellipse at 50% 50%, rgba(0,0,0,0.0) 0%, rgba(0,0,0,0.55) 100%),
      linear-gradient(160deg, #0c2018 0%, #03060a 100%);
    animation: ls-bg-shift 16s ease-in-out infinite alternate;
  }
  @keyframes ls-bg-shift {
    0%   { filter: hue-rotate(0deg)   saturate(1.0); transform: scale(1.00); }
    100% { filter: hue-rotate(-14deg) saturate(1.2); transform: scale(1.04); }
  }

  /* Decorative court line drawing — strokes draw in over 2.6s. */
  #loading-screen .ls-court {
    position: absolute; inset: 0;
    width: 100%; height: 100%;
    opacity: 0.22;
    mix-blend-mode: screen;
  }
  #loading-screen .ls-court-lines * {
    fill: none;
    stroke: #c9efd1;
    stroke-width: 1.6;
    stroke-dasharray: 1800;
    stroke-dashoffset: 1800;
    animation: ls-draw 2.6s ease-out forwards;
  }
  #loading-screen .ls-court-lines :nth-child(1) { animation-delay: 0.10s; }
  #loading-screen .ls-court-lines :nth-child(2) { animation-delay: 0.35s; }
  #loading-screen .ls-court-lines :nth-child(3) { animation-delay: 0.55s; }
  #loading-screen .ls-court-lines :nth-child(4) { animation-delay: 0.75s; }
  #loading-screen .ls-court-lines :nth-child(5) { animation-delay: 0.95s; }
  #loading-screen .ls-court-lines :nth-child(6) { animation-delay: 1.15s; }
  #loading-screen .ls-court-lines :nth-child(7) { animation-delay: 1.35s; }
  @keyframes ls-draw { to { stroke-dashoffset: 0; } }

  /* Floating motes — instances created in menu-loading.js. */
  #loading-screen .ls-particles { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
  #loading-screen .ls-mote {
    position: absolute;
    top: -8vh;
    width: 3px; height: 3px;
    background: radial-gradient(circle, rgba(255,230,160,0.9), transparent 70%);
    border-radius: 50%;
    animation: ls-mote-fall linear infinite;
  }
  @keyframes ls-mote-fall {
    0%   { transform: translate(0, 0); opacity: 0; }
    8%   { opacity: 0.95; }
    92%  { opacity: 0.95; }
    100% { transform: translate(var(--drift, 0), 118vh); opacity: 0; }
  }

  #loading-screen .ls-content {
    position: relative; z-index: 2;
    width: 100%; height: 100%;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 36px;
    padding: 40px; text-align: center;
  }

  #loading-screen .ls-title-main {
    font-size: clamp(38px, 7vw, 86px);
    font-weight: 800;
    letter-spacing: 0.18em;
    background: linear-gradient(180deg, #ffffff 0%, #c2e1cb 55%, #6f9a7e 100%);
    -webkit-background-clip: text; background-clip: text;
    color: transparent;
    filter: drop-shadow(0 0 28px rgba(120,255,180,0.18));
    animation: ls-title-in 1.4s ease-out 0.1s both;
  }
  #loading-screen .ls-title-sub {
    margin-top: 10px;
    font-size: clamp(10px, 1.2vw, 13px);
    letter-spacing: 0.48em;
    color: #7da793;
    animation: ls-title-in 1.4s ease-out 0.4s both;
  }
  @keyframes ls-title-in {
    from { opacity: 0; transform: translateY(14px); letter-spacing: 0.42em; }
    to   { opacity: 1; transform: translateY(0); }
  }

  /* Tennis ball — felt highlight + curved white seam approximated with
     two clip-path arcs. CSS-only, no image asset. */
  #loading-screen .ls-ball {
    width: 72px; height: 72px;
    border-radius: 50%;
    background:
      radial-gradient(circle at 32% 30%, #fdfd8a 0%, #d8d63a 55%, #8a8810 100%);
    box-shadow:
      inset -10px -10px 22px rgba(0,0,0,0.4),
      inset 8px 8px 18px rgba(255,255,200,0.45),
      0 20px 40px rgba(255,230,80,0.16),
      0 0 60px rgba(220,255,120,0.18);
    position: relative;
    animation: ls-ball-bob 1.7s cubic-bezier(.5,0,.5,1) infinite;
  }
  #loading-screen .ls-ball::before,
  #loading-screen .ls-ball::after {
    content: ''; position: absolute; inset: 4%;
    border-radius: 50%;
    border: 1.8px solid rgba(255,255,255,0.85);
    clip-path: polygon(0 38%, 100% 22%, 100% 36%, 0 54%);
    mix-blend-mode: screen;
  }
  #loading-screen .ls-ball::after { transform: rotate(180deg); }
  @keyframes ls-ball-bob {
    0%, 100% { transform: translateY(0)   rotate(-14deg); }
    50%      { transform: translateY(-16px) rotate(14deg); }
  }

  #loading-screen .ls-progress {
    display: flex; flex-direction: column; align-items: center; gap: 12px;
    width: min(440px, 70vw);
    transition: opacity 0.45s ease-out, transform 0.45s ease-out;
  }
  #loading-screen .ls-progress-track {
    position: relative;
    width: 100%; height: 4px;
    background: rgba(255,255,255,0.07);
    border-radius: 999px;
    overflow: hidden;
  }
  #loading-screen .ls-progress-fill {
    position: absolute; top: 0; left: -40%;
    width: 40%; height: 100%;
    background: linear-gradient(90deg, transparent, #b8ff8a, transparent);
    animation: ls-shimmer 1.4s linear infinite;
  }
  @keyframes ls-shimmer {
    0%   { transform: translateX(0); }
    100% { transform: translateX(360%); }
  }
  #loading-screen.ls-ready .ls-progress { opacity: 0; transform: translateY(8px); pointer-events: none; }
  #loading-screen .ls-progress-label {
    font-size: 11px; letter-spacing: 0.45em; color: #93b3a0;
  }
  #loading-screen .ls-dots i {
    display: inline-block; font-style: normal; opacity: 0.2;
    animation: ls-dot 1.2s ease-in-out infinite;
  }
  #loading-screen .ls-dots i:nth-child(2) { animation-delay: 0.2s; }
  #loading-screen .ls-dots i:nth-child(3) { animation-delay: 0.4s; }
  @keyframes ls-dot {
    0%, 100% { opacity: 0.2; }
    50%      { opacity: 1; }
  }

  /* "PRESS TO BEGIN" CTA — hidden until setReady(). It's the
     visible signal that boot is finished AND it's the click target
     whose gesture-event-handler invokes startMenuMusic() so the
     autoplay-policy permits the menu BGM to begin playing. */
  #loading-screen .ls-start {
    appearance: none;
    background: linear-gradient(180deg, rgba(40,80,60,0.55), rgba(20,40,30,0.65));
    border: 1.5px solid rgba(184,255,138,0.65);
    border-radius: 999px;
    color: #f6fff7;
    font-family: inherit;
    padding: 18px 48px 16px;
    display: none;
    align-items: center; gap: 16px;
    cursor: pointer;
    opacity: 0;
    transform: translateY(14px) scale(0.96);
    transition: opacity 0.55s ease-out, transform 0.55s ease-out,
                background 0.25s ease-out;
    box-shadow: 0 8px 24px rgba(0,0,0,0.45);
  }
  #loading-screen.ls-ready .ls-start { display: inline-flex; }
  #loading-screen.ls-ready .ls-start.ls-start--visible {
    opacity: 1;
    transform: translateY(0) scale(1);
    animation: ls-start-pulse 2.2s ease-in-out 0.6s infinite;
  }
  @keyframes ls-start-pulse {
    0%, 100% { box-shadow: 0 0 0 rgba(184,255,138,0), 0 8px 24px rgba(0,0,0,0.45); }
    50%      { box-shadow: 0 0 36px rgba(184,255,138,0.55), 0 8px 24px rgba(0,0,0,0.45); }
  }
  #loading-screen .ls-start:hover {
    background: linear-gradient(180deg, rgba(60,120,82,0.7), rgba(30,60,42,0.75));
    transform: translateY(-1px) scale(1.02);
  }
  #loading-screen .ls-start-arrow {
    font-size: 18px; color: #b8ff8a;
    display: inline-block;
    transform: translateY(-1px);
  }
  #loading-screen .ls-start-text {
    font-size: 22px; letter-spacing: 0.3em; font-weight: 700;
  }
  #loading-screen .ls-start-hint {
    font-size: 10px; letter-spacing: 0.4em; color: #94b3a1;
    margin-left: 10px;
  }
  @media (prefers-reduced-motion: reduce) {
    #loading-screen .ls-bg,
    #loading-screen .ls-court-lines *,
    #loading-screen .ls-mote,
    #loading-screen .ls-ball,
    #loading-screen .ls-progress-fill,
    #loading-screen .ls-dots i,
    #loading-screen.ls-ready .ls-start.ls-start--visible {
      animation: none;
    }
    #loading-screen .ls-court-lines * { stroke-dashoffset: 0; }
  }

  /* "Your player" editor (vs CPU setup, online lobby) */
  .profile-editor .pe-row { display: flex; align-items: center; justify-content: center; gap: 10px; }
  .profile-editor .pe-flag { width: 36px; height: 27px; object-fit: cover; border-radius: 3px; box-shadow: 0 2px 6px rgba(0,0,0,.5); }
  .profile-editor select, .profile-editor input {
    background: rgba(0,0,0,.45); color: #fff; border: 1px solid rgba(255,255,255,.3); border-radius: 8px;
    padding: 8px 12px; font: 600 13px/1 inherit; letter-spacing: 2px; outline: none; }
  .profile-editor input { width: 200px; }
  .profile-editor select:focus, .profile-editor input:focus { border-color: #ffd84d; }
  .profile-top { margin-top: 8px; }
  .profile-top .format-selector { background: rgba(0,0,0,.35); padding: 10px 18px 12px; border-radius: 14px; }

/* ---- venue loading (the drone waits until the venue is fully built) ---- */
#venue-loader {
  position: fixed; inset: 0; z-index: 9000;
  display: grid; place-items: center;
  background: radial-gradient(ellipse at center, rgba(8, 14, 24, .72), rgba(4, 7, 12, .92));
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  opacity: 0; pointer-events: none; transition: opacity .35s ease;
}
#venue-loader.show { opacity: 1; pointer-events: auto; }
#venue-loader .vl-box { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 0 16px; text-align: center; }
#venue-loader .vl-spin { width: 96px; height: 96px; }
#venue-loader svg { width: 100%; height: 100%; overflow: visible; }
#venue-loader circle { fill: none; stroke-linecap: round; }
#venue-loader .vl-track { stroke: rgba(255, 255, 255, .08); stroke-width: 3; }
#venue-loader .vl-arc.a { stroke: #d7f24a; stroke-width: 4; stroke-dasharray: 70 194; transform-origin: 50px 50px; animation: vl-rot 1.1s cubic-bezier(.55, .15, .45, .85) infinite; filter: drop-shadow(0 0 6px rgba(215, 242, 74, .55)); }
#venue-loader .vl-arc.b { stroke: rgba(255, 255, 255, .85); stroke-width: 2.5; stroke-dasharray: 36 153; transform-origin: 50px 50px; animation: vl-rot 1.6s linear infinite reverse; }
#venue-loader .vl-ball { fill: #e8ff5a; stroke: none; transform-origin: 50px 50px; animation: vl-rot 2.2s linear infinite; filter: drop-shadow(0 0 5px rgba(232, 255, 90, .8)); }
@keyframes vl-rot { to { transform: rotate(360deg); } }
#venue-loader .vl-title { color: #fff; font-weight: 700; font-size: 17px; letter-spacing: .12em; }
#venue-loader .vl-venue { color: rgba(255, 255, 255, .6); font-size: 11px; letter-spacing: .28em; min-height: 1em; }
#venue-loader .vl-bar { width: min(240px, 60vw); height: 2px; background: rgba(255, 255, 255, .1); border-radius: 2px; overflow: hidden; }
#venue-loader .vl-bar i { display: block; width: 40%; height: 100%; background: linear-gradient(90deg, transparent, #d7f24a, transparent); animation: vl-sweep 1.3s ease-in-out infinite; }
@keyframes vl-sweep { from { transform: translateX(-100%); } to { transform: translateX(250%); } }
@media (prefers-reduced-motion: reduce) { #venue-loader .vl-arc, #venue-loader .vl-ball, #venue-loader .vl-bar i { animation-duration: 4s; } }
