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

body {
    font-family: 'Fredoka', sans-serif;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
    background-attachment: fixed;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1rem;
}

.game-container {
    max-width: 420px;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    position: relative;
}

.game-header {
    text-align: center;
    width: 100%;
}

.game-title {
    font-family: 'Bubblegum Sans', cursive;
    font-size: 2.5rem;
    color: #fff;
    text-shadow: 3px 3px 0 #ff6b9d, 6px 6px 0 rgba(0,0,0,0.2);
    margin-bottom: 1rem;
    animation: bounce 2s ease-in-out infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

.stats-row {
    display: flex;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.stat-box {
    background: rgba(255,255,255,0.95);
    padding: 0.5rem 1.25rem;
    border-radius: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    min-width: 80px;
}

.stat-label {
    font-size: 0.75rem;
    color: #764ba2;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #333;
}

.stat-value.best {
    color: #f093fb;
}

.stat-value.low {
    color: #ff4444;
    animation: pulse 0.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.combo-popup {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: 'Bubblegum Sans', cursive;
    font-size: 2rem;
    color: #fff;
    text-shadow: 2px 2px 0 #ff6b9d;
    z-index: 100;
    animation: comboAnim 0.8s ease-out forwards;
    pointer-events: none;
}

@keyframes comboAnim {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.5); }
    50% { opacity: 1; transform: translate(-50%, -50%) scale(1.2); }
    100% { opacity: 0; transform: translate(-50%, -80%) scale(1); }
}

.game-board {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 4px;
    background: rgba(255,255,255,0.3);
    padding: 8px;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2), inset 0 2px 10px rgba(255,255,255,0.3);
    backdrop-filter: blur(10px);
    width: 100%;
    aspect-ratio: 1;
}

.candy {
    aspect-ratio: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: clamp(1.2rem, 4vw, 2rem);
    background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.9), var(--candy-color, #fff));
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 3px 8px rgba(0,0,0,0.15);
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.candy:hover {
    transform: scale(1.08);
    box-shadow: 0 5px 15px rgba(0,0,0,0.25);
}

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

.candy.selected {
    animation: selectedPulse 0.6s ease-in-out infinite;
    box-shadow: 0 0 0 3px #fff, 0 0 0 6px #764ba2;
}

@keyframes selectedPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.candy.matched {
    animation: matchPop 0.4s ease-out forwards;
}

@keyframes matchPop {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.3); }
    100% { transform: scale(0); opacity: 0; }
}

.reset-btn {
    font-family: 'Fredoka', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    padding: 0.75rem 2rem;
    background: linear-gradient(135deg, #ff6b9d 0%, #ff9a56 100%);
    color: white;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(255,107,157,0.4);
    transition: all 0.3s ease;
}

.reset-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255,107,157,0.5);
}

.reset-btn:active {
    transform: translateY(0);
}

.game-over-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease;
}

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

.game-over-modal {
    background: white;
    padding: 2.5rem;
    border-radius: 24px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    animation: slideUp 0.4s ease;
}

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

.game-over-modal h2 {
    font-family: 'Bubblegum Sans', cursive;
    font-size: 2rem;
    color: #764ba2;
    margin-bottom: 1rem;
}

.final-score {
    font-size: 1.5rem;
    color: #333;
    margin-bottom: 0.5rem;
}

.new-record {
    color: #ff6b9d;
    font-weight: 700;
    animation: newRecord 0.5s ease infinite;
}

@keyframes newRecord {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.play-again-btn {
    font-family: 'Fredoka', sans-serif;
    font-size: 1.1rem;
    font-weight: 600;
    padding: 1rem 2.5rem;
    margin-top: 1.5rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.play-again-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 8px 25px rgba(102,126,234,0.4);
}

.footer {
    margin-top: 1rem;
    text-align: center;
}

.footer a {
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    font-size: 0.85rem;
    transition: color 0.3s ease;
}

.footer a:hover {
    color: #fff;
}

@media (max-width: 400px) {
    .game-board {
        gap: 3px;
        padding: 6px;
    }
    
    .candy {
        border-radius: 8px;
    }
    
    .game-title {
        font-size: 2rem;
    }
    
    .stat-box {
        padding: 0.4rem 1rem;
        min-width: 70px;
    }
}