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

:root {
    --cream: #FDF6E3;
    --warm-beige: #F5E6D3;
    --soft-pink: #FFB5BA;
    --coral: #F4A259;
    --rust: #BC6C25;
    --golden: #DDA15E;
    --soft-blue: #A8DADC;
    --dark-brown: #3D2914;
}

body {
    font-family: 'Nunito', sans-serif;
    background: var(--cream);
    min-height: 100vh;
    background-image: 
        radial-gradient(circle at 20% 20%, rgba(255, 181, 186, 0.2) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(244, 162, 89, 0.2) 0%, transparent 50%);
}

.app-container {
    max-width: 600px;
    margin: 0 auto;
    padding: 16px;
    min-height: 100vh;
    position: relative;
    display: flex;
    flex-direction: column;
}

/* Sound toggle */
.sound-toggle {
    position: fixed;
    top: 16px;
    right: 16px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--warm-beige);
    border: 3px dashed var(--golden);
    font-size: 20px;
    cursor: pointer;
    z-index: 100;
    transition: transform 0.2s;
}

.sound-toggle:hover {
    transform: scale(1.1);
}

/* Header */
.header {
    text-align: center;
    padding: 24px 16px;
    background: linear-gradient(135deg, var(--warm-beige) 0%, var(--cream) 100%);
    border-radius: 24px;
    border: 4px dashed var(--golden);
    margin-bottom: 20px;
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
}

.header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0 30 L60 30 M30 0 L30 60' stroke='%23DDA15E' stroke-width='0.5' fill='none' stroke-dasharray='4 8'/%3E%3C/svg%3E");
    opacity: 0.3;
}

.header-content {
    position: relative;
    z-index: 1;
}

.title {
    font-size: 2.5rem;
    font-weight: 900;
    color: var(--rust);
    text-shadow: 3px 3px 0 var(--golden);
    margin-bottom: 4px;
}

.subtitle {
    font-size: 1rem;
    color: var(--dark-brown);
    font-weight: 600;
}

/* Main content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Mode toggle */
.mode-toggle {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-bottom: 20px;
    flex-shrink: 0;
}

.mode-btn {
    flex: 1;
    max-width: 160px;
    padding: 14px 20px;
    border: none;
    border-radius: 20px;
    font-family: 'Nunito', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    background: var(--warm-beige);
    color: var(--dark-brown);
    border: 3px solid transparent;
    box-shadow: 0 4px 0 var(--golden);
}

.mode-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 0 var(--golden);
}

.mode-btn.active {
    background: var(--soft-pink);
    border-color: var(--coral);
    box-shadow: 0 4px 0 var(--rust);
}

/* Input panel */
.input-panel {
    background: white;
    border-radius: 24px;
    padding: 20px;
    border: 4px dashed var(--golden);
    margin-bottom: 20px;
    flex-shrink: 0;
}

.description-input {
    width: 100%;
    min-height: 120px;
    padding: 14px;
    border: 3px dashed var(--soft-pink);
    border-radius: 16px;
    font-family: 'Nunito', sans-serif;
    font-size: 1rem;
    resize: vertical;
    background: var(--cream);
    color: var(--dark-brown);
}

.description-input:focus {
    outline: none;
    border-color: var(--coral);
}

.description-input::placeholder {
    color: #999;
}

.char-count {
    text-align: right;
    font-size: 0.85rem;
    color: #888;
    margin-top: 6px;
}

/* Photo mode */
.upload-zone {
    border: 4px dashed var(--soft-pink);
    border-radius: 20px;
    padding: 30px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    background: var(--cream);
}

.upload-zone:hover {
    border-color: var(--coral);
    background: rgba(244, 162, 89, 0.1);
}

.upload-icon {
    font-size: 3rem;
    margin-bottom: 12px;
}

.upload-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 16px;
}

.upload-btn {
    padding: 12px 20px;
    background: var(--warm-beige);
    border: 2px solid var(--golden);
    border-radius: 12px;
    font-family: 'Nunito', sans-serif;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.upload-btn:hover {
    background: var(--golden);
    color: white;
}

.photo-preview-container {
    text-align: center;
}

.polaroid-frame {
    display: inline-block;
    background: white;
    padding: 10px 10px 30px 10px;
    border-radius: 4px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    transform: rotate(-2deg);
}

.photo-preview {
    max-width: 100%;
    max-height: 200px;
    border-radius: 2px;
}

.remove-photo {
    margin-top: 12px;
    padding: 8px 16px;
    background: #ff6b6b;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-family: 'Nunito', sans-serif;
    font-weight: 600;
}

.additional-details {
    width: 100%;
    min-height: 60px;
    padding: 12px;
    border: 3px dashed var(--soft-pink);
    border-radius: 12px;
    font-family: 'Nunito', sans-serif;
    font-size: 1rem;
    margin-top: 14px;
    background: var(--cream);
    resize: vertical;
}

/* Webcam styles */
.webcam-container {
    display: flex;
    flex-direction: column;
    width: 100%;
}

.webcam-video {
    width: 100%;
    height: auto;
    aspect-ratio: 4/3;
    object-fit: cover;
    border-radius: 16px;
    border: 4px solid var(--coral);
    background: #000;
    display: block;
}

.webcam-controls {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 16px;
}

.capture-btn {
    padding: 14px 28px;
    background: linear-gradient(135deg, var(--coral) 0%, var(--soft-pink) 100%);
    border: none;
    border-radius: 16px;
    font-family: 'Nunito', sans-serif;
    font-size: 1.1rem;
    font-weight: 700;
    color: white;
    cursor: pointer;
    box-shadow: 0 4px 0 var(--rust);
    transition: all 0.2s;
}

.capture-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 0 var(--rust);
}

.cancel-btn {
    padding: 14px 24px;
    background: var(--warm-beige);
    border: 2px solid var(--golden);
    border-radius: 16px;
    font-family: 'Nunito', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.cancel-btn:hover {
    background: #ff6b6b;
    color: white;
    border-color: #ff6b6b;
}

/* Generate button */
.generate-btn {
    width: 100%;
    padding: 18px;
    margin-top: 16px;
    background: linear-gradient(135deg, var(--coral) 0%, var(--soft-pink) 100%);
    border: none;
    border-radius: 20px;
    font-family: 'Nunito', sans-serif;
    font-size: 1.3rem;
    font-weight: 800;
    color: white;
    cursor: pointer;
    box-shadow: 0 6px 0 var(--rust);
    transition: all 0.2s;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.2);
}

.generate-btn:hover:not(:disabled) {
    transform: translateY(-3px);
    box-shadow: 0 9px 0 var(--rust);
}

.generate-btn:active:not(:disabled) {
    transform: translateY(2px);
    box-shadow: 0 2px 0 var(--rust);
}

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

/* Loading */
.loading-container {
    text-align: center;
    padding: 40px 20px;
}

.yarn-ball {
    width: 70px;
    height: 70px;
    margin: 0 auto 20px;
    background: var(--coral);
    border-radius: 50%;
    position: relative;
    animation: bounce 1s ease-in-out infinite;
}

.yarn-strand {
    position: absolute;
    width: 100%;
    height: 100%;
    border: 3px solid var(--soft-pink);
    border-radius: 50%;
    animation: spin 2s linear infinite;
}

.yarn-strand:nth-child(2) {
    transform: rotate(60deg);
    animation-delay: -0.5s;
}

.yarn-strand:nth-child(3) {
    transform: rotate(120deg);
    animation-delay: -1s;
}

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

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

.loading-message {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--rust);
    margin-bottom: 6px;
}

.loading-pun {
    font-size: 0.95rem;
    color: var(--dark-brown);
    font-style: italic;
}

/* Result */
.result-container {
    text-align: center;
}

.toy-box {
    background: linear-gradient(180deg, #FFE5E5 0%, white 100%);
    border-radius: 24px;
    padding: 14px;
    border: 6px solid var(--coral);
    box-shadow: 0 10px 40px rgba(188, 108, 37, 0.3);
    margin-bottom: 20px;
}

.toy-box-header {
    margin-bottom: 10px;
}

.toy-tag {
    display: inline-block;
    background: var(--golden);
    color: white;
    padding: 6px 14px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 0.85rem;
}

.toy-box-window {
    background: white;
    border-radius: 16px;
    overflow: hidden;
    border: 4px solid rgba(0,0,0,0.05);
}

.plush-image {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 12px;
}

.result-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.action-btn {
    padding: 12px 14px;
    border: none;
    border-radius: 16px;
    font-family: 'Nunito', sans-serif;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}

.action-btn.download {
    background: var(--soft-blue);
    color: var(--dark-brown);
}

.action-btn.share {
    background: #1DA1F2;
    color: white;
}

.action-btn.retry {
    background: var(--golden);
    color: white;
}

.action-btn.new {
    background: var(--soft-pink);
    color: var(--dark-brown);
}

.action-btn:hover {
    transform: scale(1.05);
}

/* Example gallery */
.example-section {
    margin-top: 24px;
    flex-shrink: 0;
}

.section-title {
    text-align: center;
    font-size: 1.2rem;
    color: var(--rust);
    margin-bottom: 12px;
}

.example-gallery {
    display: flex;
    gap: 14px;
    overflow-x: auto;
    padding: 6px 0 14px;
    scroll-snap-type: x mandatory;
}

.example-card {
    flex: 0 0 120px;
    scroll-snap-align: start;
    background: white;
    border-radius: 16px;
    padding: 6px;
    border: 3px dashed var(--golden);
    cursor: pointer;
    transition: all 0.3s;
}

.example-card:hover {
    transform: scale(1.05);
    border-style: solid;
}

.example-image {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: 12px;
}

.example-name {
    display: block;
    text-align: center;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--dark-brown);
    margin-top: 6px;
}

/* Collection */
.collection-toggle {
    width: 100%;
    padding: 14px;
    margin-top: 20px;
    background: var(--warm-beige);
    border: 3px dashed var(--rust);
    border-radius: 16px;
    font-family: 'Nunito', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    color: var(--dark-brown);
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.collection-toggle:hover {
    background: var(--golden);
    color: white;
}

.collection-drawer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-radius: 24px 24px 0 0;
    padding: 24px;
    box-shadow: 0 -10px 40px rgba(0,0,0,0.2);
    max-height: 60vh;
    overflow-y: auto;
    z-index: 1000;
}

.collection-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.collection-header h3 {
    font-size: 1.3rem;
    color: var(--rust);
}

.collection-header button {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: var(--warm-beige);
    font-size: 1.2rem;
    cursor: pointer;
}

.collection-hint {
    font-size: 0.85rem;
    color: #888;
    margin-bottom: 16px;
    text-align: center;
    font-style: italic;
}

.collection-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 12px;
}

.collection-item {
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    border-radius: 16px;
    padding: 6px;
}

.collection-item:hover {
    transform: scale(1.08);
    background: var(--cream);
}

.collection-item img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: 12px;
    border: 3px solid var(--golden);
    transition: border-color 0.2s;
}

.collection-item:hover img {
    border-color: var(--coral);
}

.collection-item span {
    display: block;
    font-size: 0.8rem;
    color: var(--dark-brown);
    margin-top: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Lightbox */
.lightbox-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.lightbox-content {
    background: white;
    border-radius: 24px;
    max-width: 90vw;
    max-height: 90vh;
    overflow: hidden;
    position: relative;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: scaleIn 0.3s ease;
}

@keyframes scaleIn {
    from { 
        opacity: 0;
        transform: scale(0.9);
    }
    to { 
        opacity: 1;
        transform: scale(1);
    }
}

.lightbox-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.95);
    font-size: 1.3rem;
    cursor: pointer;
    z-index: 10;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    transition: all 0.2s;
}

.lightbox-close:hover {
    background: #ff6b6b;
    color: white;
    transform: scale(1.1);
}

.lightbox-image-container {
    max-height: 70vh;
    overflow: hidden;
}

.lightbox-image {
    width: 100%;
    max-height: 70vh;
    object-fit: contain;
    display: block;
}

.lightbox-info {
    padding: 20px;
    text-align: center;
    background: linear-gradient(180deg, var(--cream) 0%, white 100%);
    border-top: 4px dashed var(--golden);
}

.lightbox-title {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--rust);
    margin-bottom: 6px;
}

.lightbox-date {
    font-size: 0.9rem;
    color: #888;
    margin-bottom: 16px;
}

.lightbox-download {
    padding: 14px 28px;
    background: linear-gradient(135deg, var(--coral) 0%, var(--soft-pink) 100%);
    border: none;
    border-radius: 16px;
    font-family: 'Nunito', sans-serif;
    font-size: 1.1rem;
    font-weight: 700;
    color: white;
    cursor: pointer;
    box-shadow: 0 4px 0 var(--rust);
    transition: all 0.2s;
}

.lightbox-download:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 0 var(--rust);
}

.lightbox-download:active {
    transform: translateY(1px);
    box-shadow: 0 2px 0 var(--rust);
}

/* Footer */
.footer {
    text-align: center;
    padding: 24px 16px;
    margin-top: auto;
    border-top: 4px dashed var(--golden);
    flex-shrink: 0;
}

.footer p {
    color: var(--dark-brown);
    font-weight: 600;
    margin-bottom: 8px;
}

.footer-link {
    display: inline-block;
    background: var(--coral);
    color: white;
    padding: 8px 20px;
    border-radius: 20px;
    text-decoration: none;
    font-weight: 700;
    margin-bottom: 8px;
}

.footer-credit {
    display: block;
    font-size: 0.85rem;
    color: #888;
}

/* Confetti */
.confetti-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 9999;
    overflow: hidden;
}

.confetti-piece {
    position: absolute;
    width: 10px;
    height: 10px;
    top: -20px;
    border-radius: 2px;
    animation: fall 3s ease-out forwards;
}

@keyframes fall {
    to {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

/* Responsive */
@media (max-width: 480px) {
    .title {
        font-size: 2rem;
    }
    
    .mode-btn {
        padding: 12px 16px;
        font-size: 0.95rem;
    }
    
    .generate-btn {
        font-size: 1.1rem;
        padding: 16px;
    }
    
    .result-actions {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }
    
    .action-btn {
        padding: 10px 12px;
        font-size: 0.85rem;
    }

    .lightbox-content {
        max-width: 95vw;
    }

    .lightbox-title {
        font-size: 1.2rem;
    }

    .lightbox-download {
        padding: 12px 24px;
        font-size: 1rem;
    }
}