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

:root {
    --purple: #7c4dff;
    --pink: #ff5ca8;
    --yellow: #ffd23f;
    --green: #3ddc84;
    --blue: #29b6f6;
    --orange: #ff9f43;
    --ink: #2b2150;
    --card-radius: 26px;
    --shadow: 0 8px 0 rgba(0,0,0,0.12);
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: 'Baloo 2', system-ui, sans-serif;
    color: var(--ink);
    background: linear-gradient(180deg, #8ed1fc 0%, #b8e6ff 45%, #d4f5d0 100%);
    position: relative;
    overscroll-behavior: none;
}

/* ===== Sky decorations ===== */
.sky { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.cloud { position: absolute; font-size: 56px; opacity: 0.9; animation: drift linear infinite; }
.cloud-1 { top: 8%; left: -20%; animation-duration: 40s; }
.cloud-2 { top: 22%; left: -20%; font-size: 40px; animation-duration: 55s; animation-delay: -10s; }
.cloud-3 { top: 4%; left: -20%; font-size: 32px; animation-duration: 70s; animation-delay: -30s; }
.sun { position: absolute; top: 14px; right: 16px; font-size: 60px; animation: spin 30s linear infinite; }
@keyframes drift { to { transform: translateX(140vw); } }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== App / screens ===== */
#app {
    position: relative;
    z-index: 1;
    height: 100%;
    max-width: 560px;
    margin: 0 auto;
}

.screen {
    position: absolute;
    inset: 0;
    display: none;
    flex-direction: column;
    align-items: center;
    padding: max(16px, env(safe-area-inset-top)) 18px calc(18px + env(safe-area-inset-bottom));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
.screen.active { display: flex; animation: popIn 0.4s ease; }
@keyframes popIn { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: scale(1); } }

/* ===== Home ===== */
.mascot-bubble { display: flex; align-items: center; gap: 12px; margin-top: 8px; width: 100%; }
.mascot { font-size: 64px; animation: bob 2s ease-in-out infinite; flex-shrink: 0; }
@keyframes bob { 0%,100% { transform: translateY(0) rotate(-3deg); } 50% { transform: translateY(-8px) rotate(3deg); } }
.speech {
    background: #fff;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 18px;
    font-weight: 600;
    box-shadow: var(--shadow);
    position: relative;
    flex: 1;
}
.speech::before {
    content: '';
    position: absolute;
    left: -10px; top: 50%;
    transform: translateY(-50%);
    border: 10px solid transparent;
    border-right-color: #fff;
}

.game-title {
    font-size: clamp(38px, 12vw, 60px);
    font-weight: 800;
    color: #fff;
    text-align: center;
    margin: 10px 0 6px;
    letter-spacing: 1px;
    text-shadow: 0 3px 0 var(--purple), 0 6px 10px rgba(0,0,0,0.2);
}

.picker { width: 100%; margin-top: 14px; }
.picker-label {
    font-size: 20px;
    font-weight: 700;
    color: var(--ink);
    margin-bottom: 10px;
    text-align: center;
    text-shadow: 0 1px 0 #fff;
}

.theme-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}
.theme-card {
    background: #fff;
    border: 4px solid transparent;
    border-radius: var(--card-radius);
    padding: 14px 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    box-shadow: var(--shadow);
    transition: transform 0.12s ease, border-color 0.12s ease;
}
.theme-card:active { transform: scale(0.94); }
.theme-card.selected { border-color: var(--purple); background: #f3edff; }
.theme-card .emoji { font-size: 46px; line-height: 1; }
.theme-card .name { font-size: 17px; font-weight: 700; }

.count-row { display: flex; gap: 14px; justify-content: center; }
.count-btn {
    width: 70px; height: 70px;
    border-radius: 50%;
    border: 4px solid #fff;
    background: var(--blue);
    color: #fff;
    font-size: 28px;
    font-weight: 800;
    font-family: inherit;
    cursor: pointer;
    box-shadow: var(--shadow);
    transition: transform 0.12s ease;
}
.count-btn:active { transform: scale(0.9); }
.count-btn.active { background: var(--pink); transform: scale(1.08); }

.big-play-btn {
    margin-top: 22px;
    background: linear-gradient(180deg, var(--green), #2cb56c);
    color: #fff;
    border: none;
    border-radius: 40px;
    padding: 18px 44px;
    font-size: 28px;
    font-weight: 800;
    font-family: inherit;
    cursor: pointer;
    box-shadow: 0 8px 0 #1e8f54;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: transform 0.1s ease, box-shadow 0.1s ease;
}
.big-play-btn:active { transform: translateY(5px); box-shadow: 0 3px 0 #1e8f54; }
.play-icon { font-size: 22px; }

.sound-toggle, .icon-btn {
    background: #fff;
    border: none;
    border-radius: 50%;
    width: 52px; height: 52px;
    font-size: 24px;
    cursor: pointer;
    box-shadow: var(--shadow);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.sound-toggle { position: fixed; bottom: calc(16px + env(safe-area-inset-bottom)); right: 16px; z-index: 5; }
.sound-toggle.muted, .icon-btn.muted { opacity: 0.5; }

/* ===== Hunt ===== */
.hunt-top {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
}
.star-counter {
    background: #fff;
    border-radius: 30px;
    padding: 8px 20px;
    font-size: 26px;
    font-weight: 800;
    color: var(--orange);
    box-shadow: var(--shadow);
    display: flex; align-items: center; gap: 6px;
}
.star-big { font-size: 26px; }

.track {
    width: 100%;
    height: 22px;
    background: #fff;
    border-radius: 20px;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.12);
    position: relative;
    margin-bottom: 10px;
}
.track-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--yellow), var(--orange));
    border-radius: 20px;
    transition: width 0.45s cubic-bezier(0.34,1.56,0.64,1);
}
.track-critter {
    position: absolute;
    top: 50%; left: 0%;
    transform: translate(-50%, -50%);
    font-size: 30px;
    transition: left 0.45s cubic-bezier(0.34,1.56,0.64,1);
}

.hunt-instruction {
    font-size: 19px;
    font-weight: 700;
    text-align: center;
    margin-bottom: 14px;
    color: var(--ink);
    text-shadow: 0 1px 0 #fff;
}

.card-grid {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
    padding-bottom: 20px;
}

.find-card {
    background: #fff;
    border-radius: var(--card-radius);
    padding: 16px 10px 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    box-shadow: var(--shadow);
    border: 5px solid transparent;
    position: relative;
    transition: transform 0.12s ease;
    aspect-ratio: 1 / 1;
    justify-content: center;
}
.find-card:active { transform: scale(0.94); }
.find-card .card-emoji { font-size: clamp(48px, 16vw, 76px); line-height: 1; transition: transform 0.2s ease; }
.find-card .card-name { font-size: 18px; font-weight: 700; text-align: center; }
.find-card .say-btn {
    position: absolute;
    top: 8px; right: 8px;
    background: var(--blue);
    color: #fff;
    border: none;
    width: 38px; height: 38px;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 3px 0 rgba(0,0,0,0.15);
}
.find-card .say-btn:active { transform: scale(0.9); }

.find-card.found {
    background: linear-gradient(180deg, #e8ffe8, #c9f7c9);
    border-color: var(--green);
}
.find-card.found .card-emoji { transform: scale(1.05); }
.find-card .check-stamp {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%) scale(0) rotate(-25deg);
    font-size: 80px;
    pointer-events: none;
}
.find-card.found .check-stamp { animation: stamp 0.5s cubic-bezier(0.34,1.56,0.64,1) forwards; }
@keyframes stamp {
    0% { transform: translate(-50%,-50%) scale(2.4) rotate(20deg); opacity: 0; }
    60% { opacity: 1; }
    100% { transform: translate(-50%,-50%) scale(1) rotate(-12deg); opacity: 1; }
}

.find-card.pop { animation: cardPop 0.45s ease; }
@keyframes cardPop {
    0%,100% { transform: scale(1); }
    35% { transform: scale(1.12) rotate(3deg); }
    70% { transform: scale(0.96) rotate(-2deg); }
}

/* ===== Win ===== */
.win-screen { justify-content: center; text-align: center; gap: 8px; }
.win-mascot { font-size: 100px; animation: cheer 0.7s ease-in-out infinite; }
@keyframes cheer { 0%,100% { transform: rotate(-8deg) translateY(0); } 50% { transform: rotate(8deg) translateY(-12px); } }
.win-title { font-size: 46px; font-weight: 800; color: #fff; text-shadow: 0 3px 0 var(--pink), 0 6px 8px rgba(0,0,0,0.2); }
.medal { font-size: 88px; animation: bob 1.6s ease-in-out infinite; }
.win-sub { font-size: 22px; font-weight: 700; text-shadow: 0 1px 0 #fff; }
.win-stars { font-size: 40px; letter-spacing: 6px; min-height: 50px; }
.text-btn {
    background: none;
    border: none;
    font-family: inherit;
    font-size: 20px;
    font-weight: 700;
    color: var(--ink);
    cursor: pointer;
    margin-top: 6px;
    text-decoration: underline;
}

/* ===== Camera button + photo proof ===== */
.find-card .cam-btn {
    position: absolute;
    bottom: 8px; right: 8px;
    background: var(--purple);
    color: #fff;
    border: none;
    width: 38px; height: 38px;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 3px 0 rgba(0,0,0,0.15);
    z-index: 2;
}
.find-card .cam-btn:active { transform: scale(0.9); }

.find-card .photo-thumb {
    position: absolute;
    inset: 0;
    width: 100%; height: 100%;
    object-fit: cover;
    border-radius: 21px;
    display: none;
}
.find-card.has-photo .photo-thumb { display: block; }
.find-card.has-photo .card-emoji,
.find-card.has-photo .card-name { opacity: 0; }
.find-card.has-photo .photo-badge {
    position: absolute;
    bottom: 6px; left: 6px;
    background: rgba(255,255,255,0.92);
    border-radius: 14px;
    padding: 2px 8px;
    font-size: 14px;
    font-weight: 700;
    z-index: 2;
}

/* ===== Golden surprise item ===== */
.find-card.golden {
    background: linear-gradient(135deg, #fff6c8, #ffd23f, #ffb347);
    border-color: #ffae00;
    box-shadow: 0 8px 0 #d99100, 0 0 22px rgba(255,210,63,0.8);
    animation: goldenGlow 1.4s ease-in-out infinite;
}
@keyframes goldenGlow {
    0%,100% { box-shadow: 0 8px 0 #d99100, 0 0 16px rgba(255,210,63,0.6); }
    50% { box-shadow: 0 8px 0 #d99100, 0 0 30px rgba(255,210,63,1); }
}
.find-card.golden .card-name { color: #a35a00; }

/* ===== Sticker book (home) ===== */
.sticker-book { width: 100%; margin-top: 18px; }
.sticker-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    background: rgba(255,255,255,0.6);
    border-radius: 20px;
    padding: 12px;
    min-height: 60px;
}
.sticker-row .sticker {
    font-size: 38px;
    animation: pop-sticker 0.4s ease;
    filter: drop-shadow(0 2px 2px rgba(0,0,0,0.2));
}
@keyframes pop-sticker { from { transform: scale(0); } to { transform: scale(1); } }

/* ===== Reward sticker (win) ===== */
.reward-sticker {
    background: #fff;
    border-radius: 22px;
    padding: 10px 22px;
    box-shadow: var(--shadow);
    display: flex; flex-direction: column; align-items: center;
}
.reward-label { font-size: 16px; font-weight: 700; color: var(--purple); }
.reward-emoji { font-size: 56px; animation: stamp 0.6s cubic-bezier(0.34,1.56,0.64,1); }

/* ===== Scrapbook (win) ===== */
.scrapbook { width: 100%; margin: 6px 0; }
.scrap-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 6px;
}
.scrap-item {
    aspect-ratio: 1/1;
    border-radius: 16px;
    background: #fff;
    box-shadow: var(--shadow);
    display: flex; align-items: center; justify-content: center;
    font-size: 36px;
    overflow: hidden;
    position: relative;
}
.scrap-item img { width: 100%; height: 100%; object-fit: cover; }
.scrap-item .scrap-tag {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    background: rgba(0,0,0,0.45);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 1px 0;
    text-align: center;
}

/* ===== Confetti ===== */
.confetti-layer { position: fixed; inset: 0; pointer-events: none; z-index: 50; overflow: hidden; }
.confetti-piece {
    position: absolute;
    width: 14px; height: 14px;
    top: -20px;
    animation: fall linear forwards;
}
@keyframes fall {
    to { transform: translateY(110vh) rotate(720deg); opacity: 0.9; }
}

/* ===== Larger screens ===== */
@media (min-width: 600px) {
    .theme-grid { grid-template-columns: repeat(4, 1fr); }
    .card-grid { grid-template-columns: repeat(3, 1fr); }
}
