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

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
    overflow-y: auto;
    position: relative;
    padding: 20px 0;
}

body::before {
    content: '';
    position: absolute;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg, transparent 30%, rgba(255, 255, 255, 0.1) 50%, transparent 70%);
    animation: shimmer 3s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-50%) translateY(-50%) rotate(0deg); }
    100% { transform: translateX(-50%) translateY(-50%) rotate(360deg); }
}

.container {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(20px);
    border-radius: 30px;
    padding: 40px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    border: 2px solid rgba(255, 255, 255, 0.2);
    max-width: 500px;
    width: 90%;
    position: relative;
    z-index: 1;
}

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

.title {
    font-size: 2.5rem;
    font-weight: 900;
    background: linear-gradient(45deg, #fff, #ffd1ff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 10px;
    text-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.subtitle {
    color: rgba(255, 255, 255, 0.9);
    font-size: 1rem;
    font-weight: 500;
}

.visualizer-container {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 20px;
    padding: 20px;
    margin-bottom: 30px;
    min-height: 200px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

#waveform {
    width: 100%;
    height: 150px;
    border-radius: 10px;
}

.status-text {
    color: #fff;
    font-size: 1.1rem;
    font-weight: 600;
    margin-top: 15px;
    text-align: center;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

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

.btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 50px;
    padding: 18px 30px;
    color: white;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.5s, height 0.5s;
}

.btn:hover::before {
    width: 300px;
    height: 300px;
}

.btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.btn:active {
    transform: translateY(-1px);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

.btn-icon {
    font-size: 1.5rem;
    position: relative;
    z-index: 1;
}

.btn-text {
    position: relative;
    z-index: 1;
}

.btn-record {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.btn-record.recording {
    animation: recordPulse 1s infinite;
}

@keyframes recordPulse {
    0%, 100% { box-shadow: 0 6px 20px rgba(245, 87, 108, 0.4); }
    50% { box-shadow: 0 6px 30px rgba(245, 87, 108, 0.8); }
}

.btn-play {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

.btn-reverse {
    background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
}

.btn-challenge {
    background: linear-gradient(135deg, #ff6b35 0%, #f7931e 100%);
    animation: firePulse 2s infinite;
}

@keyframes firePulse {
    0%, 100% { box-shadow: 0 6px 20px rgba(255, 107, 53, 0.4); }
    50% { box-shadow: 0 6px 30px rgba(255, 107, 53, 0.7); }
}

.btn-share {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    margin-bottom: 10px;
}

.btn-download {
    background: linear-gradient(135deg, #2d3748 0%, #4a5568 100%);
}

.timer {
    text-align: center;
    font-size: 2rem;
    font-weight: 900;
    color: white;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    animation: fadeIn 0.3s ease;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

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

.modal.show {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 20px 10px;
    min-height: 100vh;
}

.modal-content {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.95) 0%, rgba(118, 75, 162, 0.95) 100%);
    backdrop-filter: blur(20px);
    border-radius: 30px;
    padding: 40px;
    max-width: 500px;
    width: 100%;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    overflow-x: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    border: 2px solid rgba(255, 255, 255, 0.3);
    position: relative;
    animation: slideUp 0.4s ease;
    margin: auto;
    -webkit-overflow-scrolling: touch;
}

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

.close-btn {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 2rem;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 300;
    line-height: 1;
}

.close-btn:hover {
    transform: rotate(90deg) scale(1.2);
    color: #ff6b35;
}

.modal-title {
    font-size: 2rem;
    font-weight: 900;
    color: white;
    text-align: center;
    margin-bottom: 10px;
}

.modal-subtitle {
    color: rgba(255, 255, 255, 0.9);
    text-align: center;
    margin-bottom: 25px;
    font-size: 1rem;
}

.preview-section {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 25px;
}

.preview-label {
    color: white;
    font-weight: 600;
    margin-bottom: 10px;
    font-size: 0.95rem;
}

#previewAudio {
    width: 100%;
    border-radius: 10px;
    outline: none;
}

#previewAudio::-webkit-media-controls-panel {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.2) 0%, rgba(255, 255, 255, 0.1) 100%);
    border-radius: 10px;
}

.share-message {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 25px;
}

.message-label {
    color: white;
    font-weight: 600;
    margin-bottom: 12px;
    font-size: 0.95rem;
}

.message-box {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    padding: 15px;
    border-left: 4px solid #ff6b35;
}

.message-text {
    color: white;
    margin: 8px 0;
    line-height: 1.6;
    font-size: 0.95rem;
}

.message-text strong {
    font-weight: 800;
}

.main-question {
    font-size: 1.4rem !important;
    font-weight: 800 !important;
    color: white !important;
    margin: 15px 0 !important;
}

.challenge-hint {
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.9rem;
    margin-top: 12px;
}

.domain-link {
    font-size: 1.3rem !important;
    font-weight: 800;
    color: #ffd700;
    text-shadow: 0 2px 10px rgba(255, 215, 0, 0.5);
    margin: 12px 0 !important;
    letter-spacing: 0.5px;
    word-break: break-all;
}

.emoji-text {
    margin-top: 12px;
    font-style: italic;
    color: rgba(255, 255, 255, 0.9);
}

/* Prevent body scroll when modal is open */
body.modal-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
}

/* Better touch handling */
.modal-content * {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

/* Ensure buttons are properly sized on mobile */
.modal-content .btn {
    width: 100%;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

    .container {
        padding: 25px;
        width: 95%;
    }

    .title {
        font-size: 2rem;
    }

    .btn {
        padding: 15px 25px;
        font-size: 1rem;
    }

    .timer {
        font-size: 1.5rem;
    }

    .modal {
        padding: 0;
    }

    .modal.show {
        padding: 10px 5px;
        align-items: center;
    }

    .modal-content {
        padding: 30px 20px;
        width: calc(100% - 10px);
        max-width: 100%;
        max-height: calc(100vh - 20px);
        border-radius: 20px;
        margin: auto;
        position: relative;
    }

    .close-btn {
        top: 10px;
        right: 15px;
        font-size: 1.8rem;
    }

    .modal-title {
        font-size: 1.5rem;
        margin-bottom: 8px;
        padding-right: 30px;
        word-wrap: break-word;
    }

    .modal-subtitle {
        font-size: 0.9rem;
        margin-bottom: 20px;
    }

    .preview-section {
        padding: 15px;
        margin-bottom: 20px;
        border-radius: 12px;
    }

    .preview-label {
        font-size: 0.9rem;
    }

    .share-message {
        padding: 15px;
        margin-bottom: 20px;
        border-radius: 12px;
    }

    .message-label {
        font-size: 0.9rem;
    }

    .message-box {
        padding: 12px;
        border-radius: 10px;
    }

    .main-question {
        font-size: 1.1rem !important;
        margin: 10px 0 !important;
        line-height: 1.4 !important;
        word-wrap: break-word;
    }

    .domain-link {
        font-size: 0.9rem !important;
        margin: 10px 0 !important;
        word-break: break-all;
        line-height: 1.4 !important;
    }

    .message-text {
        font-size: 0.85rem;
        margin: 6px 0;
        line-height: 1.5;
    }

    .challenge-hint {
        font-size: 0.85rem;
        line-height: 1.5;
    }

    .emoji-text {
        font-size: 0.9rem;
    }

    .btn-share,
    .btn-download {
        padding: 14px 20px;
        font-size: 0.95rem;
        margin-bottom: 10px;
    }

    .btn-icon {
        font-size: 1.3rem;
    }
}
