/* ============================================
   Sesam Game
   Design System: Sesam Brand Colors
   Style: Clean UI
   ============================================ */

/* CSS Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Primary Brand Colors (from design system) */
    --primary-blue: #006DB6;
    --primary-blue-dark: #003E6B;
    --primary-blue-light: #64B5F6;
    --primary-cyan: #00B8D4;
    
    /* Secondary/Neutral Colors */
    --white: #FFFFFF;
    --off-white: #F5F7FA;
    --gray-100: #E8EAED;
    --gray-200: #D1D5DB;
    --gray-300: #9CA3AF;
    --gray-400: #6B7280;
    --gray-500: #4B5563;
    --gray-600: #374151;
    --gray-700: #1F2937;
    --black: #111827;
    
    /* Status Colors */
    --success-green: #00A86B;
    --error-red: #DC2626;
    --warning-yellow: #F59E0B;
    
    /* Legacy aliases for compatibility */
    --light-gray: var(--gray-100);
    --medium-gray: var(--gray-400);
    --soft-yellow: var(--warning-yellow);
    --soft-yellow-light: #FEF3C7;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.15);
    
    /* Border Radius (matching design system - more subtle) */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    
    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;
}

body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Roboto', sans-serif;
    background: linear-gradient(135deg, var(--primary-blue) 0%, var(--primary-blue-dark) 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    color: var(--gray-700);
}

/* ============================================
   Game Container
   ============================================ */
#game-container {
    width: 100%;
    max-width: 500px;
    min-height: 600px;
    background: var(--white);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    position: relative;
    overflow: hidden;
}

/* ============================================
   Screens
   ============================================ */
.screen {
    display: none;
    width: 100%;
    height: 100%;
    min-height: 600px;
}

.screen.active {
    display: flex;
    flex-direction: column;
}

.screen.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(30, 90, 168, 0.9);
    z-index: 100;
    justify-content: center;
    align-items: center;
}

.screen-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    flex: 1;
    text-align: center;
}

/* ============================================
   Start Screen
   ============================================ */
#start-screen h1 {
    font-size: 2.5rem;
    color: var(--primary-blue);
    margin-bottom: 10px;
    text-shadow: var(--shadow-sm);
}

#start-screen h2 {
    font-size: 1.5rem;
    color: var(--primary-cyan);
    font-weight: 400;
    margin-bottom: 20px;
}

.tagline {
    font-size: 1.1rem;
    color: var(--gray-300);
    margin-bottom: 15px;
}

.game-mode {
    font-size: 1rem;
    color: var(--primary-cyan);
    font-weight: 600;
    margin-bottom: 25px;
    padding: 8px 20px;
    background: rgba(0, 184, 212, 0.15);
    border-radius: var(--radius-lg);
}

/* Player Name Setup on Start Screen */
.player-setup {
    width: 100%;
    max-width: 280px;
    margin-bottom: 25px;
}

.name-label {
    display: block;
    font-size: 0.9rem;
    color: var(--primary-blue);
    font-weight: 600;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ============================================
   Buttons
   ============================================ */
.btn {
    padding: 14px 32px;
    font-size: 1.1rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

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

.primary-btn {
    background: var(--primary-blue);
    color: var(--white);
    border: 2px solid var(--primary-blue);
}

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

.secondary-btn {
    background: var(--white);
    color: var(--primary-blue);
    border: 2px solid var(--primary-blue);
}

.secondary-btn:hover {
    background: var(--off-white);
    color: var(--primary-blue-dark);
    border-color: var(--primary-blue-dark);
}

/* Icon button (sound toggle) */
.icon-btn {
    background: var(--white);
    color: var(--gray-600);
    border: 1px solid var(--gray-300);
    padding: 8px 12px;
    font-size: 1.2rem;
    min-width: auto;
    border-radius: var(--radius-md);
}

.icon-btn:hover {
    background: var(--gray-100);
    border-color: var(--gray-400);
}

.icon-btn.muted {
    opacity: 0.5;
}

/* ============================================
   Level Selection
   ============================================ */
.level-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin: 30px 0;
    padding: 0 20px;
}

.level-btn {
    width: 70px;
    height: 70px;
    border-radius: var(--radius-md);
    font-size: 1.5rem;
    font-weight: 700;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.level-btn .level-stars {
    font-size: 0.6rem;
    color: var(--warning-amber);
}

.level-btn.locked {
    background: var(--gray-100);
    color: var(--gray-400);
    cursor: not-allowed;
}

.level-btn.locked:hover {
    transform: none;
    box-shadow: none;
}

.level-btn.completed {
    background: var(--success-green);
    color: var(--white);
    border-color: var(--success-green);
}

/* ============================================
   Game Header / HUD
   ============================================ */
.game-header {
    display: flex;
    justify-content: space-around;
    padding: 14px 10px;
    background: var(--primary-blue-dark);
    color: var(--white);
}

.hud-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.hud-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    opacity: 0.85;
    letter-spacing: 0.5px;
    font-weight: 500;
}

.hud-value {
    font-size: 1.3rem;
    font-weight: 700;
}

/* ============================================
   Objective Display
   ============================================ */
.objective-display {
    background: var(--off-white);
    padding: 10px 20px;
    text-align: center;
    font-weight: 600;
    color: var(--gray-600);
    border-bottom: 1px solid var(--gray-200);
    font-size: 0.9rem;
}

/* ============================================
   Game Board
   ============================================ */
.game-board {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 4px;
    padding: 12px;
    background: var(--gray-200);
    margin: 10px;
    border-radius: var(--radius-md);
    aspect-ratio: 1;
    border: 1px solid var(--gray-300);
}

.tile {
    aspect-ratio: 1;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    background: var(--white);
    box-shadow: var(--shadow-sm);
    user-select: none;
    position: relative;
    border: 1px solid var(--gray-200);
}

/* Tile icon images */
.tile-icon {
    width: 75%;
    height: 75%;
    object-fit: contain;
    pointer-events: none;
}

.tile:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-md);
    border-color: var(--primary-cyan);
}

.tile.selected {
    transform: scale(1.1);
    box-shadow: 0 0 0 3px var(--primary-blue), var(--shadow-md);
    border-color: var(--primary-blue);
    z-index: 10;
}

/* Match animation - enhanced with glow and zoom */
.tile.matched {
    animation: matchPop 0.5s ease forwards;
    z-index: 20;
}

/* Glow effect before pop */
.tile.match-highlight {
    animation: matchHighlight 0.4s ease forwards;
    z-index: 15;
}

/* Falling animation - smoother and more visible */
.tile.falling {
    animation: tileFall 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* New tiles spawning from top */
.tile.spawning {
    animation: tileSpawn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.tile.swapping {
    transition: transform 0.25s ease;
}

.tile.invalid-swap {
    animation: shake 0.4s ease;
}

.tile.hint {
    animation: hintPulse 1s ease infinite;
}

/* Mystery box type indicator - shows what type it matches with */
.mystery-type-indicator {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 18px;
    height: 18px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(0, 0, 0, 0.1);
    z-index: 5;
}

.mystery-type-icon {
    width: 12px;
    height: 12px;
    object-fit: contain;
}

/* Combo glow effect on matched tiles */
.tile.combo-glow {
    animation: comboGlow 0.6s ease forwards;
    z-index: 25;
}

/* Score pop effect at tile position */
.tile .score-pop {
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--warning-amber);
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
    animation: scoreFloat 0.8s ease forwards;
    pointer-events: none;
    z-index: 30;
}

/* Special Tiles */
.tile.special-row {
    background: linear-gradient(90deg, rgba(0, 184, 212, 0.15), var(--white), rgba(0, 184, 212, 0.15));
    box-shadow: 0 0 8px var(--primary-cyan);
}

.tile.special-area {
    background: linear-gradient(135deg, rgba(0, 109, 182, 0.15), var(--white));
    box-shadow: 0 0 8px var(--primary-blue);
}

.tile.special-color {
    background: linear-gradient(135deg, rgba(0, 62, 107, 0.2), var(--white));
    box-shadow: 0 0 12px var(--primary-blue-dark);
}

.tile .special-indicator {
    position: absolute;
    bottom: 2px;
    right: 2px;
    font-size: 0.6rem;
}

/* ============================================
   Game Controls
   ============================================ */
.game-controls {
    display: flex;
    justify-content: center;
    padding: 15px;
    gap: 15px;
}

.game-controls .btn {
    padding: 10px 24px;
    font-size: 0.9rem;
}

/* ============================================
   Popup Screens (Win, Lose, Pause) - Card Style
   ============================================ */
.popup {
    background: var(--white);
    padding: 32px 24px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    max-width: 350px;
    width: 90%;
    border: 1px solid var(--gray-200);
}

.popup h2 {
    font-size: 1.8rem;
    color: var(--primary-blue-dark);
    margin-bottom: 15px;
}

.popup p {
    font-size: 1.1rem;
    color: var(--gray-500);
    margin-bottom: 10px;
}

.popup .encourage-text {
    font-size: 0.95rem;
    color: var(--primary-blue);
    margin-bottom: 20px;
}

.popup-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 20px;
}

.popup-buttons .btn {
    width: 100%;
}

/* Stars Display */
.stars {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin: 20px 0;
}

.star {
    font-size: 2rem;
    opacity: 0.3;
    transition: all var(--transition-normal);
}

.star.earned {
    opacity: 1;
    animation: starPop 0.5s ease;
}

/* ============================================
   Combo Display
   ============================================ */
.combo-display {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--warning-amber);
    color: var(--primary-blue-dark);
    padding: 15px 30px;
    border-radius: var(--radius-lg);
    font-size: 1.5rem;
    font-weight: 700;
    z-index: 50;
    animation: comboAppear 0.8s ease forwards;
    pointer-events: none;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.combo-display.hidden {
    display: none;
}

/* ============================================
   Level Up Display
   ============================================ */
.level-up-display {
    position: absolute;
    top: 40%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: linear-gradient(135deg, var(--primary-blue) 0%, var(--primary-blue-dark) 100%);
    color: var(--white);
    padding: 20px 40px;
    border-radius: var(--radius-xl);
    font-size: 1.6rem;
    font-weight: 700;
    z-index: 55;
    animation: levelUpAppear 1.2s ease forwards;
    pointer-events: none;
    box-shadow: var(--shadow-xl);
    text-align: center;
}

.level-up-display.hidden {
    display: none;
}

/* ============================================
   High Score Celebration (During Gameplay)
   ============================================ */
.highscore-celebration {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    pointer-events: none;
    animation: celebrationFadeIn 0.3s ease forwards;
}

.highscore-celebration.hidden {
    display: none;
}

.highscore-celebration.fade-out {
    animation: celebrationFadeOut 0.5s ease forwards;
}

.celebration-content {
    background: linear-gradient(135deg, #FFD700 0%, #FFA500 50%, #FFD700 100%);
    padding: 30px 50px;
    border-radius: var(--radius-xl);
    text-align: center;
    box-shadow: 
        0 0 30px rgba(255, 215, 0, 0.6),
        0 0 60px rgba(255, 165, 0, 0.4),
        0 10px 40px rgba(0, 0, 0, 0.3);
    animation: celebrationPulse 0.6s ease infinite alternate;
    border: 3px solid rgba(255, 255, 255, 0.5);
}

.celebration-crown {
    font-size: 3rem;
    animation: crownBounce 0.5s ease infinite alternate;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.celebration-stars {
    font-size: 1.5rem;
    animation: starsSpin 1s linear infinite;
    display: inline-block;
}

.celebration-text {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--primary-blue-dark);
    text-shadow: 2px 2px 0 rgba(255, 255, 255, 0.8);
    letter-spacing: 2px;
    margin: 10px 0 5px;
}

.celebration-subtext {
    font-size: 1rem;
    font-weight: 600;
    color: var(--primary-blue-dark);
    opacity: 0.8;
}

@keyframes celebrationFadeIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes celebrationFadeOut {
    from {
        opacity: 1;
        transform: scale(1);
    }
    to {
        opacity: 0;
        transform: scale(1.1);
    }
}

@keyframes celebrationPulse {
    from {
        transform: scale(1);
        box-shadow: 
            0 0 30px rgba(255, 215, 0, 0.6),
            0 0 60px rgba(255, 165, 0, 0.4),
            0 10px 40px rgba(0, 0, 0, 0.3);
    }
    to {
        transform: scale(1.03);
        box-shadow: 
            0 0 40px rgba(255, 215, 0, 0.8),
            0 0 80px rgba(255, 165, 0, 0.5),
            0 15px 50px rgba(0, 0, 0, 0.3);
    }
}

@keyframes crownBounce {
    from {
        transform: translateY(0) rotate(-5deg);
    }
    to {
        transform: translateY(-8px) rotate(5deg);
    }
}

@keyframes starsSpin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* ============================================
   Final Stats (Game Over Screen)
   ============================================ */
.final-stats {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 20px 0;
    width: 100%;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--gray-100);
    border-radius: var(--radius-md);
    border: 1px solid var(--gray-200);
}

.stat-label {
    font-size: 0.9rem;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--primary-blue-dark);
}

.new-high-score {
    background: var(--success-green);
    color: var(--white);
    padding: 12px 24px;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 10px;
    animation: pulse 1s ease infinite;
}

/* ============================================
   Leaderboard Styles
   ============================================ */
.leaderboard-content {
    padding: 30px 20px;
}

.leaderboard-content h2 {
    color: var(--primary-blue-dark);
    margin-bottom: 20px;
}

.leaderboard-list {
    width: 100%;
    max-width: 400px;
    margin: 0 auto 20px;
}

.leaderboard-entry {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background: var(--white);
    border-radius: var(--radius-md);
    margin-bottom: 8px;
    border: 1px solid var(--gray-200);
    transition: all var(--transition-fast);
}

.leaderboard-entry:hover {
    transform: translateX(5px);
    border-color: var(--primary-blue-light);
}

.leaderboard-entry.top-3 {
    border-left: 4px solid var(--primary-blue);
    background: var(--off-white);
}

.leaderboard-rank {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary-blue-dark);
    min-width: 40px;
    text-align: center;
}

.leaderboard-rank.gold { color: #D4AF37; }
.leaderboard-rank.silver { color: #8A8A8A; }
.leaderboard-rank.bronze { color: #CD7F32; }

.leaderboard-name {
    flex: 1;
    font-size: 1rem;
    font-weight: 600;
    color: var(--primary-blue-dark);
    margin-left: 10px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.leaderboard-score {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary-blue);
}

.leaderboard-level {
    font-size: 0.8rem;
    color: var(--medium-gray);
    margin-left: 10px;
    min-width: 50px;
    text-align: right;
}

.leaderboard-empty {
    text-align: center;
    color: var(--medium-gray);
    padding: 40px 20px;
    font-style: italic;
}

/* Name Input Section */
.name-input-section {
    margin: 15px 0;
    padding: 15px;
    background: var(--light-gray);
    border-radius: var(--radius-md);
}

.leaderboard-qualify {
    font-size: 1rem;
    color: var(--primary-blue-dark);
    font-weight: 600;
    margin-bottom: 12px;
}

.player-name-input {
    width: 100%;
    padding: 12px 16px;
    font-size: 1rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-md);
    margin-bottom: 12px;
    text-align: center;
    font-weight: 500;
    color: var(--gray-700);
    background: var(--white);
    transition: all var(--transition-fast);
}

.player-name-input:focus {
    outline: none;
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(0, 109, 182, 0.15);
}

.player-name-input::placeholder {
    color: var(--gray-400);
    font-weight: 400;
}

/* Pause Menu Styles */
.pause-player-name,
.pause-score {
    font-size: 0.95rem;
    color: var(--gray-500);
    margin-bottom: 8px;
}

.pause-player-name span,
.pause-score span {
    font-weight: 700;
    color: var(--primary-blue-dark);
}

/* Leaderboard Status Message */
.leaderboard-status {
    background: var(--success-green);
    color: var(--white);
    padding: 12px 20px;
    border-radius: var(--radius-md);
    font-weight: 600;
    margin: 10px 0;
}

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

/* ============================================
   Animations
   ============================================ */

/* Match highlight - glow before popping */
@keyframes matchHighlight {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 rgba(251, 191, 36, 0);
        filter: brightness(1);
    }
    50% {
        transform: scale(1.15);
        box-shadow: 0 0 20px rgba(251, 191, 36, 0.8);
        filter: brightness(1.3);
    }
    100% {
        transform: scale(1.2);
        box-shadow: 0 0 25px rgba(251, 191, 36, 1);
        filter: brightness(1.4);
    }
}

/* Match pop - satisfying disappear effect */
@keyframes matchPop {
    0% {
        transform: scale(1.2);
        opacity: 1;
        filter: brightness(1.4);
    }
    30% {
        transform: scale(1.4);
        opacity: 1;
        filter: brightness(1.6);
    }
    60% {
        transform: scale(1.5) rotate(10deg);
        opacity: 0.6;
    }
    100% {
        transform: scale(0) rotate(20deg);
        opacity: 0;
    }
}

/* Combo glow - extra effect for combos */
@keyframes comboGlow {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 rgba(30, 90, 168, 0);
    }
    25% {
        transform: scale(1.25);
        box-shadow: 0 0 30px rgba(251, 191, 36, 0.9), 0 0 60px rgba(30, 90, 168, 0.5);
    }
    50% {
        transform: scale(1.35);
        box-shadow: 0 0 40px rgba(251, 191, 36, 1), 0 0 80px rgba(30, 90, 168, 0.7);
        filter: brightness(1.5);
    }
    100% {
        transform: scale(0);
        opacity: 0;
    }
}

/* Tile fall - bouncy landing */
@keyframes tileFall {
    0% {
        transform: translateY(-60px) scale(0.8);
        opacity: 0;
    }
    60% {
        transform: translateY(5px) scale(1.05);
        opacity: 1;
    }
    80% {
        transform: translateY(-3px) scale(0.98);
    }
    100% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

/* New tile spawn animation */
@keyframes tileSpawn {
    0% {
        transform: translateY(-100px) scale(0.5);
        opacity: 0;
    }
    50% {
        opacity: 1;
    }
    70% {
        transform: translateY(8px) scale(1.08);
    }
    85% {
        transform: translateY(-4px) scale(0.95);
    }
    100% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

/* Score floating up from matched tile */
@keyframes scoreFloat {
    0% {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
    100% {
        transform: translateX(-50%) translateY(-40px);
        opacity: 0;
    }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-6px) rotate(-2deg); }
    40% { transform: translateX(6px) rotate(2deg); }
    60% { transform: translateX(-4px) rotate(-1deg); }
    80% { transform: translateX(4px) rotate(1deg); }
}

/* Bonus round explosion effect */
.tile.bonus-explode {
    animation: bonusExplode 0.4s ease forwards;
    z-index: 30;
}

@keyframes bonusExplode {
    0% {
        transform: scale(1);
        opacity: 1;
        box-shadow: 0 0 0 var(--explode-color, rgba(255, 215, 0, 0.8));
    }
    30% {
        transform: scale(1.4);
        opacity: 1;
        box-shadow: 0 0 30px var(--explode-color, rgba(255, 215, 0, 0.8));
        filter: brightness(1.5);
    }
    60% {
        transform: scale(1.6) rotate(15deg);
        opacity: 0.7;
        box-shadow: 0 0 50px var(--explode-color, rgba(255, 215, 0, 0.8));
    }
    100% {
        transform: scale(0) rotate(45deg);
        opacity: 0;
        box-shadow: 0 0 0 var(--explode-color, rgba(255, 215, 0, 0.8));
    }
}

@keyframes hintPulse {
    0%, 100% { 
        transform: scale(1);
        box-shadow: 0 0 0 rgba(0, 184, 212, 0);
        border-color: var(--gray-200);
    }
    50% { 
        transform: scale(1.08);
        box-shadow: 0 0 15px rgba(0, 184, 212, 0.7), 0 0 30px rgba(0, 184, 212, 0.4);
        border-color: var(--primary-cyan);
    }
}

@keyframes comboAppear {
    0% {
        transform: translate(-50%, -50%) scale(0.3);
        opacity: 0;
    }
    15% {
        transform: translate(-50%, -50%) scale(1.3);
        opacity: 1;
    }
    30% {
        transform: translate(-50%, -50%) scale(1);
    }
    75% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -50%) scale(0.8) translateY(-20px);
        opacity: 0;
    }
}

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

@keyframes levelUpAppear {
    0% {
        transform: translate(-50%, -50%) scale(0.3);
        opacity: 0;
    }
    15% {
        transform: translate(-50%, -50%) scale(1.15);
        opacity: 1;
    }
    30% {
        transform: translate(-50%, -50%) scale(1);
    }
    80% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -50%) scale(0.8);
        opacity: 0;
    }
}

/* Row/Column clear effect */
@keyframes rowClear {
    0% {
        background: var(--soft-yellow);
    }
    100% {
        background: transparent;
    }
}

/* ============================================
   Mystery Box Styles
   ============================================ */

/* Mystery tile default pulsing animation */
.tile[data-type="mystery"] {
    animation: mysteryPulse 1.5s ease-in-out infinite;
    background: linear-gradient(135deg, #9333EA, #EC4899) !important;
}

@keyframes mysteryPulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 10px rgba(147, 51, 234, 0.5);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 0 20px rgba(236, 72, 153, 0.8), 0 0 40px rgba(147, 51, 234, 0.5);
    }
}

/* Mystery reveal - good (color bomb) */
.tile.mystery-reveal-good {
    animation: mysteryRevealGood 0.5s ease forwards;
}

@keyframes mysteryRevealGood {
    0% {
        transform: scale(1) rotateY(0);
        background: linear-gradient(135deg, #9333EA, #EC4899);
    }
    50% {
        transform: scale(1.3) rotateY(90deg);
        background: linear-gradient(135deg, #34D399, #10B981);
    }
    100% {
        transform: scale(1.2) rotateY(0);
        background: linear-gradient(135deg, #34D399, #10B981);
        box-shadow: 0 0 30px rgba(52, 211, 153, 0.8);
    }
}

/* Mystery reveal - bad (death bomb) */
.tile.mystery-reveal-bad {
    animation: mysteryRevealBad 0.5s ease forwards;
}

@keyframes mysteryRevealBad {
    0% {
        transform: scale(1) rotateY(0);
        background: linear-gradient(135deg, #9333EA, #EC4899);
    }
    50% {
        transform: scale(1.3) rotateY(90deg);
        background: linear-gradient(135deg, #EF4444, #991B1B);
    }
    100% {
        transform: scale(1.2) rotateY(0);
        background: linear-gradient(135deg, #EF4444, #991B1B);
        box-shadow: 0 0 30px rgba(239, 68, 68, 0.8);
    }
}

/* Color bomb clear effect */
.tile.color-bomb-clear {
    animation: colorBombClear 0.6s ease forwards;
}

@keyframes colorBombClear {
    0% {
        transform: scale(1);
        opacity: 1;
        filter: hue-rotate(0deg);
    }
    33% {
        transform: scale(1.3);
        filter: hue-rotate(120deg) brightness(1.5);
        box-shadow: 0 0 30px rgba(52, 211, 153, 0.8);
    }
    66% {
        transform: scale(1.4);
        filter: hue-rotate(240deg) brightness(1.3);
    }
    100% {
        transform: scale(0);
        opacity: 0;
        filter: hue-rotate(360deg);
    }
}

/* Death bomb shake effect */
.death-bomb-shake {
    animation: deathBombShake 0.5s ease;
}

@keyframes deathBombShake {
    0%, 100% { transform: translateX(0) translateY(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px) translateY(2px); }
    20%, 40%, 60%, 80% { transform: translateX(5px) translateY(-2px); }
}

/* Mystery result message */
.mystery-result {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 20px 40px;
    border-radius: 15px;
    font-size: 1.5rem;
    font-weight: bold;
    z-index: 1000;
    animation: mysteryResultAppear 0.4s ease;
    text-align: center;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.mystery-result.mystery-good {
    background: linear-gradient(135deg, #34D399, #10B981);
    color: white;
    box-shadow: 0 0 40px rgba(52, 211, 153, 0.6), 0 10px 30px rgba(0, 0, 0, 0.2);
}

.mystery-result.mystery-bad {
    background: linear-gradient(135deg, #EF4444, #991B1B);
    color: white;
    box-shadow: 0 0 40px rgba(239, 68, 68, 0.6), 0 10px 30px rgba(0, 0, 0, 0.2);
}

@keyframes mysteryResultAppear {
    0% {
        transform: translate(-50%, -50%) scale(0.3);
        opacity: 0;
    }
    60% {
        transform: translate(-50%, -50%) scale(1.1);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -50%) scale(1);
    }
}

.mystery-result.mystery-fade {
    animation: mysteryResultFade 0.5s ease forwards;
}

@keyframes mysteryResultFade {
    0% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -50%) scale(0.8) translateY(-30px);
        opacity: 0;
    }
}

/* ============================================
   Responsive Design
   ============================================ */
@media (max-width: 500px) {
    body {
        padding: 10px;
    }
    
    #game-container {
        border-radius: var(--radius-lg);
    }
    
    .game-board {
        padding: 10px;
        gap: 3px;
        margin: 5px;
    }
    
    .tile {
        font-size: 1.4rem;
        border-radius: 6px;
    }
    
    #start-screen h1 {
        font-size: 2rem;
    }
    
    .hud-value {
        font-size: 1.2rem;
    }
    
    .level-btn {
        width: 60px;
        height: 60px;
        font-size: 1.3rem;
    }
}

@media (max-width: 380px) {
    .tile {
        font-size: 1.2rem;
    }
    
    .game-board {
        gap: 2px;
    }
}

/* ============================================
   Utility Classes
   ============================================ */
.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}
