
/* ============================================
   LANDSCAPE GAME STAGE ARCHITECTURE
   Fixed Stage: 1280×720px (16:9 landscape)
   Scales to fit viewport using transform: scale()
   Touch Target Minimum: 52px (WCAG 44px + toddler buffer)
   ============================================ */

:root {
    --stage-scale: 1;
    --stage-width: 1280px;
    --stage-height: 720px;

    /* Responsive size tokens using clamp() for bounded scaling */
    --gap-xs: clamp(6px, 0.8vw, 10px);
    --gap-sm: clamp(10px, 1.2vw, 16px);
    --gap-md: clamp(14px, 1.8vw, 24px);
    --gap-lg: clamp(20px, 2.5vw, 36px);

    --font-title: clamp(28px, 3.5vw, 48px);
    --font-body: clamp(20px, 2.2vw, 32px);
    --font-button: clamp(22px, 2.5vw, 36px);
    --font-instruction: clamp(18px, 2vw, 28px);

    --btn-height: clamp(52px, 8vh, 84px);
    --btn-width: clamp(100px, 14vw, 180px);

    --tile-size: clamp(72px, 10vw, 130px);
    --emoji-size: clamp(48px, 6vw, 80px);
}

/* App shell - handles viewport and safe areas */
html, body {
    font-family: var(--font-main);
    background: url('../wallpaper_space.png') no-repeat center center fixed;
    background-size: cover;
    color: var(--color-text-main);
}

#app-shell {
    position: fixed;
    inset: 0;
    overflow: hidden;
    /* Safe area insets for notched devices */
    padding:
        env(safe-area-inset-top)
        env(safe-area-inset-right)
        env(safe-area-inset-bottom)
        env(safe-area-inset-left);
}

/* Game stage - fixed 1280x720 canvas, scaled by JS */
#game-stage {
    /* JS sets: position: absolute, left: 50%, top: 50%, transform-origin: center */
    /* JS sets: width: 1280px, height: 720px, transform: translate(-50%, -50%) scale(X) */
    background: transparent;
}

/* App container - holds all game content at 1280x720 stage size */
#app {
    width: 1280px;
    height: 720px;
    position: relative;
    overflow: hidden;
}

:root {
    /* Glossy Game Palette */

    /* Background */
    --color-bg-wood: #5D4037;
    --color-bg-table: radial-gradient(circle at center, #8D6E63 0%, #4E342E 100%);

    /* Panels */
    --color-panel-bg: #FFFFFF;
    --color-panel-border: #00BCD4;
    --panel-border-width: 6px;
    --panel-radius: 24px;
    --shadow-panel: 0 10px 20px rgba(0, 0, 0, 0.3);

    /* Glossy Tile Colors - Vibrant gradients for good contrast */
    --tile-red: linear-gradient(to bottom, #FF5252, #D32F2F);
    --tile-red-shadow: #B71C1C;

    --tile-green: linear-gradient(to bottom, #69F0AE, #00C853);
    --tile-green-shadow: #1B5E20;

    --tile-blue: linear-gradient(to bottom, #448AFF, #2979FF);
    --tile-blue-shadow: #01579B;

    --tile-orange: linear-gradient(to bottom, #FFB74D, #FF6D00);
    --tile-orange-shadow: #E65100;

    /* Text */
    --color-text-main: #3E2723;
    --font-main: 'Outfit', 'Segoe UI', 'San Francisco', -apple-system, BlinkMacSystemFont, 'Roboto', sans-serif;
    --font-hand: 'Bubblegum Sans', cursive;

    /* Fallback */
    --color-bg-page: #FFF8E1;
}

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

body {
    margin: 0;
    padding: 0;
    font-family: var(--font-main);
    background: url('../wallpaper_space.png') no-repeat center center fixed;
    background-size: cover;
    color: var(--color-text-main);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

/* Base Classes */
.full-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.flex-center {
    display: flex;
    align-items: center;
    justify-content: center;
}

.column {
    flex-direction: column;
}

/* Confetti */
.confetti {
    position: absolute;
    width: 20px;
    height: 20px;
    background: #f00;
    top: -50px;
    animation: rain 3s linear forwards;
    z-index: 101;
}

.confetti-particle {
    position: absolute;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    z-index: 999;
    pointer-events: none;
}

@keyframes rain {
    to {
        transform: translateY(110vh) rotate(720deg);
    }
}

@keyframes fall {
    to {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

/* 1. Game Panel (The White Card) */
.game-panel {
    background: var(--color-panel-bg);
    border: var(--panel-border-width) solid var(--color-panel-border);
    border-radius: var(--panel-radius);
    box-shadow: var(--shadow-panel);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* 2. Glossy Button/Tile */
.btn-tile {
    border: none;
    border-radius: 16px;
    color: #ffffff !important;
    font-weight: 900;
    font-size: 48px;
    text-shadow: 0 3px 6px rgba(0, 0, 0, 0.5);
    cursor: pointer;
    position: relative;
    transition: transform 0.1s;
    font-family: var(--font-main);

    /* Default Blue */
    background: var(--tile-blue);
    box-shadow: 0 6px 0 var(--tile-blue-shadow), 0 10px 10px rgba(0, 0, 0, 0.2);
}

.btn-tile:active {
    transform: translateY(6px);
    box-shadow: 0 0 0 var(--tile-blue-shadow), inset 0 2px 5px rgba(0, 0, 0, 0.2);
}

/* Variant Colors */
.btn-tile.red {
    background: var(--tile-red);
    box-shadow: 0 6px 0 var(--tile-red-shadow);
}

.btn-tile.red:active {
    box-shadow: 0 0 0 var(--tile-red-shadow);
}

.btn-tile.green {
    background: var(--tile-green);
    box-shadow: 0 6px 0 var(--tile-green-shadow);
}

.btn-tile.green:active {
    box-shadow: 0 0 0 var(--tile-green-shadow);
}

.btn-tile.orange {
    background: var(--tile-orange);
    box-shadow: 0 6px 0 var(--tile-orange-shadow);
}

.btn-tile.orange:active {
    box-shadow: 0 0 0 var(--tile-orange-shadow);
}

.btn-secondary {
    background: #FF9800;
    border: 3px solid #fff;
    color: white;
    font-size: 24px;
    padding: 10px 30px;
    border-radius: 30px;
    box-shadow: 0 5px 0 #E65100, 0 10px 10px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    font-weight: bold;
    transition: transform 0.1s;
    font-family: var(--font-main);
}

.btn-secondary:active {
    transform: translateY(5px);
    box-shadow: 0 0 0 #E65100;
}

/* 3. Beads (Shiny Spheres) */
.bead {
    border-radius: 50%;
    box-shadow: 2px 4px 5px rgba(0, 0, 0, 0.3);
    position: relative;
}

.bead::after {
    content: '';
    position: absolute;
    top: 15%;
    left: 15%;
    width: 30%;
    height: 30%;
    background: radial-gradient(white, transparent);
    border-radius: 50%;
    opacity: 0.8;
}

.bead.green {
    background: radial-gradient(circle at 30% 30%, #66BB6A, #1B5E20);
}

.bead.red {
    background: radial-gradient(circle at 30% 30%, #EF5350, #B71C1C);
}

.bead.yellow {
    background: radial-gradient(circle at 30% 30%, #FFEE58, #F57F17);
}

/* Common UI */
/* Mapping btn-core to match btn-tile style manually since CSS doesn't support @extend */
.btn-core {
    border: none;
    border-radius: 16px;
    color: white;
    font-weight: 900;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    /* Explicit size */

    /* Default Blue */
    background: var(--tile-blue);
    box-shadow: 0 6px 0 var(--tile-blue-shadow), 0 10px 10px rgba(0, 0, 0, 0.2);

    cursor: pointer;
    position: relative;
    transition: transform 0.1s;
    font-family: var(--font-main);
}

.btn-core:active {
    transform: translateY(6px);
    box-shadow: 0 0 0 var(--tile-blue-shadow), inset 0 2px 5px rgba(0, 0, 0, 0.2);
}

/* --- NEW V2 STYLES (COMMERCIAL GRADE) --- */

/* Top Navigation Bar */
.top-bar {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    padding: 15px 25px;
    display: flex;
    justify-content: space-between;
    z-index: 100;
}

.btn-nav {
    background: rgba(255, 255, 255, 0.9);
    border: 3px solid #eee;
    border-radius: 50px;
    /* Toddler Sizing */
    padding: 12px 25px;
    font-size: 29px;
    font-weight: bold;
    color: #5D4037;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    transition: transform 0.1s;
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: var(--font-hand);
}

.btn-nav:active {
    transform: scale(0.95);
}

.icon-lock {
    font-size: 19px;
    opacity: 0.6;
}

/* Main Title Area */
.title-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    margin-top: -60px;
    /* Offset for carousel */
    z-index: 10;
}

.game-title {
    font-size: 80px;
    color: #fff;
    text-shadow: 0 5px 0 #3E2723, 0 10px 20px rgba(0, 0, 0, 0.4);
    line-height: 1.1;
    text-align: center;
    margin-bottom: 30px;
    transform: rotate(-3deg);
    font-family: var(--font-hand);
}

.daily-adventure-card {
    background: #fff;
    border-radius: 30px;
    padding: 20px 40px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
    text-align: center;
    cursor: pointer;
    animation: gentle-float 4s infinite ease-in-out;
    border: 6px solid #FFCA28;
}

.daily-adventure-card:active {
    transform: scale(0.95);
}

.rocket-icon {
    font-size: 96px;
    display: block;
    margin-bottom: 10px;
}

.cta-text {
    font-size: 32px;
    font-weight: 900;
    color: #E65100;
    text-transform: uppercase;
    letter-spacing: 2px;
    font-family: var(--font-main);
}

@keyframes gentle-float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-15px);
    }
}

/* Bottom Carousel Strip */
.carousel-strip {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 220px;
    background: rgba(255, 255, 255, 0.95);
    border-top: 6px solid #4DB6AC;
    display: flex;
    align-items: center;
    padding: 0 10px;
    box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.1);
    z-index: 90;
}

.carousel-track {
    flex: 1;
    display: flex;
    overflow-x: auto;
    gap: 20px;
    padding: 20px;
    scroll-behavior: smooth;
    -ms-overflow-style: none;
    /* Hide scrollbar IE */
    scrollbar-width: none;
    /* Hide scrollbar Firefox */
}

.carousel-track::-webkit-scrollbar {
    display: none;
}

.game-tile {
    min-width: 140px;
    height: 140px;
    background: #fff;
    border-radius: 25px;
    box-shadow: 0 8px 0 rgba(0, 0, 0, 0.1), 0 10px 10px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px;
    cursor: pointer;
    border: 3px solid #eee;
    transition: transform 0.1s;
}

.game-tile:active {
    transform: translateY(5px);
    box-shadow: 0 3px 0 rgba(0, 0, 0, 0.1);
}

.game-tile.selected {
    border-color: #FF9800;
    transform: scale(1.05);
}

.tile-icon {
    font-size: 56px;
    margin-bottom: 5px;
}

.tile-label {
    font-size: 16px;
    font-weight: bold;
    color: #5D4037;
    text-align: center;
    line-height: 1.1;
    font-family: var(--font-hand);
}

/* Color Variants for Tiles */
.tile-blue {
    background: linear-gradient(135deg, #E3F2FD, #BBDEFB);
    border-color: #2196F3;
}

.tile-green {
    background: linear-gradient(135deg, #E8F5E9, #C8E6C9);
    border-color: #4CAF50;
}

.tile-orange {
    background: linear-gradient(135deg, #FFF3E0, #FFE0B2);
    border-color: #FF9800;
}

.tile-purple {
    background: linear-gradient(135deg, #F3E5F5, #E1BEE7);
    border-color: #9C27B0;
}

.tile-red {
    background: linear-gradient(135deg, #FFEBEE, #FFCDD2);
    border-color: #F44336;
}

.carousel-arrow {
    border-radius: 50%;
    border: 3px solid #fff;
    color: white;
    font-size: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 0 #AF6C00;
    z-index: 95;
    flex-shrink: 0;
    transition: transform 0.1s;
    /* Toddler Target Size */
    width: 80px;
    height: 80px;
}

.carousel-arrow:hover {
    transform: scale(1.1);
}

.carousel-arrow:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 #AF6C00;
}

/* Parents Gate Overlay */
.parents-gate {
    background: rgba(0, 0, 0, 0.9);
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: white;
}

.gate-msg {
    font-size: 32px;
    margin-bottom: 30px;
    text-align: center;
    font-family: var(--font-main);
}

.gate-actions {
    display: flex;
    gap: 20px;
}

.gate-btn {
    padding: 15px 40px;
    border-radius: 15px;
    font-size: 24px;
    border: none;
    cursor: pointer;
    font-family: var(--font-main);
}

.btn-cancel {
    background: #555;
    color: #fff;
}

.btn-confirm {
    background: #4CAF50;
    color: #fff;
}

/* Hold Gate Specifics */
.gate-actions.column {
    flex-direction: column;
    align-items: center;
}

.btn-giant {
    font-size: 40px;
    padding: 30px 60px;
    border-radius: 25px;
    background: #2196F3;
    color: white;
    border: 6px solid #fff;
    box-shadow: 0 10px 0 #0D47A1;
    cursor: pointer;
    transition: all 0.1s;
    user-select: none;
    -webkit-user-select: none;
    font-family: var(--font-main);
}

.btn-giant:active,
.btn-giant.holding {
    transform: scale(0.95);
    background: #1976D2;
    box-shadow: 0 4px 0 #0D47A1;
}

.progress-bar-container {
    width: 300px;
    height: 20px;
    background: #333;
    border-radius: 10px;
    margin-top: 20px;
    overflow: hidden;
    border: 2px solid #555;
}

.progress-bar-fill {
    width: 0%;
    height: 100%;
    background: #4CAF50;
}

/* Sticker Preview */
.stickers-preview {
    position: absolute;
    bottom: 20px;
    width: 100%;
    text-align: center;
    font-size: 48px;
}

.floating-sticker {
    display: inline-block;
    animation: float 3s infinite ease-in-out;

    margin: 0 10px;
}

/* Sticker Book */
.sticker-book {
    background: url('data:image/svg+xml;utf8,<svg width="100" height="100" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg"><circle cx="50" cy="50" r="2" fill="%23FFE0B2" opacity="0.5"/></svg>'), #FFF8E1;
    overflow: hidden;
    /* Fix: Prevent whole page scroll */
}

.sticker-header {
    width: 100%;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #FFECB3;
    border-bottom: 4px solid #FFCA28;
    box-shadow: 0 5px 10px rgba(0, 0, 0, 0.1);
}

.sticker-grid {
    flex: 1;
    width: 100%;
    max-width: 900px;
    padding: 40px;
    display: flex;
    flex-wrap: wrap;
    gap: 30px;
    justify-content: center;
    align-content: flex-start;
    overflow-y: auto;
    /* Fix: Scroll content only */
    -webkit-overflow-scrolling: touch;
    /* Smooth scroll on iOS */
}

.sticker-item {
    width: 120px;
    height: 120px;
    background: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 80px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    transform: rotate(calc(var(--r, 0deg)));
    transition: transform 0.2s;
}

.sticker-item:hover {
    transform: scale(1.2) rotate(10deg);
}

.sticker-item:nth-child(2n) {
    --r: 5deg;
}

.sticker-item:nth-child(3n) {
    --r: -5deg;
}

.empty-msg {
    font-size: 32px;
    color: #8D6E63;
    opacity: 0.6;
    margin-top: 50px;
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

/* Game Interface */
.game-viewport {
    width: 95vw;
    height: 85vh;
    /* Use vh for better scaling */
    max-height: 850px;
    background: rgba(255, 255, 255, 0.95);
    /* Increased opacity for better contrast */
    border-radius: 30px;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    /* Center content vertically */
    position: relative;
    padding: 80px 20px 20px 20px;
    /* Top padding to clear header */
    margin: 10px auto;
    border: 6px solid #FFF;
    /* Add border for pop */
}

.game-header {
    position: absolute;
    top: 15px;
    left: 15px;
    right: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 100;
    pointer-events: none;
    /* Let clicks pass through spacer */
}

.game-header button {
    pointer-events: auto;
    /* Re-enable clicks on buttons */
}

.btn-icon {
    background: #fff;
    border: 4px solid #eee;
    /* Thicker border */
    font-size: 35px;
    border-radius: 50%;
    width: 70px;
    /* Slightly smaller to save space */
    height: 70px;
    cursor: pointer;
    transition: transform 0.1s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    /* Center icon */
    align-items: center;
    justify-content: center;
    box-shadow: 0 5px 10px rgba(0, 0, 0, 0.15);
}

.btn-icon:active {
    transform: scale(0.9);
    background-color: #f0f0f0;
}

.level-indicator {
    background: #FF9800;
    color: white;
    padding: 8px 25px;
    border-radius: 30px;
    font-weight: 900;
    font-size: 29px;
    font-family: var(--font-hand);
    /* Use playful font */
    box-shadow: 0 4px 0 #E65100;
    border: 3px solid #fff;
}

/* Game Modes */
.count-container {
    flex-direction: column;
    gap: 30px;
    /* Increased gap */
    width: 100%;
    max-width: 900px;
    align-items: center;
}

.items-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 25px;
    /* Increased gap */
    justify-content: center;
    max-width: 100%;
    padding: 10px;
}

.game-item {
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
    font-size: 80px;
    /* Standard size */
    width: 120px;
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    background: rgba(255, 255, 255, 0.5);
    /* Subtle background */
    border-radius: 20%;
    user-select: none;
}

.game-item:active,
.game-item.pulse {
    transform: scale(1.15);
}

.options-row {
    display: flex;
    gap: 30px;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 20px;
}

.option {
    min-width: clamp(120px, 15vw, 180px);
    min-height: clamp(80px, 10vh, 120px);
    padding: 2vmin 3vmin;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(32px, 4vw, 56px);
    font-weight: 900;
    color: #ffffff !important;
    text-shadow: 0 3px 6px rgba(0, 0, 0, 0.5);
}

@keyframes point-click {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-15px);
    }
}

/* Hand Pointer */
.hand-pointer {
    filter: drop-shadow(0 5px 10px rgba(0, 0, 0, 0.3));
    font-size: 80px !important;
    /* Force large size */
}

/* Feedback Overlay */
.feedback-overlay {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    font-size: 12rem;
    /* Larger */
    pointer-events: none;
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 200;
    text-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
}

.feedback-overlay.active {
    transform: translate(-50%, -50%) scale(1);
    animation: wobble 0.6s ease-in-out;
}

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

    15% {
        transform: translate(-50%, -50%) rotate(-10deg) scale(1.1);
    }

    30% {
        transform: translate(-50%, -50%) rotate(8deg) scale(1.1);
    }

    45% {
        transform: translate(-50%, -50%) rotate(-6deg) scale(1.1);
    }

    60% {
        transform: translate(-50%, -50%) rotate(4deg) scale(1.1);
    }

    75% {
        transform: translate(-50%, -50%) rotate(-2deg) scale(1.1);
    }

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

/* Celebration Overlay */
.celebration-overlay {
    background: rgba(0, 0, 0, 0.85);
    z-index: 500;
    transition: opacity 0.5s;
}

.celebration-emoji {
    font-size: 12rem;
    filter: drop-shadow(0 0 30px rgba(255, 215, 0, 0.5));
}

.sticker-reward {
    font-size: 8rem;
    background: white;
    padding: 20px;
    border-radius: 50%;
    box-shadow: 0 0 50px white;
    margin-top: 20px;
    animation: spinPop 1s ease-out;
}

@keyframes spinPop {
    from {
        transform: scale(0) rotate(-180deg);
    }

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

.fade-out {
    opacity: 0;
}

/* Instruction Toast */
.instruction-toast {
    position: absolute;
    bottom: 20%;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 10px 30px;
    border-radius: 50px;
    font-size: 32px;
    animation: fadeUp 0.5s ease-out;
}

@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Animations */
.animate-pop {
    animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.animate-drop {
    animation: dropIn 0.5s ease-out backwards;
}

@keyframes dropIn {
    from {
        opacity: 0;
        transform: translateY(-50px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes point-click {

    0%,
    100% {
        transform: translateY(0) scale(1);
    }

    50% {
        transform: translateY(-10px) scale(1.2);
    }
}

/* --- Game Mode Specifics --- */

/* Compare Game */
.compare-container {
    display: flex;
    gap: 20px;
    width: 100%;
    height: 100%;
    align-items: center;
    justify-content: center;
}

.compare-side {
    flex: 1;
    height: 80%;
    background: #fff;
    border: 4px solid #eee;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.1s, border-color 0.2s;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
}

.compare-side:active {
    transform: scale(0.95);
    border-color: #00BCD4;
}

.mini-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.mini-item {
    font-size: 48px;
}

/* Pattern Game */
.pattern-container {
    width: 100%;
    gap: 40px;
}

.sequence-row {
    display: flex;
    gap: 10px;
    background: rgba(255, 255, 255, 0.5);
    padding: 20px;
    border-radius: 20px;
}

.seq-item {
    width: 80px;
    height: 80px;
    background: #fff;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    box-shadow: 0 4px 0 rgba(0, 0, 0, 0.1);
}

.seq-item.question {
    background: #eee;
    color: #bbb;
    border: 2px dashed #ccc;
    box-shadow: none;
}

/* Find Odd Game */
.odd-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
}

.grid-item {
    width: 90px;
    height: 90px;
    background: #fff;
    border-radius: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 56px;
    cursor: pointer;
    box-shadow: 0 6px 0 rgba(0, 0, 0, 0.1);
    transition: transform 0.1s;
}

.grid-item:active {
    transform: translateY(4px);
    box-shadow: 0 2px 0 rgba(0, 0, 0, 0.1);
}

/* Sort Game */
.sort-game {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    justify-content: space-between;
}

.items-pool {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}

.sort-item {
    font-size: 64px;
    cursor: pointer;
    transition: transform 0.2s;
    filter: drop-shadow(0 5px 5px rgba(0, 0, 0, 0.2));
}

.sort-item:hover {
    transform: scale(1.1);
}

.baskets-row {
    display: flex;
    justify-content: space-around;
    padding-bottom: 20px;
}

/* Three-basket layout for advanced sorting */
.baskets-row.three-baskets {
    gap: 15px;
}

.baskets-row.three-baskets .basket {
    width: 150px;
    height: 130px;
    font-size: 24px;
}

.basket {
    width: 200px;
    /* Increased from 150px */
    height: 150px;
    /* Increased from 100px */
    border: 6px dashed #8D6E63;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 20px 20px 50px 50px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: #5D4037;
    font-size: 32px;
    /* Bigger text */
    text-align: center;
    line-height: 1.2;
}

.hidden {
    display: none !important;
}

.draggable {
    touch-action: none;
    cursor: grab;
}

.dragging {
    opacity: 0.8;
    transform: scale(1.1);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
    pointer-events: none;
}

/* Magnet Effect - Visual feedback when item is close to drop zone */
.magnet-active {
    animation: magnet-pulse 0.6s ease-in-out infinite;
    border-color: #4CAF50 !important;
    border-width: 4px !important;
    box-shadow: 0 0 20px rgba(76, 175, 80, 0.6), 0 10px 40px rgba(0, 0, 0, 0.3);
}

@keyframes magnet-pulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 20px rgba(76, 175, 80, 0.6), 0 10px 40px rgba(0, 0, 0, 0.3);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 0 30px rgba(76, 175, 80, 0.8), 0 15px 50px rgba(0, 0, 0, 0.4);
    }
}

/* Toddler Enhancements */
.game-item,
.sort-item,
.grid-item,
.btn-tile,
.option,
.basket,
.btn-icon,
.btn-giant,
.btn-secondary {
    min-width: 100px;
    /* Increased from 80px */
    min-height: 100px;
    /* Increased from 80px */
    touch-action: none;
    /* Prevent zoom */
}

.game-item {
    font-size: 8rem;
    /* Increased from 6rem */
}

.instruction-sub {
    font-size: 40px;
    color: #fff;
    text-align: center;
    margin-bottom: 20px;
    font-weight: 600;
    background: linear-gradient(135deg, #2196F3, #1976D2);
    padding: 15px 30px;
    border-radius: 50px;
    box-shadow: 0 5px 15px rgba(33, 150, 243, 0.3);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    animation: pulseGlow 2s infinite;
}

@keyframes pulseGlow {

    0%,
    100% {
        box-shadow: 0 5px 15px rgba(33, 150, 243, 0.3);
    }

    50% {
        box-shadow: 0 5px 25px rgba(33, 150, 243, 0.5);
    }
}

.hand-pointer {
    filter: drop-shadow(0 5px 10px rgba(0, 0, 0, 0.3));
}

/* --- MISSING GAME STYLES (Restored) --- */

/* 1. Compare Game ({..} vs {..}) */
.compare-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 50px;
    width: 100%;
    height: 100%;
}

.compare-side {
    background: rgba(255, 255, 255, 0.5);
    border: 4px dashed #BCAAA4;
    border-radius: 20px;
    padding: 20px;
    min-width: 300px;
    min-height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    /* Interaction hint */
    transition: transform 0.2s, background 0.2s;
}

.compare-side:active {
    transform: scale(0.95);
    background: #FFECB3;
    border-color: #FFCA28;
}

.mini-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.mini-item {
    font-size: 48px;
}

/* 2. Pattern Game (A B A ?) */
.pattern-container {
    width: 100%;
    gap: 40px;
}

.sequence-row {
    display: flex;
    gap: 20px;
    background: #FFF3E0;
    padding: 20px 40px;
    border-radius: 50px;
    box-shadow: inset 0 5px 10px rgba(0, 0, 0, 0.1);
}

.seq-item {
    width: 100px;
    height: 100px;
    font-size: 64px;
    background: white;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 0 #ddd;
}

.drop-zone {
    border: 4px dashed #FF9800;
    background: rgba(255, 255, 255, 0.5);
    color: #FF9800;
    font-weight: bold;
}

/* 3. Find Odd (Grid) */
.odd-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    padding: 20px;
}

.grid-item {
    width: 140px;
    height: 140px;
    background: white;
    border-radius: 25px;
    font-size: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 0 rgba(0, 0, 0, 0.1);
    cursor: pointer;
    transition: transform 0.1s;
    border: 4px solid transparent;
}

.grid-item:active {
    transform: scale(0.9);
}

/* 4. Sort Game (Baskets) */
.sort-game {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    height: 100%;
    width: 100%;
    padding-bottom: 20px;
}

.items-pool {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    justify-content: center;
    padding: 20px;
    min-height: 150px;
}

.sort-item {
    font-size: 80px;
    cursor: grab;
    transition: opacity 0.3s;
    user-select: none;
    /* Optional: circle bg */
    width: 100px;
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    border-radius: 50%;
    box-shadow: 0 5px 10px rgba(0, 0, 0, 0.1);
}

.sort-item.dragging {
    opacity: 0.8;
    transform: scale(1.2);
    pointer-events: none;
    /* Let clicks pass through to drop zones if needed */
}

.baskets-row {
    display: flex;
    gap: 50px;
    margin-bottom: 20px;
}

.basket {
    width: 180px;
    height: 180px;
    background: #FFF8E1;
    border: 6px solid #FFB74D;
    border-radius: 0 0 40px 40px;
    /* Bucket shape */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    /* Label Emoji Size */
    font-weight: bold;
    color: #E65100;
    text-align: center;
    line-height: 1.2;
    box-shadow: 0 10px 0 #F57C00;
}

/* 5. Add Game (Equation) */
.add-game {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.group-box {
    background: white;
    padding: 15px 25px;
    border-radius: 20px;
    border: 3px solid #eee;
    margin: 0 15px;
    letter-spacing: -10px;
    /* Overlap emojis slightly */
    box-shadow: inset 0 5px 10px rgba(0, 0, 0, 0.05);
}

/* Ensure hidden works */
.hidden {
    display: none !important;
}

/* Responsive Adjustments */
@media (max-width: 600px) {
    .compare-container {
        flex-direction: column;
        gap: 20px;
    }

    .compare-side {
        min-width: 200px;
        min-height: 200px;
    }

    .basket {
        width: 120px;
        height: 120px;
        font-size: 32px;
    }

    .game-item {
        font-size: 80px;
    }

    .seq-item {
        width: 70px;
        height: 70px;
        font-size: 48px;
    }
}

/* --- SINHALA SPECIFIC OVERRIDES --- */

/* 1. Global Font Adjustment */
body.lang-si {
    /* Sinhala intricate glyphs look better with slightly less weight than 900 */
    font-weight: 600;
}

/* 2. Looser Line Heights for Tall Glyphs (Ascenders/Descenders) */
body.lang-si .game-title {
    line-height: 1.3;
    font-size: 64px;
    /* Reduce slightly to prevent overflow with taller lines */
    padding-top: 10px;
}

body.lang-si .tile-label {
    line-height: 1.3;
    font-size: 0.95rem;
    /* Slight reduction to fit 2-3 lines */
    font-weight: 700;
    /* 900 might be too bold/blobby for complex glyphs */
}

body.lang-si .btn-tile {
    border: none;
    border-radius: 16px;
    color: #ffffff !important;
    font-weight: 900;
    font-size: 48px;
    text-shadow: 0 3px 6px rgba(0, 0, 0, 0.5);
    cursor: pointer;
    position: relative;
    transition: transform 0.1s;
    font-family: var(--font-main);

    /* Default Blue */
    background: var(--tile-blue);
    box-shadow: 0 6px 0 var(--tile-blue-shadow), 0 10px 10px rgba(0, 0, 0, 0.2);
}

body.lang-si .instruction-sub,
body.lang-si .instruction-toast {
    line-height: 1.4;
    font-weight: 600;
}

body.lang-si .gate-msg,
body.lang-si .celebration-overlay h1 {
    line-height: 1.4;
}

/* 3. Adjust Tile Layout for Longer Text */
body.lang-si .game-tile {
    padding-bottom: 5px;
    /* Less bottom padding to give text room */
    justify-content: space-evenly;
    /* Better distribution */
}

body.lang-si .tile-icon {
    font-size: 48px;
    /* Slightly smaller icon to give text more room */
    margin-bottom: 0;
}

/* --- 4 YEAR UPGRADE OVERRIDES --- */

/* 1. Comparison Game: Denser Grids */
.mini-grid.four-year {
    grid-template-columns: repeat(4, 1fr);
    gap: 5px;
}

.mini-grid.four-year .mini-item {
    font-size: 29px;
    /* Smaller items to fit more */
}

/* 2. Odd One Out: Progressive Grid Sizes */
.odd-grid.four-year {
    gap: 10px;
}

/* Small grid (2x2, 4 items) - larger items for easier tapping */
.odd-grid.grid-small .grid-item {
    width: 140px;
    height: 140px;
    font-size: 80px;
    border-radius: 25px;
}

/* Medium grid (2x3, 6 items) */
.odd-grid.grid-medium .grid-item {
    width: 120px;
    height: 120px;
    font-size: 4.5rem;
    border-radius: 22px;
}

/* Large grid (3x3, 9 items) */
.odd-grid.grid-large .grid-item,
.odd-grid.four-year .grid-item {
    width: 100px;
    height: 100px;
    font-size: 64px;
    /* Reduced from 5rem */
    border-radius: 20px;
}

/* 3. Counting Game: More Items */
.count-container .items-grid {
    gap: 10px;
    /* Tighter gap */
}

/* Dynamic sizing for large counts handled by flex, but let's ensure they shrink if needed */
.game-item {
    flex-shrink: 1;
    /* Allow shrinking if needed on small screens */
    min-width: 80px;
    min-height: 80px;
    font-size: 64px;
    /* Base size reduced slightly for potential 20 items */
}

@media (max-width: 600px) {
    .mini-grid.four-year {
        grid-template-columns: repeat(3, 1fr);
        /* 3 cols on mobile */
    }

    .odd-grid.four-year .grid-item {
        width: 70px;
        height: 70px;
        font-size: 40px;
    }

    .game-item {
        min-width: 60px;
        min-height: 60px;
        font-size: 48px;
    }
}

/* --- NEW GAME MODES (Memory & Subtraction) --- */

/* Memory Game - Container */
.memory-grid {
    width: 100%;
    max-width: 600px;
    margin: 20px auto;
    justify-content: center;
}

/* Card Flip Styles */
.memory-card {
    background: transparent;
    perspective: 1000px;
    cursor: pointer;
    min-width: 80px;
    aspect-ratio: 1;
    position: relative;
}

.memory-card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    transition: transform 0.6s cubic-bezier(0.4, 0.0, 0.2, 1);
    transform-style: preserve-3d;
}

.memory-card.flipped .memory-card-inner {
    transform: rotateY(180deg);
}

.memory-front,
.memory-back {
    position: absolute;
    width: 100%;
    height: 100%;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 56px;
    border-radius: 15px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    border: 3px solid #fff;
    user-select: none;
}

/* Front is the Question Mark side initially (actually the back in 3D space) */
.memory-front {
    background: linear-gradient(135deg, #FFB74D, #F57C00);
    color: white;
    text-shadow: 0 2px 0 rgba(0, 0, 0, 0.2);
}

/* Back is the Content side (revealed on flip) */
.memory-back {
    background: white;
    transform: rotateY(180deg);
    border: 3px solid #F57C00;
}

.memory-card.matched .memory-back {
    background: #DCEDC8;
    /* Light Green */
    border-color: #689F38;
    box-shadow: 0 0 15px #8BC34A;
}


/* Subtraction Game */
.sub-item {
    font-size: 4.5rem;
    margin: 10px;
    transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: inline-block;
    filter: drop-shadow(0 4px 2px rgba(0, 0, 0, 0.1));
    position: relative;
}

.sub-item.removed {
    transform: scale(0.8) rotate(15deg);
    opacity: 0.5;
    filter: grayscale(100%);
}

.sub-item.removed::after {
    content: '❌';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 56px;
    opacity: 0.8;
    text-shadow: 0 0 5px white;
}

/* Mobile adjustments */
@media (max-width: 600px) {

    .memory-front,
    .memory-back {
        font-size: 40px;
    }

    .sub-item {
        font-size: 56px;
        margin: 5px;
    }

    .sub-item.removed::after {
        font-size: 40px;
    }
}
/* Fix Find Odd grid overflow - responsive grid items */
.odd-grid.grid-large .grid-item {
    width: clamp(70px, 10vw, 100px);
    height: clamp(70px, 10vw, 100px);
    font-size: clamp(40px, 5vw, 64px);
}

.odd-grid {
    max-width: 90vw;
    margin: 0 auto;
}

/* Ensure baskets are properly sized and responsive */
.basket {
    min-width: clamp(150px, 18vw, 200px);
    min-height: clamp(130px, 16vh, 180px);
    font-size: clamp(24px, 3vw, 48px);
}

.baskets-row.three-baskets .basket {
    min-width: clamp(120px, 14vw, 150px);
    min-height: clamp(110px, 14vh, 130px);
    font-size: clamp(20px, 2.5vw, 32px);
}



/* ========================================
   COMPREHENSIVE MOBILE OPTIMIZATIONS
   ======================================== */

/* Game viewport - ensure it fits mobile screens */
.game-viewport {
    width: 100vw;
    height: calc(100vh - 10px);
    max-width: 100%;
    max-height: 100%;
    padding: clamp(60px, 10vh, 80px) clamp(10px, 2vw, 20px) clamp(10px, 2vw, 20px);
    margin: 0;
    border-radius: clamp(15px, 3vw, 30px);
}

/* Instruction text - always readable */
.instruction-sub {
    font-size: clamp(18px, 4.5vw, 40px) !important;
    padding: clamp(10px, 2vw, 15px) clamp(15px, 3vw, 30px) !important;
    line-height: 1.3;
    max-width: 95%;
    word-wrap: break-word;
}

/* Question/display text */
.question-text,
.story-text,
.big-number {
    font-size: clamp(1.5rem, 5vw, 3rem) !important;
    padding: 1vmin;
    max-width: 95%;
    word-wrap: break-word;
}

/* Options row - better mobile layout */
.options-row {
    gap: clamp(15px, 3vw, 30px);
    flex-wrap: wrap;
    padding: 1vmin;
    justify-content: center;
    max-width: 100%;
}

/* All game items - consistent sizing */
.game-item,
.grid-item,
.seq-item {
    font-size: clamp(2.5rem, 8vw, 5rem) !important;
    min-width: clamp(60px, 12vw, 120px) !important;
    min-height: clamp(60px, 12vw, 120px) !important;
}

/* Groups and containers */
.groups-container,
.items-grid,
.items-pool {
    max-width: 95vw;
    margin: 0 auto;
    padding: 1vmin;
}

/* Place value blocks */
.place-value-blocks {
    max-width: 90vw;
    overflow-x: auto;
    padding: 1vmin;
}

/* Baskets for sorting */
.baskets-row {
    flex-wrap: wrap;
    gap: clamp(20px, 4vw, 50px);
    padding: 1vmin;
    justify-content: center;
}

/* Clock face */
.clock-face {
    width: clamp(250px, 55vmin, 400px) !important;
    height: clamp(250px, 55vmin, 400px) !important;
}

/* Coins */
.coin {
    width: clamp(45px, 8vmin, 80px) !important;
    height: clamp(45px, 8vmin, 80px) !important;
}

/* Level indicator */
.level-indicator {
    font-size: clamp(18px, 4vw, 29px);
    padding: clamp(6px, 1.5vw, 8px) clamp(15px, 3vw, 25px);
}

/* Button icons */
.btn-icon {
    font-size: clamp(24px, 5vw, 35px);
    width: clamp(50px, 10vw, 70px);
    height: clamp(50px, 10vw, 70px);
}

/* Giant comparison buttons */
.btn-tile.giant {
    font-size: clamp(3rem, 12vw, 6rem) !important;
    min-width: clamp(100px, 25vw, 200px) !important;
    min-height: clamp(100px, 25vw, 200px) !important;
    padding: 2vmin !important;
}

/* Responsive grid layouts */
.odd-grid,
.shape-grid,
.memory-grid {
    grid-gap: clamp(10px, 2vw, 20px);
    padding: 1vmin;
    max-width: 95vw;
    margin: 0 auto;
}

/* Pattern/Sequence rows */
.sequence-row {
    gap: clamp(8px, 2vw, 20px);
    padding: clamp(15px, 3vw, 20px) clamp(20px, 4vw, 40px);
    flex-wrap: wrap;
    justify-content: center;
    max-width: 95vw;
    margin: 0 auto;
}

/* Comparison containers */
.compare-container {
    gap: clamp(20px, 4vw, 50px);
    padding: 1vmin;
}

.compare-side {
    min-width: clamp(150px, 35vw, 300px);
    min-height: clamp(150px, 35vw, 300px);
    padding: 1.5vmin;
}

/* Mini grids for comparison */
.mini-grid {
    gap: clamp(5px, 1vw, 10px);
}

.mini-item {
    font-size: clamp(32px, 6vw, 48px) !important;
}

/* Ensure proper spacing on very small screens */
@media (max-width: 360px) {
    .game-viewport {
        padding: 50px 5px 5px;
    }

    .instruction-sub {
        font-size: 16px !important;
        padding: 8px 12px !important;
    }

    .options-row {
        gap: 10px;
    }

    .option {
        min-width: 90px !important;
        min-height: 70px !important;
        font-size: 24px !important;
    }
}

/* Landscape mode optimizations */
@media (orientation: landscape) and (max-height: 500px) {
    .game-viewport {
        height: calc(100vh - 5px);
        padding: 45px 10px 5px;
    }

    .instruction-sub {
        font-size: clamp(14px, 3vw, 24px) !important;
        padding: 6px 15px !important;
        margin-bottom: 1vmin;
    }

    .game-header {
        top: 5px;
    }

    .level-indicator {
        font-size: clamp(14px, 3vw, 20px);
        padding: 4px 15px;
    }

    .btn-icon {
        width: 45px;
        height: 45px;
        font-size: 24px;
    }
}

/* Geometry Game - Fix grid overflow */
.shape-grid {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: clamp(15px, 3vw, 25px) !important;
    max-width: min(90vw, 500px) !important;
    margin: 3vmin auto 0 !important;
    padding: 2vmin !important;
    justify-items: center;
    align-items: center;
}

.shape-grid .grid-item {
    width: 100% !important;
    aspect-ratio: 1 !important;
    min-height: clamp(90px, 20vw, 140px) !important;
    max-width: 140px;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: clamp(3.5rem, 10vw, 6rem) !important;
}

.shape-game {
    width: 100%;
    max-width: 100%;
    overflow: hidden;
}
