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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    color: #333;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

header {
    text-align: center;
    color: white;
    margin-bottom: 30px;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
}

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

.upload-section {
    background: white;
    border-radius: 20px;
    padding: 60px 40px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.1);
}

.upload-box {
    border: 3px dashed #667eea;
    border-radius: 15px;
    padding: 60px 20px;
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
}

.upload-box:hover {
    border-color: #764ba2;
    background: #f8f9ff;
}

.upload-box.dragover {
    border-color: #764ba2;
    background: #f0f2ff;
    transform: scale(1.02);
}

.upload-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    cursor: pointer;
    color: #667eea;
}

.upload-label svg {
    color: #667eea;
}

.upload-label span {
    font-size: 1.2rem;
    font-weight: 600;
}

.upload-label small {
    color: #999;
    font-size: 0.9rem;
}

.editor-section {
    background: white;
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.1);
}

.canvas-wrapper {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 30px;
    background: #f5f5f5;
    border-radius: 15px;
    overflow: hidden;
    min-height: 400px;
}

#canvas {
    max-width: 100%;
    max-height: 70vh;
    display: block;
}

.hat-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.christmas-hat {
    position: absolute;
    cursor: move;
    pointer-events: all;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
    filter: drop-shadow(2px 2px 4px rgba(0,0,0,0.3));
    transition: filter 0.2s ease;
}

.christmas-hat:hover {
    filter: drop-shadow(3px 3px 6px rgba(0,0,0,0.4));
}

.christmas-hat:active {
    cursor: grabbing;
}

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

.control-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.control-group label {
    display: flex;
    align-items: center;
    gap: 15px;
    font-weight: 500;
}

.control-group label > span:first-child {
    min-width: 80px;
    color: #555;
}

.control-group input[type="range"] {
    flex: 1;
    height: 6px;
    border-radius: 3px;
    background: #e0e0e0;
    outline: none;
    -webkit-appearance: none;
}

.control-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
    transition: all 0.2s ease;
}

.control-group input[type="range"]::-webkit-slider-thumb:hover {
    background: #764ba2;
    transform: scale(1.2);
}

.control-group input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
}

.control-group input[type="range"]::-moz-range-thumb:hover {
    background: #764ba2;
    transform: scale(1.2);
}

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

.control-group label > span:last-child {
    min-width: 60px;
    text-align: right;
    color: #667eea;
    font-weight: 600;
}

.hat-selection label {
    margin-bottom: 5px;
}

.hat-options {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
    padding: 10px 0;
}

.hat-option {
    aspect-ratio: 1;
    border: 3px solid transparent;
    border-radius: 10px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #f5f5f5;
    padding: 5px;
}

.hat-option:hover {
    border-color: #667eea;
    transform: scale(1.05);
}

.hat-option.active {
    border-color: #764ba2;
    background: #f0f2ff;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

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

.button-group {
    display: flex;
    gap: 15px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.btn {
    flex: 1;
    min-width: 120px;
    padding: 12px 24px;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

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

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: white;
    color: #667eea;
    border: 2px solid #667eea;
}

.btn-secondary:hover {
    background: #667eea;
    color: white;
    transform: translateY(-2px);
}

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

@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    header h1 {
        font-size: 1.8rem;
    }

    header p {
        font-size: 0.95rem;
    }

    .upload-section {
        padding: 40px 20px;
    }

    .upload-box {
        padding: 40px 15px;
    }

    .editor-section {
        padding: 20px;
    }

    .canvas-wrapper {
        min-height: 300px;
    }

    #canvas {
        max-height: 50vh;
    }

    .control-group label {
        flex-wrap: wrap;
    }

    .control-group label > span:first-child {
        min-width: 100%;
    }

    .control-group input[type="range"] {
        width: 100%;
    }

    .hat-options {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }

    .button-group {
        flex-direction: column;
    }

    .btn {
        width: 100%;
        min-width: auto;
    }
}

@media (max-width: 480px) {
    header h1 {
        font-size: 1.5rem;
    }

    .upload-label span {
        font-size: 1rem;
    }

    .upload-label svg {
        width: 48px;
        height: 48px;
    }
}
