* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@300;400;500;600;700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@700&display=swap');

body {
    font-family: 'Fredoka', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f1f2f4;
    min-height: 100vh;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

/* White Header Bar - Full Width at Top */
.header-white-bar {
    background: #FFFFFF;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 2px 20px;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}

.youkids-logo {
    height: 48px;
    flex-shrink: 0;
}

.game-name {
    font-family: 'Roboto', sans-serif;
    font-size: 16px;
    font-weight: 700;
    color: #000;
    margin: 0;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
}

.hamburger-menu {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #000;
    transition: opacity 0.2s;
    flex-shrink: 0;
}

.hamburger-menu svg {
    width: 24px;
    height: 24px;
}

.hamburger-menu:hover {
    opacity: 0.7;
}

.game-container {
    max-width: 400px;
    margin: 0 auto;
    padding: 6px;
    padding-top: 56px;
    position: relative;
    min-height: 100vh;
}

/* Timer Section */
.timer-section {
    text-align: center;
    padding: 8px 0 12px;
}

.timer-display {
    font-family: 'Roboto', sans-serif;
    font-size: 18px;
    font-weight: 400;
    color: #888;
    letter-spacing: -0.5px;
}

/* Decorative background elements */
.game-container::before,
.game-container::after {
    content: '';
    position: fixed;
    border-radius: 50%;
    pointer-events: none;
    z-index: 0;
}

.game-container::before {
    top: -40px;
    left: -40px;
    width: 128px;
    height: 128px;
    background: rgba(253, 224, 71, 0.2);
    filter: blur(60px);
}

.game-container::after {
    top: 160px;
    right: -40px;
    width: 160px;
    height: 160px;
    background: rgba(236, 72, 153, 0.2);
    filter: blur(60px);
}




/* Game Board */
.game-board {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(4, 1fr);
    gap: 6px;
    padding: 0 6px 50px;
    background: transparent;
    position: relative;
    z-index: 10;
}

/* Card */
.card {
    aspect-ratio: 1;
    position: relative;
    cursor: pointer;
    perspective: 1000px;
    transform: translate3d(0, 0, 0);
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    contain: layout style paint;
    transition: all 0.3s ease;
}

.card,
.card:hover,
.card:active,
.card.flipped,
.card.matched {
    transform: translate3d(0, 0, 0);
}

.card:hover {
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.card-inner {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transition: transform 0.5s;
    transform-style: preserve-3d;
    -webkit-transform-style: preserve-3d;
}

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

.card-face {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 0;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    transition: all 0.3s ease;
}

/* Card Back (face-down) */
.card-back {
    background: #000;
    position: relative;
    border: 2px solid transparent;
    backface-visibility: hidden;
    z-index: 1;
}

.card:hover .card-back {
    border-color: rgba(234, 88, 12, 0.5);
}

.card-back::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: radial-gradient(circle, #fff 1.5px, transparent 0);
    background-size: 16px 16px;
    opacity: 0.2;
}

.card-back::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 12px;
    height: 12px;
    background: #374151;
    border-radius: 50%;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
}

.card:hover .card-back::after {
    background: #ea580c;
    transform: translate(-50%, -50%) scale(1.1);
}

/* Card Front (face-up) */
.card-front {
    background: #FFFFFF !important;
    transform: rotateY(180deg);
    -webkit-transform: rotateY(180deg);
    font-size: clamp(32px, 8vw, 72px) !important;
    position: absolute;
    border: 2px solid #000000 !important;
    line-height: 1;
    color: #000 !important;
    z-index: 2;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex !important;
    align-items: center;
    justify-content: center;
    transition: border-color 0.3s ease;
}

.card.matched .card-front {
    border-color: #10b981 !important;
}

.card.mismatch .card-front {
    border-color: #ef4444 !important;
}

.card-front::after {
    content: '';
    position: absolute;
    top: 8px;
    right: 8px;
    width: 10px;
    height: 10px;
    background: #10b981;
    border-radius: 50%;
    opacity: 0;
    transform: scale(0);
    transition: all 0.3s ease;
}

.card.matched .card-front::after {
    opacity: 1;
    transform: scale(1);
}

.card.matched .card-inner {
    animation: matchPulse 0.3s ease;
}

@keyframes matchPulse {
    0%, 100% {
        transform: rotateY(180deg) scale(1);
    }
    50% {
        transform: rotateY(180deg) scale(1.05);
    }
}


/* Win Screen */
.win-screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.win-screen.show {
    display: flex;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.win-content {
    background: #FFFFFF;
    padding: 40px;
    border-radius: 32px;
    text-align: center;
    max-width: 90%;
    width: 400px;
    animation: slideUp 0.3s ease;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.win-title {
    font-size: 32px;
    margin-bottom: 24px;
    color: #000;
}

.win-stats {
    margin-bottom: 32px;
    font-size: 18px;
}

.win-stats p {
    margin: 8px 0;
    color: #333;
}

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

.btn {
    padding: 14px 32px;
    border: none;
    border-radius: 16px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Fredoka', sans-serif;
}

.btn-primary {
    background: #ea580c;
    color: #FFF;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.btn-primary:hover {
    background: #c2410c;
    transform: scale(1.05);
}

.btn-secondary {
    background: #E5E7EB;
    color: #374151;
}

.btn-secondary:hover {
    background: #D1D5DB;
    transform: scale(1.05);
}

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

/* Responsive breakpoints for header */
@media (min-width: 360px) {
    .youkids-logo {
        height: 52px;
    }

    .game-name {
        font-size: 18px;
    }

    .game-container {
        padding-top: 60px;
    }
}

@media (min-width: 400px) {
    .youkids-logo {
        height: 56px;
    }

    .game-name {
        font-size: 20px;
    }

    .game-container {
        padding-top: 64px;
    }
}

@media (min-width: 480px) {
    .header-white-bar {
        padding: 4px 30px;
    }

    .youkids-logo {
        height: 64px;
    }

    .game-name {
        font-size: 22px;
    }

    .hamburger-menu svg {
        width: 28px;
        height: 28px;
    }

    .game-container {
        padding-top: 76px;
    }

    .timer-display {
        font-size: 20px;
    }
}

/* Tablet and larger screens */
@media (min-width: 600px) {
    .youkids-logo {
        height: 68px;
    }

    .game-name {
        font-size: 24px;
    }

    .game-container {
        max-width: 480px;
        padding-top: 80px;
    }

    .game-board {
        gap: 8px;
        padding: 0 10px 55px;
    }
}

/* Desktop screens */
@media (min-width: 768px) {
    .youkids-logo {
        height: 72px;
    }

    .game-name {
        font-size: 28px;
    }

    .game-container {
        padding-top: 84px;
    }
}

@media (min-width: 900px) {
    .game-container {
        max-width: 500px;
    }

    .game-board {
        gap: 10px;
        padding: 0 12px 60px;
    }
}


/* Game Menu Overlay */
.game-menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
}

.game-menu-overlay.active {
    display: flex;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.game-menu {
    background: white;
    border-radius: 24px;
    padding: 32px;
    max-width: 90%;
    width: 400px;
    position: relative;
    animation: slideUp 0.3s ease;
}

.close-menu {
    position: absolute;
    top: 16px;
    right: 16px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    color: #666;
    transition: color 0.2s;
}

.close-menu:hover {
    color: #000;
}

.game-menu h2 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 24px;
    color: #000;
    text-align: center;
}

.menu-item {
    display: block;
    padding: 16px 20px;
    margin-bottom: 12px;
    border-radius: 12px;
    background: #f3f4f6;
    color: #374151;
    text-decoration: none;
    font-weight: 600;
    font-size: 18px;
    transition: all 0.2s;
    text-align: center;
}

.menu-item:hover {
    background: #e5e7eb;
    transform: translateX(4px);
}

.menu-item.active {
    background: #ea580c;
    color: white;
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}
