/* =================== RESET & GLOBAL 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;
    overflow-x: hidden;
    overflow-y: auto;
    color: #333;
}

/* Canvas Background */
#backgroundCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
}

/* =================== LANDING PAGE =================== */
.landing-page {
    position: relative;
    z-index: 10;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 20px;
    animation: fadeIn 0.6s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

.logo-section h1 {
    font-size: 2.5rem;
    color: #667eea;
    margin-bottom: 5px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.logo-section .subtitle {
    font-size: 1.1rem;
    color: #666;
    font-weight: 500;
}

.music-toggle {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.music-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.6);
}

.music-toggle.muted {
    opacity: 0.6;
}

/* Welcome Section */
.welcome-section {
    margin-bottom: 40px;
    animation: slideDown 0.8s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.welcome-card {
    background: rgba(255, 255, 255, 0.95);
    padding: 30px;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    text-align: center;
}

.welcome-card h2 {
    font-size: 2rem;
    color: #667eea;
    margin-bottom: 15px;
}

.welcome-card p {
    font-size: 1.1rem;
    color: #666;
    line-height: 1.6;
}

/* Features Container */
.features-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 25px;
    margin-bottom: 40px;
    flex: 1;
}

/* Feature Card */
.feature-card {
    background: rgba(255, 255, 255, 0.95);
    padding: 35px 25px;
    border-radius: 25px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    border: 3px solid transparent;
    animation: cardSlideIn 0.6s ease-out;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 280px;
}

@keyframes cardSlideIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}


.feature-card:hover {
    transform: translateY(-15px) scale(1.05);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
}

.feature-card.selected {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border-color: #fff;
    transform: scale(1.08);
    box-shadow: 0 20px 50px rgba(102, 126, 234, 0.5);
}

.feature-card.selected h3,
.feature-card.selected p {
    color: white;
}

/* Icon to lớn */
.card-icon {
    font-size: 5rem;
    margin-bottom: 20px;
    display: block;
    line-height: 1;
    animation: iconBounce 0.6s ease-out;
}
@keyframes iconBounce {
    0% {
        transform: scale(0.5);
        opacity: 0;
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.feature-card:hover .card-icon {
    animation: iconFloat 0.6s ease-in-out infinite;
}

@keyframes iconFloat {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-15px);
    }
}
/* Chữ to hơn */
.feature-card h3 {
    font-size: 1.6rem;
    color: #667eea;
    margin-bottom: 15px;
    font-weight: 700;
    line-height: 1.3;
}

.feature-card p {
    font-size: 1.1rem;
    color: #666;
    margin-bottom: 20px;
    line-height: 1.6;
    font-weight: 500;
}

.exercise-count {
    display: inline-block;
    background: #f0f0f0;
    color: #667eea;
    padding: 8px 18px;
    border-radius: 25px;
    font-size: 1rem;
    font-weight: 700;
}

.feature-card.selected .exercise-count {
    background: rgba(255, 255, 255, 0.3);
    color: white;
}
.exercise-count {
    display: inline-block;
    background: #f0f0f0;
    color: #667eea;
    padding: 5px 15px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

.feature-card.selected .exercise-count {
    background: rgba(255, 255, 255, 0.3);
    color: white;
}

/* Button Section */
.button-section {
    text-align: center;
    margin-bottom: 30px;
}

.start-btn {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    padding: 18px 50px;
    font-size: 1.3rem;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 10px 25px rgba(102, 126, 234, 0.4);
    font-weight: 600;
    margin-bottom: 15px;
}

.start-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 15px 35px rgba(102, 126, 234, 0.6);
}

.start-btn:active {
    transform: scale(0.98);
}

.hint-text {
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.95rem;
    margin-top: 10px;
}

/* Footer */
.footer {
    text-align: center;
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.9rem;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
}

/* =================== APP PAGE =================== */
.app-page {
    position: relative;
    z-index: 10;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 20px;
    animation: fadeIn 0.6s ease-in;
}

.app-page.hidden {
    display: none;
}

/* App Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    margin-bottom: 30px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    flex-wrap: wrap;
}

.back-btn {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    padding: 12px 25px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.3);
}

.back-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.5);
}

.progress-section {
    flex: 1;
    min-width: 200px;
}

.progress-text {
    display: block;
    font-size: 0.95rem;
    color: #667eea;
    font-weight: 600;
    margin-bottom: 8px;
}

.progress-bar {
    width: 100%;
    height: 12px;
    background: #e0e0e0;
    border-radius: 10px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea, #764ba2);
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 10px;
}

.tts-controls {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 180px;
}

.tts-label {
    font-size: 0.9rem;
    color: #667eea;
    font-weight: 700;
}

.tts-select {
    border: 2px solid #667eea;
    border-radius: 999px;
    padding: 10px 14px;
    font-size: 0.95rem;
    color: #333;
    background: #fff;
    font-weight: 600;
}

.score-text {
    font-size: 1.2rem;
    color: #667eea;
    font-weight: 600;
    white-space: nowrap;
}

/* Exercise Container */
.exercise-container {
    flex: 1;
    background: rgba(255, 255, 255, 0.95);
    padding: clamp(24px, 3vw, 50px) clamp(18px, 2.5vw, 40px);
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    gap: 8px;
    animation: fadeIn 0.6s ease-in;
    width: min(100%, 960px);
    margin: 0 auto;
}

.exercise-type {
    font-size: clamp(1.3rem, 2.5vw, 1.8rem);
    color: #667eea;
    font-weight: 700;
    text-align: center;
}

/* Chữ câu hỏi to lớn */
.exercise-question {
    font-size: clamp(1.15rem, 2.1vw, 2.1rem);
    color: #333;
    text-align: center;
    line-height: 1.5;
    min-height: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    width: 100%;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.exercise-question > span,
.exercise-question [style*="font-size: 7rem"],
.exercise-question [style*="font-size: 8rem"],
.exercise-question [style*="font-size: 6rem"],
.exercise-question [style*="font-size: 5rem"],
.exercise-question [style*="font-size: 4.5rem"],
.exercise-question [style*="font-size: 4rem"],
.exercise-question [style*="font-size: 3.5rem"],
.exercise-question [style*="font-size: 3rem"],
.exercise-question [style*="font-size: 2.5rem"] {
    max-width: 100%;
    display: block;
    margin: 0.3em auto;
}

/* Các nút lựa chọn to hơn */
.exercise-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 14px;
    margin-bottom: 4px;
    width: 100%;
}

.option-btn {
    background: white;
    border: 4px solid #667eea;
    color: #667eea;
    padding: clamp(20px, 2.2vw, 30px) 18px;
    border-radius: 24px;
    font-size: clamp(1.2rem, 2.5vw, 1.9rem);
    font-weight: 800;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 10px 24px rgba(102, 126, 234, 0.22);
    min-height: 110px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    line-height: 1.4;
    width: 100%;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.option-btn:hover:not(:disabled) {
    background: #667eea;
    color: white;
    transform: translateY(-8px) scale(1.05);
    box-shadow: 0 15px 35px rgba(102, 126, 234, 0.5);
}

.option-btn:disabled {
    cursor: not-allowed;
}

.option-btn.correct {
    background: #27ae60;
    border-color: #27ae60;
    color: white;
    animation: correctPulse 0.6s ease;
}

.option-btn.incorrect {
    background: #e74c3c;
    border-color: #e74c3c;
    color: white;
    animation: shake 0.5s ease;
}

@keyframes correctPulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    25% {
        transform: translateX(-10px);
    }
    75% {
        transform: translateX(10px);
    }
}

.exercise-feedback {
    text-align: center;
    font-size: 1.2rem;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.feedback-correct {
    color: #27ae60;
    font-weight: 600;
    animation: slideUp 0.5s ease;
}

.feedback-incorrect {
    color: #e74c3c;
    font-weight: 600;
    animation: slideUp 0.5s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* =================== CONFETTI =================== */
.confetti-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 100;
}

.confetti {
    position: fixed;
    font-size: 2rem;
    animation: confettiFall 3s ease-in forwards;
}

@keyframes confettiFall {
    to {
        transform: translateY(100vh) rotate(360deg);
        opacity: 0;
    }
}

/* =================== HIDDEN STATE =================== */
.hidden {
    display: none !important;
}

/* =================== RESPONSIVE DESIGN =================== */

@media (max-width: 1024px) {
    .features-container {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        gap: 20px;
    }

    .feature-card {
        min-height: 260px;
        padding: 30px 20px;
    }

    .card-icon {
        font-size: 4.5rem;
    }

    .feature-card h3 {
        font-size: 1.4rem;
    }
}

@media (max-width: 768px) {
    .features-container {
        grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
        gap: 15px;
    }

    .feature-card {
        min-height: 240px;
        padding: 25px 15px;
    }

    .card-icon {
        font-size: 4rem;
        margin-bottom: 15px;
    }

    .feature-card h3 {
        font-size: 1.2rem;
    }

    .feature-card p {
        font-size: 0.95rem;
    }

    .app-header {
        flex-direction: column;
        align-items: stretch;
    }

    .progress-section {
        min-width: 0;
    }

    .score-text {
        align-self: flex-start;
    }

    .exercise-container {
        padding: 28px 18px;
        gap: 6px;
    }

    .exercise-options {
        grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
        gap: 12px;
        margin-bottom: 0;
    }

    .option-btn {
        min-height: 104px;
        font-size: clamp(1.15rem, 2.7vw, 1.65rem);
        padding: 18px 16px;
    }
}

@media (max-width: 480px) {
    .landing-page {
        padding: 10px;
    }

    .header {
        flex-direction: column;
        gap: 15px;
        padding: 15px;
    }

    .logo-section h1 {
        font-size: 1.5rem;
    }

    .features-container {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .feature-card {
        min-height: 220px;
        padding: 20px 15px;
    }

    .card-icon {
        font-size: 3.5rem;
        margin-bottom: 12px;
    }

    .feature-card h3 {
        font-size: 1.1rem;
    }

    .feature-card p {
        font-size: 0.9rem;
        margin-bottom: 12px;
    }

    .exercise-container {
        padding: 22px 14px;
        border-radius: 18px;
        gap: 6px;
    }

    .exercise-options {
        grid-template-columns: 1fr;
        gap: 10px;
        margin-bottom: 0;
    }

    .option-btn {
        border-width: 3px;
        min-height: 104px;
        font-size: 1.2rem;
        padding: 18px 16px;
    }

    .start-btn {
        padding: 15px 30px;
        font-size: 1.1rem;
    }

    .exercise-feedback {
        font-size: 1rem;
    }
}