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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    overflow: hidden;
}

header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

h1 {
    font-size: 1.8em;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
}

.btn {
    background: white;
    color: #667eea;
    border: none;
    padding: 12px 24px;
    border-radius: 25px;
    font-size: 1em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}

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

main {
    display: flex;
    flex-direction: column;
    gap: 30px;
    padding: 30px;
}

.avatar-preview {
    display: flex;
    justify-content: center;
    align-items: center;
    background: #f8f9fa;
    border-radius: 15px;
    padding: 20px;
    border: 3px dashed #dee2e6;
}

canvas {
    background: white;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}

.controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.control-group {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 12px;
    border: 2px solid #e9ecef;
}

.control-group h3 {
    color: #495057;
    margin-bottom: 10px;
    font-size: 1em;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.part-selector {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-bottom: 10px;
}

.part-btn {
    background: #667eea;
    color: white;
    border: none;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    font-size: 1em;
    cursor: pointer;
    transition: all 0.2s ease;
}

.part-btn:hover {
    background: #5a6fd6;
    transform: scale(1.1);
}

.part-btn:active {
    transform: scale(0.95);
}

#faceType, #eyesType, #noseType, #mouthType, #hairType, #shirtType {
    font-size: 1.2em;
    font-weight: bold;
    color: #495057;
    min-width: 30px;
    text-align: center;
}

input[type="color"] {
    width: 100%;
    height: 35px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    background: white;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.saved-section {
    padding: 20px 30px 30px;
    background: #f8f9fa;
    border-top: 2px solid #e9ecef;
}

.saved-section h2 {
    color: #495057;
    font-size: 1.2em;
    margin-bottom: 15px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.saved-avatars {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.saved-item {
    position: relative;
    background: white;
    border-radius: 12px;
    padding: 10px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    cursor: pointer;
    transition: all 0.3s ease;
}

.saved-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.2);
}

.saved-item canvas {
    border-radius: 8px;
    display: block;
}

.saved-item .delete-btn {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 24px;
    height: 24px;
    background: #e74c3c;
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s;
}

.saved-item:hover .delete-btn {
    opacity: 1;
}

.saved-item .delete-btn:hover {
    background: #c0392b;
}

.saved-item .name {
    font-size: 0.8em;
    color: #666;
    margin-top: 8px;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100px;
}

.header-buttons {
    display: flex;
    gap: 10px;
}

@media (max-width: 600px) {
    .controls {
        grid-template-columns: 1fr;
    }
    
    header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
    
    h1 {
        font-size: 1.4em;
    }
}