
  :root {
    --sky-top:    #b6e5ff;
    --sky-mid:    #ffd5ec;
    --sky-bot:    #ffe9b0;
    --ground:     #6dbf52;
    --ground-dk:  #3f8a35;
    --platform:   #d8a878;
    --platform-dk:#9c6f48;
    --ink:        #3a2d4f;
  }
  html, body {
    margin: 0;
    padding: 0;
    /* svh = SMALL viewport height: stable on iOS while the browser chrome
       shows/hides (dvh re-layouts the whole game mid-hop). */
    height: 100svh;
    font-family: "Comic Sans MS", "Chalkboard SE", "Baloo", system-ui, sans-serif;
    color: var(--ink);
    background:
      url('/assets/kenney/newplatformerpack1.1/Sprites/Backgrounds/Double/background_color_hills.png')
        bottom center / 100vw auto no-repeat fixed,
      linear-gradient(180deg, var(--sky-top) 0%, var(--sky-mid) 60%, var(--sky-bot) 100%);
    overflow: hidden;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: none;
  }

  header {
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: space-between;
    /* Safe-area padding keeps Home/score cards clear of the notch in
       landscape (where most kids hold the phone). */
    padding: max(8px, env(safe-area-inset-top))
             max(14px, env(safe-area-inset-right))
             8px
             max(14px, env(safe-area-inset-left));
    pointer-events: none;
  }
  header > * { pointer-events: auto; }
  .home-btn, .music-btn {
    background: #fff;
    border: 3px solid #ff8fb8;
    border-radius: 999px;
    padding: 6px 14px;
    font: inherit;
    font-weight: 700;
    color: #c2185b;
    text-decoration: none;
    box-shadow: 0 3px 0 #ff8fb8;
    cursor: pointer;
  }
  .music-btn { border-color: #66d2ff; color: #2a86b3; box-shadow: 0 3px 0 #66d2ff; }
  .music-btn.on { background: #66d2ff; color: #fff; }
  .header-left, .header-right { display: flex; gap: 8px; align-items: center; }
  .scorecard, .timecard, .bestcard {
    background: #fff;
    border-radius: 14px;
    padding: 4px 12px;
    font-weight: 700;
    border: 3px solid #ffd166;
    box-shadow: 0 3px 0 #e0a93b;
    white-space: nowrap;
  }
  .scorecard { border-color: #ffd166; box-shadow: 0 3px 0 #e0a93b; }
  .scorecard .num { color: #c2185b; font-size: 22px; margin-left: 4px; }
  .timecard  { border-color: #66d2ff; box-shadow: 0 3px 0 #2a86b3; }
  .timecard .num { color: #2a86b3; font-size: 20px; margin-left: 4px; }
  .timecard.urgent { animation: urgentPulse 0.6s ease-in-out infinite; border-color: #ff6b9d; box-shadow: 0 3px 0 #c2185b; }
  .timecard.urgent .num { color: #c2185b; }
  @keyframes urgentPulse {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.05); }
  }
  .bestcard { border-color: #d8a878; box-shadow: 0 3px 0 #9c6f48; }
  .bestcard .num { color: #6b4a2b; font-size: 18px; margin-left: 4px; }

  /* Round-theme badge. Sits centered under the header so the header
     cards stay where they are. Updates whenever the server stamps a
     new round theme. */
  #theme-badge {
    position: fixed;
    top: 52px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 4;
    background: linear-gradient(135deg, #ffd166, #ff8fb8);
    border: 3px solid #fff;
    border-radius: 999px;
    padding: 4px 14px;
    font-weight: 800;
    color: #fff;
    text-shadow: 0 2px 3px rgba(0,0,0,0.35);
    box-shadow: 0 4px 10px rgba(0,0,0,0.25);
    font-size: 15px;
    pointer-events: none;
    display: none;
    white-space: nowrap;
  }
  #theme-badge.show { display: inline-block; animation: themePop 320ms cubic-bezier(.5,1.6,.4,1); }
  @keyframes themePop {
    from { transform: translateX(-50%) scale(0.6); opacity: 0; }
    to   { transform: translateX(-50%) scale(1);   opacity: 1; }
  }
  #theme-badge .icon { margin-right: 4px; font-size: 18px; }

  /* ===== Round overlays (winner + countdown + START!) ===== */
  .round-overlay {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
    pointer-events: none;
  }
  .round-overlay.show { display: flex; }
  .round-card {
    background: linear-gradient(180deg, #fff 0%, #fff5f9 100%);
    border: 4px solid #ff6bb5;
    border-radius: 24px;
    padding: 22px 28px;
    text-align: center;
    box-shadow: 0 12px 30px rgba(0,0,0,0.35);
    max-width: 90vw;
    animation: cardPop 280ms cubic-bezier(.5,1.6,.4,1) both;
  }
  @keyframes cardPop {
    from { transform: scale(0.6); opacity: 0; }
    to   { transform: scale(1);   opacity: 1; }
  }
  .round-card .crown { font-size: 36px; }
  .round-card .winner-line {
    font-size: clamp(22px, 4vw, 32px);
    color: #c2185b;
    margin: 6px 0 2px;
  }
  .round-card .winner-name {
    font-size: clamp(20px, 4vw, 28px);
    color: #6b1b6b;
  }
  .round-card .winner-score {
    font-size: clamp(36px, 8vw, 56px);
    font-weight: 900;
    color: #c2185b;
    text-shadow: 0 3px 0 #ff8fb8;
    margin: 8px 0;
  }
  /* Round standings — everyone's score, best first, my row highlighted. */
  .round-card .standings {
    margin: 10px auto 0;
    max-width: 300px;
    text-align: left;
  }
  .round-card .srow {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #fff;
    border: 2px solid #ffd9ec;
    border-radius: 12px;
    padding: 4px 10px;
    margin: 4px 0;
    font-size: 15px;
    font-weight: 700;
  }
  .round-card .srow.mine { border-color: #ffce4a; background: #fff6dd; }
  .round-card .srow .medal { width: 26px; text-align: center; }
  .round-card .srow .nm {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #6b1b6b;
  }
  .round-card .srow .sc { color: #c2185b; }

  .round-card .next-line {
    font-size: clamp(16px, 3vw, 22px);
    color: #2a86b3;
    margin-top: 14px;
  }
  .round-card .countdown {
    font-size: clamp(48px, 10vw, 80px);
    font-weight: 900;
    color: #2a86b3;
    text-shadow: 0 4px 0 #66d2ff;
    line-height: 1;
  }
  /* Big START! banner */
  .start-banner {
    position: fixed;
    inset: 0;
    z-index: 51;
    display: none;
    align-items: center;
    justify-content: center;
    pointer-events: none;
  }
  .start-banner.show { display: flex; animation: startFlash 1s ease-out forwards; }
  .start-banner .text {
    font-size: clamp(72px, 16vw, 140px);
    font-weight: 900;
    color: #fff;
    text-shadow:
      0 0 18px #ff6bb5,
      0 6px 0 #c2185b,
      0 8px 22px rgba(0,0,0,0.4);
    transform: scale(0.6);
    animation: startBoom 1s cubic-bezier(.5,1.6,.4,1) forwards;
  }
  @keyframes startBoom {
    0%   { transform: scale(0.4) rotate(-8deg); opacity: 0; }
    20%  { transform: scale(1.2) rotate(4deg);  opacity: 1; }
    60%  { transform: scale(1)   rotate(0deg);  opacity: 1; }
    100% { transform: scale(1.1) rotate(0deg);  opacity: 0; }
  }
  @keyframes startFlash {
    0%, 100% { background: rgba(255,255,255,0); }
    20%      { background: rgba(255,255,255,0.6); }
  }

  /* ===== World ===== */
  /* The world is a 0..100 coordinate space mapped to the viewport. */
  #world {
    position: fixed;
    inset: 0;
    overflow: hidden;
  }
  /* Ground: Kenney dirt block tiles. Top row has the grassy tile,
     everything below is the center dirt tile, both repeated. */
  #world .ground {
    position: absolute;
    left: 0; right: 0;
    bottom: 0;
    height: 18%;
    background-image:
      url('/assets/kenney/newplatformerpack1.1/Sprites/Tiles/Default/terrain_dirt_block_top.png'),
      url('/assets/kenney/newplatformerpack1.1/Sprites/Tiles/Default/terrain_dirt_block_center.png');
    background-position: 0 0, 0 56px;
    background-size: 56px 56px, 56px 56px;
    background-repeat: repeat-x, repeat;
    background-color: #6b4a2b;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    z-index: 1;
  }
  /* Bushes + cacti decorating the grass strip. They sit on top of the
     ground tile, in front of distant hills but behind platforms. */
  .decor {
    position: absolute;
    bottom: 18%;            /* grass-strip top */
    width: 36px;
    height: 36px;
    background-position: bottom center;
    background-size: contain;
    background-repeat: no-repeat;
    transform: translate(-50%, 8%);  /* feet "rooted" into the grass */
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    pointer-events: none;
    z-index: 2;
    filter: drop-shadow(0 2px 2px rgba(0,0,0,0.18));
  }
  .decor.bush   { background-image: url('/assets/kenney/newplatformerpack1.1/Sprites/Tiles/Default/bush.png');   width: 38px; height: 26px; }
  .decor.cactus { background-image: url('/assets/kenney/newplatformerpack1.1/Sprites/Tiles/Default/cactus.png'); width: 30px; height: 42px; }
  /* Floating platforms: left edge, middle filler, right edge — three
     Kenney horizontal dirt tiles stitched together. */
  .platform {
    position: absolute;
    height: 28px;
    background-image:
      url('/assets/kenney/newplatformerpack1.1/Sprites/Tiles/Default/terrain_dirt_horizontal_left.png'),
      url('/assets/kenney/newplatformerpack1.1/Sprites/Tiles/Default/terrain_dirt_horizontal_right.png'),
      url('/assets/kenney/newplatformerpack1.1/Sprites/Tiles/Default/terrain_dirt_horizontal_middle.png');
    background-position: left top, right top, center top;
    background-size: 28px 28px, 28px 28px, 28px 28px;
    background-repeat: no-repeat, no-repeat, repeat-x;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    z-index: 2;
  }

  /* Player + remote players */
  .player {
    position: absolute;
    width: 56px;
    height: 56px;
    transform: translate(-50%, -100%);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    pointer-events: none;
    transition: filter 120ms;
  }
  .player .body {
    font-size: 44px;
    line-height: 1;
    filter: drop-shadow(0 3px 2px rgba(0,0,0,0.25));
    transition: transform 60ms ease-out;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    height: 100%;
    width: 100%;
  }
  .player .body img {
    width: 56px;
    height: 56px;
    object-fit: contain;
    image-rendering: -webkit-optimize-contrast;
    pointer-events: none;
  }
  .player.face-left .body { transform: scaleX(-1); }
  /* Squash & stretch juice. Uses the standalone `scale` property so it
     COMPOSES with the face-left scaleX(-1) transform instead of
     overriding it (older browsers just skip the effect). */
  .player .body { transform-origin: 50% 100%; }
  .player .body.squash-jump { animation: squashJump 220ms ease-out; }
  .player .body.squash-land { animation: squashLand 200ms ease-out; }
  @keyframes squashJump {
    0%   { scale: 1.12 0.85; }
    45%  { scale: 0.88 1.14; }
    100% { scale: 1 1; }
  }
  @keyframes squashLand {
    0%   { scale: 1.18 0.78; }
    100% { scale: 1 1; }
  }
  .player .name {
    position: absolute;
    bottom: 100%;
    margin-bottom: 4px;
    background: #fff;
    border: 2px solid #b08bd8;
    border-radius: 999px;
    padding: 1px 8px;
    font-size: 12px;
    font-weight: 700;
    color: var(--ink);
    white-space: nowrap;
  }
  .player.me .name { border-color: #ff8fb8; color: #c2185b; }

  /* Coins — three Kenney variants. Class set by JS from coin.kind. */
  .coin {
    position: absolute;
    width: 32px;
    height: 32px;
    transform: translate(-50%, -50%);
    background-position: center;
    background-size: contain;
    background-repeat: no-repeat;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    filter: drop-shadow(0 2px 3px rgba(0,0,0,0.3));
    animation: coinSpin 1.6s ease-in-out infinite;
    pointer-events: none;
  }
  .coin.bronze { background-image: url('/assets/kenney/newplatformerpack1.1/Sprites/Tiles/Default/coin_bronze.png'); }
  .coin.silver { background-image: url('/assets/kenney/newplatformerpack1.1/Sprites/Tiles/Default/coin_silver.png'); }
  .coin.gold   { background-image: url('/assets/kenney/newplatformerpack1.1/Sprites/Tiles/Default/coin_gold.png');
                 filter: drop-shadow(0 2px 3px rgba(0,0,0,0.3))
                         drop-shadow(0 0 8px rgba(255,209,102,0.7)); }
  .coin.pop { z-index: 3; }

  /* Event banner — pops at the top of the screen for ~1.4s when a
     sprinkled event fires. */
  #event-banner {
    position: fixed;
    top: 130px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 6;
    background: linear-gradient(135deg, #ff6bb5, #ffd166);
    border: 3px solid #fff;
    border-radius: 16px;
    padding: 6px 18px;
    font-weight: 800;
    color: #fff;
    text-shadow: 0 2px 3px rgba(0,0,0,0.4);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    font-size: 22px;
    pointer-events: none;
    opacity: 0;
    white-space: nowrap;
  }
  #event-banner.show { animation: bannerPop 1.4s ease-out; }
  @keyframes bannerPop {
    0%   { opacity: 0; transform: translate(-50%, 14px) scale(0.6); }
    20%  { opacity: 1; transform: translate(-50%, 0)    scale(1.08); }
    60%  { opacity: 1; transform: translate(-50%, 0)    scale(1); }
    100% { opacity: 0; transform: translate(-50%, -10px) scale(0.95); }
  }

  /* Bonus platform — sparkly variant of the regular platform. */
  .bonus-platform {
    position: absolute;
    height: 28px;
    background: linear-gradient(180deg, #ffe066 0%, #ff8fb8 100%);
    border: 3px solid #fff;
    border-radius: 14px;
    box-shadow: 0 0 14px #ffd166, 0 4px 6px rgba(0,0,0,0.3);
    z-index: 2;
    animation: bonusGlow 0.9s ease-in-out infinite;
    pointer-events: none;
  }
  @keyframes bonusGlow {
    0%, 100% { filter: brightness(1)   saturate(1); }
    50%      { filter: brightness(1.2) saturate(1.4); }
  }

  /* Confetti + firework particles. Animated by CSS so we don't need
     a per-particle JS update loop. */
  .confetti {
    position: absolute;
    width: 10px;
    height: 14px;
    pointer-events: none;
    z-index: 4;
    border-radius: 2px;
    will-change: transform;
    animation: confettiFall 1500ms linear forwards;
  }
  @keyframes confettiFall {
    0%   { transform: translate(0, 0) rotate(0deg);    opacity: 1; }
    100% { transform: translate(var(--cx, 0), 60vh) rotate(var(--cr, 360deg)); opacity: 0; }
  }
  .firework {
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    pointer-events: none;
    z-index: 4;
    will-change: transform, opacity;
    animation: fireworkBurst 900ms ease-out forwards;
  }
  @keyframes fireworkBurst {
    0%   { transform: translate(0, 0) scale(0.6); opacity: 1; }
    100% { transform: translate(var(--fx, 0), var(--fy, 0)) scale(1.4); opacity: 0; }
  }

  /* Disco mode — slow hue cycle on the body background. */
  body.disco {
    animation: discoBg 1.6s linear infinite;
  }
  @keyframes discoBg {
    0%   { filter: hue-rotate(0deg)   saturate(1.2); }
    50%  { filter: hue-rotate(180deg) saturate(1.4); }
    100% { filter: hue-rotate(360deg) saturate(1.2); }
  }

  /* Slow-zone — a translucent circle where falling coins get extra
     time. Purely visual cue; the slowdown math runs in tickBurst. */
  .slow-zone {
    position: absolute;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    border: 3px dashed #b29eff;
    background: radial-gradient(circle, rgba(178,158,255,0.15), rgba(178,158,255,0));
    pointer-events: none;
    z-index: 1;
    animation: slowPulse 1.4s ease-in-out infinite;
  }
  @keyframes slowPulse {
    0%, 100% { transform: translate(-50%, -50%) scale(1);   opacity: 0.8; }
    50%      { transform: translate(-50%, -50%) scale(1.06); opacity: 1; }
  }

  /* Friendly enemies that bump (never kill) the local player.
     Real Kenney sprites, 2 frames each: #world.f2 (toggled every 250ms by
     the game loop) flips every enemy to its second frame in one class
     change. The cloud/ghost ids kept their names for seed stability but
     now draw as a buzzing fly and a silly flying fish. */
  .enemy {
    position: absolute;
    width: 44px;
    height: 44px;
    transform: translate(-50%, -50%);
    background-position: center;
    background-size: contain;
    background-repeat: no-repeat;
    pointer-events: none;
    z-index: 2;
    filter: drop-shadow(0 3px 3px rgba(0,0,0,0.25));
    animation: enemyBob 1.4s ease-in-out infinite;
  }
  .enemy-bee   { background-image: url('/assets/kenney/newplatformerpack1.1/Sprites/Enemies/Default/bee_a.png'); }
  .enemy-slime { background-image: url('/assets/kenney/newplatformerpack1.1/Sprites/Enemies/Default/slime_normal_walk_a.png'); }
  .enemy-cloud { background-image: url('/assets/kenney/newplatformerpack1.1/Sprites/Enemies/Default/fly_a.png'); }
  .enemy-ghost { background-image: url('/assets/kenney/newplatformerpack1.1/Sprites/Enemies/Default/fish_blue_swim_a.png'); }
  #world.f2 .enemy-bee   { background-image: url('/assets/kenney/newplatformerpack1.1/Sprites/Enemies/Default/bee_b.png'); }
  #world.f2 .enemy-slime { background-image: url('/assets/kenney/newplatformerpack1.1/Sprites/Enemies/Default/slime_normal_walk_b.png'); }
  #world.f2 .enemy-cloud { background-image: url('/assets/kenney/newplatformerpack1.1/Sprites/Enemies/Default/fly_b.png'); }
  #world.f2 .enemy-ghost { background-image: url('/assets/kenney/newplatformerpack1.1/Sprites/Enemies/Default/fish_blue_swim_b.png'); }
  @keyframes enemyBob {
    0%, 100% { transform: translate(-50%, -50%) scale(1); }
    50%      { transform: translate(-50%, -54%) scale(1.04); }
  }

  /* Knockback hit flash on the player sprite (0.25s, auto-removed). */
  .player.hit-flash .body {
    filter: drop-shadow(0 0 16px #ff4747)
            drop-shadow(0 0 10px #ff8a8a)
            brightness(1.6) saturate(1.3);
    animation: hitJitter 0.25s linear;
  }
  @keyframes hitJitter {
    0%   { transform: translate(0, 0) rotate(0deg); }
    25%  { transform: translate(-3px, -1px) rotate(-3deg); }
    50%  { transform: translate(3px, 1px)  rotate(3deg); }
    75%  { transform: translate(-2px, 2px) rotate(-2deg); }
    100% { transform: translate(0, 0) rotate(0deg); }
  }

  /* Whole-world screen shake when the local player takes a bump. */
  #world.shake { animation: worldShake 0.4s ease-out; }
  @keyframes worldShake {
    0%   { transform: translate(0, 0); }
    20%  { transform: translate(-4px, 2px); }
    40%  { transform: translate(4px, -3px); }
    60%  { transform: translate(-3px, 3px); }
    80%  { transform: translate(3px, -2px); }
    100% { transform: translate(0, 0); }
  }

  /* Power-up pickup — floating collectible. .powerup-<type> tints the
     glow + gradient so each type reads at a glance. */
  .powerup {
    position: absolute;
    width: 44px;
    height: 44px;
    transform: translate(-50%, -50%);
    font-size: 32px;
    line-height: 44px;
    text-align: center;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, #fff, #ffd9ec 60%, #ff6bb5);
    box-shadow: 0 0 14px #ff8fb8, 0 4px 6px rgba(0,0,0,0.3);
    pointer-events: none;
    animation: powerupFloat 1.6s ease-in-out infinite;
    z-index: 3;
  }
  .powerup-magnet  { background: radial-gradient(circle at 30% 30%, #fff, #ffd9ec 60%, #ff6bb5); box-shadow: 0 0 14px #ff8fb8, 0 4px 6px rgba(0,0,0,0.3); }
  .powerup-jetpack { background: radial-gradient(circle at 30% 30%, #fff, #ffd6a8 60%, #ff7a3d); box-shadow: 0 0 14px #ffae6a, 0 4px 6px rgba(0,0,0,0.3); }
  .powerup-star    { background: radial-gradient(circle at 30% 30%, #fff, #fff2a8 55%, #ffc83d); box-shadow: 0 0 14px #ffd84d, 0 4px 6px rgba(0,0,0,0.3); }
  .powerup-springs { background: radial-gradient(circle at 30% 30%, #fff, #d2f5b6 60%, #5fbd3a); box-shadow: 0 0 14px #8fd968, 0 4px 6px rgba(0,0,0,0.3); }
  .powerup-slowmo  { background: radial-gradient(circle at 30% 30%, #fff, #d2c5ff 60%, #7b5dd6); box-shadow: 0 0 14px #b29eff, 0 4px 6px rgba(0,0,0,0.3); }
  @keyframes powerupFloat {
    0%, 100% { transform: translate(-50%, -50%) scale(1)    rotate(-8deg); }
    50%      { transform: translate(-50%, -65%) scale(1.08) rotate(8deg); }
  }

  /* Player auras: layered per active effect. .magnet-on (legacy name)
     stays for the magnet glow; new aura classes added per type. */
  .player.magnet-on .body {
    filter: drop-shadow(0 3px 2px rgba(0,0,0,0.25))
            drop-shadow(0 0 10px #ff6bb5)
            drop-shadow(0 0 18px #ff8fb8);
  }
  .player.star-on .body {
    filter: drop-shadow(0 3px 2px rgba(0,0,0,0.25))
            drop-shadow(0 0 12px #ffd84d)
            drop-shadow(0 0 22px #ffc83d);
  }
  .player.jetpack-on .body {
    filter: drop-shadow(0 3px 2px rgba(0,0,0,0.25))
            drop-shadow(0 0 10px #ff8a3a)
            drop-shadow(0 0 18px #ffae6a);
  }
  .player.springs-on .body {
    filter: drop-shadow(0 3px 2px rgba(0,0,0,0.25))
            drop-shadow(0 0 8px #8fd968);
  }
  .player.slowmo-on .body {
    filter: drop-shadow(0 3px 2px rgba(0,0,0,0.25))
            drop-shadow(0 0 10px #b29eff)
            drop-shadow(0 0 18px #7b5dd6);
  }

  /* HUD: row of chips, one per active power-up. Sits below the
     theme badge. */
  #powerup-hud {
    position: fixed;
    top: 92px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 5;
    display: flex;
    gap: 6px;
    pointer-events: none;
    max-width: 96vw;
    flex-wrap: wrap;
    justify-content: center;
  }
  .powerup-chip {
    background: linear-gradient(135deg, #ff6bb5, #ffd166);
    border: 3px solid #fff;
    border-radius: 999px;
    padding: 3px 11px;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 2px 3px rgba(0,0,0,0.35);
    box-shadow: 0 4px 10px rgba(0,0,0,0.25);
    font-size: 15px;
    white-space: nowrap;
    animation: powerupPulse 0.6s ease-in-out infinite;
  }
  .powerup-chip-magnet  { background: linear-gradient(135deg, #ff6bb5, #ffd166); }
  .powerup-chip-jetpack { background: linear-gradient(135deg, #ff7a3d, #ffd166); }
  .powerup-chip-star    { background: linear-gradient(135deg, #ffc83d, #fff2a8); color: #6b4a00; text-shadow: 0 1px 0 rgba(255,255,255,0.5); }
  .powerup-chip-springs { background: linear-gradient(135deg, #5fbd3a, #d2f5b6); color: #1a4d0a; text-shadow: 0 1px 0 rgba(255,255,255,0.5); }
  .powerup-chip-slowmo  { background: linear-gradient(135deg, #7b5dd6, #d2c5ff); }
  @keyframes powerupPulse {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.06); }
  }
  @keyframes coinSpin {
    0%, 100% { transform: translate(-50%, -50%) scale(1)   rotate(0deg); }
    50%      { transform: translate(-50%, -52%) scale(1.1) rotate(20deg); }
  }
  .coin.pop {
    animation: coinPop 320ms ease-out forwards;
  }
  @keyframes coinPop {
    0%   { transform: translate(-50%, -50%) scale(1);   opacity: 1; }
    100% { transform: translate(-50%, -120%) scale(1.6); opacity: 0; }
  }

  /* ===== On-screen buttons ===== */
  #controls {
    position: fixed;
    bottom: max(14px, env(safe-area-inset-bottom));
    left: 0; right: 0;
    z-index: 6;
    display: flex;
    justify-content: space-between;
    padding: 0 14px;
    pointer-events: none;
  }
  .pad {
    display: flex;
    gap: 12px;
    pointer-events: auto;
  }
  .btn {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    /* Hitbox = visible circle. clip-path clips both the rendering and
       the pointer-events area to the inscribed circle, so corner taps
       don't register. Press shadow uses filter: drop-shadow (not
       box-shadow) so it survives the clip and hugs the circle. */
    clip-path: circle(50%);
    border: 4px solid #fff;
    font-size: 30px;
    font-weight: 700;
    color: #fff;
    background: #ff8fb8;
    filter: drop-shadow(0 4px 0 #c2185b) drop-shadow(0 6px 14px rgba(0,0,0,0.2));
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
    touch-action: manipulation;
  }
  .btn:active { transform: translateY(2px); filter: drop-shadow(0 2px 0 #c2185b) drop-shadow(0 4px 10px rgba(0,0,0,0.2)); }
  .btn.jump {
    background: #66d2ff;
    filter: drop-shadow(0 4px 0 #2a86b3) drop-shadow(0 6px 14px rgba(0,0,0,0.2));
    width: 80px; height: 80px;
    font-size: 26px;
  }
  .btn.jump:active { filter: drop-shadow(0 2px 0 #2a86b3) drop-shadow(0 4px 10px rgba(0,0,0,0.2)); }

  /* hide on big screens — keyboard works there */
  @media (min-width: 900px) and (hover: hover) {
    #controls { display: none; }
  }

  #status {
    position: fixed;
    left: 50%;
    top: 92px;
    transform: translateX(-50%);
    background: rgba(255,255,255,0.85);
    border-radius: 999px;
    padding: 4px 12px;
    font-size: 13px;
    font-weight: 700;
    color: #6a1b6a;
    z-index: 4;
    pointer-events: none;
  }
  #status.hide { display: none; }

  /* Princess-Run-style title screen — full-bleed painted hero art that
     doubles as the asset-loading curtain. */
  #title-screen {
    position: fixed; inset: 0;
    z-index: 9000;
    display: grid; place-items: center;
    transition: opacity 0.5s ease;
    background: #0a1a3a;
    overflow: hidden;
  }
  #title-screen.hide,
  #title-screen.hide * {
    pointer-events: none;
  }
  #title-screen.hide { opacity: 0; }
  /* KGLobby host overrides: the standard lobby card replaces the old absolute
     title-art/wood-button layout, so neutralize those positioning rules. */
  #title-screen.kgl-host { display: flex; align-items: center; justify-content: center; padding: 18px; }
  #title-screen.kgl-host #title-text {
    position: static; left: auto; top: auto; transform: none;
    width: auto; line-height: 1.1;
  }
  #title-screen #title-art {
    position: absolute; inset: 0;
    width: 100%; height: 100%;
    object-fit: cover; object-position: center;
    z-index: 0; pointer-events: none;
  }
  #title-screen #title-text {
    position: absolute; z-index: 1;
    left: 50%; top: 6vh;
    transform: translateX(-50%);
    text-align: center;
    pointer-events: none; user-select: none;
    line-height: 0.9;
    font-family: "Fredoka", "Comic Sans MS", system-ui, sans-serif;
    font-weight: 800;
    width: max-content;
  }
  #title-screen #title-text .row1,
  #title-screen #title-text .row2 {
    display: block;
    color: #fff7d6;
    letter-spacing: 2px;
    text-shadow:
      -3px 0 0 #1a2440, 3px 0 0 #1a2440,
      0 -3px 0 #1a2440, 0 3px 0 #1a2440,
      -3px -3px 0 #1a2440, 3px 3px 0 #1a2440,
      -3px 3px 0 #1a2440, 3px -3px 0 #1a2440,
      0 6px 0 rgba(0,0,0,0.35),
      0 12px 22px rgba(0,0,0,0.55);
    animation: title-bob 2.4s ease-in-out infinite alternate;
  }
  #title-screen #title-text .row1 {
    font-size: clamp(24px, 6.5vw, 76px);
    color: #ffe18f;
    margin-bottom: 4px;
  }
  #title-screen #title-text .row2 {
    font-size: clamp(40px, 11vw, 132px);
    color: #ffdf63;
    letter-spacing: 4px;
    animation-delay: 0.2s;
  }
  @keyframes title-bob {
    from { transform: translateY(0)    rotate(-1deg); }
    to   { transform: translateY(-6px) rotate(1deg); }
  }
  #title-screen .title-actions {
    position: absolute; z-index: 1;
    left: 50%; bottom: 10vh;
    transform: translateX(-50%);
    display: flex; flex-direction: column;
    align-items: center; gap: 14px;
  }
  #title-screen .wood-btn {
    appearance: none; border: none; cursor: pointer;
    font-family: "Georgia", "Times New Roman", serif;
    font-weight: 900;
    font-size: clamp(20px, 3.4vw, 34px);
    letter-spacing: 0.06em;
    color: #4a2a14;
    text-shadow: 0 1px 0 rgba(255, 240, 210, 0.7);
    padding: 0.5em 1.6em;
    border-radius: 18px;
    background: linear-gradient(180deg, #fbe6b1 0%, #f1c878 45%, #d99a3f 100%);
    box-shadow:
      0 0 0 4px #4a2a14,
      0 0 0 7px #b6803a,
      inset 0 4px 0 rgba(255, 250, 220, 0.65),
      inset 0 -6px 8px rgba(120, 60, 20, 0.45),
      0 8px 14px rgba(0, 0, 0, 0.45);
    transition: transform 0.12s ease;
  }
  #title-screen .wood-btn:hover  { transform: translateY(-2px); }
  #title-screen .wood-btn:active { transform: translateY(2px); }
  #title-screen .wood-btn:disabled { cursor: wait; filter: saturate(0.5) brightness(0.85); }
