/* Import Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Fredoka+One:wght@400&family=Comic+Neue:wght@400;700&display=swap');

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Comic Neue', cursive;
    background: linear-gradient(135deg, #87CEEB 0%, #98FB98 50%, #FFB6C1 100%);
    min-height: 100vh;
    overflow: hidden;
    position: relative;
}

/* Background Pattern */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        radial-gradient(circle at 20% 30%, rgba(255, 255, 255, 0.1) 2px, transparent 2px),
        radial-gradient(circle at 80% 70%, rgba(255, 255, 255, 0.1) 1px, transparent 1px);
    background-size: 100px 100px, 50px 50px;
    z-index: -1;
}

/* Container */
.container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 40px;
    z-index: 10;
}

.main-title {
    font-family: 'Fredoka One', cursive;
    font-size: clamp(2.5rem, 8vw, 4rem);
    color: #2E4A62;
    text-shadow: 
        3px 3px 0px #FFD700,
        6px 6px 0px rgba(0,0,0,0.2);
    margin-bottom: 10px;
    letter-spacing: 2px;
    animation: titleBounce 2s ease-in-out infinite alternate;
}

.subtitle {
    font-size: clamp(1rem, 3vw, 1.4rem);
    color: #4A5568;
    font-weight: 600;
    text-shadow: 1px 1px 2px rgba(255,255,255,0.8);
}

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

/* Screen Management */
.screen {
    display: none;
    width: 100%;
    max-width: 600px;
    text-align: center;
}

.screen.active {
    display: block;
}

/* Input Screen */
#input-screen {
    animation: fadeIn 1s ease-in;
}

.input-container {
    background: linear-gradient(145deg, #ffffff, #e6e6e6);
    border-radius: 25px;
    padding: 40px;
    box-shadow: 
        20px 20px 60px #bebebe,
        -20px -20px 60px #ffffff;
    border: 3px solid #FFD700;
}

.input-container label {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: #2E4A62;
    margin-bottom: 20px;
    text-shadow: 1px 1px 2px rgba(255,255,255,0.8);
}

#team-code {
    width: 100%;
    max-width: 300px;
    padding: 15px 20px;
    font-size: 1.4rem;
    font-family: 'Comic Neue', cursive;
    font-weight: 700;
    text-align: center;
    border: 3px solid #FF6B35;
    border-radius: 15px;
    background: #fff;
    text-transform: uppercase;
    letter-spacing: 3px;
    margin-bottom: 25px;
    transition: all 0.3s ease;
}

#team-code:focus {
    outline: none;
    border-color: #2E4A62;
    box-shadow: 0 0 15px rgba(46, 74, 98, 0.4);
    transform: scale(1.05);
}

#submit-btn {
    background: linear-gradient(145deg, #FF6B35, #e55a2b);
    color: white;
    border: none;
    padding: 15px 30px;
    font-size: 1.2rem;
    font-family: 'Fredoka One', cursive;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
    box-shadow: 
        5px 5px 15px rgba(0,0,0,0.2),
        inset -2px -2px 5px rgba(0,0,0,0.2),
        inset 2px 2px 5px rgba(255,255,255,0.3);
}

#submit-btn:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 
        7px 7px 20px rgba(0,0,0,0.3),
        inset -2px -2px 5px rgba(0,0,0,0.2),
        inset 2px 2px 5px rgba(255,255,255,0.3);
}

#submit-btn:active {
    transform: translateY(1px) scale(0.98);
}

/* Error Message */
.error {
    color: #e53e3e;
    font-weight: 700;
    font-size: 1.1rem;
    margin-top: 15px;
    padding: 10px;
    background: rgba(229, 62, 62, 0.1);
    border-radius: 10px;
    border: 2px solid #e53e3e;
}

.hidden {
    display: none !important;
}

/* Machine Screen */
#machine-screen {
    animation: machineStartup 0.8s ease-out;
}

.machine-container {
    position: relative;
    background: linear-gradient(145deg, #2d3748, #1a202c);
    border-radius: 25px;
    padding: 40px;
    border: 4px solid #FFD700;
    box-shadow: 
        0 0 30px rgba(255, 215, 0, 0.3),
        inset 0 0 20px rgba(0,0,0,0.5);
}

.machine-container h2 {
    color: #FFD700;
    font-family: 'Fredoka One', cursive;
    font-size: clamp(1.5rem, 4vw, 2.2rem);
    margin-bottom: 30px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
    animation: machinePulse 1.5s ease-in-out infinite;
}

.machine-parts {
    position: relative;
    height: 300px;
    overflow: hidden;
}

/* Gear Animations */
.gear {
    position: absolute;
    border-radius: 50%;
    background: linear-gradient(145deg, #4a5568, #2d3748);
    box-shadow: 
        inset 0 0 20px rgba(0,0,0,0.8),
        0 0 15px rgba(255, 215, 0, 0.2);
    animation: rotate 3s linear infinite;
}

.gear-teeth {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80%;
    height: 80%;
    background: radial-gradient(circle, #FFD700 20%, transparent 20%);
    background-size: 20px 20px;
    border-radius: 50%;
}

.large-gear {
    width: 120px;
    height: 120px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation-duration: 4s;
}

.medium-gear {
    width: 80px;
    height: 80px;
    animation-duration: 2.5s;
}

.gear-1 {
    top: 20%;
    left: 20%;
    animation-direction: reverse;
}

.gear-2 {
    top: 20%;
    right: 20%;
    animation-duration: 3s;
}

.small-gear {
    width: 50px;
    height: 50px;
    animation-duration: 1.8s;
}

.gear-3 {
    bottom: 30%;
    left: 15%;
    animation-direction: reverse;
}

.gear-4 {
    bottom: 30%;
    right: 15%;
}

/* Spinners */
.spinner {
    position: absolute;
    border: 4px solid rgba(255, 215, 0, 0.3);
    border-top: 4px solid #FFD700;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.spinner-1 {
    width: 60px;
    height: 60px;
    top: 10%;
    left: 45%;
    animation-duration: 0.8s;
}   

/* Progress Bar */
.progress-container {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0,0,0,0.3);
    padding: 20px;
    border-radius: 0 0 20px 20px;
}

.progress-bar {
    width: 100%;
    height: 10px;
    background: #2d3748;
    border-radius: 5px;
    overflow: hidden;
    margin-bottom: 10px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #FFD700, #FF6B35);
    width: 0%;
    animation: progressFill 3s ease-out forwards;
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.8);
}

.status-text {
    color: #FFD700;
    font-weight: 700;
    font-size: 1rem;
    animation: textFlicker 2s ease-in-out infinite;
}

/* Result Screen */
#result-screen {
    animation: resultZoom 1s ease-out;
}

.result-container {
    position: relative;
    background: linear-gradient(145deg, #ffffff, #f7fafc);
    border-radius: 25px;
    padding: 50px;
    border: 4px solid #FFD700;
    box-shadow: 
        0 0 40px rgba(255, 215, 0, 0.4),
        20px 20px 60px rgba(0,0,0,0.1);
}

.result-container h2 {
    font-family: 'Fredoka One', cursive;
    font-size: clamp(1.8rem, 5vw, 2.5rem);
    color: #2E4A62;
    margin-bottom: 30px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
    animation: resultShake 0.8s ease-out;
}

.team-name {
    font-family: 'Fredoka One', cursive;
    font-size: clamp(3rem, 10vw, 5rem);
    font-weight: 700;
    margin: 20px 0;
    text-shadow: 4px 4px 8px rgba(0,0,0,0.3);
    animation: teamPulse 1.5s ease-in-out infinite;
    letter-spacing: 3px;
}

.color-display {
    width: 150px;
    height: 150px;
    margin: 30px auto;
    border-radius: 50%;
    border: 6px solid #fff;
    box-shadow: 
        0 0 30px rgba(0,0,0,0.3),
        inset 0 0 20px rgba(255,255,255,0.5);
    animation: colorPulse 2s ease-in-out infinite;
}

/* Confetti Canvas */
#confetti-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 100;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes machineStartup {
    0% { opacity: 0; transform: scale(0.8) rotateY(90deg); }
    50% { transform: scale(1.05) rotateY(0deg); }
    100% { opacity: 1; transform: scale(1) rotateY(0deg); }
}

@keyframes machinePulse {
    0%, 100% { text-shadow: 2px 2px 4px rgba(0,0,0,0.8), 0 0 10px #FFD700; }
    50% { text-shadow: 2px 2px 4px rgba(0,0,0,0.8), 0 0 20px #FFD700, 0 0 30px #FF6B35; }
}

@keyframes rotate {
    from { transform: translate(-50%, -50%) rotate(0deg); }
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

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

@keyframes progressFill {
    0% { width: 0%; }
    30% { width: 30%; }
    60% { width: 70%; }
    100% { width: 100%; }
}

@keyframes textFlicker {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

@keyframes resultZoom {
    0% { opacity: 0; transform: scale(0.3) rotate(180deg); }
    50% { transform: scale(1.1) rotate(0deg); }
    100% { opacity: 1; transform: scale(1) rotate(0deg); }
}

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

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

@keyframes colorPulse {
    0%, 100% { 
        transform: scale(1);
        box-shadow: 0 0 30px rgba(0,0,0,0.3), inset 0 0 20px rgba(255,255,255,0.5);
    }
    50% { 
        transform: scale(1.1);
        box-shadow: 0 0 40px rgba(0,0,0,0.4), inset 0 0 30px rgba(255,255,255,0.7);
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    .input-container, .machine-container, .result-container {
        padding: 25px;
    }
    
    .machine-parts {
        height: 200px;
    }
    
    .large-gear {
        width: 80px;
        height: 80px;
    }
    
    .medium-gear {
        width: 60px;
        height: 60px;
    }
    
    .small-gear {
        width: 40px;
        height: 40px;
    }
}