:root {
    --bg-deep: #F4EDE0;
    --bg-warm: #FAF6EE;
    --stone-surface: #FAF6EE;
    --stone-dark: #2A2118;
    --stone-locked: #E6DDD0;
    --stone-locked-lip: #C7B59C;
    --brass: #C88435;
    --brass-bright: #9E5E16;
    --brass-dim: #D6C4AA;
    --brass-lip: #B8A387;
    --gold-glow: #F4CA7A;
    --terracotta: #C87436;
    --terracotta-lip: #9F5621;
    --jade: #288A63;
    --ruby: #C24D4A;
    --ink-gold: #8A5311;
    --ink-ivory: #2A2118;
    --ink-muted: #5A4A3B;
    
    /* ── EYE-FRIENDLY ALABASTER & MINERAL LIGHT TOKENS ── */
    --toy-cobalt: #256BA6;
    --toy-cobalt-dark: #1A4E7A;
    --toy-cobalt-light: #5C9BD1;
    --toy-tangerine: #E5A952;
    --toy-tangerine-dark: #B57A29;
    --toy-tangerine-glow: rgba(229, 169, 82, 0.3);
    --toy-lime: #BCE8D2;
    --toy-lime-dark: #24825B;
    --toy-magenta: #C96A5C;
    --toy-magenta-dark: #9B473B;
    --toy-cream: #FAF6EE;
    --toy-cream-dim: #F4EDE0;
    --toy-ink: #2A2118;
    --toy-ink-mid: #5A4A3B;
    --toy-gold: #F4CA7A;
    --toy-cyan: #D8ECF8;
    --toy-snow: #FFFFFF;

    /* ── SOFT ELEVATED BORDERS & SHADOWS ── */
    --border-thick: 2px solid #D6C4AA;
    --border-mid: 2px solid #D6C4AA;
    --border-thin: 1.5px solid #D6C4AA;
    --shadow-btn: 0px 4px 0px #C8B59B, 0px 6px 14px rgba(42, 33, 24, 0.09);
    --shadow-btn-pressed: 0px 1px 0px #C8B59B;
    --shadow-card: 0px 10px 28px rgba(42, 33, 24, 0.12), 0px 3px 0px #D6C4AA;
    --shadow-modal: 0px 18px 46px rgba(42, 33, 24, 0.16), 0px 4px 0px #D6C4AA;
    --radius-sm: 12px;
    --radius-md: 18px;
    --radius-lg: 24px;
    --radius-pill: 9999px;

    /* ── TYPOGRAPHY ── */
    --font-display: 'Bungee', 'Lilita One', 'Fredoka', cursive, sans-serif;
    --font-body: 'Fredoka', 'Nunito', system-ui, sans-serif;
    --font-mono: 'Rubik Mono One', 'Space Mono', monospace;

    /* Compatibility Aliases */
    --fg-accent: #C87B2E;
    --fg-accent-glow: rgba(200, 123, 46, 0.25);
    --fg-pink: #C96A5C;
    --fg-sky: #256BA6;
    --fg-purple: #6D5FA6;
    --fg-lime: #24825B;
    --menu-bg: #FAF6EE;
  }

  * {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
  }

  html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    background: linear-gradient(180deg, #FAF6EE 0%, #F4EDE0 100%);
    font-family: var(--font-body);
    color: var(--toy-ink);
    overscroll-behavior: none;
    font-weight: 700;
  }

  input {
    user-select: text;
    -webkit-user-select: text;
  }

  #game-canvas-host {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    touch-action: none;
  }

  #game-canvas-host canvas {
    display: block;
    width: 100%;
    height: 100%;
    touch-action: none;
  }

  .tabular { font-variant-numeric: tabular-nums; }
  .temple-font { font-family: var(--font-display); }

  /* =========================================================
     SOFT TACTILE LIGHT BUTTONS
     ========================================================= */
  .duo-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-radius: 14px;
    font-family: var(--font-body);
    font-weight: 800;
    font-size: 14px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    cursor: pointer;
    padding: 11px 16px;
    border: 1.5px solid #D6C4AA;
    box-shadow: 0 3px 0 #C8B59B, 0 6px 14px rgba(42, 33, 24, 0.08);
    transition: transform 0.12s cubic-bezier(0.34, 1.6, 0.64, 1), box-shadow 0.12s ease, filter 0.12s ease;
    outline: none;
    max-width: 100%;
    position: relative;
    overflow: hidden;
  }
  .duo-btn::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 36%;
    background: linear-gradient(180deg, rgba(255,255,255,0.28) 0%, rgba(255,255,255,0) 100%);
    border-radius: 12px 12px 50% 50%;
    pointer-events: none;
  }
  .duo-btn:hover {
    filter: brightness(1.04);
    transform: translateY(-1px);
    box-shadow: 0 4px 0 #C8B59B, 0 8px 18px rgba(42, 33, 24, 0.12);
  }
  .duo-btn:active {
    transform: translateY(2px) scale(0.99) !important;
    box-shadow: 0 1px 0 #C8B59B !important;
    filter: brightness(0.97);
  }

  /* Sage-Emerald Primary CTA */
  .duo-btn-emerald {
    background: linear-gradient(180deg, #27845D 0%, #1D6B4A 100%);
    color: #FFFFFF;
    border: 1.5px solid #18573C;
    box-shadow: 0 4px 0 #165138, 0 8px 18px rgba(29, 107, 74, 0.22);
    text-shadow: none;
  }
  .duo-btn-emerald:hover {
    filter: brightness(1.05);
    box-shadow: 0 5px 0 #165138, 0 10px 22px rgba(29, 107, 74, 0.28);
  }

  /* Soft Mineral Sky-Blue CTA */
  .duo-btn-sky {
    background: linear-gradient(180deg, #2B72AD 0%, #1F5B8E 100%);
    color: #FFFFFF;
    border: 1.5px solid #194A74;
    box-shadow: 0 4px 0 #18476F, 0 8px 18px rgba(31, 91, 142, 0.22);
    text-shadow: none;
  }
  .duo-btn-sky:hover {
    filter: brightness(1.05);
    box-shadow: 0 5px 0 #18476F, 0 10px 22px rgba(31, 91, 142, 0.28);
  }

  /* Warm Ivory Secondary Button */
  .duo-btn-white {
    background: linear-gradient(180deg, #FFFFFF 0%, #F4EDE0 100%);
    color: #2A2118;
    border: 1.5px solid #D6C4AA;
    box-shadow: 0 3px 0 #C7B398;
    font-weight: 800;
  }
  .duo-btn-white:hover {
    background: linear-gradient(180deg, #FFFFFF 0%, #FAF6EE 100%);
    box-shadow: 0 4px 0 #C7B398;
  }

  /* Soft Sage-Mint Equipped / Positive Button */
  .duo-btn-jade {
    background: linear-gradient(180deg, #CBEFE0 0%, #A9DFC8 100%);
    color: #134A33;
    border: 1.5px solid #74B99B;
    box-shadow: 0 3px 0 #62A689;
    font-weight: 900;
  }

  .duo-btn-locked {
    background: #EAE2D4;
    color: #5A4A3B;
    border: 1.5px solid #D6C4AA;
    box-shadow: 0 2px 0 #C7B398;
    cursor: not-allowed;
  }
  .duo-btn-locked:hover { filter: none; transform: none; }
  .duo-btn-locked:active {
    transform: none !important;
    box-shadow: 0 2px 0 #C7B398 !important;
  }

  .duo-icon-btn {
    width: 42px;
    height: 42px;
    padding: 0;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #FFFFFF;
    color: #2A2118;
    border: 1.5px solid #D6C4AA;
    box-shadow: 0 3px 0 #C8B59B, 0 4px 10px rgba(42, 33, 24, 0.08);
    cursor: pointer;
    transition: transform 0.1s cubic-bezier(0.34, 1.6, 0.64, 1), box-shadow 0.1s ease;
    pointer-events: auto;
    flex-shrink: 0;
  }
  .duo-icon-btn:hover { background: #FAF6EE; }
  .duo-icon-btn:active {
    transform: translateY(2px);
    box-shadow: 0 1px 0 #C8B59B;
  }

  .duo-gfx-btn {
    width: auto !important;
    min-width: 58px;
    height: 36px;
    padding: 0 10px;
    border-radius: 999px;
    font-family: 'Cinzel', serif;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    color: #2A2118;
    background: #FFFFFF;
    border: 1.5px solid #D6C4AA;
    box-shadow: 0 2px 0 #C8B59B;
    cursor: pointer;
    transition: all 0.15s ease;
    user-select: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  .duo-gfx-btn.is-high {
    color: #8A4E0F;
    background: #FDF1DB;
    border-color: #DEC089;
    box-shadow: 0 2px 0 #C9A467;
  }
  .duo-gfx-btn.is-med {
    color: #1A4E7A;
    background: #E9F3FC;
    border-color: #96C4E6;
    box-shadow: 0 2px 0 #6FA6CF;
  }
  .duo-gfx-btn.is-low,
  .duo-gfx-btn.is-fast {
    color: #16553A;
    background: #E4F4EC;
    border-color: #7BC2A2;
    box-shadow: 0 2px 0 #5BA684;
  }
  #game-hud .duo-gfx-btn {
    height: 44px;
    min-width: 64px;
    padding: 0 12px;
    font-size: 0.78rem;
  }

  /* =========================================================
     HOME SHELL: GAME MENU (FALL GUYS-INSPIRED)
     ========================================================= */

  /* Floating ball particles animation */
  @keyframes floatBall {
    0%   { transform: translateY(0px) rotate(0deg); opacity: 0.7; }
    33%  { transform: translateY(-18px) rotate(120deg); opacity: 1; }
    66%  { transform: translateY(-8px) rotate(240deg); opacity: 0.85; }
    100% { transform: translateY(0px) rotate(360deg); opacity: 0.7; }
  }
  @keyframes drift {
    0%   { transform: translateX(0px) translateY(0px) scale(1); }
    25%  { transform: translateX(12px) translateY(-15px) scale(1.08); }
    50%  { transform: translateX(-8px) translateY(-28px) scale(0.95); }
    75%  { transform: translateX(-16px) translateY(-12px) scale(1.05); }
    100% { transform: translateX(0px) translateY(0px) scale(1); }
  }
  @keyframes titleWobble {
    0%, 100% { transform: rotate(-1.2deg) scale(1); }
    50%       { transform: rotate(1.2deg) scale(1.015); }
  }
  @keyframes shimmerSweep {
    0%   { left: -120%; opacity: 0.6; }
    40%  { opacity: 1; }
    100% { left: 120%; opacity: 0.6; }
  }
  @keyframes cardEntrance {
    0%   { opacity: 0; transform: translateY(32px) scale(0.93); }
    100% { opacity: 1; transform: translateY(0px) scale(1); }
  }
  @keyframes starSpin {
    0%   { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
  }
  @keyframes pulseGlow {
    0%, 100% { box-shadow: 0 0 0px rgba(255, 200, 0, 0); }
    50%       { box-shadow: 0 0 24px rgba(255, 200, 0, 0.45), 0 0 48px rgba(255, 150, 0, 0.2); }
  }
  @keyframes menuBounce {
    0%, 100% { transform: translateY(0); }
    40%       { transform: translateY(-6px); }
    60%       { transform: translateY(-3px); }
  }

  #home-screen {
    position: fixed;
    inset: 0;
    z-index: 30;
    background: radial-gradient(ellipse 95% 75% at 50% 12%, rgba(26, 33, 77, 0.88) 0%, rgba(14, 19, 43, 0.94) 70%, rgba(7, 10, 24, 0.98) 100%);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: opacity 0.3s ease, transform 0.3s ease;
  }
  #home-screen.hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(1.03);
  }

  /* ── Particle Balls Layer ── */
  .menu-particles {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
  }
  .menu-particle {
    position: absolute;
    border-radius: 50%;
    opacity: 0;
  }

  /* ── TOP HEADER BAR ── */
  .map-header {
    position: relative;
    z-index: 10;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    padding: max(12px, env(safe-area-inset-top, 12px)) 16px 12px 16px;
    background: rgba(14, 19, 43, 0.92);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 3.5px solid var(--toy-ink);
    box-shadow: 0 4px 0 rgba(0, 0, 0, 0.3);
  }

  .brand-wrap {
    display: flex;
    flex-direction: column;
    line-height: 1;
    min-width: 0;
    flex: 1 1 auto;
    overflow: hidden;
  }
  .brand-title {
    font-family: var(--font-display);
    font-size: clamp(15px, 4.4vw, 22px);
    font-weight: 900;
    letter-spacing: 0.05em;
    color: var(--toy-cream);
    text-shadow: 0 3px 0 var(--toy-ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .brand-sub {
    align-self: flex-start;
    font-size: clamp(8px, 2vw, 10px);
    font-weight: 900;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    background: var(--toy-magenta);
    color: #FFFFFF;
    padding: 2px 8px;
    border-radius: 9999px;
    border: 2px solid var(--toy-ink);
    box-shadow: 0 2px 0 var(--toy-ink);
    margin-top: 4px;
    white-space: nowrap;
  }

  .header-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
  }

  .orbs-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 38px;
    padding: 0 12px;
    border-radius: var(--radius-sm);
    background: linear-gradient(165deg, #FFFFFF 0%, #FFF8E7 60%, #EFE3C3 100%);
    color: var(--toy-ink);
    border: 3px solid var(--toy-ink);
    box-shadow: 0 4px 0 var(--toy-ink);
    font-family: var(--font-display);
    font-size: 11px;
    font-weight: 900;
    letter-spacing: 0.06em;
    cursor: pointer;
    transition: transform 0.12s cubic-bezier(0.34,1.6,0.64,1), box-shadow 0.12s ease;
    white-space: nowrap;
  }
  .orbs-btn:hover { filter: brightness(1.08); transform: translateY(-2px); box-shadow: 0 6px 0 var(--toy-ink); }
  .orbs-btn:active {
    transform: translateY(3px) scale(0.97);
    box-shadow: 0 1px 0 var(--toy-ink);
  }

  .star-total-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 38px;
    background: var(--toy-ink-mid);
    border: 3px solid var(--toy-ink);
    box-shadow: 0 4px 0 var(--toy-ink);
    border-radius: var(--radius-sm);
    padding: 0 10px;
    font-size: 13px;
    font-weight: 800;
    color: var(--toy-gold);
    white-space: nowrap;
  }

  .map-header .duo-icon-btn {
    width: 38px;
    height: 38px;
    border: 3px solid var(--toy-ink);
    border-radius: var(--radius-sm);
    background: var(--toy-ink-mid);
    color: var(--toy-cream);
    box-shadow: 0 4px 0 var(--toy-ink);
    transition: transform 0.12s ease, box-shadow 0.12s ease;
  }
  .map-header .duo-icon-btn:hover { transform: translateY(-2px); box-shadow: 0 6px 0 var(--toy-ink); }
  .map-header .duo-icon-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--toy-ink); }
  .map-header .duo-icon-btn svg { width: 18px; height: 18px; }

  /* ── HERO LOGO ZONE ── */
  .menu-hero {
    position: relative;
    z-index: 5;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 16px 16px 10px 16px;
    text-align: center;
  }

  /* Rotating Sunburst Halo behind Logo */
  .hero-sunburst {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 360px;
    height: 360px;
    margin-top: -180px;
    margin-left: -180px;
    background: repeating-conic-gradient(
      from 0deg,
      rgba(255, 107, 26, 0.14) 0deg 15deg,
      transparent 15deg 30deg
    );
    border-radius: 50%;
    pointer-events: none;
    z-index: -1;
    animation: sunburstSpin 40s linear infinite;
    filter: blur(1px);
  }
  @keyframes sunburstSpin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
  }

  .hero-logo-wrap {
    position: relative;
    display: inline-block;
    animation: heroLogoWiggle 4s ease-in-out infinite;
  }
  @keyframes heroLogoWiggle {
    0%, 100% { transform: translateY(0px) rotate(-1.5deg); }
    50% { transform: translateY(-6px) rotate(1.5deg); }
  }

  .hero-logo-text {
    font-family: var(--font-display);
    font-size: clamp(30px, 9.5vw, 52px);
    font-weight: 900;
    letter-spacing: 0.05em;
    line-height: 0.92;
    display: block;
    color: var(--toy-tangerine);
    -webkit-text-stroke: 2.5px var(--toy-ink);
    text-shadow:
      0 4px 0 var(--toy-cobalt),
      0 8px 0 var(--toy-ink),
      0 12px 24px rgba(255, 107, 26, 0.45);
    transform: perspective(600px) rotateX(8deg);
  }

  .hero-logo-shine {
    position: absolute;
    top: 0;
    left: -120%;
    width: 55%;
    bottom: 0;
    background: linear-gradient(
      105deg,
      transparent 10%,
      rgba(255, 255, 255, 0.45) 50%,
      transparent 90%
    );
    animation: shimmerSweep 3.2s ease-in-out infinite;
    pointer-events: none;
  }

  .hero-tagline-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    padding: 4px 14px;
    border-radius: 9999px;
    background: var(--toy-magenta);
    border: 3px solid var(--toy-ink);
    box-shadow: 0 4px 0 var(--toy-ink);
    transform: rotate(-1.5deg);
  }
  .tagline-pip {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--toy-lime);
    box-shadow: 0 0 8px var(--toy-lime);
    animation: gemPulse 1.8s ease-in-out infinite alternate;
  }
  @keyframes gemPulse {
    0% { opacity: 0.6; transform: scale(0.8); }
    100% { opacity: 1; transform: scale(1.2); }
  }
  .hero-tagline {
    font-family: var(--font-body);
    font-size: clamp(10px, 2.6vw, 12px);
    font-weight: 800;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: #FFFFFF;
    margin: 0;
  }

  /* ── MODE SELECTOR: GAME CARDS ── */
  .menu-mode-row {
    position: relative;
    z-index: 5;
    flex-shrink: 0;
    display: flex;
    gap: 12px;
    padding: 0 16px;
    justify-content: center;
  }

  .mode-card {
    flex: 1;
    max-width: 210px;
    position: relative;
    border-radius: var(--radius-md);
    padding: 14px 12px 12px 12px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    text-align: center;
    border: var(--border-mid);
    box-shadow: var(--shadow-btn);
    transition:
      transform 0.15s cubic-bezier(0.34, 1.6, 0.64, 1),
      box-shadow 0.15s ease,
      filter 0.12s ease;
    overflow: hidden;
    animation: cardEntrance 0.4s cubic-bezier(0.22,1.2,0.36,1) both;
  }
  .mode-card:nth-child(2) { animation-delay: 0.07s; }

  .mode-card::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: linear-gradient(160deg, rgba(255,255,255,0.25) 0%, transparent 50%);
    pointer-events: none;
  }

  .mode-card:hover {
    transform: translateY(-4px) scale(1.03);
    box-shadow: 0 8px 0 var(--toy-ink);
    filter: brightness(1.08);
  }
  .mode-card:active {
    transform: translateY(4px) scale(0.97);
    box-shadow: 0 2px 0 var(--toy-ink);
  }
  .mode-card.active {
    transform: translateY(-3px) scale(1.02);
  }

  /* Multi: Electric Cobalt Hero Theme */
  .mode-card-multi {
    background: linear-gradient(165deg, #385BFF 0%, #1E40FF 60%, #1228A8 100%);
    border: 3.5px solid var(--toy-ink);
    box-shadow: 0 6px 0 var(--toy-ink);
  }
  .mode-card-multi.active {
    box-shadow:
      0 7px 0 var(--toy-ink),
      0 12px 28px rgba(30, 64, 255, 0.5),
      0 0 0 3px var(--toy-lime);
    animation: cardPulseMulti 2.4s ease-in-out infinite, cardEntrance 0.4s cubic-bezier(0.22,1.2,0.36,1) both;
  }
  @keyframes cardPulseMulti {
    0%, 100% {
      box-shadow: 0 7px 0 var(--toy-ink), 0 10px 24px rgba(30, 64, 255, 0.45), 0 0 0 3px var(--toy-lime);
    }
    50% {
      box-shadow: 0 7px 0 var(--toy-ink), 0 16px 36px rgba(30, 64, 255, 0.7), 0 0 0 4px var(--toy-lime);
    }
  }

  /* Training: Sunshine Tangerine / Acid Lime Theme */
  .mode-card-training {
    background: linear-gradient(165deg, #FF8C38 0%, #FF6B1A 60%, #C44600 100%);
    border: 3.5px solid var(--toy-ink);
    box-shadow: 0 6px 0 var(--toy-ink);
  }
  .mode-card-training.active {
    box-shadow:
      0 7px 0 var(--toy-ink),
      0 12px 28px rgba(255, 107, 26, 0.5),
      0 0 0 3px var(--toy-lime);
    animation: cardPulseTraining 2.4s ease-in-out infinite, cardEntrance 0.4s cubic-bezier(0.22,1.2,0.36,1) both;
  }
  @keyframes cardPulseTraining {
    0%, 100% {
      box-shadow: 0 7px 0 var(--toy-ink), 0 10px 24px rgba(255, 107, 26, 0.45), 0 0 0 3px var(--toy-lime);
    }
    50% {
      box-shadow: 0 7px 0 var(--toy-ink), 0 16px 36px rgba(255, 107, 26, 0.7), 0 0 0 4px var(--toy-lime);
    }
  }

  .mode-card-icon {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 2px;
    flex-shrink: 0;
    border: 2.5px solid var(--toy-ink);
    box-shadow: 0 3px 0 var(--toy-ink);
  }
  .mode-card-multi .mode-card-icon {
    background: radial-gradient(circle at 35% 30%, #5472FF 0%, #1E40FF 60%, #1228A8 100%);
  }
  .mode-card-training .mode-card-icon {
    background: radial-gradient(circle at 35% 30%, #FF9B54 0%, #FF6B1A 60%, #C44600 100%);
  }

  .mode-card-label {
    font-family: 'Cinzel', Georgia, serif;
    font-size: clamp(10px, 2.8vw, 13px);
    font-weight: 900;
    letter-spacing: 0.08em;
    color: #FFFAF0;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
    white-space: nowrap;
  }
  .mode-card-training .mode-card-label { color: #DFFFFA; }

  .mode-card-sub {
    font-size: clamp(8px, 2vw, 10px);
    font-weight: 700;
    color: rgba(255, 240, 210, 0.75);
    line-height: 1.2;
  }
  .mode-card-training .mode-card-sub { color: rgba(200, 255, 248, 0.72); }

  .mode-card-meta {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    min-width: 0;
  }

  .mode-card-pip {
    position: absolute;
    top: 8px; right: 8px;
    width: 8px; height: 8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.4);
    transition: background 0.2s ease, box-shadow 0.2s ease;
  }
  .mode-card.active .mode-card-pip {
    background: #fff;
    box-shadow: 0 0 8px rgba(255, 255, 255, 0.9);
  }

  /* ── UNIFIED SCROLLABLE MENU WRAPPER ── */
  .menu-scroll-wrap {
    flex: 1;
    width: 100%;
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    position: relative;
    z-index: 5;
    display: flex;
    flex-direction: column;
  }
  .menu-scroll-wrap::-webkit-scrollbar {
    width: 6px;
  }
  .menu-scroll-wrap::-webkit-scrollbar-track {
    background: transparent;
  }
  .menu-scroll-wrap::-webkit-scrollbar-thumb {
    background: rgba(200, 150, 62, 0.35);
    border-radius: 999px;
  }
  .menu-scroll-wrap::-webkit-scrollbar-thumb:hover {
    background: rgba(200, 150, 62, 0.6);
  }

  .menu-main-content {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-sizing: border-box;
    padding-bottom: max(36px, env(safe-area-inset-bottom, 36px));
  }

  .menu-nav-column {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
  }

  .menu-stage-column {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
  }

  /* ── CONTENT PANEL ── */
  .tab-panel {
    position: relative;
    z-index: 5;
    width: 100%;
    box-sizing: border-box;
    padding: 10px 14px;
  }
  .tab-panel.hidden {
    display: none !important;
  }

  /* Divider between mode selector and content */
  .menu-divider {
    position: relative;
    z-index: 5;
    width: min(92%, 460px);
    height: 1px;
    margin: 12px auto 10px auto;
    background: linear-gradient(90deg, transparent, rgba(200, 150, 62, 0.4), transparent);
  }

  /* Responsive: on taller phones, give the hero more breathing room */
  @media (min-height: 720px) and (max-width: 959px) {
    .menu-hero { padding: 22px 16px 12px 16px; }
    .hero-logo-text { font-size: clamp(32px, 9vw, 50px); }
  }

  /* On very short screens, compress the hero */
  @media (max-height: 600px) and (max-width: 959px) {
    .menu-hero { padding: 8px 16px 4px 16px; }
    .hero-logo-text { font-size: clamp(20px, 6vw, 30px); }
    .hero-tagline { margin-top: 2px; font-size: 8px; }
    .mode-card { padding: 8px 8px 7px 8px; }
    .mode-card-icon { width: 32px; height: 32px; }
    .mode-card-icon svg { width: 16px; height: 16px; }
  }

  /* Desktop Widescreen: 2-Column Game Hub (Fall Guys Style) */
  @media (min-width: 960px) {
    .menu-main-content {
      display: grid;
      grid-template-columns: 370px 480px;
      justify-content: center;
      gap: 36px;
      align-items: start;
      padding: 24px 20px 48px 20px;
      max-width: 1080px;
      margin: 0 auto;
    }
    .menu-nav-column {
      position: sticky;
      top: 18px;
      display: flex;
      flex-direction: column;
      align-items: stretch;
      gap: 16px;
    }
    .menu-hero {
      padding: 6px 0 10px 0;
      text-align: left;
      align-items: flex-start;
    }
    .hero-logo-wrap {
      text-align: left;
    }
    .hero-logo-text {
      font-size: 46px;
      line-height: 0.95;
      text-align: left;
    }
    .hero-tagline {
      font-size: 11px;
      margin-top: 8px;
      text-align: left;
    }
    .menu-mode-row {
      flex-direction: column;
      width: 100%;
      padding: 0;
      gap: 12px;
      max-width: 100%;
    }
    .mode-card {
      max-width: 100%;
      width: 100%;
      flex-direction: row;
      align-items: center;
      text-align: left;
      gap: 16px;
      padding: 15px 18px;
      box-sizing: border-box;
    }
    .mode-card-icon {
      margin-bottom: 0;
      width: 48px;
      height: 48px;
      flex-shrink: 0;
    }
    .mode-card-meta {
      align-items: flex-start;
      text-align: left;
      gap: 3px;
    }
    .mode-card-label {
      font-size: 14px;
      white-space: nowrap;
    }
    .mode-card-sub {
      font-size: 11px;
    }
    .menu-divider {
      display: none;
    }
    .menu-stage-column {
      width: 100%;
    }
    .tab-panel {
      padding: 0;
    }
    .lobby-shell {
      max-width: 100%;
    }
  }

  /* =========================================================
     PLAY TOGETHER LOBBY UI — GAME MENU STYLE
     ========================================================= */
  .lobby-shell {
    width: 100%;
    max-width: 480px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
  }

  .stone-panel {
    position: relative;
    background: #FAF6EE;
    color: #2A2118;
    border: 2px solid #D6C4AA;
    border-radius: 24px;
    padding: 18px;
    box-shadow: 0 12px 32px rgba(42, 33, 24, 0.12), 0 3px 0 #D6C4AA;
    animation: cardEntrance 0.35s cubic-bezier(0.22,1.2,0.36,1) both;
  }
  .stone-panel::before {
    content: '';
    position: absolute;
    top: 2px; left: 14px; right: 14px;
    height: 2px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.8), transparent);
    border-radius: 999px;
    pointer-events: none;
  }

  .panel-label {
    font-family: var(--font-display);
    font-size: 11px;
    font-weight: 900;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #5A4A3B;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  .net-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 10px;
    font-weight: 900;
    letter-spacing: 0.06em;
    padding: 3px 10px;
    border-radius: 9999px;
    background: #FFFFFF;
    border: 1.5px solid #D6C4AA;
    box-shadow: 0 2px 0 #E3D6C3;
    color: #2A2118;
  }
  .net-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #94A3B8;
    position: relative;
    flex-shrink: 0;
  }
  .net-badge.online {
    background: #E4F4EC;
    border-color: #72B99B;
    color: #134A33;
  }
  .net-badge.online .net-dot {
    background: #24825B;
    box-shadow: 0 0 6px rgba(36, 130, 91, 0.45);
  }
  .net-badge.online .net-dot::after {
    content: '';
    position: absolute;
    inset: -3px;
    border-radius: 50%;
    border: 1.5px solid #24825B;
    animation: radarRing 2s cubic-bezier(0.2, 0.8, 0.4, 1) infinite;
    pointer-events: none;
  }
  @keyframes radarRing {
    0% { transform: scale(0.8); opacity: 1; }
    100% { transform: scale(2.8); opacity: 0; }
  }

  .stone-input {
    width: 100%;
    background: #FFFFFF;
    border: 1.5px solid #D6C4AA;
    border-radius: 14px;
    padding: 10px 13px;
    color: #2A2118;
    font-family: var(--font-body);
    font-size: 14.5px;
    font-weight: 800;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    box-shadow: inset 0 1px 3px rgba(42, 33, 24, 0.06);
  }
  .stone-input:focus {
    border-color: #2B72AD;
    box-shadow: 0 0 0 3px rgba(43, 114, 173, 0.18);
  }
  .stone-input.code-input {
    text-transform: uppercase;
    letter-spacing: 0.2em;
    text-align: center;
    font-family: var(--font-display);
    font-size: 16px;
    color: #1F5B8E;
  }

  /* 3 Arena Map Selector Cards */
  .arena-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 8px;
  }
  .arena-card {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    text-align: left;
    padding: 12px 16px;
    border-radius: 20px;
    border: 3.5px solid var(--toy-ink);
    box-shadow: 0 6px 0 var(--toy-ink);
    background: #FFFFFF;
    cursor: pointer;
    transition: transform 0.15s cubic-bezier(0.34,1.6,0.64,1), box-shadow 0.18s ease;
    color: var(--toy-ink);
    overflow: hidden;
  }
  .arena-card::before {
    display: none;
  }
  .arena-card:hover {
    transform: translateY(-3px) scale(1.01);
    box-shadow: 0 8px 0 var(--toy-ink);
  }
  .arena-card:active {
    transform: translateY(2px) scale(0.99);
    box-shadow: 0 2px 0 var(--toy-ink);
  }

  .arena-card.selected {
    border-color: var(--toy-ink);
    transform: translateY(-3px);
    box-shadow: 0 8px 0 var(--toy-ink), 0 0 0 3px var(--toy-tangerine);
  }

  .arena-card.a0 { background: linear-gradient(135deg, #2E1F13 0%, #1A1108 100%); border-color: #614224; }
  .arena-card.a1 { background: linear-gradient(135deg, #0E2B23 0%, #061A14 100%); border-color: #1A5444; }
  .arena-card.a2 { background: linear-gradient(135deg, #2A113D 0%, #150621 100%); border-color: #59257F; }

  .arena-card.a0.selected { background: linear-gradient(135deg, #4F331A 0%, #29180A 100%); border-color: #FFB800; box-shadow: 0 6px 0 var(--toy-ink), 0 0 16px rgba(255,184,0,0.4); }
  .arena-card.a1.selected { background: linear-gradient(135deg, #154C3D 0%, #0A261E 100%); border-color: #00D68F; box-shadow: 0 6px 0 var(--toy-ink), 0 0 16px rgba(0,214,143,0.4); }
  .arena-card.a2.selected { background: linear-gradient(135deg, #4A1A6B 0%, #240B36 100%); border-color: #C084FC; box-shadow: 0 6px 0 var(--toy-ink), 0 0 16px rgba(192,132,252,0.4); }

  /* Bespoke Vector Crest Medallions */
  .arena-crest {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border: 2.5px solid var(--toy-ink);
    box-shadow: 0 3px 0 var(--toy-ink);
    transition: transform 0.2s cubic-bezier(0.34, 1.5, 0.64, 1);
    position: relative;
    overflow: hidden;
  }
  .arena-crest-0 {
    background: radial-gradient(circle at 35% 30%, #FF9B54 0%, #FF6B1A 60%, #C44600 100%);
  }
  .arena-crest-1 {
    background: radial-gradient(circle at 35% 30%, #5472FF 0%, #1E40FF 60%, #102BB5 100%);
  }
  .arena-crest-2 {
    background: radial-gradient(circle at 35% 30%, #D4FF5E 0%, #B8FF2C 60%, #7CAE0F 100%);
  }
  .arena-card:hover .arena-crest {
    transform: scale(1.1) rotate(-4deg);
  }
  .arena-card.selected .arena-crest {
    transform: scale(1.08);
  }

  .arena-info { flex: 1; min-width: 0; }
  .arena-title {
    font-family: var(--font-display);
    font-size: 13.5px;
    font-weight: 900;
    color: #FFF8E7;
    letter-spacing: 0.05em;
    text-shadow: 0 1.5px 0 #121024;
  }
  .arena-desc {
    font-size: 11px;
    font-weight: 700;
    color: #D6C4AD;
    margin-top: 3px;
    line-height: 1.35;
  }
  .arena-check {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2.5px solid var(--toy-ink);
    box-shadow: 0 2px 0 var(--toy-ink);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: transparent;
    background: #EAEBF2;
    transition: background 0.15s ease, transform 0.15s cubic-bezier(0.34, 1.5, 0.64, 1);
  }
  .arena-card.selected .arena-check {
    background: var(--toy-lime);
    color: var(--toy-ink);
    transform: scale(1.1);
  }

  .join-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
    margin-top: 12px;
  }

  .lobby-actions-stack {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 16px;
  }
  .lobby-actions-stack .duo-btn { width: 100%; }

  /* Animated Master Play Button */
  #btn-quick-play {
    position: relative;
    overflow: hidden;
    animation: quickPlayBreath 3.2s ease-in-out infinite;
    font-size: 14.5px;
    letter-spacing: 0.08em;
  }
  #btn-quick-play::before {
    content: '';
    position: absolute;
    top: 0;
    left: -130%;
    width: 60%;
    height: 100%;
    background: linear-gradient(
      105deg,
      transparent 15%,
      rgba(255, 255, 255, 0.55) 50%,
      transparent 85%
    );
    animation: playShineBeam 3s ease-in-out infinite;
    pointer-events: none;
  }
  @keyframes playShineBeam {
    0% { left: -130%; }
    40%, 100% { left: 160%; }
  }
  @keyframes quickPlayBreath {
    0%, 100% { filter: brightness(1); }
    50% { filter: brightness(1.08); }
  }

  /* Waiting Room UI */
  .room-code-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: #FFFFFF;
    border: 1.5px solid #D6C4AA;
    border-radius: 16px;
    padding: 10px 14px;
    margin-bottom: 10px;
    box-shadow: 0 3px 0 #E3D6C3;
  }
  .room-code-val {
    font-family: var(--font-display);
    font-size: 24px;
    font-weight: 900;
    letter-spacing: 0.2em;
    color: #1F5B8E;
    text-shadow: none;
  }

  .slots-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin: 8px 0 12px 0;
  }
  .player-slot {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #F4EDE0;
    border: 1.5px solid #D6C4AA;
    border-radius: 14px;
    padding: 9px 10px;
    min-width: 0;
  }
  .player-slot.filled {
    border-color: #7BC2A2;
    background: #FFFFFF;
    box-shadow: 0 2px 6px rgba(42, 33, 24, 0.06);
  }
  .slot-orb-dot {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    flex-shrink: 0;
    border: 2px solid #D6C4AA;
    box-shadow: inset 0 2px 3px rgba(255, 255, 255, 0.5), 0 2px 4px rgba(42, 33, 24, 0.12);
  }
  .slot-meta {
    min-width: 0;
    flex: 1;
  }
  .slot-name {
    font-size: 12.5px;
    font-weight: 800;
    color: #2A2118;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .slot-role {
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #1C6949;
  }
  .slot-role.bot { color: #1E5D8F; }

  /* =========================================================
     TRAINING MODE: WINDING STAGE MAP (LIGHT PARCHMENT)
     ========================================================= */
  .map-container {
    width: 100%;
    max-width: 440px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
  }

  .unit-banner {
    position: relative;
    width: 100%;
    border-radius: 18px;
    padding: 14px 16px;
    color: #2A2118;
    margin: 16px 0 28px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    overflow: hidden;
  }
  .unit-banner::before {
    content: '';
    position: absolute;
    inset: 4px;
    border-radius: 13px;
    border: 1px solid rgba(255, 255, 255, 0.55);
    pointer-events: none;
  }
  .unit-banner:first-child { margin-top: 2px; }
  .unit-banner.u1 { background: linear-gradient(135deg, #FCEFE0 0%, #F4DFC4 100%); border: 2px solid #D9A76E; box-shadow: 0 4px 0 #C9965C; }
  .unit-banner.u2 { background: linear-gradient(135deg, #E5F5EE 0%, #CEEBE0 100%); border: 2px solid #72B99B; box-shadow: 0 4px 0 #5EA487; }
  .unit-banner.u3 { background: linear-gradient(135deg, #EFEBFB 0%, #DFD6F6 100%); border: 2px solid #A492D4; box-shadow: 0 4px 0 #8E7BC0; }
  .unit-banner.u4 { background: linear-gradient(135deg, #EBF4FC 0%, #D8E9F8 100%); border: 2px solid #86B5D9; box-shadow: 0 4px 0 #6F9EC4; }

  .unit-kicker { font-size: 10px; font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase; color: #5A4A3B; }
  .unit-name { font-family: 'Cinzel', Georgia, serif; font-size: 16.5px; font-weight: 900; margin-top: 2px; letter-spacing: 0.05em; color: #2A2118; }
  .unit-desc { font-size: 11.5px; font-weight: 700; color: #5A4A3B; margin-top: 2px; }

  .path-connector {
    width: 240px;
    height: 34px;
    margin: -8px 0 -4px 0;
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .node-row { position: relative; display: flex; flex-direction: column; align-items: center; margin-bottom: 10px; }
  .node-wrap { position: relative; display: flex; flex-direction: column; align-items: center; }

  .play-callout {
    position: absolute;
    top: -42px;
    background: linear-gradient(180deg, #FBE09B 0%, #ECC064 100%);
    color: #2A2118;
    border: 1.5px solid #C69238;
    border-radius: 12px;
    padding: 4px 14px;
    font-family: 'Cinzel', Georgia, serif;
    font-size: 11.5px;
    font-weight: 900;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    box-shadow: 0 3px 0 #B6822B, 0 6px 14px rgba(42, 33, 24, 0.15);
    animation: bobble 1.6s ease-in-out infinite;
    white-space: nowrap;
    z-index: 4;
    cursor: pointer;
  }
  .play-callout::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%) rotate(45deg);
    width: 10px;
    height: 10px;
    background: #ECC064;
    border-right: 1.5px solid #C69238;
    border-bottom: 1.5px solid #C69238;
  }
  @keyframes bobble { 0%, 100% { transform: translateY(0px); } 50% { transform: translateY(-6px); } }

  .pulse-ring {
    position: absolute;
    top: -10px;
    left: -10px;
    width: 96px;
    height: 90px;
    border-radius: 50%;
    border: 2.5px dashed rgba(185, 130, 44, 0.65);
    animation: pulseMandala 2.2s ease-out infinite;
    pointer-events: none;
  }
  @keyframes pulseMandala { 0% { transform: scale(0.94) rotate(0deg); opacity: 0.95; } 100% { transform: scale(1.24) rotate(28deg); opacity: 0; } }

  .level-node {
    position: relative;
    width: 74px;
    height: 68px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Cinzel', Georgia, serif;
    font-size: 22px;
    font-weight: 900;
    cursor: pointer;
    transition: transform 0.08s ease, box-shadow 0.08s ease;
    z-index: 2;
  }
  .level-node::after {
    content: '';
    position: absolute;
    inset: 6px;
    border-radius: 50%;
    border: 1.5px solid rgba(255, 255, 255, 0.55);
    pointer-events: none;
  }
  .level-node:active:not(.locked) { transform: translateY(4px); box-shadow: none !important; }
  .level-node.current {
    background: radial-gradient(circle at 35% 28%, #FCE19E 0%, #EAB557 65%, #D19736 100%);
    color: #2A2118;
    border: 2px solid #B67D24;
    box-shadow: 0 4px 0 #9E6A1A, 0 6px 16px rgba(182, 125, 36, 0.25);
  }
  .level-node.completed {
    background: radial-gradient(circle at 35% 28%, #D1F2E2 0%, #97D8BA 68%, #68BA94 100%);
    color: #134A33;
    border: 2px solid #4B9874;
    box-shadow: 0 4px 0 #3C7F60;
  }
  .level-node.locked {
    background: radial-gradient(circle at 35% 28%, #EFE7DA 0%, #E2D6C3 72%, #D4C5AE 100%);
    color: #6B5948;
    border: 2px solid #C2B097;
    box-shadow: 0 4px 0 #B3A085;
    cursor: not-allowed;
  }
  .node-stars { display: flex; gap: 4px; margin-top: 8px; }
  .node-label { font-size: 12px; font-weight: 800; color: #2A2118; margin-top: 3px; }

  /* =========================================================
     MINIMAL IN-GAME HUD & COUNTDOWN OVERLAY
     ========================================================= */
  #game-hud {
    position: fixed;
    top: max(14px, env(safe-area-inset-top, 14px));
    left: 14px;
    right: 14px;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    pointer-events: none;
    transition: opacity 0.2s ease;
  }
  #game-hud.hidden { opacity: 0; pointer-events: none; }

  #game-hud .duo-icon-btn {
    width: 44px;
    height: 44px;
    background: linear-gradient(180deg, rgba(26, 22, 18, 0.52) 0%, rgba(16, 14, 12, 0.42) 100%);
    border: 1.5px solid rgba(255, 255, 255, 0.34);
    border-top: 1.5px solid rgba(255, 255, 255, 0.55);
    border-bottom: 1px solid rgba(255, 255, 255, 0.18);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.14), inset 0 1px 1px rgba(255, 255, 255, 0.45);
    border-radius: var(--radius-sm);
    color: #FFFFFF;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
    pointer-events: auto;
    transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.15s ease, color 0.15s ease;
  }
  #game-hud .duo-icon-btn:hover {
    transform: translateY(-2px);
    border-color: rgba(255, 255, 255, 0.45);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45), inset 0 1px 1px rgba(255, 255, 255, 0.6);
    color: var(--toy-gold, #FFD000);
  }
  #game-hud .duo-icon-btn:active {
    transform: translateY(2px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  }

  /* Canvas Cursor Feedback */
  canvas#game-canvas, #game-container canvas {
    cursor: grab;
  }
  canvas#game-canvas.is-dragging, #game-container canvas.is-dragging {
    cursor: grabbing !important;
  }

  .hud-center-pill {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    display: inline-flex;
    align-items: center;
    gap: 14px;
    background: linear-gradient(180deg, rgba(26, 22, 18, 0.50) 0%, rgba(16, 14, 12, 0.40) 100%);
    border: 1.5px solid rgba(255, 255, 255, 0.34);
    border-top: 1.5px solid rgba(255, 255, 255, 0.55);
    border-bottom: 1.5px solid rgba(255, 255, 255, 0.18);
    box-shadow:
      0 6px 20px rgba(0, 0, 0, 0.14),
      0 2px 8px rgba(0, 0, 0, 0.25),
      inset 0 1.5px 1.5px rgba(255, 255, 255, 0.55),
      inset 0 -1.5px 2px rgba(0, 0, 0, 0.35);
    border-radius: 9999px;
    padding: 8px 22px;
    font-size: 16px;
    font-weight: 900;
    color: #FFFFFF;
    pointer-events: auto;
    position: relative;
    overflow: hidden;
  }

  .hud-center-pill::before {
    content: '';
    position: absolute;
    top: 1px;
    left: 14px;
    right: 14px;
    height: 48%;
    border-radius: 9999px 9999px 0 0;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.32) 0%, rgba(255, 255, 255, 0.02) 100%);
    pointer-events: none;
  }

  /* Multiplayer Specific Pill Glasslike & Translucent */
  #hud-multi-pill {
    background: linear-gradient(180deg, rgba(26, 22, 18, 0.50) 0%, rgba(16, 14, 12, 0.40) 100%);
    border: 1.5px solid rgba(255, 255, 255, 0.34);
    border-top: 1.5px solid rgba(255, 255, 255, 0.55);
    border-bottom: 1.5px solid rgba(255, 255, 255, 0.18);
    box-shadow:
      0 6px 20px rgba(0, 0, 0, 0.14),
      0 2px 8px rgba(0, 0, 0, 0.25),
      inset 0 1.5px 1.5px rgba(255, 255, 255, 0.55),
      inset 0 -1.5px 2px rgba(0, 0, 0, 0.35);
    color: #FFFFFF;
  }
  #hud-multi-pill #hud-rank {
    font-family: var(--font-display) !important;
    font-size: 17px;
    font-weight: 900;
    color: #FFFFFF !important;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8), 0 0 12px rgba(255, 215, 0, 0.3);
    display: inline-flex;
    align-items: baseline;
  }
  #hud-multi-pill #hud-rank sup {
    font-size: 0.68em;
    font-weight: 900;
    color: #FFD000;
    margin-left: 1.5px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
  }

  .hud-segment { display: inline-flex; align-items: center; gap: 7px; position: relative; z-index: 1; }
  .hud-divider {
    width: 2px;
    height: 18px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.45) 0%, rgba(255, 255, 255, 0.1) 100%);
    border-radius: 1px;
    box-shadow: 0 0 2px rgba(0, 0, 0, 0.3);
    position: relative;
    z-index: 1;
  }
  .hearts-wrap { display: inline-flex; align-items: center; gap: 4px; position: relative; z-index: 1; }
  #hud-progress {
    font-family: var(--font-display, inherit);
    font-size: 16px;
    font-weight: 900;
    color: #FFFFFF;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
    letter-spacing: 0.03em;
    position: relative;
    z-index: 1;
  }

  /* Race 3-2-1-GO Countdown Banner */
  #countdown-overlay {
    position: fixed;
    inset: 0;
    z-index: 25;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease;
  }
  #countdown-overlay.show { opacity: 1; }
  #countdown-text {
    font-family: var(--font-display);
    font-size: clamp(80px, 22vw, 140px);
    font-weight: 900;
    color: var(--toy-tangerine);
    -webkit-text-stroke: 4px var(--toy-ink);
    text-shadow:
      0 6px 0 var(--toy-cobalt),
      0 12px 0 var(--toy-ink),
      0 20px 40px rgba(255, 107, 26, 0.6);
    transform: scale(1);
    transition: transform 0.18s cubic-bezier(0.22, 1.5, 0.36, 1);
  }

  #game-toast {
    position: fixed;
    top: max(74px, calc(env(safe-area-inset-top, 12px) + 60px));
    left: 50%;
    transform: translateX(-50%) translateY(-8px);
    background: #FAF6EE;
    border: 1.5px solid #D6C4AA;
    box-shadow: 0 8px 22px rgba(42, 33, 24, 0.16), 0 3px 0 #D6C4AA;
    color: #2A2118;
    padding: 7px 18px;
    border-radius: 9999px;
    font-family: var(--font-body);
    font-size: 12.5px;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    opacity: 0;
    pointer-events: none;
    z-index: 38;
    transition: opacity 0.2s ease, transform 0.2s ease;
    white-space: nowrap;
  }
  #game-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

  #thumb-indicator {
    position: fixed;
    width: 112px;
    height: 112px;
    margin-left: -56px;
    margin-top: -56px;
    border-radius: 50%;
    border: 2.5px solid #2B72AD;
    background: rgba(43, 114, 173, 0.14);
    pointer-events: none;
    z-index: 15;
    opacity: 0;
    transition: opacity 0.1s ease;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  #thumb-indicator.active { opacity: 1; }
  #thumb-dot {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #E5A952;
    border: 2px solid #2A2118;
    box-shadow: 0 2px 0 #2A2118;
    transform: translate(0px, 0px);
  }

  /* =========================================================
     SOFT ALABASTER MODALS (PAUSE, VICTORY, PODIUM, FORGE)
     ========================================================= */
  .hidden {
    display: none !important;
  }

  .modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 40;
    background: rgba(32, 24, 18, 0.54);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    transition: opacity 0.22s ease;
  }
  .modal-backdrop.hidden { opacity: 0; pointer-events: none !important; display: none !important; }

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

  .duo-card {
    position: relative;
    z-index: 42;
    width: min(92vw, 390px);
    max-width: 100%;
    background: #FAF6EE;
    color: #2A2118;
    border: 2px solid #D6C4AA;
    border-radius: 24px;
    padding: 20px 18px;
    text-align: center;
    box-shadow: 0 18px 46px rgba(42, 33, 24, 0.18), 0 4px 0 #D6C4AA;
    animation: cardPop 0.22s cubic-bezier(0.22, 1.25, 0.36, 1);
    overflow: hidden;
  }
  .duo-card::before {
    content: '';
    position: absolute;
    top: 2px; left: 14px; right: 14px;
    height: 3px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.9), transparent);
    pointer-events: none;
  }
  @keyframes cardPop { 0% { transform: scale(0.92); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }

  .card-kicker {
    display: inline-block;
    font-family: var(--font-body);
    font-size: 10.5px;
    font-weight: 900;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    background: #F6E7CD;
    color: #75460F;
    border: 1.5px solid #D8BA8A;
    box-shadow: none;
    border-radius: 9999px;
    padding: 3px 12px;
    margin-bottom: 8px;
  }
  .card-heading {
    font-family: var(--font-display);
    font-size: 24px;
    font-weight: 900;
    letter-spacing: 0.04em;
    color: #2A2118;
    margin: 0 0 12px 0;
  }

  .stars-showcase { display: flex; justify-content: center; align-items: center; gap: 12px; margin: 4px 0 14px 0; }
  .star-big { transform: scale(0.3) rotate(-18deg); opacity: 0; transition: transform 0.44s cubic-bezier(0.22, 1.55, 0.36, 1), opacity 0.24s ease; }
  .star-big.popped { transform: scale(1) rotate(0deg); opacity: 1; }

  .metrics-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
  .metric-box {
    background: #FFFFFF;
    border: 1.5px solid #D6C4AA;
    box-shadow: 0 3px 0 #E3D5C1;
    border-radius: 16px;
    padding: 10px 8px;
    min-width: 0;
  }
  .metric-val {
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 900;
    color: #1F5B8E;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    min-height: 24px;
  }
  .metric-lbl {
    font-size: 10px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #5A4A3B;
    margin-top: 2px;
  }

  .modal-actions { display: flex; flex-direction: column; gap: 10px; width: 100%; }
  .modal-actions > .duo-btn { width: 100%; }
  .modal-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; }
  .modal-row .duo-btn {
    width: 100%;
    min-width: 0;
    padding: 11px 8px;
    font-size: 13px;
    gap: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Podium List inside Multiplayer Finish Modal */
  .podium-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 6px 0 14px 0;
    text-align: left;
  }
  .podium-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 12px;
    border-radius: 14px;
    background: #FFFFFF;
    border: 1.5px solid #D6C4AA;
    box-shadow: 0 2px 0 #E3D5C1;
    color: #2A2118;
  }
  .podium-row.is-me {
    border-color: #D5A357;
    background: linear-gradient(90deg, #FDF2DC 0%, #FFFFFF 100%);
    box-shadow: 0 2px 0 #D5A357;
  }
  .podium-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
  }
  .podium-rank {
    width: 28px;
    height: 28px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-display);
    font-size: 13px;
    font-weight: 900;
    background: #F4EDE0;
    border: 1.5px solid #D6C4AA;
    color: #2A2118;
    flex-shrink: 0;
  }
  .podium-rank.r1 { background: #F8D994; border-color: #C79438; color: #2A2118; }
  .podium-rank.r2 { background: #E3E8EE; border-color: #A6B2C0; color: #2A2118; }
  .podium-rank.r3 { background: #F5CFA5; border-color: #C78C50; color: #2A2118; }
  .podium-name {
    font-size: 14px;
    font-weight: 800;
    color: #2A2118;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .podium-time {
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 800;
    color: #1F5B8E;
    flex-shrink: 0;
  }

  .podium-reward-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #DCF2E7;
    border: 1.5px solid #72B99B;
    box-shadow: 0 2px 0 #5BA485;
    color: #134A33;
    border-radius: 9999px;
    padding: 5px 14px;
    font-size: 12.5px;
    font-weight: 900;
    margin-bottom: 10px;
  }

  /* Spectate Floating Bar */
  #hud-spectate-bar {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 180;
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(250, 246, 238, 0.94);
    border: 1.5px solid #D6C4AA;
    box-shadow: 0 8px 24px rgba(42, 33, 24, 0.16), 0 3px 0 #D6C4AA;
    border-radius: 9999px;
    padding: 8px 18px;
    color: #2A2118;
    font-family: var(--font-body);
    font-weight: 900;
    font-size: 0.9rem;
    pointer-events: auto;
  }
  #hud-spectate-bar.hidden {
    display: none !important;
  }

  /* Pause Settings Toggles */
  .pause-toggles {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-bottom: 14px;
  }
  .toggle-chip {
    background: #FFFFFF;
    border: 1.5px solid #D6C4AA;
    border-radius: 12px;
    box-shadow: 0 2px 0 #DFD1BC;
    padding: 9px 10px;
    color: #2A2118;
    font-family: var(--font-body);
    font-size: 11.5px;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    cursor: pointer;
    transition: transform 0.1s ease, box-shadow 0.1s ease;
  }
  .toggle-chip:hover { transform: translateY(-1px); box-shadow: 0 3px 0 #D6C4AA; }
  .toggle-chip:active { transform: translateY(1px); box-shadow: 0 1px 0 #D6C4AA; }
  .toggle-chip span {
    color: #1F5B8E;
    font-weight: 900;
    margin-left: 4px;
  }
  .toggle-chip.is-high span { color: #8A4E0F; }
  .toggle-chip.is-med span { color: #1F5B8E; }
  .toggle-chip.is-low span { color: #16553A; }

  /* =========================================================
     RELIC FORGE (TOYBOX SKIN STORE MODAL)
     ========================================================= */
  .forge-card {
    width: min(94vw, 410px);
    max-height: min(92dvh, 720px);
    padding: 20px 18px 18px 18px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    text-align: left;
    background: var(--toy-cream);
    border: 4px solid var(--toy-ink);
    border-radius: 28px;
    box-shadow: 0 12px 0 var(--toy-ink), 0 24px 60px rgba(0, 0, 0, 0.5);
  }
  .forge-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
  .forge-title {
    font-family: var(--font-display);
    font-size: 20px;
    font-weight: 900;
    letter-spacing: 0.05em;
    color: var(--toy-ink);
    margin: 0;
  }
  .forge-header-right { display: flex; align-items: center; gap: 8px; }
  .forge-stars-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #FFFFFF;
    border: 2.5px solid var(--toy-ink);
    box-shadow: 0 2px 0 var(--toy-ink);
    border-radius: 9999px;
    padding: 5px 12px;
    font-size: 13px;
    font-weight: 900;
    color: var(--toy-ink);
  }
  .forge-close-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2.5px solid var(--toy-ink);
    background: #FFFFFF;
    color: var(--toy-ink);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 3px 0 var(--toy-ink);
    transition: transform 0.1s ease, box-shadow 0.1s ease;
  }
  .forge-close-btn:hover { transform: translateY(-2px); box-shadow: 0 5px 0 var(--toy-ink); }
  .forge-close-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--toy-ink); }

  .forge-preview-wrap {
    position: relative;
    width: 100%;
    height: 172px;
    border-radius: 20px;
    overflow: hidden;
    background: radial-gradient(circle at 50% 42%, #FFFFFF 0%, #EAE8DF 80%);
    border: 3.5px solid var(--toy-ink);
    box-shadow: 0 4px 0 var(--toy-ink);
    touch-action: none;
  }
  #forge-preview-canvas { display: block; width: 100%; height: 100%; }
  .forge-preview-hint {
    position: absolute;
    bottom: 8px;
    right: 12px;
    font-family: var(--font-body);
    font-size: 10.5px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    background: var(--toy-ink);
    color: #FFFFFF;
    padding: 2px 8px;
    border-radius: 9999px;
    pointer-events: none;
  }

  .forge-selected-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
  .forge-selected-meta { min-width: 0; flex: 1; }
  .forge-skin-name {
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: 900;
    color: var(--toy-ink);
    line-height: 1.15;
  }
  .forge-skin-sub { font-size: 11.5px; font-weight: 700; color: #4D577F; margin-top: 2px; line-height: 1.25; }
  #btn-forge-action { flex-shrink: 0; padding: 11px 16px; font-size: 12px; white-space: nowrap; }

  .forge-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; width: 100%; overflow-y: auto; padding-bottom: 4px; }
  .skin-tile {
    display: flex; flex-direction: column; align-items: center; justify-content: space-between; gap: 4px;
    padding: 10px 6px 8px 6px; border-radius: 16px;
    background: #FFFFFF;
    border: 2.5px solid var(--toy-ink);
    box-shadow: 0 3px 0 var(--toy-ink);
    cursor: pointer; min-width: 0; text-align: center;
    transition: transform 0.12s ease, box-shadow 0.12s ease;
  }
  .skin-tile:hover { transform: translateY(-2px); box-shadow: 0 5px 0 var(--toy-ink); }
  .skin-tile:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--toy-ink); }
  .skin-tile.selected {
    border-color: var(--toy-ink);
    background: #FFF8E7;
    box-shadow: 0 4px 0 var(--toy-ink), 0 0 0 2.5px var(--toy-cobalt);
    transform: scale(1.03);
  }
  .skin-tile.locked { opacity: 0.75; }
  .skin-tile-title { font-size: 11.5px; font-weight: 800; color: var(--toy-ink); width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .skin-tile-badge { display: inline-flex; align-items: center; justify-content: center; gap: 3px; font-size: 10px; font-weight: 900; border-radius: 9999px; padding: 2px 8px; border: 1.5px solid var(--toy-ink); }
  .skin-tile-badge.equipped { background: var(--toy-lime); color: var(--toy-ink); }
  .skin-tile-badge.unlocked { background: var(--toy-gold); color: var(--toy-ink); }
  .skin-tile-badge.locked { background: #CBD5E1; color: #475569; }


/* Restored Authentic Styles from Raw HTML */
.duo-btn-jade:active {
    transform: translateY(2px);
    box-shadow: 0 1px 0 #62A689 !important;
  }

.map-scroll {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    padding: 18px 16px max(64px, env(safe-area-inset-bottom, 64px)) 16px;
  }

.level-node.completed::after {
    border-color: rgba(255, 255, 255, 0.65);
  }

.level-node.locked::after {
    border-color: rgba(255, 255, 255, 0.45);
  }

.tablet-corner {
    position: absolute;
    width: 22px;
    height: 22px;
    color: var(--brass);
    opacity: 0.72;
    pointer-events: none;
  }
