:root {
    --red: #c41e3a;
    --red-dark: #9a1830;
    --green: #165B33;
    --green-light: #1e7a45;
    --gold: #FFD700;
    --cream: #fef9e7;
    --white: #ffffff;
    --shadow: rgba(0, 0, 0, 0.15);
}

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

body {
    font-family: 'Nunito', sans-serif;
    background: linear-gradient(135deg, #1a1a3e 0%, #2d1b4e 50%, #1a2a4a 100%);
    min-height: 100vh;
    color: var(--white);
    overflow-x: hidden;
}

.snowflakes {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
    overflow: hidden;
}

.snowflake {
    position: absolute;
    top: -20px;
    color: rgba(255, 255, 255, 0.8);
    font-size: 1.5rem;
    animation: fall linear infinite;
    text-shadow: 0 0 5px rgba(255, 255, 255, 0.5);
}

.snowflake:nth-child(1) { left: 5%; animation-duration: 12s; animation-delay: 0s; font-size: 1rem; }
.snowflake:nth-child(2) { left: 15%; animation-duration: 15s; animation-delay: 2s; font-size: 1.2rem; }
.snowflake:nth-child(3) { left: 25%; animation-duration: 10s; animation-delay: 4s; }
.snowflake:nth-child(4) { left: 35%; animation-duration: 14s; animation-delay: 1s; font-size: 0.8rem; }
.snowflake:nth-child(5) { left: 45%; animation-duration: 11s; animation-delay: 3s; }
.snowflake:nth-child(6) { left: 55%; animation-duration: 13s; animation-delay: 5s; font-size: 1.1rem; }
.snowflake:nth-child(7) { left: 65%; animation-duration: 16s; animation-delay: 0.5s; }
.snowflake:nth-child(8) { left: 75%; animation-duration: 9s; animation-delay: 2.5s; font-size: 1.3rem; }
.snowflake:nth-child(9) { left: 85%; animation-duration: 12s; animation-delay: 4.5s; }
.snowflake:nth-child(10) { left: 95%; animation-duration: 14s; animation-delay: 1.5s; font-size: 0.9rem; }

@keyframes fall {
    0% {
        transform: translateY(-20px) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(360deg);
        opacity: 0.3;
    }
}

header {
    background: linear-gradient(135deg, var(--red) 0%, var(--red-dark) 100%);
    padding: 1.5rem 2rem;
    text-align: center;
    box-shadow: 0 4px 20px var(--shadow);
    position: relative;
    z-index: 10;
}

header h1 {
    font-family: 'Fredoka', sans-serif;
    font-size: 2.5rem;
    font-weight: 700;
    letter-spacing: 1px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

header p {
    font-size: 1.1rem;
    opacity: 0.9;
    margin-top: 0.3rem;
}

main {
    max-width: 1000px;
    margin: 0 auto;
    padding: 2rem 1rem;
    position: relative;
    z-index: 5;
}

.upload-zone {
    background: var(--white);
    border: 4px dashed var(--green);
    border-radius: 24px;
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    color: #333;
}

.upload-zone:hover,
.upload-zone.dragover {
    border-color: var(--red);
    background: var(--cream);
    transform: scale(1.02);
}

.upload-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.silhouette {
    width: 150px;
    height: 150px;
    background: linear-gradient(135deg, #ddd 0%, #bbb 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: visible;
}

.preview-hat {
    position: absolute;
    top: -40px;
    width: 100px;
    height: auto;
    animation: wobble 3s ease-in-out infinite;
}

@keyframes wobble {
    0%, 100% { transform: rotate(-5deg); }
    50% { transform: rotate(5deg); }
}

.upload-text {
    font-family: 'Fredoka', sans-serif;
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--green);
}

.upload-subtext {
    color: #666;
    font-size: 1rem;
}

.tip {
    font-size: 0.9rem;
    color: var(--red);
    font-weight: 600;
    margin-top: 1rem;
}

.btn {
    padding: 0.8rem 1.5rem;
    border: none;
    border-radius: 12px;
    font-family: 'Fredoka', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-primary {
    background: linear-gradient(135deg, var(--green) 0%, var(--green-light) 100%);
    color: var(--white);
    box-shadow: 0 4px 15px rgba(22, 91, 51, 0.4);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(22, 91, 51, 0.5);
}

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

.btn-secondary:hover {
    background: var(--green);
    color: var(--white);
}

.btn-outline {
    background: transparent;
    color: var(--white);
    border: 2px solid rgba(255, 255, 255, 0.5);
}

.btn-outline:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--white);
}

.btn-large {
    padding: 1rem 2.5rem;
    font-size: 1.3rem;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.editor {
    animation: fadeIn 0.5s ease;
}

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

.editor-layout {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 2rem;
    margin-bottom: 2rem;
}

@media (max-width: 768px) {
    .editor-layout {
        grid-template-columns: 1fr;
    }
}

.canvas-container {
    background: var(--white);
    border-radius: 20px;
    padding: 1rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    position: relative;
}

#canvas {
    width: 100%;
    height: auto;
    border-radius: 12px;
    display: block;
}

.quick-positions {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    display: flex;
    gap: 0.5rem;
}

.pos-btn {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
}

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

.controls-panel {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.controls-panel h3 {
    font-family: 'Fredoka', sans-serif;
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}

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

.hat-options {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.hat-btn {
    width: 60px;
    height: 60px;
    border: 3px solid transparent;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.9);
    cursor: pointer;
    transition: all 0.2s;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hat-btn img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.hat-btn:hover {
    transform: scale(1.1);
}

.hat-btn.active {
    border-color: var(--gold);
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.5);
}

.sliders {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.slider-group {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.slider-group label {
    font-size: 0.9rem;
    font-weight: 600;
}

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

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    background: var(--gold);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: var(--gold);
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

.action-buttons {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.action-buttons .btn {
    flex: 1;
    min-width: 80px;
    padding: 0.6rem 0.8rem;
    font-size: 0.85rem;
}

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

.circle-preview {
    width: 120px;
    height: 120px;
    margin: 0 auto;
    border-radius: 50%;
    overflow: hidden;
    border: 4px solid var(--gold);
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
}

#preview-canvas {
    width: 100%;
    height: 100%;
}

.download-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    animation: fadeIn 0.3s ease;
}

.modal-content {
    background: var(--white);
    color: #333;
    padding: 2.5rem;
    border-radius: 24px;
    text-align: center;
    max-width: 400px;
    margin: 1rem;
    animation: popIn 0.3s ease;
}

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

.modal-content h2 {
    font-family: 'Fredoka', sans-serif;
    color: var(--green);
    margin-bottom: 1rem;
}

.modal-content p {
    margin-bottom: 0.5rem;
}

.share-text {
    color: var(--red);
    font-weight: 600;
    margin: 1rem 0;
}

.modal-content .btn {
    margin-top: 1rem;
}

footer {
    text-align: center;
    padding: 2rem;
    background: rgba(0, 0, 0, 0.2);
    margin-top: 2rem;
}

footer a {
    color: var(--gold);
    text-decoration: none;
    font-weight: 600;
}

footer a:hover {
    text-decoration: underline;
}

.footer-sub {
    font-size: 0.9rem;
    opacity: 0.8;
    margin-top: 0.5rem;
}

.hidden {
    display: none !important;
}

@media (max-width: 768px) {
    header h1 {
        font-size: 1.8rem;
    }
    
    main {
        padding: 1rem;
    }
    
    .upload-zone {
        padding: 2rem 1rem;
    }
    
    .silhouette {
        width: 120px;
        height: 120px;
    }
    
    .preview-hat {
        width: 80px;
        top: -30px;
    }
    
    .controls-panel {
        padding: 1rem;
    }
    
    .hat-btn {
        width: 50px;
        height: 50px;
    }
    
    .quick-positions {
        top: 0.75rem;
        right: 0.75rem;
    }
    
    .pos-btn {
        width: 30px;
        height: 30px;
        font-size: 0.8rem;
    }
}