* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #0f0c29 0%, #302b63 50%, #24243e 100%);
    color: white;
    overflow: hidden;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    user-select: none;
}

#game-container {
    width: 100%;
    max-width: 500px;
    height: 100vh;
    position: relative;
}

.screen {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100%;
    padding: 20px;
}

.screen.active {
    display: flex;
}

#menu-screen h1 {
    font-size: 3em;
    margin-bottom: 10px;
    text-align: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: gradientShift 3s ease infinite;
    background-size: 200% 200%;
    font-weight: 800;
    letter-spacing: -1px;
}

@keyframes gradientShift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

.tagline {
    font-size: 1.2em;
    margin-bottom: 40px;
    opacity: 0.8;
    color: #ff3b30;
    font-weight: 600;
}

.btn-primary, .btn-secondary {
    padding: 18px 50px;
    font-size: 1.2em;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 700;
    margin: 10px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    position: relative;
    overflow: hidden;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-secondary {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
}

.btn-primary:hover, .btn-secondary:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 40px rgba(0,0,0,0.4);
}

.btn-primary:active, .btn-secondary:active {
    transform: translateY(0) scale(0.98);
    box-shadow: 0 5px 20px rgba(0,0,0,0.3);
}

#high-score {
    margin-top: 30px;
    font-size: 1.5em;
    opacity: 0.9;
    background: rgba(255,255,255,0.1);
    padding: 15px 30px;
    border-radius: 15px;
    backdrop-filter: blur(10px);
}

#game-header {
    display: flex;
    justify-content: center;
    width: 100%;
    padding: 20px;
    font-size: 1.5em;
    font-weight: 700;
    background: rgba(255,255,255,0.05);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    margin: 10px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

#target-color {
    text-align: center;
    margin: 30px 0;
}

#target-color p {
    font-size: 1.2em;
    opacity: 0.8;
    margin-bottom: 10px;
}

#color-name {
    font-size: 2.5em;
    font-weight: 800;
    padding: 20px 40px;
    border-radius: 20px;
    display: inline-block;
    box-shadow: 0 8px 25px rgba(0,0,0,0.3);
    animation: colorPulse 0.5s ease;
    letter-spacing: 2px;
}

@keyframes colorPulse {
    0% { transform: scale(0.8); opacity: 0; }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); opacity: 1; }
}

#color-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    width: 100%;
    max-width: 400px;
    padding: 20px;
}

.color-box {
    aspect-ratio: 1;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 8px 25px rgba(0,0,0,0.4), inset 0 -2px 10px rgba(0,0,0,0.2);
    position: relative;
    animation: boxFadeIn 0.4s ease backwards;
}

.color-box::before {
    content: '';
    position: absolute;
    top: 10%;
    left: 10%;
    right: 10%;
    height: 30%;
    background: linear-gradient(to bottom, rgba(255,255,255,0.3), transparent);
    border-radius: 15px;
    pointer-events: none;
}

.color-box:hover {
    transform: translateY(-5px) scale(1.02);
    box-shadow: 0 15px 35px rgba(0,0,0,0.5), inset 0 -2px 10px rgba(0,0,0,0.2);
}

.color-box:active {
    transform: scale(0.95);
    box-shadow: 0 4px 15px rgba(0,0,0,0.4), inset 0 2px 10px rgba(0,0,0,0.3);
}

@keyframes boxFadeIn {
    from {
        opacity: 0;
        transform: scale(0.8) translateY(20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

#game-over-screen h2 {
    font-size: 3em;
    margin-bottom: 10px;
    color: #ff3b30;
}

.game-over-message {
    font-size: 1.3em;
    opacity: 0.8;
    margin-bottom: 20px;
}

.auto-return {
    font-size: 0.9em;
    opacity: 0.6;
    margin-top: 20px;
    animation: blink 1.5s ease-in-out infinite;
}

@keyframes blink {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 0.3; }
}

.final-score {
    font-size: 2em;
    margin-bottom: 20px;
}

.high-score-text {
    font-size: 1.5em;
    color: #ffd700;
    margin-bottom: 20px;
    animation: pulse 1s infinite;
}

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

@media (max-width: 600px) {
    #menu-screen h1 {
        font-size: 2.5em;
    }
    
    #color-name {
        font-size: 2em;
    }
}


/* Particle effects */
.particle {
    position: fixed;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    pointer-events: none;
    animation: particleFloat 0.6s ease-out forwards;
    box-shadow: 0 0 10px currentColor;
    z-index: 1000;
}

@keyframes particleFloat {
    0% {
        transform: translate(0, 0) scale(1);
        opacity: 1;
    }
    100% {
        transform: translate(var(--tx), var(--ty)) scale(0);
        opacity: 0;
    }
}

@keyframes correctPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.15); box-shadow: 0 0 30px rgba(255,255,255,0.8); }
    100% { transform: scale(1); }
}

@keyframes wrongShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

/* Smooth transitions for score and timer */
#current-score, #time-left {
    display: inline-block;
    transition: transform 0.2s ease;
}

#current-score.score-update {
    animation: scorePopup 0.3s ease;
}

@keyframes scorePopup {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); color: #4ade80; }
    100% { transform: scale(1); }
}

/* Glass morphism effect */
#target-color {
    background: rgba(255,255,255,0.05);
    backdrop-filter: blur(10px);
    border-radius: 25px;
    padding: 20px;
    margin: 30px 20px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}

/* Smooth color grid appearance */
#color-grid {
    animation: gridFadeIn 0.5s ease;
}

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

/* Enhanced game over screen */
#game-over-screen {
    animation: gameOverFadeIn 0.5s ease;
}

@keyframes gameOverFadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}
