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

body {
    background: #f5f3f0;
    font-family: 'Bricolage Grotesque', sans-serif;
    color: #333;
    overflow: hidden;
    min-height: 100vh;
    min-height: 100dvh;
}

.hidden {
    display: none !important;
}

/* Welcome Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(155deg, #faf8f5 0%, #f0ede8 35%, #e8e4de 60%, #f5f3f0 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    text-align: center;
    padding: 3rem 2rem;
    max-width: 540px;
    position: relative;
}

.modal-particles {
    position: absolute;
    top: -120px;
    left: -120px;
    right: -120px;
    bottom: -120px;
    overflow: hidden;
    pointer-events: none;
}

.floating-particle {
    position: absolute;
    width: 3px;
    height: 3px;
    background: rgba(180, 140, 255, 0.4);
    border-radius: 50%;
    animation: float 6s ease-in-out infinite;
    box-shadow: 0 0 14px rgba(180, 140, 255, 0.4);
}

.floating-particle:nth-child(3n) {
    background: rgba(255, 140, 180, 0.4);
    box-shadow: 0 0 14px rgba(255, 140, 180, 0.4);
}

.floating-particle:nth-child(5n) {
    background: rgba(140, 200, 180, 0.4);
    box-shadow: 0 0 14px rgba(140, 200, 180, 0.4);
}

.floating-particle:nth-child(7n) {
    background: rgba(255, 180, 100, 0.35);
    box-shadow: 0 0 12px rgba(255, 180, 100, 0.35);
}

@keyframes float {
    0%, 100% { transform: translateY(0) translateX(0); opacity: 0.15; }
    50% { transform: translateY(-50px) translateX(20px); opacity: 1; }
}

.modal-title {
    font-family: 'Crimson Pro', serif;
    font-size: 3rem;
    font-weight: 300;
    font-style: italic;
    margin-bottom: 0.4rem;
    color: #2a2a2a;
    text-shadow: 0 0 60px rgba(180, 140, 255, 0.2);
}

.modal-subtitle {
    font-family: 'Crimson Pro', serif;
    font-size: 2.2rem;
    font-weight: 300;
    font-style: italic;
    margin-bottom: 2.2rem;
    background: linear-gradient(135deg, #9070cc, #cc7090, #70b090);
    background-size: 200% 200%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: gradient-shift 5s ease-in-out infinite;
}

@keyframes gradient-shift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

.modal-text {
    font-size: 1rem;
    line-height: 1.9;
    color: rgba(50, 50, 50, 0.7);
    margin-bottom: 2.8rem;
    font-weight: 300;
    letter-spacing: 0.01em;
}

.begin-button {
    display: inline-flex;
    align-items: center;
    gap: 0.7rem;
    padding: 1rem 2.6rem;
    font-size: 1.15rem;
    font-family: 'Bricolage Grotesque', sans-serif;
    font-weight: 500;
    background: linear-gradient(135deg, #9070cc 0%, #cc7090 50%, #70b090 100%);
    background-size: 200% 200%;
    border: none;
    border-radius: 50px;
    color: #fff;
    cursor: pointer;
    transition: all 0.3s ease;
    animation: gradient-shift 4s ease-in-out infinite;
    box-shadow: 0 4px 35px rgba(140, 100, 180, 0.3);
}

.begin-button:hover {
    transform: scale(1.06);
    box-shadow: 0 6px 45px rgba(140, 100, 180, 0.45);
}

.begin-button .mic-icon {
    width: 22px;
    height: 22px;
}

/* Mic Test Overlay */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(245, 243, 240, 0.97);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 900;
}

.overlay-content {
    text-align: center;
}

.sound-waves {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 2rem;
}

.sound-waves span {
    width: 5px;
    height: 35px;
    background: linear-gradient(to top, #9070cc, #cc7090, #70b090);
    border-radius: 3px;
    animation: wave 0.9s ease-in-out infinite;
}

.sound-waves span:nth-child(1) { animation-delay: 0s; height: 22px; }
.sound-waves span:nth-child(2) { animation-delay: 0.1s; height: 32px; }
.sound-waves span:nth-child(3) { animation-delay: 0.15s; height: 42px; }
.sound-waves span:nth-child(4) { animation-delay: 0.1s; height: 32px; }
.sound-waves span:nth-child(5) { animation-delay: 0s; height: 22px; }

@keyframes wave {
    0%, 100% { transform: scaleY(0.5); opacity: 0.65; }
    50% { transform: scaleY(1.4); opacity: 1; }
}

.overlay-text {
    font-size: 1.5rem;
    font-weight: 300;
    color: rgba(50, 50, 50, 0.9);
    font-family: 'Crimson Pro', serif;
    font-style: italic;
}

.overlay-success {
    font-size: 1.3rem;
    color: #50a080;
    animation: fadeInScale 0.5s ease;
    font-weight: 400;
}

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

/* App Container */
#app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    position: relative;
}

/* Top Banner */
#top-banner {
    background: linear-gradient(180deg, rgba(245, 243, 240, 0.98) 0%, rgba(245, 243, 240, 0.5) 70%, transparent 100%);
    padding: 1rem 1.5rem 2.2rem;
    text-align: center;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10;
    pointer-events: none;
}

.main-message {
    font-family: 'Crimson Pro', serif;
    font-size: 1.2rem;
    font-weight: 300;
    font-style: italic;
    margin-bottom: 0.3rem;
    color: rgba(50, 50, 50, 0.8);
    text-shadow: 0 2px 25px rgba(255, 255, 255, 0.6);
}

.encouraging-text {
    font-size: 0.85rem;
    color: rgba(50, 50, 50, 0.45);
    transition: opacity 0.5s ease;
    font-weight: 300;
    letter-spacing: 0.02em;
}

/* Canvas */
#canvas {
    flex: 1;
    display: block;
    cursor: crosshair;
}

/* Color Palette */
#color-palette {
    position: fixed;
    right: 18px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    z-index: 10;
    opacity: 0.75;
    transition: opacity 0.3s ease;
}

#color-palette:hover {
    opacity: 1;
}

.palette-label {
    font-size: 0.6rem;
    color: rgba(50, 50, 50, 0.4);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    writing-mode: vertical-rl;
    text-orientation: mixed;
    transform: rotate(180deg);
    margin-bottom: 6px;
    font-weight: 500;
}

.palette-gradient {
    width: 6px;
    height: 140px;
    border-radius: 3px;
    background: linear-gradient(to top, 
        hsl(255, 60%, 50%) 0%,
        hsl(175, 60%, 45%) 33%,
        hsl(25, 75%, 55%) 66%,
        hsl(340, 65%, 60%) 100%
    );
    position: relative;
    box-shadow: 0 0 25px rgba(140, 100, 180, 0.15);
}

.pitch-indicator {
    position: absolute;
    left: -6px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid rgba(100, 100, 100, 0.5);
    transition: bottom 0.1s ease-out, background-color 0.1s ease;
    box-shadow: 0 0 18px rgba(100, 100, 100, 0.3);
    bottom: 50%;
}

.palette-high, .palette-low {
    font-size: 0.5rem;
    color: rgba(50, 50, 50, 0.3);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 400;
}

/* Emotion Display */
#emotion-display {
    position: fixed;
    left: 18px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
}

.emotion-indicator {
    font-size: 1.6rem;
    opacity: 0.25;
    transition: opacity 0.3s ease;
    filter: drop-shadow(0 0 10px rgba(100, 100, 100, 0.15));
}

/* Controls */
#controls {
    position: fixed;
    bottom: 28px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 26px;
    background: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    border: 1px solid rgba(100, 100, 100, 0.1);
    border-radius: 60px;
    z-index: 100;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.1);
}

.control-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(100, 100, 100, 0.08);
    border: 1px solid rgba(100, 100, 100, 0.15);
    color: rgba(80, 80, 80, 0.7);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.25s ease;
}

.control-btn:hover {
    background: rgba(100, 100, 100, 0.15);
    transform: scale(1.08);
    color: rgba(50, 50, 50, 0.95);
}

.control-btn svg {
    width: 18px;
    height: 18px;
}

.mic-button {
    width: 68px;
    height: 68px;
    border-radius: 50%;
    background: rgba(140, 100, 180, 0.15);
    border: 2px solid rgba(140, 100, 180, 0.3);
    color: #555;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: all 0.3s ease;
}

.mic-button .mic-icon {
    width: 26px;
    height: 26px;
    z-index: 2;
}

.mic-button.active {
    background: linear-gradient(135deg, #9070cc, #cc7090);
    border-color: transparent;
    box-shadow: 0 0 35px rgba(140, 100, 180, 0.35);
}

.mic-button.active .mic-icon {
    animation: mic-pulse 1.3s ease-in-out infinite;
    fill: #fff;
}

@keyframes mic-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.12); }
}

.volume-ring {
    position: absolute;
    top: -5px;
    left: -5px;
    right: -5px;
    bottom: -5px;
    border-radius: 50%;
    border: 3px solid rgba(140, 100, 180, 0.5);
    opacity: 0;
    transition: all 0.08s ease;
    pointer-events: none;
}

.pulse-ring {
    position: absolute;
    top: -10px;
    left: -10px;
    right: -10px;
    bottom: -10px;
    border-radius: 50%;
    border: 2px solid rgba(140, 100, 180, 0.2);
    animation: pulse-ring 2.2s ease-out infinite;
    pointer-events: none;
}

.mic-button:not(.active) .pulse-ring {
    animation: none;
    opacity: 0;
}

@keyframes pulse-ring {
    0% { transform: scale(1); opacity: 0.45; }
    100% { transform: scale(1.7); opacity: 0; }
}

/* Clear Confirm */
.confirm-popup {
    position: fixed;
    bottom: 125px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    padding: 1rem 1.5rem;
    border-radius: 16px;
    border: 1px solid rgba(100, 100, 100, 0.12);
    z-index: 200;
    animation: slideUp 0.25s ease;
    box-shadow: 0 10px 45px rgba(0, 0, 0, 0.15);
}

@keyframes slideUp {
    from { opacity: 0; transform: translateX(-50%) translateY(12px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.confirm-popup p {
    margin-bottom: 0.8rem;
    text-align: center;
    font-weight: 300;
    font-size: 0.95rem;
    color: #444;
}

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

.confirm-buttons button {
    padding: 0.5rem 1.4rem;
    border-radius: 20px;
    border: none;
    cursor: pointer;
    font-family: 'Bricolage Grotesque', sans-serif;
    transition: all 0.2s ease;
    font-weight: 400;
    font-size: 0.9rem;
}

#confirm-yes {
    background: linear-gradient(135deg, #cc7090, #cc6060);
    color: white;
}

#confirm-no {
    background: rgba(100, 100, 100, 0.12);
    color: #555;
}

.confirm-buttons button:hover {
    transform: scale(1.05);
}

/* Toast */
.toast {
    position: fixed;
    bottom: 135px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    padding: 0.7rem 1.5rem;
    border-radius: 28px;
    border: 1px solid rgba(100, 100, 100, 0.15);
    font-size: 0.9rem;
    color: #444;
    z-index: 300;
    animation: toastIn 0.25s ease;
    box-shadow: 0 8px 35px rgba(0, 0, 0, 0.12);
    font-weight: 400;
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(-50%) translateY(10px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* Footer */
#footer {
    position: fixed;
    bottom: 6px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.65rem;
    color: rgba(80, 80, 80, 0.3);
    z-index: 5;
    font-weight: 400;
}

#footer a {
    color: rgba(80, 80, 80, 0.45);
    text-decoration: none;
    transition: color 0.2s ease;
}

#footer a:hover {
    color: rgba(80, 80, 80, 0.7);
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .modal-title {
        font-size: 2.2rem;
    }
    
    .modal-subtitle {
        font-size: 1.6rem;
    }
    
    .modal-text {
        font-size: 0.9rem;
        padding: 0 0.5rem;
    }
    
    .main-message {
        font-size: 1rem;
    }
    
    #color-palette {
        right: 10px;
    }
    
    .palette-gradient {
        height: 110px;
    }
    
    #emotion-display {
        left: 10px;
    }
    
    #controls {
        bottom: 18px;
        gap: 12px;
        padding: 10px 20px;
    }
    
    .mic-button {
        width: 58px;
        height: 58px;
    }
    
    .control-btn {
        width: 40px;
        height: 40px;
    }
    
    #footer {
        bottom: 3px;
        font-size: 0.55rem;
    }
}

@media (max-width: 400px) {
    .modal-content {
        padding: 2rem 0.8rem;
    }
    
    .modal-title {
        font-size: 1.8rem;
    }
    
    .modal-subtitle {
        font-size: 1.4rem;
    }
    
    .begin-button {
        padding: 0.85rem 1.8rem;
        font-size: 1rem;
    }
    
    #controls {
        gap: 8px;
        padding: 8px 14px;
    }
    
    .mic-button {
        width: 52px;
        height: 52px;
    }
    
    .control-btn {
        width: 36px;
        height: 36px;
    }
    
    #color-palette {
        display: none;
    }
    
    #emotion-display {
        display: none;
    }
}