/* =========================================
   VARIABLES & RESET
   ========================================= */
:root {
    --primary-color: #FF5722;
    --primary-hover: #E64A19;
    --secondary-color: #2196F3;
    --secondary-hover: #1976D2;
    --success-color: #4CAF50;
    --error-color: #F44336;
    --bg-color: #F0F8FF;
    /* AliceBlue for a soft, friendly feel */
    --surface-color: #FFFFFF;
    --text-color: #333333;

    --font-heading: 'Fredoka One', cursive, sans-serif;
    --font-body: 'Nunito', sans-serif;

    --border-radius-sm: 8px;
    --border-radius-md: 16px;
    --border-radius-lg: 24px;
    --border-radius-round: 50%;

    --shadow-soft: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-glow: 0 0 15px rgba(255, 235, 59, 0.8);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    /* Prevent text selection during gameplay for kids */
    -webkit-user-select: none;
    touch-action: manipulation;
    /* Disable double-tap-to-zoom */
}

html {
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: none;
    -webkit-overflow-scrolling: touch;
}

body {
    font-family: var(--font-body);
    background-color: var(--bg-color);
    color: var(--text-color);
    overflow: hidden;
    overflow-x: hidden;
    overscroll-behavior: none;
    /* Use dynamic viewport height so Chrome mobile bar doesn't push content below fold */
    min-height: 100vh;
    min-height: 100dvh;
    min-height: var(--vh, 100vh);
    height: 100vh;
    height: 100dvh;
    height: var(--vh, 100dvh);
    width: 100%;
    max-width: 100vw;
    position: relative;
}

h1,
h2,
h3,
.font-heading {
    font-family: var(--font-heading);
    color: var(--secondary-color);
}

button {
    font-family: var(--font-heading);
    cursor: pointer;
    border: none;
    border-radius: var(--border-radius-md);
    padding: 12px 24px;
    font-size: 1.2rem;
    color: white;
    transition: transform 0.1s ease, box-shadow 0.2s ease, background-color 0.2s ease;
    box-shadow: 0 4px 0 rgba(0, 0, 0, 0.15);
    /* Chunky "pushable" button look */
}

button:active {
    transform: translateY(4px);
    box-shadow: 0 0px 0 rgba(0, 0, 0, 0.15);
}

.primary-btn {
    background-color: var(--primary-color);
}

.primary-btn:hover {
    background-color: var(--primary-hover);
}

.secondary-btn {
    background-color: var(--secondary-color);
}

.secondary-btn:hover {
    background-color: var(--secondary-hover);
}


/* =========================================
   APP STRUCTURE & SCREENS
   ========================================= */
#app {
    width: 100%;
    max-width: 100vw;
    height: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    min-height: var(--vh, 100vh);
    position: relative;
    overflow-x: hidden;
}

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.screen.active {
    display: flex;
}

.overlay {
    background-color: rgba(255, 255, 255, 0.9);
    z-index: 100;
}

/* =========================================
   LANGUAGE SELECTOR
   ========================================= */
.app-header {
    position: absolute;
    top: 20px;
    right: 30px;
    z-index: 1000;
}

.lang-dropdown {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    padding: 8px 16px;
    border-radius: 20px;
    border: 3px solid var(--primary-color);
    background-color: white;
    color: var(--text-color);
    cursor: pointer;
    box-shadow: 0 4px 0 var(--primary-color);
    outline: none;
    transition: transform 0.1s;
}

.lang-dropdown:active {
    transform: translateY(4px);
    box-shadow: none;
}

/* =========================================
   OFFLINE BANNER (non-dismissible, light overlay; no user action)
   ========================================= */
.offline-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 2147483647;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    background: rgba(248, 250, 252, 0.92);
    color: #475569;
    font-family: var(--font-body);
    font-size: 0.8rem;
    text-align: center;
    padding: 8px 16px;
    box-shadow: 0 -1px 3px rgba(0, 0, 0, 0.08);
    transform: translateY(100%);
    transition: transform 0.25s ease-out;
    pointer-events: none;
}
.offline-banner.visible {
    transform: translateY(0);
}

.offline-banner-text {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.35em;
}
.offline-banner-text strong {
    font-weight: 700;
    color: #334155;
}
.offline-banner-icon {
    display: inline-block;
    width: 1.1em;
    height: 1.1em;
    margin-right: 0.35em;
    vertical-align: -0.2em;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23475569' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2 12h4M10 12h4M18 12h4M4 8v8M12 8v8M20 8v8'/%3E%3C/svg%3E") center/contain no-repeat;
}

/* Game screen: small offline indicator over the black letterbox at top */
.game-offline-indicator {
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: rgba(30, 30, 30, 0.75);
    color: rgba(255, 255, 255, 0.9);
    font-family: var(--font-body);
    font-size: 0.7rem;
    border-radius: 20px;
    pointer-events: none;
}
.game-offline-indicator[hidden] {
    display: none !important;
}
.game-offline-icon {
    display: inline-block;
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='rgba(255,255,255,0.95)' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M18 10h-1.26A8 8 0 1 0 9 20h9a5 5 0 0 0 0-10z'/%3E%3Cline x1='2' y1='2' x2='22' y2='22'/%3E%3C/svg%3E") center/contain no-repeat;
}
.game-offline-audio-hint {
    max-width: 200px;
    line-height: 1.2;
}
.game-offline-audio-hint.hidden {
    display: none !important;
}

/* App toast for offline / error messages */
.app-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    max-width: min(90vw, 360px);
    padding: 12px 16px;
    background: rgba(15, 23, 42, 0.95);
    color: #e5e7eb;
    font-family: var(--font-body);
    font-size: 0.85rem;
    text-align: center;
    border-radius: var(--border-radius-md);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    z-index: 9998;
    opacity: 0;
    pointer-events: none;
    transition: transform 0.25s ease-out, opacity 0.2s ease-out;
}
.app-toast.visible {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
    pointer-events: auto;
}

/* Language Header */
.app-header {
    position: absolute;
    top: 20px;
    right: 30px;
    z-index: 1000;
}

.lang-dropdown {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    padding: 8px 16px;
    border-radius: 20px;
    border: 3px solid var(--primary-color);
    background-color: white;
    color: var(--text-color);
    cursor: pointer;
    box-shadow: 0 4px 0 var(--primary-color);
    outline: none;
    transition: transform 0.1s;
}

.lang-dropdown:active {
    transform: translateY(4px);
    box-shadow: none;
}

/* =========================================
   MAIN MENU
   ========================================= */
#main-menu {
    position: relative;
    overflow: hidden;
    background: radial-gradient(circle at center, #ffffff 0%, var(--bg-color) 100%);
}

/* Subtle \"ground\" footer like a crayon/bookend at the bottom of the main menu */
#main-menu::after {
    content: \"\";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 38px;
    background:
        repeating-linear-gradient(
            -8deg,
            rgba(255, 193, 7, 0.16),
            rgba(255, 193, 7, 0.16) 6px,
            rgba(255, 255, 255, 0.25) 6px,
            rgba(255, 255, 255, 0.25) 12px
        ),
        linear-gradient(180deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.9) 40%, #ffe8b2 100%);
    pointer-events: none;
}

/* Toddler-friendly themed backgrounds for the main menu */
#main-menu.menu-theme-sky {
    background:
        /* clouds */
        radial-gradient(circle at 15% 18%, rgba(255, 255, 255, 0.9) 0, transparent 45%),
        radial-gradient(circle at 75% 20%, rgba(255, 255, 255, 0.8) 0, transparent 45%),
        radial-gradient(circle at 35% 32%, rgba(255, 255, 255, 0.8) 0, transparent 50%),
        /* sun */
        radial-gradient(circle at 88% 8%, rgba(255, 241, 118, 1) 0, rgba(255, 241, 118, 0.15) 60%),
        /* balloons / balls */
        radial-gradient(circle at 18% 42%, rgba(255, 183, 77, 1) 0, rgba(255, 183, 77, 0.15) 35%),
        radial-gradient(circle at 72% 40%, rgba(3, 169, 244, 1) 0, rgba(3, 169, 244, 0.15) 33%),
        radial-gradient(circle at 48% 18%, rgba(244, 143, 177, 1) 0, rgba(244, 143, 177, 0.15) 33%),
        linear-gradient(180deg, #e0f4ff 0%, #f0f8ff 45%, #ffffff 100%);
}

#main-menu.menu-theme-meadow {
    background:
        /* soft sky puffs */
        radial-gradient(circle at 18% 10%, rgba(255, 255, 255, 0.9) 0, transparent 45%),
        radial-gradient(circle at 78% 12%, rgba(255, 255, 255, 0.8) 0, transparent 45%),
        /* trees / bushes */
        radial-gradient(circle at 14% 34%, rgba(129, 199, 132, 1) 0, transparent 45%),
        radial-gradient(circle at 38% 28%, rgba(76, 175, 80, 0.95) 0, transparent 45%),
        radial-gradient(circle at 72% 30%, rgba(139, 195, 74, 0.95) 0, transparent 45%),
        /* flowers / balls */
        radial-gradient(circle at 26% 20%, rgba(244, 143, 177, 1) 0, transparent 40%),
        radial-gradient(circle at 84% 24%, rgba(255, 202, 40, 1) 0, transparent 40%),
        linear-gradient(180deg, #e3f9e5 0%, #f5fff7 40%, #ffffff 100%);
}

#main-menu.menu-theme-sunset {
    background:
        /* soft glow */
        radial-gradient(circle at 12% 10%, rgba(255, 255, 255, 0.9) 0, transparent 45%),
        /* sun + halo */
        radial-gradient(circle at 84% 8%, rgba(255, 241, 118, 1) 0, rgba(255, 241, 118, 0.15) 60%),
        radial-gradient(circle at 84% 8%, rgba(255, 213, 79, 1) 0, rgba(255, 213, 79, 0.1) 80%),
        /* stars / confetti */
        radial-gradient(circle at 18% 24%, rgba(255, 255, 255, 1) 0, transparent 34%),
        radial-gradient(circle at 62% 20%, rgba(255, 255, 255, 0.95) 0, transparent 34%),
        radial-gradient(circle at 30% 34%, rgba(244, 143, 177, 0.95) 0, transparent 45%),
        radial-gradient(circle at 78% 32%, rgba(255, 183, 77, 0.95) 0, transparent 45%),
        linear-gradient(180deg, #ffe0b2 0%, #ffe5c7 35%, #fff8e1 65%, #ffffff 100%);
}

#main-menu.menu-theme-ocean {
    background:
        /* bubbles */
        radial-gradient(circle at 18% 16%, rgba(255, 255, 255, 0.95) 0, transparent 45%),
        radial-gradient(circle at 74% 14%, rgba(255, 255, 255, 0.9) 0, transparent 45%),
        radial-gradient(circle at 26% 30%, rgba(129, 212, 250, 1) 0, transparent 45%),
        radial-gradient(circle at 80% 32%, rgba(0, 188, 212, 1) 0, transparent 45%),
        /* waves / ribbons */
        linear-gradient(120deg, rgba(3, 169, 244, 0.5) 0, rgba(3, 169, 244, 0.0) 32%, rgba(3, 169, 244, 0.45) 64%, rgba(3, 169, 244, 0.0) 100%),
        linear-gradient(300deg, rgba(0, 188, 212, 0.45) 0, rgba(0, 188, 212, 0.0) 30%, rgba(0, 188, 212, 0.45) 65%, rgba(0, 188, 212, 0.0) 100%),
        linear-gradient(180deg, #e0f7fa 0%, #e3f2fd 40%, #ffffff 100%);
}

#main-menu.menu-theme-candy {
    background:
        /* puffy clouds */
        radial-gradient(circle at 18% 12%, rgba(255, 255, 255, 0.95) 0, transparent 45%),
        radial-gradient(circle at 80% 10%, rgba(255, 255, 255, 0.9) 0, transparent 45%),
        /* candy swirls / lollipops */
        radial-gradient(circle at 18% 34%, rgba(244, 143, 177, 1) 0, transparent 45%),
        radial-gradient(circle at 78% 32%, rgba(255, 138, 101, 1) 0, transparent 45%),
        radial-gradient(circle at 50% 22%, rgba(129, 212, 250, 1) 0, transparent 45%),
        /* ribbons */
        linear-gradient(135deg, rgba(255, 171, 145, 0.55) 0, rgba(255, 171, 145, 0.0) 40%, rgba(255, 171, 145, 0.45) 70%, rgba(255, 171, 145, 0.0) 100%),
        linear-gradient(225deg, rgba(244, 143, 177, 0.55) 0, rgba(244, 143, 177, 0.0) 40%, rgba(244, 143, 177, 0.45) 70%, rgba(244, 143, 177, 0.0) 100%),
        linear-gradient(180deg, #ffe4ec 0%, #fff3f8 45%, #ffffff 100%);
}

#main-menu.menu-theme-playroom {
    background:
        /* soft top glow */
        radial-gradient(circle at 12% 10%, rgba(255, 255, 255, 0.9) 0, transparent 45%),
        radial-gradient(circle at 90% 12%, rgba(255, 241, 118, 0.9) 0, transparent 55%),
        /* toy blocks / balls */
        radial-gradient(circle at 18% 30%, rgba(255, 183, 77, 1) 0, transparent 45%),
        radial-gradient(circle at 38% 26%, rgba(100, 181, 246, 1) 0, transparent 45%),
        radial-gradient(circle at 70% 28%, rgba(129, 199, 132, 1) 0, transparent 45%),
        radial-gradient(circle at 88% 30%, rgba(244, 143, 177, 1) 0, transparent 45%),
        linear-gradient(180deg, #fffde7 0%, #fffdf3 40%, #ffffff 100%);
}

.menu-content {
    text-align: center;
    background: rgba(255, 255, 255, 0.88);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-soft);
    border: 1px solid rgba(255, 255, 255, 0.9);
}

.menu-content h1 {
    text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.1);
}

.menu-content p {
    color: #666;
    font-weight: 700;
}

.made-in-india {
    font-family: var(--font-body);
    font-size: 0.7rem;
    position: absolute;
    left: 50%;
    bottom: 10px;
    transform: translateX(-50%);
    pointer-events: auto;
    max-width: 90vw;
    line-height: 1.2;
}

@media (max-width: 600px) {
    .made-in-india {
        font-size: 0.6rem;
        max-width: 86vw;
        line-height: 1.15;
    }
}

.carousel-container {
}

.carousel-arrow {
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--border-radius-round);
    width: 50px;
    height: 50px;
    font-size: 1.5rem;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    box-shadow: 0 4px 0 rgba(0, 0, 0, 0.15);
    flex-shrink: 0;
}

.carousel-arrow:hover {
    background-color: var(--primary-hover);
}

.carousel-arrow:active {
    transform: translateY(4px);
    box-shadow: 0 0px 0 rgba(0, 0, 0, 0.15);
}

.scene-selection {
    /* Carousel Scrolling */
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    /* Soften scrollbars */
    scrollbar-width: none;
    /* Hide scrollbar for cleaner look with arrows */
}

.scene-selection::-webkit-scrollbar {
    display: none;
}

.scene-selection::-webkit-scrollbar {
    height: 8px;
}

.scene-selection::-webkit-scrollbar-thumb {
    background: var(--secondary-color);
    border-radius: 4px;
}

.scene-selection::-webkit-scrollbar-track {
    background: var(--bg-color);
    border-radius: 4px;
}

.scene-btn {
    color: var(--secondary-color);
    box-shadow: var(--shadow-soft);
    position: relative;
    overflow: hidden;
    scroll-snap-align: center;
}

.scene-btn:hover {
    background: var(--bg-color);
    transform: translateY(-5px);
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.1);
}

.scene-thumb-wrap {
    position: relative;
    width: 100%;
}

.scene-btn img.scene-thumb {
    background-color: #eee;
}

.scene-thumb-done {
    position: absolute;
    top: 6px;
    right: 6px;
    display: none;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
    pointer-events: none;
}

.scene-thumb-done.visible {
    display: flex;
}

.scene-done-tick {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background-color: #5a8f5a;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

.scene-done-tick::after {
    content: '';
    width: 6px;
    height: 10px;
    margin-bottom: 2px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.scene-best-time {
    font-size: 0.6rem;
    font-weight: 700;
    color: #2d5a2d;
    line-height: 1.1;
    padding: 2px 6px;
    border-radius: 9999px;
    background: white;
    border: 1px solid rgba(0, 0, 0, 0.15);
    box-shadow: 0 0 1px rgba(0, 0, 0, 0.1);
}

/* Menu toggles (Timer, Game mode) – compact, non-dominant */
.menu-toggles {
    border-color: rgba(0, 0, 0, 0.08);
}

/* Same font size for label and toggle option text */
.toggle-label,
.toggle-pill,
.toggle-pill .mode-option,
.toggle-pill .timer-option {
    font-size: 0.8rem;
}

.toggle-label {
    font-weight: 600;
    color: #6b7280;
    white-space: nowrap;
    flex-shrink: 0;
}

.toggle-pill {
    position: relative;
    font-family: var(--font-body);
    font-weight: 600;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 8px;
    overflow: hidden;
}

/* Single continuous border as top layer – same on all sides */
.toggle-pill::after {
    content: "";
    position: absolute;
    inset: 0;
    border: 2px solid #4a5568;
    border-radius: 8px;
    pointer-events: none;
    box-sizing: border-box;
}

.toggle-pill .mode-option,
.toggle-pill .timer-option {
    padding: 6px 12px;
    min-width: 3.25rem;
    border: none;
    outline: none;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease;
    background-color: #e8ecf0;
    color: #5c6b7a;
    position: relative;
    z-index: 0;
}

.toggle-pill .mode-option:focus,
.toggle-pill .timer-option:focus {
    outline: none;
}

/* Match pill radius so segments fill to the inner edge (8px - 0 = 8px outer; inner curve ~6px) */
.toggle-pill .mode-option:first-child,
.toggle-pill .timer-option:first-child {
    border-radius: 6px 0 0 6px;
}

.toggle-pill .mode-option:last-child,
.toggle-pill .timer-option:last-child {
    border-radius: 0 6px 6px 0;
}

.toggle-pill .mode-option:hover:not(.active),
.toggle-pill .timer-option:hover:not(.active) {
    background-color: #d4e1ed;
    color: #37474f;
}

/* Selected: Timer Off = dark grey, Timer On = green */
#toggle-timer-off.active {
    background-color: #455a64;
    color: white;
}
#toggle-timer-off.active:hover {
    background-color: #37474f;
    color: white;
}
#toggle-timer-on.active {
    background-color: var(--success-color);
    color: white;
}
#toggle-timer-on.active:hover {
    background-color: #43a047;
    color: white;
}

/* Selected: Easy = lighter green, Hard = maroon-red */
#toggle-easy.active {
    background-color: #66bb6a;
    color: white;
}
#toggle-easy.active:hover {
    background-color: #5cb860;
    color: white;
}
#toggle-hard.active {
    background-color: #8e2a3a;
    color: white;
}
#toggle-hard.active:hover {
    background-color: #7a2331;
    color: white;
}

.toggle-pill .mode-option:active,
.toggle-pill .timer-option:active {
    transform: none;
}

/* =========================================
   GAME SCREEN (LAYOUT)
   ========================================= */
#game-screen {
    display: none;
    /* hidden by default; flex layout handled via Tailwind classes */
    height: 100%;
    max-width: 100vw;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: none;
}

#game-screen.active {
    display: flex;
    height: 100%;
}

#sidebar {
    background-color: var(--surface-color);
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    z-index: 10;
    display: flex;
    flex-direction: column;
}

#sidebar h2 {
    margin-bottom: 8px;
    font-size: 1.2rem;
}

.target-grid {
    flex: 1;
    align-content: start;
}

/* Custom Scrollbar for Sidebar */
.target-grid::-webkit-scrollbar {
    width: 8px;
}

.target-grid::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.target-grid::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 4px;
}

.target-grid::-webkit-scrollbar-thumb:hover {
    background: #aaa;
}


.target-item {
    position: relative;
    background-color: #f9f9f9;
    border: 3px solid #eee;
    border-radius: var(--border-radius-md);
    padding: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: all 0.3s ease;
    cursor: pointer;
}

.target-item:active {
    transform: scale(0.95);
}

.target-item.hint-anim {
    animation: hintShake 0.4s ease;
    border-color: var(--secondary-color);
}

.target-item .sprite-thumb {
    width: 60px;
    height: 60px;
    object-fit: contain;
    margin-bottom: 5px;
    border-radius: var(--border-radius-sm);
    filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.2));
}

.target-item span {
    font-weight: 700;
    font-size: 0.9rem;
    text-align: center;
}

/* State when found */
.target-item.found {
    border-color: var(--success-color);
    background-color: #E8F5E9;
    opacity: 0.6;
    transform: scale(0.95);
}

.target-item.found .sprite-thumb {
    filter: grayscale(80%);
}

/* Centred thick rounded tick on found items (game-style) */
.target-item.found::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 36px;
    height: 36px;
    background-color: var(--success-color);
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12l5 6 9-10'/%3E%3C/svg%3E") center / contain no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12l5 6 9-10'/%3E%3C/svg%3E") center / contain no-repeat;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.2));
    pointer-events: none;
}

.target-item.recently-found {
    animation: pulseGlow 1s ease;
}

.target-item.locked {
    border-color: rgba(255, 255, 255, 0.9);
    background-color: rgba(255, 255, 255, 0.85);
    opacity: 0.95;
}

.target-item.locked .sprite-thumb {
    filter: grayscale(100%) opacity(0.25);
}

.target-item.locked span {
    opacity: 0;
}

.target-item.locked::after {
    content: "?";
    position: absolute;
    left: 50%;
    top: 42%;
    transform: translateX(-50%);
    font-family: var(--font-heading);
    font-size: 1.4rem;
    color: rgba(96, 125, 139, 0.95);
}


.sidebar-controls {
    margin-top: auto;
}

#progress-text {
    font-family: var(--font-heading);
    color: var(--primary-color);
}

#back-to-menu-btn {}


/* =========================================
   MAIN SCENE CONTAINER
   ========================================= */
#scene-container {
    flex: 1;
    height: 100%;
    min-width: 0;
    max-width: 100%;
    position: relative;
    background-color: #333;
    /* Dark backdrop for letterboxing */
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

#scene-wrapper {
    position: relative;
    /* This will be dynamically scaled via JS to fit the container while maintaining aspect ratio */
    transform-origin: center center;
    background: #fff;
    box-shadow: var(--shadow-soft);
    flex-shrink: 0;
    /* CRITICAL: Prevent flexbox from breaking the aspect ratio */
}

#scene-image {
    display: block;
    width: 100%;
    height: auto;
    pointer-events: none;
    /* Let clicks pass through to hitboxes if needed, though usually hitboxes are above */
}

#hitboxes {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.hitbox {
    position: absolute;
    cursor: crosshair;
    border-radius: var(--border-radius-round);
    aspect-ratio: 1 / 1;
    /* Dynamically scale the minimum physical tap target to 44px regardless of container zoom */
    min-width: calc(44px * var(--inverse-scale, 1));
    min-height: calc(44px * var(--inverse-scale, 1));
}

.sprite-render {
    /* Soft shadow to pop out from background a bit */
    filter: drop-shadow(2px 2px 4px rgba(0, 0, 0, 0.5));
}

/* Animations added to hitboxes when found */
.hitbox.found-anim {
    animation: bouncePop 0.8s ease forwards;
    pointer-events: none;
}

.hitbox.found {
    pointer-events: none;
}

.hitbox.scene-hint-anim {
    animation: bouncePop 1s ease 2;
    filter: drop-shadow(0 0 25px var(--secondary-color));
    z-index: 100;
}

.popout-object {
    position: absolute;
    background-size: contain;
    background-position: center center;
    background-repeat: no-repeat;
    pointer-events: none;
    z-index: 120;
    border: 4px solid #ffffff;
    border-radius: 12px;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.8);
    animation: objPop 1.2s ease-out forwards;
    filter: drop-shadow(0 8px 12px rgba(0, 0, 0, 0.35));
}

/* =========================================
   OVERLAYS & EFFECTS
   ========================================= */
#confetti-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 50;
}

.loader {
    font-family: var(--font-heading);
    font-size: 3rem;
    color: var(--primary-color);
    animation: pulse 1s infinite alternate;
    padding: 24px 32px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 24px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.18);
}

#loading {
    background: radial-gradient(circle at center, #ffffff 0%, rgba(240, 248, 255, 0.9) 55%, rgba(240, 248, 255, 0.98) 100%);
    z-index: 200;
}

.win-content {
    background: var(--surface-color);
    padding: 50px;
    border-radius: var(--border-radius-lg);
    text-align: center;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    border: 5px solid var(--success-color);
}

.win-content h2 {
    font-size: 3.5rem;
    color: var(--success-color);
    margin-bottom: 10px;
}

.win-content p {
    font-size: 1.5rem;
    margin-bottom: 30px;
}

.win-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
}

/* =========================================
   ANIMATIONS
   ========================================= */
@keyframes pulse {
    0% {
        transform: scale(1);
    }

    100% {
        transform: scale(1.1);
    }
}

@keyframes pulseGlow {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 rgba(76, 175, 80, 0);
    }

    50% {
        transform: scale(1.1);
        box-shadow: var(--shadow-glow);
        border-color: var(--success-color);
    }

    100% {
        transform: scale(1);
        box-shadow: 0 0 0 rgba(76, 175, 80, 0);
    }
}

@keyframes bouncePop {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.5);
        filter: drop-shadow(0 0 10px yellow);
    }

    100% {
        transform: scale(1);
        opacity: 0.5;
    }
}

@keyframes objPop {
    0% {
        transform: translate(-50%, -50%) scale(0.8) rotate(0deg);
        opacity: 0;
    }

    35% {
        transform: translate(-50%, -55%) scale(1.15) rotate(0deg);
        opacity: 1;
    }

    55% {
        transform: translate(-50%, -55%) scale(1.15) rotate(-4deg);
        opacity: 1;
    }

    75% {
        transform: translate(-50%, -55%) scale(1.15) rotate(4deg);
        opacity: 1;
    }

    100% {
        transform: translate(-50%, -50%) scale(1.0) rotate(0deg);
        opacity: 0;
    }
}

@keyframes hintShake {
    0% {
        transform: rotate(0deg) scale(1.05);
    }

    25% {
        transform: rotate(-5deg) scale(1.05);
    }

    50% {
        transform: rotate(5deg) scale(1.05);
    }

    75% {
        transform: rotate(-5deg) scale(1.05);
    }

    100% {
        transform: rotate(0deg) scale(1);
    }
}

/* =========================================
   RESPONSIVE DESIGN (TABLETS/MOBILES)
   ========================================= */
@media (max-width: 900px) {
    #main-menu.screen.active {
        align-items: stretch;
        justify-content: center;
    }

    .menu-content {
        width: 100%;
        max-width: 640px;
        margin: 0 12px;
        padding: 24px 16px;
    }

    .carousel-container {
        flex-direction: row;
        align-items: center;
    }

    .carousel-arrow {
        width: 36px;
        height: 36px;
        font-size: 1.1rem;
    }

    /* Game screen: scene on top, sidebar (objects) underneath */
    #game-screen.active {
        flex-direction: column-reverse;
    }

    #sidebar {
        width: 100%;
        flex: 0 0 auto;
        height: 25%;
        max-height: 25vh;
        padding: 8px 10px 10px;
        display: flex;
        flex-direction: column;
        gap: 4px;
    }

    #sidebar h2 {
        display: block;
        font-size: 1.2rem;
        text-align: left;
        margin-bottom: 2px;
    }

    .target-grid {
        display: flex;
        flex-direction: row;
        gap: 10px;
        padding-bottom: 0;
        overflow-x: auto;
        overflow-y: hidden;
        flex: 1;
        align-items: center;
    }

    .target-item {
        flex: 0 0 auto;
        width: 80px;
        padding: 5px;
    }

    .target-item.found::after {
        width: 28px;
        height: 28px;
    }

    .target-item .sprite-thumb {
        width: 40px;
        height: 40px;
    }

    .target-item span {
        font-size: 0.7rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100%;
    }

    .sidebar-controls {
        margin-top: 4px;
        padding-top: 4px;
        border-top: 1px solid #eee;
        border-left: none;
        padding-left: 0;
        margin-left: 0;
        min-width: 0;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        gap: 8px;
    }

    #progress-text {
        font-size: 1rem;
    }

    #back-to-menu-btn {
        width: auto;
        padding: 8px 12px;
        font-size: 0.95rem;
        white-space: nowrap;
    }

    #scene-container {
        flex: 1;
        flex-direction: column;
        align-items: center;
        justify-content: center;
    }
}

/* Extra tuning for small phones */
@media (max-width: 600px) {
    body {
        font-size: 14px;
    }

    .app-header {
        top: 10px;
        right: auto;
        left: 50%;
        transform: translateX(-50%);
    }

    .lang-dropdown {
        font-size: 0.9rem;
        padding: 6px 10px;
        width: 80vw;
        max-width: 280px;
    }

    .menu-content {
        padding: 1vh 3vw 2vh;
        margin: 6vh auto 0;
        width: calc(100% - 24px); /* symmetric 12px gutters on both sides */
        max-width: 480px;
        min-width: 0;
    }

    .menu-toggles {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .toggle-group {
        justify-content: space-between;
        max-width: 100%;
    }

    .toggle-label {
        font-size: 0.8rem;
    }

    .toggle-pill .mode-option,
    .toggle-pill .timer-option {
        padding: 8px 14px;
        min-width: 3.5rem;
    }

    .menu-content h1 {
        font-size: clamp(1.8rem, 8vw, 2.4rem);
    }

    .menu-content p {
        font-size: clamp(0.9rem, 4vw, 1.1rem);
        margin-bottom: 2vh;
    }

    #main-menu.screen.active {
        justify-content: center;
        align-items: center;
        padding-top: 0;
        padding-bottom: 0;
        box-sizing: border-box;
    }

    .carousel-container {
        flex-direction: row;
        align-items: center;
        gap: 2vw;
    }

    .carousel-arrow {
        display: none;
    }

    .scene-selection {
        width: 100%;
        justify-content: flex-start;
        padding: 1vh 2vw;
        gap: 4vw;
    }

    .scene-btn {
        flex: 0 0 auto;
        max-width: none;
        padding: 2vw;
        border-width: 3px;
    }

    .scene-btn img {
        width: 100%;
        height: auto;
        max-width: none;
        max-height: none;
    }

    .target-item {
        width: 70px;
    }

    .target-item span {
        font-size: 0.65rem;
    }

    #progress-text {
        font-size: 1rem;
    }

    button {
        padding: 10px 18px;
        font-size: 1rem;
    }

    .win-content {
        padding: 24px 18px;
    }

    .win-content h2 {
        font-size: 2.2rem;
    }

    .win-content p {
        font-size: 1.1rem;
    }

    .made-in-india {
        position: absolute;
        left: 50%;
        bottom: 10px;
        transform: translateX(-50%);
        margin: 0;
        text-align: center;
        max-width: 92vw;
        line-height: 1.2;
        display: block;
    }
}