/* ============================================================
   Match Sweets — Stylesheet (candyland / pop edition)
   ============================================================ */

:root {
    --sky-top: #7ec8f5;
    --sky-bot: #c5e8ff;
    --hill-1: #f9b5d2;
    --hill-2: #ffd6a0;
    --hill-3: #b8e6b0;
    --bg-deep: #6a3aa8;
    --bg-mid: #ab44c8;
    --bg-light: #ff7fc3;
    --accent: #ffd92e;
    --accent-2: #ff3d7a;
    --accent-3: #2dc4ff;
    --accent-4: #36e07a;
    --accent-5: #b794ff;
    --good: #36e07a;
    --bad: #ff5b5b;
    --text: #ffffff;
    --text-dark: #4a1d6e;
    --text-muted: #6e549a;
    --tray-bg: #2c0e4f;
    --tile-bg: rgba(255, 255, 255, 0.15);
    --tile-border: rgba(255, 255, 255, 0.3);
    --shadow-soft: 0 8px 24px rgba(60, 10, 80, 0.45);
    --radius-lg: 24px;
    --radius-md: 14px;
    --radius-sm: 10px;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bot: env(safe-area-inset-bottom, 0px);
}

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

html, body {
    margin: 0; padding: 0; height: 100%; overflow: hidden; overscroll-behavior: none;
    background: var(--sky-top); color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", system-ui, sans-serif;
    -webkit-font-smoothing: antialiased; touch-action: manipulation;
}

#app {
    position: fixed; inset: 0; overflow: hidden;
    background: linear-gradient(180deg, var(--sky-top) 0%, var(--sky-bot) 60%, #fde2cb 100%);
}

/* ============================================================
   Screens
   ============================================================ */
.screen { position: absolute; inset: 0; display: none; flex-direction: column;
    padding-top: var(--safe-top); padding-bottom: var(--safe-bot); }
.screen.active { display: flex; animation: screen-in 0.3s ease; }
@keyframes screen-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ============================================================
   Candyland background scenery (used on title + level select)
   ============================================================ */
.candyland-bg {
    position: absolute; inset: 0;
    background:
        url('../assets/title-bg.webp') center top / cover no-repeat,
        linear-gradient(180deg, var(--sky-top) 0%, var(--sky-bot) 65%, #ffe6c6 100%);
    overflow: hidden; pointer-events: none;
}
/* The painted title-bg.png already has sun, clouds, and hills — hide the
   CSS-drawn versions so we don't render them on top. */
.candyland-bg .cl-sun,
.candyland-bg .cl-cloud,
.candyland-bg .cl-hill { display: none; }
.cl-sun {
    position: absolute; top: 32px; right: 32px;
    width: 78px; height: 78px; border-radius: 50%;
    background: radial-gradient(circle at 40% 35%, #fff5a8 0%, #ffd92e 70%, #ff9a44 100%);
    box-shadow: 0 0 50px rgba(255, 217, 46, 0.8);
    animation: pulse-sun 4s ease-in-out infinite;
}
@keyframes pulse-sun { 0%,100% { transform: scale(1); } 50% { transform: scale(1.06); } }
.cl-cloud {
    position: absolute; background: #fff; border-radius: 60px;
    box-shadow: 0 6px 18px rgba(0,0,0,0.08);
}
.cl-cloud::before, .cl-cloud::after {
    content: ''; position: absolute; background: #fff; border-radius: 50%;
}
.cl-cloud-1 { top: 90px; left: -20px; width: 130px; height: 38px; animation: drift-r 30s linear infinite; }
.cl-cloud-1::before { width: 60px; height: 60px; top: -22px; left: 20px; }
.cl-cloud-1::after  { width: 50px; height: 50px; top: -16px; left: 60px; }
.cl-cloud-2 { top: 180px; right: -30px; width: 110px; height: 32px; animation: drift-l 38s linear infinite; }
.cl-cloud-2::before { width: 50px; height: 50px; top: -18px; left: 14px; }
.cl-cloud-2::after  { width: 44px; height: 44px; top: -14px; left: 50px; }
.cl-cloud-3 { top: 260px; left: 30%; width: 90px; height: 26px; animation: drift-r 45s linear infinite; }
.cl-cloud-3::before { width: 38px; height: 38px; top: -14px; left: 10px; }
.cl-cloud-3::after  { width: 34px; height: 34px; top: -10px; left: 40px; }
@keyframes drift-r { from { transform: translateX(0); } to { transform: translateX(140vw); } }
@keyframes drift-l { from { transform: translateX(0); } to { transform: translateX(-140vw); } }

.cl-hill {
    position: absolute; bottom: -30px; border-radius: 50% 50% 0 0 / 100% 100% 0 0;
    box-shadow: 0 -6px 18px rgba(255, 255, 255, 0.4);
}
.cl-hill-1 { left: -10%; width: 60%; height: 180px; background: var(--hill-3); }
.cl-hill-2 { right: -10%; width: 50%; height: 220px; background: var(--hill-2); }
.cl-hill-3 { left: 30%; width: 50%; height: 160px; background: var(--hill-1); }

/* ============================================================
   Title screen
   ============================================================ */
.title-bubbles { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 1; }
.title-bubbles .bubble {
    position: absolute; bottom: -80px; width: 64px; height: 64px;
    animation: bubble-float linear infinite;
    display: flex; align-items: center; justify-content: center;
    filter: drop-shadow(0 6px 12px rgba(74, 29, 110, 0.35));
}
.title-bubbles .bubble svg, .title-bubbles .bubble img { width: 100%; height: 100%; object-fit: contain; }
@keyframes bubble-float {
    0%  { transform: translateY(0) rotate(0deg); opacity: 0; }
    8%  { opacity: 0.9; }
    70% { opacity: 0.9; }
    /* Fully faded by 80% — before the fruit reaches the top edge, so it never
       renders sliced in the corners. */
    80% { opacity: 0; }
    100% { transform: translateY(-110vh) rotate(360deg); opacity: 0; }
}
.title-content { position: relative; z-index: 2; flex: 1; display: flex; flex-direction: column;
    align-items: center; justify-content: center; padding: 40px 24px; gap: 16px; }
.title-mascot {
    position: absolute; top: 8%; right: 4%;
    width: clamp(140px, 36vw, 240px); height: auto;
    z-index: 2; pointer-events: none;
    filter: drop-shadow(0 8px 18px rgba(74,29,110,0.4));
    animation: mascot-bob 2.6s ease-in-out infinite;
}
@keyframes mascot-bob {
    0%,100% { transform: translateY(0) rotate(-3deg); }
    50%     { transform: translateY(-12px) rotate(3deg); }
}
.game-title {
    margin: 0 0 8px; font-size: clamp(56px, 17vw, 100px); font-weight: 900;
    letter-spacing: -1.5px; text-align: center; line-height: 0.92;
    text-shadow: 0 5px 0 #4a1d6e, 0 8px 0 #fff, 0 14px 30px rgba(74, 29, 110, 0.5);
}
.title-word { display: block; color: var(--accent-2); transform: rotate(-3deg);
    -webkit-text-stroke: 3px #fff; animation: bob 3s ease-in-out infinite; }
.title-word-2 { color: var(--accent-3); transform: rotate(2deg);
    animation: bob2 3s ease-in-out infinite 0.4s; }
@keyframes bob  { 0%,100%{ transform: translateY(0) rotate(-3deg);} 50%{ transform: translateY(-10px) rotate(-3deg);} }
@keyframes bob2 { 0%,100%{ transform: translateY(0) rotate(2deg);}  50%{ transform: translateY(-10px) rotate(2deg);} }
.game-subtitle { margin: 0 0 28px; color: #4a1d6e; font-size: 17px; text-align: center; font-weight: 700;
    text-shadow: 0 2px 0 rgba(255,255,255,0.6); }
.title-credits { position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%);
    font-size: 12px; color: #6e549a; font-weight: 700; }
.credits-link { color: #6e549a; text-decoration: underline; }

/* Ad overlay (mock demo + real-network pause backdrop) */
.ad-overlay {
    position: fixed; inset: 0; z-index: 200;
    background: rgba(30, 12, 50, 0.82);
    display: flex; align-items: center; justify-content: center;
    animation: screen-in 0.25s ease;
}
.ad-card {
    width: min(86%, 340px); background: #fff; border-radius: 22px;
    border: 4px solid #ffd92e; padding: 22px 20px 20px; text-align: center;
    box-shadow: 0 12px 40px rgba(0,0,0,0.5);
}
.ad-tag {
    display: inline-block; background: #4a1d6e; color: #ffe066;
    font-size: 11px; font-weight: 900; letter-spacing: 0.5px; text-transform: uppercase;
    padding: 3px 10px; border-radius: 999px; margin-bottom: 12px;
}
.ad-art { font-size: 44px; margin-bottom: 8px; }
.ad-note { color: var(--text-dark); font-weight: 800; font-size: 14px; margin-bottom: 10px; }
.ad-count { font-size: 26px; font-weight: 900; color: var(--accent-2); margin-bottom: 14px; }
.ad-skip { min-width: 180px; }
.ad-skip:disabled { opacity: 0.5; }
.music-toggle {
    position: absolute; top: 14px; left: 14px;
    width: 42px; height: 42px; border-radius: 50%;
    background: rgba(255,255,255,0.7); border: 2px solid #fff;
    color: var(--text-dark); font-size: 20px; cursor: pointer;
    box-shadow: 0 3px 0 rgba(74, 29, 110, 0.25);
}
.music-toggle.off { opacity: 0.4; }
.music-toggle .track-num {
    position: absolute; bottom: -2px; right: -2px;
    background: var(--accent-2); color: #fff;
    border-radius: 50%; width: 18px; height: 18px;
    font-size: 11px; font-weight: 900;
    display: flex; align-items: center; justify-content: center;
    border: 2px solid #fff;
    box-shadow: 0 2px 0 #b81c4d;
}
.music-toggle { position: relative; }

/* ============================================================
   Buttons
   ============================================================ */
.btn {
    border: none; border-radius: 999px; padding: 16px 36px; font-size: 17px; font-weight: 900;
    cursor: pointer; transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease;
    font-family: inherit; color: var(--text); min-width: 220px;
    text-shadow: 0 2px 0 rgba(0,0,0,0.25);
}
.btn:active { transform: scale(0.96); }
.btn-primary {
    background: linear-gradient(180deg, #ff7fc3 0%, #ff2e7a 100%);
    box-shadow: 0 6px 0 #b81c4d, var(--shadow-soft);
    color: #fff;
}
.btn-primary:active { box-shadow: 0 2px 0 #b81c4d, var(--shadow-soft); transform: translateY(4px) scale(0.98); }
.btn-secondary {
    background: linear-gradient(180deg, #fff 0%, #f0e5ff 100%);
    color: var(--text-dark); text-shadow: none;
    box-shadow: 0 5px 0 #b89cd6, var(--shadow-soft);
    border: 2px solid #fff;
}
.btn-secondary:active { box-shadow: 0 2px 0 #b89cd6, var(--shadow-soft); transform: translateY(3px) scale(0.98); }
/* Free "watch ad" call-to-action (rewarded) */
.btn-ad {
    background: linear-gradient(180deg, #4be07a, #1fae52);
    color: #fff; width: 100%; margin-bottom: 12px;
    box-shadow: 0 5px 0 #168a40, var(--shadow-soft);
}
.btn-ad:active { box-shadow: 0 2px 0 #168a40, var(--shadow-soft); transform: translateY(3px) scale(0.98); }
.btn-large { padding: 20px 60px; font-size: 24px; min-width: 240px; }
.btn-icon {
    width: 46px; height: 46px; border-radius: 50%; border: 2px solid #fff;
    background: rgba(255,255,255,0.85); color: var(--text-dark);
    font-size: 18px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 3px 0 #b89cd6;
}
.btn-icon:active { transform: scale(0.9); box-shadow: 0 1px 0 #b89cd6; }
.btn-back {
    width: 42px; height: 42px; border-radius: 50%; border: 2px solid #fff;
    background: rgba(255,255,255,0.85); color: var(--text-dark);
    font-size: 22px; line-height: 1; cursor: pointer;
    box-shadow: 0 3px 0 #b89cd6;
}

/* ============================================================
   App header
   ============================================================ */
.app-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; gap: 12px;
    background: linear-gradient(180deg, var(--bg-mid), var(--bg-deep));
    border-bottom: 3px solid #4a1d6e; box-shadow: 0 4px 12px rgba(0,0,0,0.2); position: relative; z-index: 2; }
.app-header h2 { margin: 0; font-size: 22px; font-weight: 900; color: #fff;
    text-shadow: 0 2px 0 rgba(0,0,0,0.3); }
.header-spacer { width: 42px; }
.coin-pill {
    display: inline-flex; align-items: center; gap: 6px;
    background: linear-gradient(180deg, #ffe066, #ffb830);
    color: #4a1d6e; font-weight: 900; padding: 6px 14px 6px 8px; border-radius: 999px;
    border: 2px solid #fff; box-shadow: 0 3px 0 #c89000;
    font-size: 15px;
}
.coin-icon { font-size: 18px; }
/* The map's balance is a tap target for opening the shop. */
#coin-pill-levels { cursor: pointer; position: relative; }
#coin-pill-levels::after {
    content: '+'; margin-left: 4px; font-size: 14px; line-height: 1;
    background: #4a1d6e; color: #ffe066; border-radius: 50%;
    width: 18px; height: 18px; display: inline-flex; align-items: center; justify-content: center;
}
#coin-pill-levels:active { transform: scale(0.94); }

/* ============================================================
   Sweet Path — winding candyland progress map
   ============================================================ */
.sweet-header {
    background: linear-gradient(180deg, #ff8ac4, #d950a0);
    border-bottom: 3px solid #b81c4d;
    position: relative;
}
.sweet-header h2 {
    background: url('../assets/banner-pink.webp') center/100% 100% no-repeat;
    padding: 16px 40px 22px 40px;
    color: #6a1a3a !important;
    text-shadow: 0 1px 0 rgba(255,255,255,0.5);
    min-width: 180px; text-align: center;
    filter: drop-shadow(0 3px 4px rgba(0,0,0,0.25));
}
.sweet-header::before {
    content: ''; position: absolute; left: 8px; top: 50%;
    width: 38px; height: 38px; transform: translateY(-50%) rotate(-10deg);
    background: url('../assets/fruits/strawberry.webp') center/contain no-repeat;
    pointer-events: none;
}
.sweet-header::after {
    content: ''; position: absolute; right: 100px; top: 50%;
    width: 38px; height: 38px; transform: translateY(-50%) rotate(10deg);
    background: url('../assets/fruits/cherry.webp') center/contain no-repeat;
    pointer-events: none;
}
.sweet-path-scroll {
    flex: 1; overflow-y: auto; overflow-x: hidden;
    background:
        linear-gradient(180deg,
            #b8e0ff 0%,
            #ffcfe0 20%,
            #d6f0c8 40%,
            #ffe6b0 60%,
            #f0d4ff 80%,
            #b8e0ff 100%);
    position: relative;
}
.sweet-path {
    position: relative;
    width: 100%;
    /* height set programmatically */
}
.sweet-path .path-line {
    position: absolute; inset: 0; width: 100%; height: 100%;
    z-index: 0; pointer-events: none;
}
.sweet-path .path-line .path-stripe {
    fill: none; stroke: #fff; stroke-width: 16;
    stroke-linecap: round; stroke-dasharray: 22 14;
    opacity: 0.95;
    filter: drop-shadow(0 3px 0 rgba(184, 28, 77, 0.35));
}
.sweet-path .path-line .path-stripe-2 {
    fill: none; stroke: #ff5b8a; stroke-width: 22;
    stroke-linecap: round; opacity: 0.85;
}
.sweet-path .deco {
    position: absolute; pointer-events: none;
    transform-origin: center center;
    will-change: transform;
}
.sweet-path .deco svg, .sweet-path .deco img { display: block;
    width: calc(56px * var(--scale, 1));
    height: calc(56px * var(--scale, 1));
    object-fit: contain;
    filter: drop-shadow(0 4px 5px rgba(74,29,110,0.22));
}
.bg-deco img { width: 100%; height: 100%; object-fit: contain;
    filter: drop-shadow(0 3px 4px rgba(74,29,110,0.18)); }
/* Sweet Path decorations — gentle vertical bob only. No rotation
   because spinning scenery (juice stands, trees, baskets) looks odd. */
.sweet-path .deco-bob,
.sweet-path .deco-spin,
.sweet-path .deco-twinkle,
.sweet-path .deco-sway { animation: deco-bob-still 3.4s ease-in-out infinite; }
@keyframes deco-bob-still {
    0%,100% { transform: translateY(0); }
    50%     { transform: translateY(-6px); }
}
.sweet-path .deco-twinkle { animation-name: deco-twinkle-still; animation-duration: 2.2s; }
@keyframes deco-twinkle-still {
    0%,100% { opacity: 0.85; transform: scale(1); }
    50%     { opacity: 1;    transform: scale(1.08); }
}

/* Level nodes along the path */
.level-card {
    position: absolute;
    width: 76px; height: 76px;
    border-radius: 50%;
    background: linear-gradient(180deg, #fff 0%, #fde7f4 100%);
    border: 4px solid #fff;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    cursor: pointer; font-weight: 900; color: var(--text-dark);
    gap: 1px; z-index: 2;
    transition: transform 0.12s ease;
    box-shadow: 0 6px 0 #b89cd6, 0 10px 22px rgba(74, 29, 110, 0.4);
}
.level-card:active { transform: scale(0.93) translateY(2px); box-shadow: 0 3px 0 #b89cd6; }
.level-card.locked {
    opacity: 0.6; cursor: not-allowed;
    background: linear-gradient(180deg, #d0c0e8, #b8a0d0);
    border-color: #c4b0dc;
    box-shadow: 0 5px 0 #6a4e8c, 0 8px 18px rgba(0,0,0,0.25);
}
.level-card.locked::after {
    content: "\1F512"; position: absolute; font-size: 30px;
    filter: drop-shadow(0 2px 2px rgba(0,0,0,0.3));
}
.level-card.locked .level-num, .level-card.locked .level-stars { display: none; }
.level-card.cleared {
    background: linear-gradient(180deg, #fff7c4 0%, #ffd166 100%);
    border-color: #ffe066;
    box-shadow: 0 6px 0 #c89000, 0 10px 22px rgba(200, 144, 0, 0.5);
}
.level-card.current {
    animation: current-pulse 1.4s ease-in-out infinite;
    background: linear-gradient(180deg, #fff 0%, #ffd9ec 100%);
    border-color: #ff5b8a;
    box-shadow: 0 6px 0 #b81c4d, 0 0 24px rgba(255, 91, 138, 0.6);
}
@keyframes current-pulse {
    0%,100% { transform: scale(1); }
    50% { transform: scale(1.06); }
}
.level-num { font-size: 28px; line-height: 1; text-shadow: 0 2px 0 rgba(255,255,255,0.7); }
.level-stars { display: flex; gap: 2px; font-size: 13px; color: #c89000; opacity: 0.45; line-height: 1; }
.level-stars .earned { opacity: 1; }
.level-card .next-arrow {
    position: absolute; top: -28px; left: 50%; transform: translateX(-50%);
    font-size: 24px; color: #ff5b8a;
    animation: bounce-arrow 0.9s ease-in-out infinite;
    filter: drop-shadow(0 2px 2px rgba(0,0,0,0.3));
}
@keyframes bounce-arrow {
    0%,100% { transform: translateX(-50%) translateY(0); }
    50% { transform: translateX(-50%) translateY(-6px); }
}

/* World banners between act boundaries — painted wooden plaque */
.world-banner {
    position: absolute; left: 50%; transform: translateX(-50%);
    background: url('../assets/banner-pink.webp') center/100% 100% no-repeat;
    color: #8a2848; font-weight: 900;
    padding: 22px 56px 26px 56px;
    font-size: 16px; white-space: nowrap; z-index: 1;
    text-shadow: 0 1px 0 rgba(255,255,255,0.6);
    min-width: 200px; text-align: center;
    filter: drop-shadow(0 4px 6px rgba(74,29,110,0.3));
}

/* ============================================================
   Shop
   ============================================================ */
.shop-content { flex: 1; overflow-y: auto; padding: 16px 18px 28px;
    background: linear-gradient(180deg, var(--sky-top) 0%, var(--sky-bot) 100%); }
.shop-intro { text-align: center; color: var(--text-dark); font-weight: 800; font-size: 17px; margin: 6px 0 18px; }
.shop-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; margin-bottom: 20px; }
.shop-card {
    background: linear-gradient(180deg, #fff 0%, #fde7f4 100%);
    border: 3px solid #fff; border-radius: 18px; padding: 16px 12px;
    text-align: center; color: var(--text-dark); cursor: pointer;
    box-shadow: 0 5px 0 #b89cd6, 0 8px 18px rgba(74,29,110,0.3);
    font-family: inherit;
}
.shop-card:active { transform: translateY(3px); box-shadow: 0 2px 0 #b89cd6, 0 4px 10px rgba(74,29,110,0.3); }
.shop-card .shop-emoji { font-size: 42px; line-height: 1; }
.shop-card .shop-amount { font-size: 22px; font-weight: 900; color: #c89000; margin-top: 4px; }
.shop-card .shop-bonus { font-size: 11px; color: var(--text-muted); font-weight: 700; }
.shop-card .shop-price {
    margin-top: 8px; display: inline-block; background: var(--accent-2); color: #fff;
    border-radius: 999px; padding: 4px 14px; font-weight: 900; font-size: 14px;
    box-shadow: 0 2px 0 #b81c4d;
}
.shop-watch-ad { width: 100%; margin-top: 8px; }
.shop-note { text-align: center; font-size: 11px; color: var(--text-muted); margin-top: 18px; line-height: 1.4; }

/* Progression-gated featured offer */
.shop-featured {
    margin: 4px 0 16px; border-radius: 18px; cursor: pointer;
    background: linear-gradient(135deg, #ff8ac4 0%, #b794ff 60%, #7d6cff 100%);
    border: 3px solid #fff; box-shadow: 0 5px 0 rgba(74,29,110,0.35);
    overflow: hidden; transition: transform 0.12s ease;
}
.shop-featured:active { transform: scale(0.98); }
.shop-featured .offer-tag {
    background: rgba(255,255,255,0.25); color: #fff; font-weight: 900;
    font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px;
    padding: 5px 14px;
}
.shop-featured .offer-body { display: flex; align-items: center; gap: 12px; padding: 12px 16px; }
.shop-featured .offer-emoji { font-size: 40px; filter: drop-shadow(0 3px 6px rgba(0,0,0,0.3)); }
.shop-featured .offer-info { flex: 1; text-align: left; color: #fff; }
.shop-featured .offer-title { font-weight: 900; font-size: 17px; text-shadow: 0 2px 0 rgba(74,29,110,0.4); }
.shop-featured .offer-amount { font-weight: 800; font-size: 14px; margin-top: 2px; }
.shop-featured .offer-bonus { font-size: 12px; opacity: 0.9; }
.shop-featured .offer-price {
    background: #fff; color: #b81c4d; font-weight: 900; font-size: 16px;
    padding: 8px 16px; border-radius: 999px; box-shadow: 0 3px 0 rgba(74,29,110,0.25);
}

/* ============================================================
   How to play
   ============================================================ */
.how-content { flex: 1; overflow-y: auto; padding: 16px 18px 28px;
    background: linear-gradient(180deg, var(--sky-top) 0%, var(--sky-bot) 100%);
    display: flex; flex-direction: column; gap: 14px; }
.how-step { display: flex; gap: 14px; align-items: flex-start;
    background: #fff; color: var(--text-dark);
    border: 2px solid #fff; border-radius: var(--radius-md); padding: 14px;
    box-shadow: 0 4px 0 #b89cd6; }
.how-step-icon { flex-shrink: 0; width: 38px; height: 38px; border-radius: 50%;
    background: var(--accent-2); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 900; font-size: 18px; box-shadow: 0 3px 0 #b81c4d; }
.how-step p { margin: 0; line-height: 1.45; font-size: 15px; }

/* ============================================================
   Game screen — Fruit Land painterly background (uses the
   uploaded orchard scene as a real background image).
   ============================================================ */
#screen-game {
    background:
        linear-gradient(180deg, rgba(135,206,235,0.0) 0%, rgba(152,200,112,0.4) 100%),
        url('../assets/bg/orchard.webp') center top / cover no-repeat,
        linear-gradient(180deg, #87ceeb 0%, #98c870 100%);
}
.game-scenery { position: absolute; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.gs-sky { position: absolute; left: 0; right: 0; top: 0; height: 55%;
    background: linear-gradient(180deg, #87ceeb 0%, #c0e8ff 70%, transparent 100%); }
.gs-sun {
    position: absolute; right: 30px; top: 16px;
    width: 70px; height: 70px; border-radius: 50%;
    background: radial-gradient(circle at 40% 35%, #fff5a8 0%, #ffd92e 60%, #ff9a00 100%);
    box-shadow: 0 0 36px rgba(255, 217, 46, 0.7);
    animation: pulse-sun 4s ease-in-out infinite;
}
.gs-cloud { position: absolute; background: #fff; border-radius: 100px;
    box-shadow: 0 6px 16px rgba(0,0,0,0.08); }
.gs-cloud::before, .gs-cloud::after { content: ''; position: absolute; background: #fff; border-radius: 50%; }
.gs-cloud-1 { top: 56px; left: -20px; width: 100px; height: 28px; animation: drift-r 32s linear infinite; }
.gs-cloud-1::before { width: 48px; height: 48px; top: -18px; left: 18px; }
.gs-cloud-1::after  { width: 38px; height: 38px; top: -12px; left: 48px; }
.gs-cloud-2 { top: 110px; right: -30px; width: 90px; height: 24px; animation: drift-l 38s linear infinite; }
.gs-cloud-2::before { width: 40px; height: 40px; top: -16px; left: 12px; }
.gs-cloud-2::after  { width: 34px; height: 34px; top: -10px; left: 42px; }
.gs-hill-back, .gs-hill-front {
    position: absolute; left: -10%; right: -10%; border-radius: 50% 50% 0 0 / 100% 100% 0 0;
}
.gs-hill-back {
    bottom: 14%; height: 22%;
    background: linear-gradient(180deg, #a8d878 0%, #6ea848 100%);
    box-shadow: 0 -6px 0 rgba(255,255,255,0.25) inset;
}
.gs-hill-front {
    bottom: 0; height: 30%; left: -15%; right: -15%;
    background: linear-gradient(180deg, #88c060 0%, #4a8830 100%);
    box-shadow: 0 -6px 0 rgba(255,255,255,0.2) inset;
}
.gs-tree { position: absolute; width: 88px; height: 110px; }
.gs-tree svg { width: 100%; height: 100%; }
.gs-tree-1 { left: 4%; bottom: 16%; animation: tree-sway 5s ease-in-out infinite; }
.gs-tree-2 { right: 4%; bottom: 16%; transform: scaleX(-1); animation: tree-sway 5s ease-in-out infinite -2.5s; }
@keyframes tree-sway {
    0%,100% { transform: rotate(-2deg); }
    50%     { transform: rotate(2deg); }
}
.gs-tree-2 { transform: scaleX(-1) rotate(0); }
@keyframes tree-sway-flip {
    0%,100% { transform: scaleX(-1) rotate(-2deg); }
    50%     { transform: scaleX(-1) rotate(2deg); }
}
.gs-tree-2 { animation-name: tree-sway-flip; }
.gs-grass {
    position: absolute; left: 0; right: 0; bottom: 0; height: 16%;
    background:
        radial-gradient(circle at 10% 0%, #5cae3a 0%, transparent 10%),
        radial-gradient(circle at 25% 5%, #5cae3a 0%, transparent 8%),
        radial-gradient(circle at 50% 0%, #5cae3a 0%, transparent 12%),
        radial-gradient(circle at 75% 5%, #5cae3a 0%, transparent 8%),
        radial-gradient(circle at 90% 0%, #5cae3a 0%, transparent 10%),
        linear-gradient(180deg, #98c870 0%, #4a8830 100%);
}
.game-bg-anim {
    position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 0;
}
.bg-deco {
    position: absolute;
    animation: bg-drift linear infinite;
    pointer-events: none;
}
.bg-deco svg { width: 100%; height: 100%; display: block;
    filter: drop-shadow(0 2px 4px rgba(74,29,110,0.15)); }
@keyframes bg-drift {
    0%   { transform: translate(0,0) rotate(0deg); }
    50%  { transform: translate(15px,-20px) rotate(8deg); }
    100% { transform: translate(0,0) rotate(0deg); }
}
#screen-game > * { position: relative; z-index: 1; }

/* ============================================================
   Target bar
   ============================================================ */
.target-bar {
    display: flex; align-items: center; gap: 10px;
    padding: 6px 12px; margin: 0 12px;
    background: rgba(255,255,255,0.7);
    border: 2px solid #fff;
    border-radius: 14px;
    box-shadow: 0 3px 0 rgba(74,29,110,0.2);
}
.target-label {
    font-size: 11px; font-weight: 900; color: var(--text-dark);
    text-transform: uppercase; letter-spacing: 0.5px;
}
.target-bar-track {
    flex: 1; height: 12px; border-radius: 999px;
    background: rgba(74,29,110,0.15);
    overflow: hidden;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.15);
}
.target-bar-fill {
    height: 100%; width: 0%;
    background: linear-gradient(90deg, #ffd92e, #ff8a44, #ff3d7a);
    transition: width 0.4s cubic-bezier(0.34,1.56,0.64,1);
    box-shadow: 0 0 10px rgba(255,217,46,0.6);
}
.target-value {
    font-size: 12px; font-weight: 800; color: var(--text-dark);
    font-variant-numeric: tabular-nums; min-width: 70px; text-align: right;
}
.game-header { display: flex; align-items: center; justify-content: space-between; padding: 8px 10px; gap: 8px;
    background: linear-gradient(180deg, var(--bg-light), var(--bg-mid));
    border-bottom: 3px solid #4a1d6e; box-shadow: 0 4px 12px rgba(0,0,0,0.25); }
.game-stats {
    display: flex; gap: 12px;
    background: url('../assets/banner-gold-1.webp') center/100% 100% no-repeat;
    padding: 14px 26px 18px 26px;
    min-width: 220px;
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.3));
}
.stat { display: flex; flex-direction: column; align-items: center; min-width: 36px; }
.stat-label { font-size: 9px; color: #7a4f24; text-transform: uppercase;
    letter-spacing: 0.5px; font-weight: 800;
    text-shadow: 0 1px 0 rgba(255,255,255,0.5); }
.stat-value { font-size: 16px; font-weight: 900; font-variant-numeric: tabular-nums;
    color: #5a3408; text-shadow: 0 1px 0 rgba(255,255,255,0.6); }
.stat-value.warn { color: var(--accent); animation: warn-pulse 0.7s ease-in-out infinite; }
.stat-value.score-bump { animation: score-bump 0.4s ease-out; }
@keyframes warn-pulse { 0%,100%{ transform: scale(1);} 50%{ transform: scale(1.15);} }
@keyframes score-bump {
    0% { transform: scale(1); color: #fff; }
    50% { transform: scale(1.5); color: var(--accent); }
    100% { transform: scale(1); color: #fff; }
}

/* ============================================================
   Board
   ============================================================ */
.board-container {
    flex: 1; position: relative; margin: 6px 10px;
    border-radius: var(--radius-lg);
    /* More opaque cream so the orchard background doesn't fight the
       tile colors. Tiles read much more clearly against this. */
    background: linear-gradient(180deg, rgba(255,250,235,0.94) 0%, rgba(255,235,225,0.94) 100%);
    border: 4px solid #fff;
    overflow: visible; min-height: 0;
    box-shadow: inset 0 3px 10px rgba(74,29,110,0.15), 0 6px 0 #cf90a8, 0 8px 18px rgba(0,0,0,0.25);
    display: flex; align-items: center; justify-content: center;
}
.board-grid {
    position: relative;
    background: rgba(255,255,255,0.45);
    border-radius: 14px;
    box-shadow: inset 0 2px 6px rgba(74,29,110,0.15);
}
.board-grid.shake { animation: shake 0.4s ease; }
.sweet-cell {
    position: absolute;
    --tile-tint: #ff5fa6;
    background:
        radial-gradient(circle at 30% 22%, rgba(255,255,255,0.98) 0%, rgba(255,255,255,0.5) 22%, transparent 50%),
        radial-gradient(circle at 70% 80%, color-mix(in srgb, var(--tile-tint) 75%, #000) 0%, transparent 65%),
        linear-gradient(180deg,
            color-mix(in srgb, var(--tile-tint) 28%, #fff) 0%,
            color-mix(in srgb, var(--tile-tint) 65%, #fff) 100%);
    border-radius: 16px;
    border: 4px solid #fff;
    box-shadow:
        0 0 0 2px color-mix(in srgb, var(--tile-tint) 60%, transparent),
        0 6px 0 color-mix(in srgb, var(--tile-tint) 70%, #2a0a4a),
        0 10px 18px rgba(0,0,0,0.42),
        inset 0 3px 0 rgba(255,255,255,0.85),
        inset 0 -4px 4px rgba(0,0,0,0.15);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    transition: left 0.32s cubic-bezier(0.34,1.56,0.64,1),
                top 0.32s cubic-bezier(0.34,1.56,0.64,1),
                transform 0.32s cubic-bezier(0.34,1.56,0.64,1);
    z-index: 1;
    overflow: hidden;
}
.sweet-cell::before {
    content: '';
    position: absolute; top: 6%; left: 14%;
    width: 36%; height: 28%;
    border-radius: 50%;
    background: linear-gradient(180deg, rgba(255,255,255,0.85), rgba(255,255,255,0));
    pointer-events: none;
    z-index: 2;
}
.sweet-cell:active { transform: scale(0.92); }
.sweet-cell svg, .sweet-cell img {
    width: 94%; height: 94%; pointer-events: none;
    object-fit: contain;
    filter: drop-shadow(0 2px 2px rgba(74,29,110,0.35));
}
/* Avocado & peach art sits small inside its canvas — scale these up so every
   fruit reads at a consistent size on the board. */
.sweet-cell[data-char="avocado"] img,
.sweet-cell[data-char="peach"] img { transform: scale(1.22); }
.sweet-cell.special-sparkle img,
.sweet-cell.special-burst img { filter: drop-shadow(0 0 6px #fff) drop-shadow(0 2px 2px rgba(0,0,0,0.4)); }
.sweet-cell.selected {
    z-index: 5;
    box-shadow: 0 0 0 3px var(--accent), 0 0 18px var(--accent), 0 3px 0 #d3a3c9;
    animation: cell-pulse 0.8s ease-in-out infinite;
}
@keyframes cell-pulse {
    0%,100% { transform: scale(1); }
    50% { transform: scale(1.08); }
}
.sweet-cell.special {
    background: linear-gradient(180deg, #fff8c4 0%, #ffe066 100%);
    border-color: #ffd92e;
    box-shadow: 0 3px 0 #c89000, 0 0 14px rgba(255,217,46,0.5);
    animation: special-shine 1.4s ease-in-out infinite;
}
@keyframes special-shine {
    0%,100% { filter: brightness(1); }
    50% { filter: brightness(1.2) saturate(1.2); }
}
.sweet-cell.special-sparkle {
    background: linear-gradient(135deg, #ff89c0, #ffd92e, #7ed4ff, #36e07a, #b794ff);
    background-size: 300% 300%;
    animation: rainbow-bg 2s linear infinite;
}
.sweet-cell.special-burst {
    background:
        radial-gradient(circle at 50% 50%, #fff 0%, #ffd9ec 40%, #ff5fa6 100%);
    border-color: #ff3d7a;
    box-shadow:
        0 0 0 3px #ff8ac4,
        0 5px 0 #b81c4d,
        0 0 22px rgba(255, 61, 122, 0.65),
        inset 0 2px 0 rgba(255,255,255,0.8);
    animation: burst-pulse 1.1s ease-in-out infinite;
}
@keyframes burst-pulse {
    0%,100% { transform: scale(1); filter: brightness(1); }
    50%     { transform: scale(1.06); filter: brightness(1.2); }
}
.sweet-cell.special-fish {
    background: radial-gradient(circle at 50% 45%, #fff 0%, #cdeffd 45%, #2dc4ff 100%);
    border-color: #1aa3e6;
    box-shadow: 0 0 0 3px #7ed4ff, 0 5px 0 #1577b3, 0 0 22px rgba(45,196,255,0.6), inset 0 2px 0 rgba(255,255,255,0.8);
    animation: burst-pulse 1.1s ease-in-out infinite;
}
.sweet-cell.special-butterfly {
    background: radial-gradient(circle at 50% 45%, #fff 0%, #f0dcff 40%, #b794ff 100%);
    border-color: #8f5fe0;
    box-shadow: 0 0 0 3px #d7c2ff, 0 5px 0 #6a3fb0, 0 0 22px rgba(143,95,224,0.6), inset 0 2px 0 rgba(255,255,255,0.85);
    animation: burst-pulse 1.1s ease-in-out infinite;
}
.sweet-cell.special-striped-h::before,
.sweet-cell.special-striped-v::before {
    content: ''; position: absolute; inset: 4px; border-radius: 8px;
    background: repeating-linear-gradient(90deg, rgba(255,255,255,0.55) 0 4px, transparent 4px 8px);
    pointer-events: none;
}
.sweet-cell.special-striped-v::before {
    background: repeating-linear-gradient(0deg, rgba(255,255,255,0.55) 0 4px, transparent 4px 8px);
}
@keyframes rainbow-bg {
    0%   { background-position: 0% 50%; }
    100% { background-position: 100% 50%; }
}

/* Board flash on big combos */
.board-grid.flash { animation: board-flash 0.5s ease; }
@keyframes board-flash {
    0%   { background: rgba(255,255,255,0.45); box-shadow: inset 0 2px 6px rgba(74,29,110,0.15); }
    40%  { background: rgba(255,255,255,1);    box-shadow: inset 0 0 30px rgba(255,217,46,0.8); }
    100% { background: rgba(255,255,255,0.45); box-shadow: inset 0 2px 6px rgba(74,29,110,0.15); }
}
.special-marker {
    position: absolute; top: -8px; right: -8px;
    width: 22px; height: 22px; border-radius: 50%;
    background: var(--accent-2); color: #fff;
    border: 2px solid #fff;
    font-size: 13px; font-weight: 900; line-height: 1;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 2px 0 #b81c4d;
}
.sweet-cell.poof { animation: poof 0.28s ease forwards; pointer-events: none; }
@keyframes shake {
    0%,100% { transform: translate(0,0); }
    20% { transform: translate(-6px, 4px) rotate(-1deg); }
    40% { transform: translate(6px, -4px) rotate(1deg); }
    60% { transform: translate(-4px, -2px) rotate(-0.5deg); }
    80% { transform: translate(4px, 2px) rotate(0.5deg); }
}

.critter {
    position: absolute; width: 56px; height: 56px; border-radius: 16px;
    background: linear-gradient(180deg, #ffffff 0%, #fde7f4 100%);
    border: 2px solid #fff;
    box-shadow:
        0 4px 0 #6a3aa8,
        0 6px 14px rgba(0,0,0,0.45),
        inset 0 1px 0 rgba(255,255,255,0.6);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    transition: transform 0.18s cubic-bezier(0.34,1.56,0.64,1), opacity 0.2s ease, top 0.4s ease, left 0.4s ease;
    will-change: transform;
}
.critter:active { transform: scale(0.86); }
.critter.locked { filter: grayscale(0.85) brightness(0.55); pointer-events: none; }
.critter.locked::after {
    content: ""; position: absolute; inset: 0; border-radius: inherit;
    background: rgba(0,0,0,0.4);
    background-image: linear-gradient(45deg, transparent 45%, rgba(255,255,255,0.3) 47%, rgba(255,255,255,0.3) 53%, transparent 55%);
}
.critter.treat {
    background: linear-gradient(180deg, #fff8c4 0%, #ffe066 100%);
    border-color: #ffd92e;
    box-shadow: 0 4px 0 #d99c00, 0 6px 18px rgba(255,217,46,0.6), inset 0 1px 0 rgba(255,255,255,0.7);
    animation: treat-pulse 1.2s ease-in-out infinite;
}
@keyframes treat-pulse {
    0%,100% { transform: scale(1); filter: brightness(1); }
    50% { transform: scale(1.08); filter: brightness(1.15); }
}
.critter.flying {
    transition: top 0.32s cubic-bezier(0.4,0,0.2,1), left 0.32s cubic-bezier(0.4,0,0.2,1),
                transform 0.32s ease, opacity 0.2s ease;
    pointer-events: none; z-index: 100;
}
.critter.poof { animation: poof 0.4s ease forwards; pointer-events: none; }
@keyframes poof {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.35) rotate(15deg); opacity: 1; }
    100% { transform: scale(0.2) rotate(-20deg); opacity: 0; }
}
.critter svg { width: 80%; height: 80%; pointer-events: none; }

body.hammer-mode .critter:not(.locked) { animation: hammer-target 0.7s ease-in-out infinite; }
body.hammer-mode .critter.locked { opacity: 0.6; pointer-events: auto; cursor: pointer; }
@keyframes hammer-target {
    0%,100% { box-shadow: 0 4px 0 rgba(255,61,122,0.6), 0 6px 14px rgba(255,61,122,0.5), inset 0 1px 0 rgba(255,255,255,0.6); }
    50% { box-shadow: 0 4px 0 rgba(255,61,122,0.9), 0 0 20px rgba(255,61,122,0.7), inset 0 1px 0 rgba(255,255,255,0.6); }
}
.hammer-cursor {
    position: fixed; font-size: 40px; pointer-events: none; z-index: 9999;
    transform: translate(-50%, -50%) rotate(-15deg);
    display: none; filter: drop-shadow(0 4px 8px rgba(0,0,0,0.5));
}
body.hammer-mode .hammer-cursor { display: block; }

/* ============================================================
   Tray
   ============================================================ */
.tray-container { padding: 4px 8px 4px; }
.tray {
    background: var(--tray-bg);
    border: 3px solid #fff;
    border-radius: 22px; padding: 6px;
    display: grid; gap: 5px;
    grid-template-columns: repeat(7, 1fr);
    box-shadow: inset 0 2px 8px rgba(0,0,0,0.6), 0 3px 0 #4a1d6e;
}
.tray.size-8 { grid-template-columns: repeat(8, 1fr); gap: 4px; }
.tray.size-9 { grid-template-columns: repeat(9, 1fr); gap: 4px; }
.tray.size-10 { grid-template-columns: repeat(10, 1fr); gap: 3px; padding: 5px; }
.tray-slot {
    aspect-ratio: 1; border-radius: 12px;
    background: rgba(255,255,255,0.05);
    border: 1px dashed rgba(255,255,255,0.18);
    position: relative; display: flex; align-items: center; justify-content: center;
}
.tray-slot .critter-in-tray {
    width: 92%; height: 92%; border-radius: 12px;
    background: linear-gradient(180deg, #ffffff 0%, #fde7f4 100%);
    border: 1.5px solid #fff;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 2px 0 #4a1d6e;
    animation: pop-in 0.22s cubic-bezier(0.34,1.56,0.64,1);
}
.tray-slot .critter-in-tray.matching { animation: match-flash 0.4s ease forwards; }
.tray-slot .critter-in-tray svg, .tray-slot .critter-in-tray img { width: 84%; height: 84%; }
@keyframes pop-in { from { transform: scale(0); } to { transform: scale(1); } }
@keyframes match-flash {
    0% { transform: scale(1); }
    40% { transform: scale(1.2); box-shadow: 0 0 28px var(--accent), 0 0 14px var(--accent-2); }
    100% { transform: scale(0); opacity: 0; }
}
.tray.warn { border-color: var(--bad); animation: tray-warn 0.6s ease-in-out infinite; }
@keyframes tray-warn {
    0%,100% { box-shadow: inset 0 2px 8px rgba(0,0,0,0.6), 0 0 0 0 rgba(255,107,107,0.6); }
    50% { box-shadow: inset 0 2px 8px rgba(0,0,0,0.6), 0 0 0 8px rgba(255,107,107,0); }
}

/* ============================================================
   Combo display
   ============================================================ */
.combo-display {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    pointer-events: none; z-index: 200;
    font-size: 60px; font-weight: 900; text-align: center; line-height: 1;
    text-shadow: 0 6px 0 #4a1d6e, 0 10px 30px rgba(0,0,0,0.6);
    -webkit-text-stroke: 3px #fff; opacity: 0;
}
.combo-display.show { animation: combo-pop 1.2s ease forwards; }
@keyframes combo-pop {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.4) rotate(-12deg); }
    20% { opacity: 1; transform: translate(-50%, -50%) scale(1.3) rotate(8deg); }
    50% { transform: translate(-50%, -50%) scale(1) rotate(-3deg); }
    100% { opacity: 0; transform: translate(-50%, -80%) scale(0.95); }
}
.combo-display .combo-multiplier {
    display: block; font-size: 28px; margin-top: 4px;
    color: var(--accent); -webkit-text-stroke: 2px #4a1d6e;
}

/* ============================================================
   Boosters
   ============================================================ */
.boosters {
    display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px;
    padding: 8px 10px 14px;
}
.booster {
    --booster-color: #b89cd6;
    --booster-tint: rgba(255,255,255,0.5);
    background:
        radial-gradient(circle at 50% 30%, rgba(255,255,255,0.95) 0%, transparent 65%),
        linear-gradient(180deg, var(--booster-tint), color-mix(in srgb, var(--booster-color) 30%, #fff));
    border: 3px solid #fff;
    border-radius: var(--radius-md);
    padding: 8px 2px 6px;
    color: var(--text-dark);
    cursor: pointer;
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    position: relative; font-family: inherit;
    box-shadow:
        0 0 0 2px color-mix(in srgb, var(--booster-color) 60%, transparent),
        0 5px 0 var(--booster-color),
        0 6px 10px rgba(74,29,110,0.3);
    transition: transform 0.1s ease, box-shadow 0.1s ease;
}
.booster:active { transform: translateY(3px); box-shadow: 0 0 0 2px color-mix(in srgb, var(--booster-color) 60%, transparent), 0 2px 0 var(--booster-color); }
.booster:disabled { opacity: 0.4; cursor: not-allowed; }
/* Per-booster colors so each one stands out. */
#boost-undo    { --booster-color: #2dc4ff; --booster-tint: #d4f1ff; }
#boost-shuffle { --booster-color: #36e07a; --booster-tint: #d4f8e2; }
#boost-freeze  { --booster-color: #7ec8f5; --booster-tint: #e0eeff; }
#boost-hammer  { --booster-color: #ff9a44; --booster-tint: #ffe5cf; }
#boost-bomb    { --booster-color: #7d6cff; --booster-tint: #e0d8ff; }
#boost-magnet  { --booster-color: #ff3d7a; --booster-tint: #ffd9e6; }
.booster-icon { width: 42px; height: 42px; display: inline-flex; align-items: center; justify-content: center; }
.booster-icon svg, .booster-icon img { width: 100%; height: 100%; display: block;
    filter: drop-shadow(0 2px 3px rgba(0,0,0,0.35));
    transform-origin: 50% 60%; }

/* Boosters are still by default. They only animate when pressed/active
   (handled below by :active and .active states) so the bottom of the
   screen doesn't constantly wiggle and distract from the board. */
.booster:active .booster-icon svg, .booster:active .booster-icon img {
    animation: ico-press 0.3s ease;
}
.booster.active .booster-icon svg, .booster.active .booster-icon img {
    animation: ico-active 0.9s ease-in-out infinite;
}
@keyframes ico-press {
    0%   { transform: scale(1) rotate(0); }
    50%  { transform: scale(1.18) rotate(-8deg); }
    100% { transform: scale(1) rotate(0); }
}
@keyframes ico-active {
    0%,100% { transform: scale(1) rotate(0); filter: drop-shadow(0 2px 3px rgba(0,0,0,0.35)); }
    50%     { transform: scale(1.1) rotate(6deg); filter: drop-shadow(0 0 8px var(--accent)); }
}

@keyframes ico-undo {
    0%,100% { transform: rotate(-14deg) translateY(0); }
    50%     { transform: rotate(14deg)  translateY(-2px); }
}
@keyframes ico-shuffle {
    0%,100% { transform: translateX(-3px) rotate(-10deg); }
    50%     { transform: translateX(3px)  rotate(10deg); }
}
@keyframes ico-freeze {
    0%   { transform: rotate(0)      scale(1); }
    50%  { transform: rotate(180deg) scale(1.1); filter: drop-shadow(0 0 6px #9be4ff); }
    100% { transform: rotate(360deg) scale(1); }
}
@keyframes ico-hammer {
    0%,100% { transform: rotate(-32deg); }
    50%     { transform: rotate(18deg) translateY(-3px); }
}
@keyframes ico-bomb {
    0%,100% { transform: scale(1) rotate(0); }
    25%     { transform: scale(1.1) rotate(-5deg); filter: drop-shadow(0 0 6px #ffd92e); }
    50%     { transform: scale(1.12) rotate(0); }
    75%     { transform: scale(1.1) rotate(5deg); filter: drop-shadow(0 0 6px #ff5b35); }
}
@keyframes ico-magnet {
    0%,100% { transform: translateY(0) rotate(0); }
    50%     { transform: translateY(-6px) rotate(8deg); filter: drop-shadow(0 0 6px #ff3d7a); }
}

/* Whole-card idle "hop" so the booster bar feels alive. Staggered per button. */
.booster:not(:disabled):not(.active) { animation: booster-hop 5s ease-in-out infinite; }
#boost-shuffle { animation-delay: 0.4s; }
#boost-freeze  { animation-delay: 0.8s; }
#boost-hammer  { animation-delay: 1.2s; }
#boost-bomb    { animation-delay: 1.6s; }
#boost-magnet  { animation-delay: 2.0s; }
@keyframes booster-hop {
    0%, 86%, 100% { transform: translateY(0) rotate(0); }
    90% { transform: translateY(-5px) rotate(-3deg); }
    94% { transform: translateY(-1px) rotate(2deg); }
    98% { transform: translateY(0) rotate(0); }
}
.booster:disabled .booster-icon svg, .booster:disabled .booster-icon img { animation: none; filter: grayscale(0.7) drop-shadow(0 1px 2px rgba(0,0,0,0.2)); }
.booster-label { font-size: 10px; font-weight: 900; text-transform: uppercase; letter-spacing: 0.4px; color: var(--text-dark); }
.booster-count {
    position: absolute; top: -8px; right: -6px;
    background: var(--accent-2); color: #fff;
    border-radius: 50%; width: 22px; height: 22px;
    font-size: 12px; font-weight: 900;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 2px 0 #b81c4d;
    border: 2.5px solid #fff;
    animation: count-pulse 1.8s ease-in-out infinite;
}
@keyframes count-pulse {
    0%,100% { transform: scale(1); }
    50% { transform: scale(1.08); }
}
/* Empty booster: badge becomes a gold coin-price pill (tap to buy a charge). */
.booster.buyable .booster-count {
    width: auto; min-width: 22px; height: 20px; padding: 0 7px;
    border-radius: 999px; border: 2px solid #fff;
    background: linear-gradient(180deg, #ffe066, #ffb830);
    color: #7a4a00; box-shadow: 0 2px 0 #c89000;
    animation: none; font-size: 11px;
}
.booster.buyable .booster-icon svg, .booster.buyable .booster-icon img {
    filter: grayscale(0.4) drop-shadow(0 1px 2px rgba(0,0,0,0.25)); opacity: 0.85;
}
/* A booster charge just dropped from a big merge. */
@keyframes reward-pop { 0% { transform: scale(1); } 35% { transform: scale(1.22); } 100% { transform: scale(1); } }
.booster.reward-pop {
    animation: reward-pop 0.5s ease;
    box-shadow: 0 0 0 3px #ffd92e, 0 5px 0 var(--booster-color), 0 6px 14px rgba(255,180,0,0.6);
}

/* Pre-level "stock up" modal */
.prelevel-world { margin: -6px 0 2px; font-weight: 900; color: var(--accent-2); font-size: 15px; }
.prelevel-sub { margin: 0 0 14px; color: var(--text-muted); font-size: 13px; }
.prelevel-boosters { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.prelevel-booster {
    position: relative; border: 2.5px solid #fff; border-radius: var(--radius-md);
    background: linear-gradient(180deg, #fff, #f0e6ff);
    padding: 10px 4px 6px; cursor: pointer; font-family: inherit;
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    box-shadow: 0 3px 0 rgba(74,29,110,0.25);
}
.prelevel-booster:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(74,29,110,0.25); }
.prelevel-booster img { width: 34px; height: 34px; }
.prelevel-booster .pb-count {
    position: absolute; top: -8px; right: -6px; min-width: 22px; height: 22px;
    background: var(--accent-2); color: #fff; border: 2.5px solid #fff; border-radius: 999px;
    font-size: 12px; font-weight: 900; display: flex; align-items: center; justify-content: center;
}
.prelevel-booster .pb-price {
    font-size: 11px; font-weight: 900; color: #7a4a00;
    background: linear-gradient(180deg, #ffe066, #ffb830); border-radius: 999px; padding: 1px 8px;
}
.prelevel-coin { margin-bottom: 12px; font-weight: 800; color: var(--text-dark); }
.booster-label { font-size: 9px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.4px; }
.booster-count {
    position: absolute; top: -7px; right: -5px;
    background: var(--accent-2); color: #fff;
    border-radius: 50%; width: 20px; height: 20px;
    font-size: 11px; font-weight: 900;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 2px 0 #b81c4d;
    border: 2px solid #fff;
}
.booster.active {
    border-color: var(--accent);
    background: linear-gradient(180deg, #fff5a8, #ffd92e);
    animation: booster-active 0.8s ease-in-out infinite;
}
@keyframes booster-active {
    0%,100% { box-shadow: 0 4px 0 #b89cd6, 0 0 0 0 rgba(255,217,46,0.6); }
    50% { box-shadow: 0 4px 0 #b89cd6, 0 0 0 8px rgba(255,217,46,0); }
}

/* ============================================================
   Modal
   ============================================================ */
.modal {
    position: fixed; inset: 0; background: rgba(20,8,46,0.65);
    display: none; align-items: center; justify-content: center;
    z-index: 1000; padding: 24px;
    backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.modal.active { display: flex; animation: modal-fade 0.2s ease; }
@keyframes modal-fade { from { opacity: 0; } to { opacity: 1; } }
.modal-content {
    background: linear-gradient(180deg, #fff 0%, #fde7f4 100%);
    color: var(--text-dark);
    border: 3px solid #fff;
    border-radius: var(--radius-lg);
    padding: 28px 24px; text-align: center;
    max-width: 360px; width: 100%;
    box-shadow: 0 8px 0 #b89cd6, var(--shadow-soft);
    display: flex; flex-direction: column; gap: 12px;
    animation: modal-pop 0.35s cubic-bezier(0.34,1.56,0.64,1);
    position: relative; overflow: hidden;
}
@keyframes modal-pop { from { transform: scale(0.8); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-content h2 { margin: 0 0 4px; font-size: 30px; font-weight: 900; color: var(--accent-2);
    text-shadow: 0 2px 0 #fff; }
.modal-content p { margin: 0 0 6px; color: var(--text-muted); line-height: 1.4; font-weight: 700; }
.modal-emoji { font-size: 72px; line-height: 1; margin-bottom: 4px; }
.modal-content .btn { width: 100%; }

.stars { display: flex; justify-content: center; gap: 10px; margin: 4px 0; font-size: 52px; line-height: 1; }
.stars .star { color: rgba(74,29,110,0.15); transition: color 0.3s ease, transform 0.3s cubic-bezier(0.34,1.56,0.64,1); }
.stars .star.earned { color: var(--accent); animation: star-pop 0.5s cubic-bezier(0.34,1.56,0.64,1);
    text-shadow: 0 0 22px rgba(255,217,46,0.85), 0 0 8px var(--accent); }
.stars .star:nth-child(2).earned { animation-delay: 0.15s; }
.stars .star:nth-child(3).earned { animation-delay: 0.3s; }
@keyframes star-pop {
    0% { transform: scale(0) rotate(-90deg); }
    60% { transform: scale(1.4) rotate(12deg); }
    100% { transform: scale(1) rotate(0); }
}

.score-display { display: flex; justify-content: center; align-items: baseline; gap: 6px; margin: 4px 0; }
.score-big {
    font-size: 42px; font-weight: 900; color: var(--accent-2);
    text-shadow: 0 3px 0 #fff;
    font-variant-numeric: tabular-nums;
    animation: score-roll 0.6s ease-out;
}
.score-suffix { font-size: 18px; color: var(--text-muted); font-weight: 700; }
@keyframes score-roll {
    0% { transform: scale(0.5); opacity: 0; }
    60% { transform: scale(1.2); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}
.coin-earned {
    background: linear-gradient(180deg, #ffe066, #ffb830);
    color: #4a1d6e; font-weight: 900; font-size: 18px;
    padding: 6px 18px; border-radius: 999px; align-self: center;
    border: 2px solid #fff; box-shadow: 0 3px 0 #c89000;
}
.win-coin-breakdown {
    margin-top: 4px; font-size: 12px; font-weight: 800;
    color: #b35a00; text-shadow: none;
}

/* ============================================================
   Continue modal (the IAP touchpoint)
   ============================================================ */
.continue-options {
    display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 6px 0;
}
.continue-card {
    background: linear-gradient(180deg, #fff 0%, #fff5a8 100%);
    border: 2px solid #ffd92e; border-radius: 14px;
    padding: 12px 6px; color: var(--text-dark); cursor: pointer;
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    box-shadow: 0 4px 0 #c89000;
    font-family: inherit;
}
.continue-card:active { transform: translateY(2px); box-shadow: 0 2px 0 #c89000; }
.continue-card:disabled { opacity: 0.5; cursor: not-allowed; }
.continue-emoji { font-size: 34px; line-height: 1; }
.continue-label { font-size: 12px; font-weight: 800; text-align: center; }
.continue-cost { font-size: 13px; font-weight: 900; color: var(--accent-2); }
.continue-coin-balance { font-size: 13px; color: var(--text-muted); margin-top: 4px; font-weight: 700; }

/* ============================================================
   Confetti / sparkles / floaters (carried over)
   ============================================================ */
.confetti-burst { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.confetti-burst .confetti {
    position: absolute; width: 8px; height: 14px; top: 20%; left: 50%;
    border-radius: 2px; animation: confetti-fall 1.6s ease-out forwards;
}
@keyframes confetti-fall {
    0% { transform: translate(0, 0) rotate(0); opacity: 1; }
    100% { transform: translate(var(--dx), var(--dy)) rotate(var(--r)); opacity: 0; }
}
.floater {
    position: absolute; pointer-events: none;
    font-weight: 900; font-size: 24px; color: var(--accent);
    text-shadow: 0 3px 0 #4a1d6e, 0 6px 14px rgba(0,0,0,0.5);
    -webkit-text-stroke: 2px #fff;
    animation: floater 1s ease forwards; z-index: 200;
}
.floater.gold { color: var(--accent); }
.floater.pink { color: var(--accent-2); }
.floater.blue { color: var(--accent-3); }
@keyframes floater {
    0% { opacity: 0; transform: translate(-50%, 0) scale(0.6); }
    20% { opacity: 1; transform: translate(-50%, -14px) scale(1.2); }
    100% { opacity: 0; transform: translate(-50%, -70px) scale(1); }
}
.sparkle { position: absolute; pointer-events: none; font-size: 22px; z-index: 250;
    animation: sparkle-fly 0.7s ease-out forwards; }
@keyframes sparkle-fly {
    0% { opacity: 1; transform: translate(0,0) scale(0.6) rotate(0); }
    100% { opacity: 0; transform: translate(var(--sx), var(--sy)) scale(1.5) rotate(180deg); }
}

/* Per-tile point popups: float "+N" above each cleared tile */
.tile-point {
    position: absolute; pointer-events: none;
    font-weight: 900; font-size: 22px; color: #ffd92e;
    -webkit-text-stroke: 2px #fff;
    text-shadow: 0 3px 0 rgba(74,29,110,0.4), 0 6px 14px rgba(0,0,0,0.4);
    transform: translate(-50%, 0);
    z-index: 220;
    animation: tile-point-rise 0.9s cubic-bezier(0.25, 0.8, 0.35, 1) forwards;
}
.tile-point.big  { font-size: 28px; color: #ff9a44; }
.tile-point.huge { font-size: 36px; color: #ff3d7a; }
@keyframes tile-point-rise {
    0%   { opacity: 0; transform: translate(-50%, 0) scale(0.4); }
    20%  { opacity: 1; transform: translate(-50%, -16px) scale(1.25); }
    100% { opacity: 0; transform: translate(-50%, -70px) scale(1); }
}

/* Burst particles radiating from a cleared tile, tinted with its color */
.burst-particle {
    position: absolute; pointer-events: none;
    width: 10px; height: 10px; border-radius: 50%;
    transform: translate(-50%, -50%);
    z-index: 200;
    animation: burst-particle-fly 0.6s cubic-bezier(0.25, 0.7, 0.4, 1) forwards;
}
@keyframes burst-particle-fly {
    0%   { opacity: 1; transform: translate(-50%, -50%) scale(1.2); }
    100% { opacity: 0; transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(0.3); }
}

/* Milestone-bonus tile pulse — flashes the new special after a score milestone */
.sweet-cell.bonus-spawn {
    animation: bonus-spawn 0.7s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 6;
}
@keyframes bonus-spawn {
    0%   { transform: scale(0.4) rotate(-180deg); filter: brightness(2); }
    40%  { transform: scale(1.35) rotate(20deg);  filter: brightness(1.6); }
    100% { transform: scale(1) rotate(0);         filter: brightness(1); }
}

/* Expanding shockwave ring on combos */
.shockwave {
    position: absolute; pointer-events: none;
    width: 30px; height: 30px;
    border-radius: 50%;
    border: 4px solid #fff;
    transform: translate(-50%, -50%);
    z-index: 195;
    box-shadow: 0 0 18px rgba(255, 217, 46, 0.7), inset 0 0 14px rgba(255, 61, 122, 0.5);
    animation: shockwave-expand 0.7s ease-out forwards;
}
@keyframes shockwave-expand {
    0%   { opacity: 0.95; transform: translate(-50%, -50%) scale(0.2); border-width: 6px; }
    100% { opacity: 0;    transform: translate(-50%, -50%) scale(8);   border-width: 1px; }
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-height: 700px) {
    .critter { width: 50px; height: 50px; }
    .game-stats { padding: 5px 10px; gap: 8px; }
    .stat-value { font-size: 14px; }
    .stat-label { font-size: 8px; }
    .booster-icon { font-size: 20px; }
    .booster-label { font-size: 8px; }
}
/* On wide / desktop viewports, present the portrait game as a centered,
   full-height column. Keep position:fixed (from the base rule) so the
   absolutely-positioned screens still fill #app — switching to position:relative
   collapses its height and blanks the game. */
@media (min-width: 600px) {
    #app {
        width: min(480px, 56.25vh);
        left: 50%; right: auto;
        transform: translateX(-50%);
    }
}
