/* Reset and base styles */
* {
    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;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
}

/* Main container - responsive height based on environment */
.container {
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 800px;
    height: 450px; /* Default iframe height */
    padding: 20px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

/* Adjust height for full browser tab */
@media (min-height: 600px) {
    body:not(.iframe-mode) .container {
        height: 90vh;
        max-height: 800px;
    }
}

/* Progress section */
.progress-section {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
}

.progress-bar {
    flex: 1;
    height: 8px;
    background: #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #4CAF50, #45a049);
    width: 0%;
    transition: width 0.3s ease;
}

.progress-text {
    font-size: 14px;
    color: #666;
    font-weight: 500;
    white-space: nowrap;
}

/* Audio section */
.audio-section {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-bottom: 25px;
}

.audio-btn {
    background: linear-gradient(135deg, #FF6B6B, #FF8E8E);
    color: white;
    border: none;
    border-radius: 50px;
    padding: 15px 30px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(255, 107, 107, 0.3);
    min-height: 50px;
}

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

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

.audio-btn.playing {
    background: linear-gradient(135deg, #4CAF50, #45a049);
    animation: pulse 1.5s infinite;
}

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

.audio-icon {
    font-size: 20px;
}

.replay-btn {
    background: #f0f0f0;
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.replay-btn:hover {
    background: #e0e0e0;
    transform: rotate(180deg);
}

/* Instruction */
.instruction {
    text-align: center;
    font-size: 18px;
    font-weight: 600;
    color: #333;
    margin-bottom: 25px;
}

/* Choices section */
.choices-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 15px;
    margin-bottom: 25px;
    flex: 1;
    align-content: start;
}

.choice-btn {
    background: white;
    border: 3px solid #e0e0e0;
    border-radius: 15px;
    padding: 20px;
    font-size: 18px;
    font-weight: 600;
    color: #333;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    min-height: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    word-break: break-word;
}

.choice-btn:hover {
    border-color: #667eea;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.2);
}

.choice-btn.correct {
    background: linear-gradient(135deg, #4CAF50, #45a049);
    border-color: #4CAF50;
    color: white;
    animation: correctPulse 0.6s ease;
}

.choice-btn.incorrect {
    background: linear-gradient(135deg, #f44336, #d32f2f);
    border-color: #f44336;
    color: white;
    animation: shake 0.6s ease;
}

.choice-btn.disabled {
    pointer-events: none;
    opacity: 0.6;
}

@keyframes correctPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* Feedback section */
.feedback-section {
    text-align: center;
    margin-bottom: 20px;
    min-height: 60px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.feedback-message {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
}

.feedback-message.correct {
    color: #4CAF50;
}

.feedback-message.incorrect {
    color: #f44336;
}

.hint-message {
    font-size: 14px;
    color: #666;
    font-style: italic;
    line-height: 1.4;
}

/* Action buttons */
.action-buttons {
    display: flex;
    justify-content: center;
    gap: 15px;
}

.try-again-btn, .next-btn {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    border-radius: 25px;
    padding: 12px 30px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    min-height: 45px;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

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

.try-again-btn {
    background: linear-gradient(135deg, #FF6B6B, #FF8E8E);
}

/* Score section */
.score-section {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 20px;
}

.score-display {
    text-align: center;
    padding: 40px;
}

.score-display h2 {
    color: #333;
    margin-bottom: 20px;
    font-size: 28px;
}

.final-score {
    font-size: 48px;
    font-weight: bold;
    color: #4CAF50;
    margin-bottom: 15px;
}

.score-message {
    font-size: 18px;
    color: #666;
    margin-bottom: 30px;
}

.restart-btn {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    border-radius: 25px;
    padding: 15px 40px;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

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

/* Mobile responsiveness */
@media (max-width: 768px) {
    .container {
        padding: 15px;
        height: 450px;
    }
    
    .choices-section {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .choice-btn {
        padding: 15px;
        font-size: 16px;
        min-height: 60px;
    }
    
    .audio-btn {
        padding: 12px 25px;
        font-size: 14px;
    }
    
    .instruction {
        font-size: 16px;
    }
    
    .progress-text {
        font-size: 12px;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    .choice-btn, .audio-btn, .replay-btn, .try-again-btn, .next-btn, .restart-btn {
        min-height: 48px;
        min-width: 48px;
    }
    
    .choice-btn:active {
        transform: scale(0.95);
    }
    
    .audio-btn:active, .replay-btn:active, .try-again-btn:active, .next-btn:active, .restart-btn:active {
        transform: scale(0.95);
    }
}