
  :root {
    --sky: #87ceeb;
    --sky-2: #b8e0f0;
    --grass: #7ec865;
    --grass-dark: #5ea849;
    --ink: #2b4a2b;
    --accent: #ff8fa3;
  }

  * { box-sizing: border-box; }

  html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    height: 100svh;   /* iOS: track the small viewport, not the URL-bar guess */
    overflow: hidden;
    font-family: "Comic Sans MS", "Chalkboard SE", "Baloo", system-ui, sans-serif;
    color: var(--ink);
    background: linear-gradient(180deg,
      #87ceeb 0%,
      #b8e0f0 50%,
      #cdf0df 72%,
      #98d982 75%,
      #7ec865 100%);
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: none;
  }

  #game-area {
    position: fixed;
    inset: 0;
    overflow: hidden;
  }

  /* Clouds in the sky */
  .cloud {
    position: absolute;
    width: 110px;
    height: 70px;
    opacity: 0.92;
    pointer-events: none;
    animation: cloudDrift 50s linear infinite;
  }
  .cloud img { width: 100%; height: 100%; object-fit: contain; display: block; }
  .cloud.c1 { top: 8%;  animation-delay: 0s; }
  .cloud.c2 { top: 18%; animation-delay: -25s; width: 140px; height: 90px; }
  .cloud.c3 { top: 30%; animation-delay: -12s; width: 90px;  height: 56px; opacity: 0.78; }
  @keyframes cloudDrift {
    0%   { left: -15%; }
    100% { left: 115%; }
  }

  /* Kitten character — GPU-composited via transform-only positioning */
  #kitten {
    position: absolute;
    bottom: 10%;
    left: 0;
    width: clamp(70px, 12vw, 110px);
    height: clamp(70px, 12vw, 110px);
    line-height: 0;
    /* JS sets: transform: translate3d(x,0,0) translateX(-50%) scale(s) */
    transform: translate3d(0,0,0) translateX(-50%);
    will-change: transform;
    z-index: 5;
    transform-origin: center bottom;
    transition: filter 200ms ease-out;
  }
  #kitten-inner {
    width: 100%;
    height: 100%;
    transform-origin: center bottom;
    filter: drop-shadow(0 4px 4px rgba(0,0,0,0.2));
  }
  #kitten-inner img { display: block; width: 100%; height: 100%; object-fit: contain; }
  #kitten.hop #kitten-inner { animation: kittenHop 300ms ease-out; }
  @keyframes kittenHop {
    0%   { transform: translateY(0);    }
    50%  { transform: translateY(-10%); }
    100% { transform: translateY(0);    }
  }
  #kitten.big #kitten-inner {
    animation: bigPulse 0.5s ease-in-out infinite, rainbowHue 1s linear infinite;
    filter: drop-shadow(0 0 18px #ffd166) drop-shadow(0 0 10px #ff6bb5) drop-shadow(0 4px 4px rgba(0,0,0,0.3));
  }
  @keyframes bigPulse {
    0%, 100% { transform: scale(1);    }
    50%      { transform: scale(1.08); }
  }
  @keyframes rainbowHue {
    0%, 100% { filter: hue-rotate(0deg)   drop-shadow(0 0 18px #ffd166) drop-shadow(0 0 10px #ff6bb5) drop-shadow(0 4px 4px rgba(0,0,0,0.3)); }
    50%      { filter: hue-rotate(180deg) drop-shadow(0 0 18px #ffd166) drop-shadow(0 0 10px #ff6bb5) drop-shadow(0 4px 4px rgba(0,0,0,0.3)); }
  }

  .falling {
    position: absolute;
    width: 50px;
    height: 50px;
    font-size: 40px;
    line-height: 50px;
    text-align: center;
    pointer-events: none;
    filter: drop-shadow(0 2px 3px rgba(0,0,0,0.2));
    will-change: transform;
  }
  .falling img { display: block; width: 100%; height: 100%; object-fit: contain; }
  .falling.bad  { filter: drop-shadow(0 0 6px rgba(120,60,30,0.5)) drop-shadow(0 2px 3px rgba(0,0,0,0.2)); }
  .falling.star { animation: starSpin 1.2s linear infinite; font-size: 46px; line-height: 50px; }
  @keyframes starSpin {
    0%   { filter: drop-shadow(0 0 6px #ffd166) drop-shadow(0 2px 3px rgba(0,0,0,0.2)) hue-rotate(0deg); }
    100% { filter: drop-shadow(0 0 12px #ffd166) drop-shadow(0 2px 3px rgba(0,0,0,0.2)) hue-rotate(360deg); }
  }
  /* Golden fish — the blue fish sprite retinted gold + a pulsing glow. */
  .falling.gold img {
    filter: sepia(1) saturate(4.5) hue-rotate(-12deg) brightness(1.18);
  }
  .falling.gold { animation: goldGlow 0.7s ease-in-out infinite alternate; }
  @keyframes goldGlow {
    from { filter: drop-shadow(0 0 5px #ffb703)  drop-shadow(0 2px 3px rgba(0,0,0,0.2)); }
    to   { filter: drop-shadow(0 0 14px #ffd166) drop-shadow(0 2px 3px rgba(0,0,0,0.2)); }
  }

  /* Power-up countdown badge. Centered with margin:auto (NOT translateX) —
     the pulse animation's transform would override a translateX and shove
     the badge off-center. */
  #powerBadge {
    position: fixed;
    top: 58px;
    left: 0;
    right: 0;
    margin: 0 auto;
    width: fit-content;
    background: linear-gradient(135deg, #ffd166, #ff6bb5, #66d2ff);
    color: #fff;
    padding: 6px 14px;
    border-radius: 999px;
    font-weight: bold;
    font-size: 16px;
    box-shadow: 0 3px 10px rgba(0,0,0,0.2);
    z-index: 22;
    display: none;
    animation: pulse 0.8s ease-in-out infinite;
  }
  #powerBadge.show { display: block; }

  /* Golden-frenzy countdown badge — same shape, gold colors, sits below
     the super-kitty badge so both can show at once. */
  #frenzyBadge {
    position: fixed;
    top: 100px;
    left: 0;
    right: 0;
    margin: 0 auto;
    width: fit-content;
    background: linear-gradient(135deg, #ffd166, #ffb703, #ff9e00);
    color: #5b3a00;
    padding: 6px 14px;
    border-radius: 999px;
    font-weight: bold;
    font-size: 16px;
    box-shadow: 0 3px 10px rgba(0,0,0,0.2);
    z-index: 22;
    display: none;
    animation: pulse 0.8s ease-in-out infinite;
  }
  #frenzyBadge.show { display: block; }

  .sparkle {
    position: absolute;
    font-size: 28px;
    pointer-events: none;
    animation: sparkPop 600ms ease-out forwards;
    z-index: 10;
  }
  @keyframes sparkPop {
    0%   { transform: translate(-50%, -50%) scale(0.4); opacity: 0; }
    30%  { opacity: 1; }
    100% { transform: translate(-50%, -160%) scale(1.4); opacity: 0; }
  }

  #hud {
    position: fixed;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 16px;
    padding: 8px 18px;
    border-radius: 999px;
    background: rgba(255,255,255,0.85);
    box-shadow: 0 3px 10px rgba(0,0,0,0.15);
    font-size: clamp(16px, 3vw, 22px);
    z-index: 20;
    white-space: nowrap;
  }
  #hud b { color: #d6336c; }

  #home-btn, #music-btn {
    position: fixed;
    top: 10px;
    font-size: 15px;
    padding: 7px 12px;
    border-radius: 999px;
    border: 3px solid #2e8a5a;
    background: #fff;
    color: var(--ink);
    text-decoration: none;
    box-shadow: 0 3px 0 #2e8a5a;
    z-index: 30;
    font-family: inherit;
    cursor: pointer;
  }
  #home-btn  { left: 10px; }
  #music-btn { right: 10px; }
  #home-btn:active, #music-btn:active { translate: 0 2px; box-shadow: 0 1px 0 #2e8a5a; }
  #music-btn.on {
    background: linear-gradient(135deg, #ff6bb5, #ffd166);
    color: #fff;
    animation: pulse 1.2s ease-in-out infinite;
  }
  @keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.07); } }

  /* On-screen arrows for touch */
  #touch-controls {
    position: fixed;
    bottom: 12px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    padding: 0 12px;
    pointer-events: none;
    z-index: 15;
  }
  #touch-controls button {
    pointer-events: auto;
    width: 68px;
    height: 68px;
    border-radius: 50%;
    border: 4px solid #2e8a5a;
    background: rgba(255,255,255,0.85);
    box-shadow: 0 4px 0 #2e8a5a;
    cursor: pointer;
    font-family: inherit;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  #touch-controls button svg { width: 40px; height: 40px; display: block; }
  #touch-controls button:active { translate: 0 3px; box-shadow: 0 1px 0 #2e8a5a; }
  @media (min-width: 900px) { #touch-controls { display: none; } }

  /* End-of-game card */
  #endScreen {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.4);
    z-index: 40;
  }
  #endScreen.show { display: flex; }
  #endScreen .card {
    background: #fff;
    border: 6px solid var(--accent);
    border-radius: 24px;
    padding: 26px 32px;
    text-align: center;
    box-shadow: 0 12px 40px rgba(0,0,0,0.3);
    max-width: 90vw;
  }
  #endScreen h2 { margin: 0 0 6px; color: var(--accent); font-size: clamp(26px, 5vw, 40px); }
  #endScreen p  { margin: 6px 0; font-size: clamp(18px, 3vw, 22px); }
  #endScreen .big-score { font-size: clamp(44px, 9vw, 72px); color: #d6336c; margin: 6px 0; }
  #endScreen #newBest {
    color: #ffaa00;
    font-weight: bold;
    font-size: clamp(18px, 3vw, 24px);
  }
  #endScreen button {
    margin-top: 14px;
    font-family: inherit;
    font-size: 22px;
    padding: 10px 24px;
    border-radius: 999px;
    border: 3px solid var(--accent);
    background: #fff;
    color: var(--accent);
    cursor: pointer;
    box-shadow: 0 3px 0 var(--accent);
    font-weight: bold;
  }
  #endScreen button:active { translate: 0 2px; box-shadow: 0 1px 0 var(--accent); }
  #endScreen .end-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 14px;
  }
  #endScreen .end-buttons button { margin-top: 0; }
  #endScreen #noThanksBtn {
    background: linear-gradient(135deg, #66a6ff 0%, #4d8fd8 100%);
    color: #fff;
    border-color: #4d8fd8;
    box-shadow: 0 3px 0 #2d6db8;
  }
  #endScreen #noThanksBtn:active {
    translate: 0 2px;
    box-shadow: 0 1px 0 #2d6db8;
  }

  .confetti {
    position: fixed;
    top: -20px;
    font-size: 22px;
    pointer-events: none;
    animation: confettiFall linear forwards;
    z-index: 35;
  }
  @keyframes confettiFall {
    to { transform: translateY(110vh) rotate(720deg); }
  }

  #author {
    position: fixed;
    bottom: 4px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 12px;
    font-style: italic;
    color: rgba(43,74,43,0.6);
    z-index: 5;
    pointer-events: none;
  }

  /* Princess-Run-style title screen — full-bleed painted hero art that
     doubles as the asset-loading curtain. */
  #intro {
    position: fixed; inset: 0;
    z-index: 9000;
    display: grid; place-items: center;
    transition: opacity 0.5s ease;
    background: #0a1a3a;
    overflow: hidden;
  }
  #intro.hide,
  #intro.hide * {
    pointer-events: none;
  }
  #intro.hide { opacity: 0; }
  #intro #title-art {
    position: absolute; inset: 0;
    width: 100%; height: 100%;
    object-fit: cover; object-position: center;
    z-index: 0; pointer-events: none;
  }
  #intro #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;
  }
  #intro #title-text .row1,
  #intro #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;
  }
  #intro #title-text .row1 {
    font-size: clamp(24px, 6.5vw, 76px);
    color: #ffe18f;
    margin-bottom: 4px;
  }
  #intro #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); }
  }
  #intro .title-actions {
    position: absolute; z-index: 1;
    left: 50%; bottom: 10vh;
    transform: translateX(-50%);
    display: flex; flex-direction: column;
    align-items: center; gap: 14px;
  }
  #intro .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;
  }
  #intro .wood-btn:hover  { transform: translateY(-2px); }
  #intro .wood-btn:active { transform: translateY(2px); }
  #intro .wood-btn:disabled { cursor: wait; filter: saturate(0.5) brightness(0.85); }

  /* Pick-your-kitten row on the title screen */
  #skin-row {
    display: flex;
    gap: 12px;
    justify-content: center;
  }
  .skin-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    width: 74px;
    padding: 8px 4px 6px;
    border-radius: 16px;
    border: 3px solid rgba(255,255,255,0.55);
    background: rgba(10, 26, 58, 0.55);
    color: #fff7d6;
    font-family: inherit;
    font-weight: bold;
    font-size: 13px;
    cursor: pointer;
    transition: transform 0.12s ease, border-color 0.12s ease;
  }
  .skin-btn img { width: 46px; height: 46px; object-fit: contain; pointer-events: none; }
  .skin-btn:hover { transform: translateY(-2px); }
  .skin-btn.sel {
    border-color: #ffd166;
    background: rgba(10, 26, 58, 0.8);
    box-shadow: 0 0 0 3px rgba(255, 209, 102, 0.45), 0 4px 12px rgba(0,0,0,0.35);
  }

  /* Ghost kittens — friends in a party round. Same footing as the local
     kitten, softened so your own cat always reads as "you". */
  .ghost-kitten {
    position: absolute;
    bottom: 10%;
    left: 0;
    width: clamp(70px, 12vw, 110px);
    height: clamp(70px, 12vw, 110px);
    line-height: 0;
    transform: translate3d(0,0,0) translateX(-50%);
    will-change: transform;
    z-index: 4;
    opacity: 0.6;
    pointer-events: none;
    transform-origin: center bottom;
  }
  .ghost-kitten img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 4px 4px rgba(0,0,0,0.18));
  }
  .ghost-kitten.big img { transform: scale(1.6); transform-origin: center bottom; }
  .ghost-tag {
    position: absolute;
    top: -22px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255,255,255,0.9);
    color: #2b4a2b;
    font-size: 12px;
    font-weight: bold;
    padding: 2px 8px;
    border-radius: 999px;
    white-space: nowrap;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
  }

  /* Friends' final scores on the end card */
  #peerScores { margin: 4px 0 2px; }
  #peerScores .peer-title {
    font-size: clamp(14px, 2.4vw, 17px);
    color: #7a6a8a;
    font-weight: bold;
  }
  #peerScores .peer-row {
    font-size: clamp(15px, 2.6vw, 19px);
    color: #5b3b50;
    font-weight: bold;
  }
