:root {
    --red: #D42426;
    --green: #165B33;
    --gold: #FFD700;
    --cream: #FFF9F0;
    --dark-green: #0a3d1f;
}

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

body {
    font-family: 'Fredoka', cursive;
    background: linear-gradient(135deg, #FFF9F0 0%, #ffefd5 100%);
    background-attachment: fixed;
    color: var(--dark-green);
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: 
        radial-gradient(circle at 20% 50%, rgba(22, 91, 51, 0.03) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(212, 36, 38, 0.03) 0%, transparent 50%);
    pointer-events: none;
}

/* Snowflakes animation */
.snowflakes {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
}

.snowflake {
    position: absolute;
    top: -10%;
    color: rgba(255, 255, 255, 0.8);
    font-size: 1.5em;
    animation: fall linear infinite;
}

.snowflake:nth-child(1) { left: 10%; animation-duration: 10s; animation-delay: 0s; }
.snowflake:nth-child(2) { left: 20%; animation-duration: 12s; animation-delay: 1s; font-size: 2em; }
.snowflake:nth-child(3) { left: 30%; animation-duration: 9s; animation-delay: 2s; }
.snowflake:nth-child(4) { left: 40%; animation-duration: 11s; animation-delay: 0.5s; font-size: 1.8em; }
.snowflake:nth-child(5) { left: 60%; animation-duration: 10s; animation-delay: 1.5s; }
.snowflake:nth-child(6) { left: 70%; animation-duration: 13s; animation-delay: 0.2s; font-size: 2.2em; }
.snowflake:nth-child(7) { left: 80%; animation-duration: 9.5s; animation-delay: 1.8s; }
.snowflake:nth-child(8) { left: 90%; animation-duration: 11.5s; animation-delay: 0.8s; font-size: 1.6em; }

@keyframes fall {
    to {
        transform: translateY(110vh) rotate(360deg);
    }
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    position: relative;
    z-index: 1;
}

.header {
    text-align: center;
    margin-bottom: 40px;
    padding: 30px 20px;
    background: linear-gradient(135deg, var(--red) 0%, #b91d1f 100%);
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(212, 36, 38, 0.3);
    position: relative;
    overflow: hidden;
}

.header::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 10px,
        rgba(255, 255, 255, 0.05) 10px,
        rgba(255, 255, 255, 0.05) 20px
    );
    animation: candy-stripe 20s linear infinite;
}

@keyframes candy-stripe {
    0% { transform: translate(0, 0); }
    100% { transform: translate(20px, 20px); }
}

.title {
    font-size: 3em;
    font-weight: 700;
    color: white;
    text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.3);
    margin-bottom: 10px;
    position: relative;
    z-index: 1;
}

.subtitle {
    font-size: 1.3em;
    color: rgba(255, 255, 255, 0.95);
    position: relative;
    z-index: 1;
}

.berry {
    display: inline-block;
    animation: bounce 2s infinite;
}

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

.upload-zone {
    background: white;
    border: 4px dashed var(--green);
    border-radius: 20px;
    padding: 60px 40px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
}

.upload-zone:hover,
.upload-zone.dragover {
    border-color: var(--red);
    background: rgba(212, 36, 38, 0.05);
    transform: scale(1.02);
}

.upload-icon {
    font-size: 5em;
    margin-bottom: 20px;
    animation: float 3s ease-in-out infinite;
}

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

.upload-text {
    font-size: 1.5em;
    font-weight: 600;
    color: var(--dark-green);
    margin-bottom: 10px;
}

.upload-subtext {
    font-size: 1.1em;
    color: var(--green);
    margin: 15px 0;
}

.upload-button {
    display: inline-block;
    background: var(--green);
    color: white;
    padding: 15px 40px;
    border-radius: 50px;
    font-size: 1.2em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 5px 15px rgba(22, 91, 51, 0.3);
}

.upload-button:hover {
    background: var(--red);
    transform: translateY(-2px);
    box-shadow: 0 7px 20px rgba(212, 36, 38, 0.4);
}

.upload-hint {
    margin-top: 20px;
    font-size: 0.9em;
    color: var(--green);
    font-style: italic;
}

.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 40px;
    background: white;
    border-radius: 20px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
}

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 6px solid rgba(212, 36, 38, 0.2);
    border-top-color: var(--red);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

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

.loading p {
    font-size: 1.3em;
    color: var(--green);
}

.editor {
    display: flex;
    gap: 30px;
    background: white;
    padding: 30px;
    border-radius: 20px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
}

.editor-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
}

#canvas {
    max-width: 100%;
    height: auto;
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.face-count {
    margin-top: 15px;
    font-size: 1.1em;
    color: var(--red);
    font-weight: 600;
}

.controls {
    width: 320px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.control-section {
    background: rgba(22, 91, 51, 0.05);
    padding: 20px;
    border-radius: 15px;
    border: 2px solid rgba(22, 91, 51, 0.1);
}

.control-section h3 {
    font-size: 1.1em;
    margin-bottom: 15px;
    color: var(--dark-green);
}

.hat-styles {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.hat-style-btn {
    background: white;
    border: 2px solid var(--green);
    border-radius: 10px;
    padding: 12px;
    font-family: 'Fredoka', cursive;
    font-size: 0.95em;
    font-weight: 600;
    color: var(--green);
    cursor: pointer;
    transition: all 0.2s ease;
}

.hat-style-btn:hover {
    background: rgba(22, 91, 51, 0.1);
    transform: scale(1.05);
}

.hat-style-btn.active {
    background: var(--green);
    color: white;
}

input[type="range"] {
    width: 100%;
    height: 8px;
    background: rgba(22, 91, 51, 0.2);
    border-radius: 5px;
    outline: none;
    -webkit-appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    background: var(--red);
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 0 10px rgba(212, 36, 38, 0.5);
}

.position-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.pos-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.pos-btn {
    background: white;
    border: 2px solid var(--green);
    border-radius: 8px;
    width: 40px;
    height: 40px;
    font-size: 1.2em;
    color: var(--green);
    cursor: pointer;
    transition: all 0.2s ease;
}

.pos-btn:hover {
    background: var(--green);
    color: white;
    transform: scale(1.1);
}

.reset-btn {
    background: var(--gold);
    border: none;
    border-radius: 8px;
    padding: 8px 16px;
    font-family: 'Fredoka', cursive;
    font-size: 0.9em;
    font-weight: 600;
    color: var(--dark-green);
    cursor: pointer;
    transition: all 0.2s ease;
}

.reset-btn:hover {
    background: #ffd000;
    transform: scale(1.05);
}

.fun-section {
    background: linear-gradient(135deg, rgba(212, 36, 38, 0.1), rgba(255, 215, 0, 0.1));
    border-color: var(--red);
}

.fun-btn {
    width: 100%;
    background: white;
    border: 2px solid var(--red);
    border-radius: 10px;
    padding: 12px;
    margin-bottom: 10px;
    font-family: 'Fredoka', cursive;
    font-size: 1em;
    font-weight: 600;
    color: var(--red);
    cursor: pointer;
    transition: all 0.2s ease;
}

.fun-btn:hover {
    background: var(--red);
    color: white;
    transform: scale(1.05);
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 1em;
    color: var(--dark-green);
}

.toggle-label input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.action-btn {
    width: 100%;
    padding: 16px;
    border: none;
    border-radius: 12px;
    font-family: 'Fredoka', cursive;
    font-size: 1.1em;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
}

.download-btn {
    background: linear-gradient(135deg, var(--green), #0d5027);
    color: white;
    box-shadow: 0 5px 15px rgba(22, 91, 51, 0.3);
}

.download-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 7px 20px rgba(22, 91, 51, 0.4);
}

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

.secondary-btn:hover {
    background: rgba(22, 91, 51, 0.1);
    transform: translateY(-2px);
}

.footer {
    margin-top: 40px;
    text-align: center;
    padding: 30px;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 20px;
    font-size: 0.95em;
}

.footer p {
    margin: 8px 0;
    color: var(--dark-green);
}

.footer a {
    color: var(--red);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s ease;
}

.footer a:hover {
    color: var(--green);
}

.credits {
    font-size: 0.9em;
    color: var(--green);
    font-style: italic;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .title {
        font-size: 2em;
    }
    
    .subtitle {
        font-size: 1em;
    }
    
    .editor {
        flex-direction: column;
    }
    
    .controls {
        width: 100%;
    }
    
    .upload-zone {
        padding: 40px 20px;
    }
    
    .upload-icon {
        font-size: 3em;
    }
}