/* ========================================
   TINY TALENTS - Professional Design 
   WuKong-inspired kids learning app
======================================== */

:root {
    /* Duolingo Color Palette */
    --primary: #1CB0F6;
    --primary-dark: #1899D6;
    --primary-light: #58D3FF;
    --secondary: #58CC02;
    --secondary-dark: #4CAE00;
    --accent: #FF9600;
    --accent-light: #FFB800;
    --red: #FF4B4B;

    /* Dark Theme Backgrounds (Default) */
    --bg-dark: #1F2937;
    --bg-darker: #131821;
    --card-bg: #2B3648;
    --card-hover: #374151;
    --overlay-bg: rgba(0, 0, 0, 0.8);

    /* Text */
    --text-primary: #FFFFFF;
    --text-secondary: #AFAFAF;
    --text-light: #777777;

    /* Misc */
    --shadow-soft: 0 4px 12px rgba(0, 0, 0, 0.3);
    --shadow-medium: 0 8px 20px rgba(0, 0, 0, 0.4);
    --shadow-strong: 0 12px 30px rgba(0, 0, 0, 0.5);
    --radius-sm: 12px;
    --radius-md: 16px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    /* Typography */
    --font-family: 'Nunito', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* Light Mode Theme */
body.light-mode {
    --bg-dark: #F7F9FC;
    --bg-darker: #FFFFFF;
    --card-bg: #FFFFFF;
    --card-hover: #F0F4F8;
    --overlay-bg: rgba(0, 0, 0, 0.6);

    --text-primary: #1F2937;
    --text-secondary: #6B7280;
    --text-light: #9CA3AF;

    --shadow-soft: 0 4px 12px rgba(0, 0, 0, 0.1);
    --shadow-medium: 0 8px 20px rgba(0, 0, 0, 0.15);
    --shadow-strong: 0 12px 30px rgba(0, 0, 0, 0.2);
}

body.light-mode header {
    background: var(--bg-darker);
    border-bottom: 1px solid #E5E7EB;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html,
body {
    height: 100%;
    overflow-x: hidden;
}

body {
    font-family: var(--font-family);
    background: var(--bg-dark);
    min-height: 100vh;
    color: var(--text-primary);
    display: flex;
    flex-direction: column;
}

/* ========================================
   HEADER
======================================== */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background: var(--bg-darker);
    border-bottom: 2px solid #374151;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left,
.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-center {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

.app-logo {
    display: flex;
    align-items: center;
    gap: 8px;
}

.logo-icon {
    font-size: 1.5rem;
}

.logo-text {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--text-primary);
}

.icon-btn {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    border: 2px solid #374151;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.icon-btn:hover {
    background: var(--card-hover);
    color: var(--text-primary);
    border-color: var(--primary);
}

.icon-btn:active {
    transform: scale(0.95);
}

.icon-btn.active {
    background: var(--card-hover);
    border-color: var(--secondary);
    color: var(--secondary);
}

.progress-pill {
    background: var(--card-bg);
    color: var(--text-primary);
    padding: 8px 20px;
    border-radius: 20px;
    font-weight: 700;
    font-size: 0.9rem;
    border: 2px solid #374151;
}

/* ========================================
   MAIN CONTENT
======================================== */
main {
    flex: 1;
    padding: 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.screen {
    display: none;
    width: 100%;
    max-width: 600px;
    flex-direction: column;
    align-items: center;
    animation: fadeIn 0.3s ease;
}

.screen.active {
    display: flex;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ========================================
   WELCOME / LEVEL SELECT
======================================== */
.welcome-section {
    text-align: center;
    margin-bottom: 32px;
}

.welcome-title {
    font-size: 2rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.welcome-subtitle {
    font-size: 1.1rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.section-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 20px;
}

/* ========================================
   LEVEL SELECT - LEARNING PATH
======================================== */
.level-grid {
    display: flex;
    flex-direction: column;
    gap: 24px;
    width: 100%;
    max-width: 500px;
    position: relative;
    padding: 20px 0;
}

/* Add path connector line */
.level-grid::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 4px;
    background: linear-gradient(180deg,
        transparent 0%,
        var(--primary) 20%,
        var(--primary) 80%,
        transparent 100%);
    transform: translateX(-50%);
    z-index: 0;
    opacity: 0.3;
}

/* Stage headers - Duolingo style */
.stage-header {
    text-align: center;
    padding: 20px 24px;
    margin: 24px 0 16px 0;
    border-radius: 20px;
    z-index: 1;
    position: relative;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2),
                0 4px 8px rgba(0, 0, 0, 0.1);
    transform: translateY(0);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 3px solid rgba(255, 255, 255, 0.2);
    overflow: hidden;
}

/* Different gradient for each stage - Duolingo style */
.stage-header:nth-of-type(1) {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.stage-header:nth-of-type(4) {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}

.stage-header:nth-of-type(7) {
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
}

/* Add shine effect */
.stage-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg,
        transparent,
        rgba(255, 255, 255, 0.3),
        transparent);
    animation: stage-shine 3s ease-in-out infinite;
}

@keyframes stage-shine {
    0%, 100% {
        left: -100%;
    }
    50% {
        left: 100%;
    }
}

.stage-header:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.25),
                0 6px 12px rgba(0, 0, 0, 0.15);
}

.stage-title {
    font-size: 1.6rem;
    font-weight: 900;
    color: #ffffff;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 2px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    position: relative;
    z-index: 1;
}

.stage-letters {
    font-size: 1.1rem;
    color: rgba(255, 255, 255, 0.95);
    font-weight: 700;
    letter-spacing: 3px;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    position: relative;
    z-index: 1;
}

.level-card {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 28px 20px;
    text-align: center;
    cursor: pointer;
    box-shadow: var(--shadow-soft);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 2px solid #374151;
    border-bottom: 4px solid #374151;
    position: relative;
    overflow: hidden;
    width: 180px;
    z-index: 1;
}

/* Stagger cards left and right */
.level-card:nth-child(odd) {
    align-self: flex-start;
    margin-left: 40px;
    animation: slideInLeft 0.5s ease backwards;
}

.level-card:nth-child(even) {
    align-self: flex-end;
    margin-right: 40px;
    animation: slideInRight 0.5s ease backwards;
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-50px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(50px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.level-card:hover {
    transform: translateY(-6px) scale(1.03);
    border-color: var(--primary);
    border-bottom-color: var(--primary-dark);
    background: var(--card-hover);
}

.level-card:active {
    transform: translateY(-2px) scale(1.0);
    border-bottom-width: 2px;
}

.level-emoji {
    font-size: 3.5rem;
    margin-bottom: 12px;
    line-height: 1;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.level-letter {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--primary);
    margin: 8px 0;
    font-family: 'Nunito', sans-serif;
    text-shadow: 0 2px 4px rgba(52, 152, 219, 0.1);
}

.level-number {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 8px 0;
}

.level-progress-bar {
    background: #374151;
    border-radius: 10px;
    height: 8px;
    overflow: hidden;
    margin: 12px 0 8px;
}

.level-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--secondary), #27AE60);
    border-radius: 10px;
    transition: width 0.4s ease;
}

.level-count {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.level-card.locked {
    opacity: 0.4;
    cursor: not-allowed;
    filter: grayscale(100%);
}

.level-card.locked:hover {
    transform: none;
    border-color: #374151;
    border-bottom-color: #374151;
    background: var(--card-bg);
}

.level-card.upcoming {
    opacity: 0.3;
    filter: grayscale(100%);
    border-style: dashed;
    border-color: #4B5563;
}

.level-card.upcoming:hover {
    transform: none;
    opacity: 0.35;
}

.level-card.upcoming .level-number {
    font-size: 0.9rem;
    color: #9CA3AF;
}

.level-card.upcoming .level-count {
    color: #9CA3AF;
    font-style: italic;
}

.level-card.completed {
    border-color: var(--secondary);
    border-bottom-color: #4CAE00;
    background: linear-gradient(135deg, var(--card-bg) 0%, #1a3a1a 100%);
}

.level-card.completed:hover {
    background: linear-gradient(135deg, var(--card-hover) 0%, #1f4a1f 100%);
}

.level-card.completed .level-progress-fill {
    background: var(--secondary);
}

.level-card.completed::after {
    content: '✓';
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    background: var(--secondary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(88, 204, 2, 0.5);
}

/* ========================================
   LOGIN & DASHBOARD
======================================== */
.login-card {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 40px;
    width: 100%;
    box-shadow: var(--shadow-soft);
    border: 2px solid #374151;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
}

.profile-card {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 32px;
    max-width: 500px;
    width: 100%;
    margin: 0 auto;
    box-shadow: var(--shadow-soft);
    border: 2px solid #374151;
}

.profile-header {
    text-align: center;
    padding-bottom: 24px;
    border-bottom: 2px solid #374151;
    margin-bottom: 24px;
}

.profile-avatar {
    font-size: 4rem;
    margin-bottom: 12px;
}

.profile-username {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
    margin: 0;
}

.profile-section {
    margin-bottom: 24px;
    padding-bottom: 24px;
    border-bottom: 2px solid #374151;
}

.profile-section:last-of-type {
    border-bottom: none;
}

.profile-section-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.profile-info {
    background: var(--bg-darker);
    padding: 16px;
    border-radius: 12px;
    margin-top: 12px;
}

.profile-info p {
    margin: 8px 0;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.profile-info strong {
    color: var(--primary);
}

.profile-success {
    background: rgba(46, 204, 113, 0.1);
    border: 2px solid var(--green);
    border-radius: 8px;
    padding: 12px;
}

.avatar-select {
    display: flex;
    gap: 16px;
    margin-bottom: 8px;
}

.avatar-btn {
    width: 60px;
    height: 60px;
    font-size: 2rem;
    border: 3px solid #374151;
    border-radius: 50%;
    background: var(--bg-darker);
    cursor: pointer;
    transition: all 0.2s;
}

.avatar-btn.selected {
    border-color: var(--primary);
    transform: scale(1.1);
    background: var(--card-bg);
    box-shadow: 0 0 0 3px rgba(28, 176, 246, 0.3);
}

.name-input {
    width: 100%;
    padding: 16px;
    border: 2px solid #374151;
    border-radius: 16px;
    font-family: var(--font-family);
    font-size: 1.2rem;
    text-align: center;
    outline: none;
    transition: border-color 0.2s;
    background: var(--bg-darker);
    color: var(--text-primary);
}

.name-input:focus {
    border-color: var(--primary);
    background: var(--card-bg);
}

.leaderboard-card {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 24px;
    width: 100%;
    box-shadow: var(--shadow-soft);
    border: 2px solid #374151;
}

.leaderboard-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 300px;
    overflow-y: auto;
}

.leader-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--bg-darker);
    border-radius: 12px;
    border: 2px solid #374151;
}

.leader-info {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 700;
    font-size: 1.1rem;
}

.leader-score {
    background: var(--primary);
    color: white;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.9rem;
    font-weight: 800;
}

.text-btn {
    background: none;
    border: none;
    color: var(--primary);
    font-family: var(--font-family);
    font-weight: 700;
    cursor: pointer;
    text-decoration: underline;
    opacity: 0.8;
}

.text-btn:hover {
    opacity: 1;
}

.header-row {
    display: flex;
    width: 100%;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 20px;
}

/* ========================================
   TASK CARD
======================================== */
.task-card {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 32px;
    width: 100%;
    box-shadow: var(--shadow-soft);
    border: 2px solid #374151;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* ========================================
   TASK PROGRESS BAR
======================================== */
.task-progress-container {
    width: 100%;
    max-width: 600px;
    margin-bottom: 16px;
    padding: 0 8px;
}

.task-progress-bar {
    width: 100%;
    height: 12px;
    background: var(--bg-darker);
    border-radius: 20px;
    overflow: hidden;
    border: 2px solid #374151;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
}

.task-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary) 0%, var(--primary-light) 100%);
    border-radius: 20px;
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 0 10px rgba(28, 176, 246, 0.5);
    position: relative;
    width: 0%;
}

.task-progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.3) 50%,
        transparent 100%);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.task-title {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 8px;
}

.instruction {
    font-size: 1.1rem;
    color: var(--text-secondary);
    font-weight: 600;
    text-align: center;
    margin-bottom: 24px;
    line-height: 1.5;
}

.sub-screen {
    display: none;
    width: 100%;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

/* ========================================
   SPEAKER BUTTON
======================================== */
.speaker-btn {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    border: none;
    border-bottom: 4px solid #1899D6;
    background: var(--primary);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(28, 176, 246, 0.4);
    transition: all 0.2s ease;
    margin-bottom: 16px;
}

.speaker-btn:hover {
    transform: scale(1.08);
    background: var(--primary-light);
    box-shadow: 0 6px 20px rgba(28, 176, 246, 0.5);
}

.speaker-btn:active {
    transform: scale(0.98) translateY(2px);
    border-bottom-width: 2px;
}

/* ========================================
   PHONICS SOUND PULSE ANIMATION
======================================== */
.listen-header {
    display: flex;
    gap: 20px;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.speaker-btn.pulse-glow {
    animation: pulse-glow 1s ease-in-out;
}

@keyframes pulse-glow {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 4px 15px rgba(28, 176, 246, 0.4);
    }
    25% {
        transform: scale(1.15);
        box-shadow: 0 8px 30px rgba(28, 176, 246, 0.8),
                    0 0 40px rgba(28, 176, 246, 0.6);
    }
    50% {
        transform: scale(1.2);
        box-shadow: 0 8px 35px rgba(28, 176, 246, 1),
                    0 0 50px rgba(88, 211, 255, 0.8);
    }
    75% {
        transform: scale(1.15);
        box-shadow: 0 8px 30px rgba(28, 176, 246, 0.8),
                    0 0 40px rgba(28, 176, 246, 0.6);
    }
}

/* Mouth Shape Container */
.mouth-shape-container {
    background: var(--card-bg);
    border: 2px solid var(--primary);
    border-radius: 16px;
    padding: 16px 24px;
    box-shadow: var(--shadow-soft);
    min-width: 140px;
}

.mouth-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.mouth-icon {
    font-size: 2.5rem;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

.mouth-label {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-secondary);
    margin: 0;
    text-align: center;
}

/* Sync mouth animation with audio */
.mouth-shape-container.speaking .mouth-icon {
    animation: mouth-speak 0.3s ease-in-out infinite;
}

@keyframes mouth-speak {
    0%, 100% { transform: scaleY(1); }
    50% { transform: scaleY(0.8); }
}

/* ========================================
   CHOICE GRID (Listen & Choose)
======================================== */
.choice-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    width: 100%;
}

.choice-card {
    background: var(--card-bg);
    border: 2px solid #374151;
    border-bottom: 4px solid #374151;
    border-radius: 16px;
    padding: 20px;
    text-align: center;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.15s ease;
}

.choice-card:hover {
    border-color: var(--primary);
    border-bottom-color: var(--primary-dark);
    background: var(--card-hover);
}

.choice-card:active {
    transform: translateY(2px);
    border-bottom-width: 2px;
}

.choice-card.correct {
    background: #1a4d1a;
    border-color: var(--secondary);
    border-bottom-color: #4CAE00;
    color: white;
}

.choice-card.incorrect {
    background: #4d1a1a;
    border-color: var(--red);
    border-bottom-color: #CC0000;
    color: white;
    animation: shake 0.4s ease;
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-6px);
    }

    75% {
        transform: translateX(6px);
    }
}

.choice-card.hint-highlight {
    animation: hint-pulse 1s ease infinite;
}

@keyframes hint-pulse {

    0%,
    100% {
        border-color: var(--accent);
    }

    50% {
        border-color: var(--accent-light);
        box-shadow: 0 0 20px var(--accent-light);
    }
}

/* ========================================
   EMOJI CHOICE CARDS
======================================== */
.choice-card.emoji-choice {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 16px;
}

.emoji-large {
    font-size: 3rem;
    line-height: 1;
}

.emoji-label {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: capitalize;
}

.choice-card.emoji-choice:hover .emoji-label {
    color: var(--primary);
}

.choice-card.emoji-choice.correct .emoji-label {
    color: var(--secondary-dark);
}

.choice-card.emoji-choice.incorrect .emoji-label {
    color: #C0392B;
}

/* ========================================
   REPEAT SOUND TASK
======================================== */
.repeat-sound-btn {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    background: var(--secondary);
    border: none;
    border-bottom: 6px solid #4CAE00;
    box-shadow: var(--shadow-strong), 0 8px 20px rgba(88, 204, 2, 0.4);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.repeat-sound-btn:hover {
    transform: scale(1.05);
    background: #6FDC1F;
    box-shadow: var(--shadow-strong), 0 12px 30px rgba(88, 204, 2, 0.5);
}

.repeat-sound-btn:active {
    transform: scale(0.98) translateY(3px);
    border-bottom-width: 3px;
}

.repeat-sound-btn.bounce {
    animation: bounce-scale 0.3s ease;
}

@keyframes bounce-scale {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

.letter-display {
    font-size: 5rem;
    font-weight: 800;
    color: white;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
    font-family: 'Nunito', sans-serif;
}

.repeat-progress {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

/* ========================================
   MULTIPLE SELECT TASK
======================================== */
.letter-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
    padding: 10px;
}

.letter-card {
    aspect-ratio: 1;
    background: var(--card-bg);
    border: 2px solid #374151;
    border-bottom: 4px solid #374151;
    border-radius: 12px;
    padding: 8px;
    cursor: pointer;
    transition: all 0.15s ease;
    box-shadow: var(--shadow-soft);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.letter-card:hover {
    transform: translateY(-2px);
    border-color: var(--primary);
    border-bottom-color: var(--primary-dark);
    background: var(--card-hover);
}

.letter-card:active {
    transform: translateY(1px);
    border-bottom-width: 2px;
}

.letter-card.selected {
    background: #2a3a1a;
    border-color: var(--accent);
    border-bottom-color: #CC7A00;
    box-shadow: 0 0 15px rgba(255, 150, 0, 0.4);
}

.letter-card.correct {
    background: #1a4d1a;
    border-color: var(--secondary);
    border-bottom-color: #4CAE00;
    animation: pulse-correct 0.6s ease;
}

.letter-card.incorrect {
    background: #4d1a1a;
    border-color: var(--red);
    border-bottom-color: #CC0000;
    animation: shake 0.5s ease;
}

.letter-emoji {
    font-size: 2rem;
    line-height: 1;
}

.letter-text {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--primary);
    font-family: 'Nunito', sans-serif;
}

.letter-card.selected .letter-text {
    color: var(--accent);
}

.letter-card.correct .letter-text {
    color: white;
}

.letter-card.incorrect .letter-text {
    color: #C0392B;
}

@keyframes pulse-correct {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* ========================================
   SENTENCE ARRANGE
======================================== */
.sentence-area {
    min-height: 70px;
    width: 100%;
    background: var(--bg-darker);
    border: 3px dashed #374151;
    border-radius: 16px;
    padding: 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    justify-content: center;
}

.sentence-area.filled {
    background: #1a3a1a;
    border-color: var(--secondary);
    border-style: solid;
}

.tile-pool {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    padding: 16px;
}

.word-tile {
    background: var(--card-bg);
    border: 2px solid #374151;
    border-bottom: 4px solid #374151;
    border-radius: 12px;
    padding: 12px 20px;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.15s ease;
    box-shadow: var(--shadow-soft);
}

.word-tile:hover {
    transform: translateY(-2px);
    border-color: var(--primary);
    border-bottom-color: var(--primary-dark);
    background: var(--card-hover);
}

.word-tile:active {
    transform: translateY(1px);
    border-bottom-width: 2px;
}

.word-tile.in-target {
    background: var(--primary);
    border-color: var(--primary);
    border-bottom-color: var(--primary-dark);
    color: white;
}

/* ========================================
   CANVAS / TRACING
======================================== */
.emoji-display {
    font-size: 3.5rem;
    margin-bottom: 16px;
}

.canvas-container {
    background:
        /* Red margin line on left */
        linear-gradient(to right,
            transparent 0,
            transparent 29px,
            #E74C3C 29px,
            #E74C3C 31px,
            transparent 31px
        ),
        /* Horizontal ruled lines */
        repeating-linear-gradient(
            to bottom,
            transparent 0px,
            transparent 24px,
            #4A5568 24px,
            #4A5568 25px,
            transparent 25px,
            transparent 49px,
            #374151 49px,
            #374151 50px
        ),
        /* Base dark paper color */
        var(--bg-darker);
    border-radius: 16px;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.3);
    border: 2px solid #374151;
    width: 100%;
    height: 200px;
    touch-action: none;
    overflow: hidden;
}

#drawing-svg {
    display: block;
    width: 100%;
    height: 100%;
    touch-action: none;
}

.ghost-text-svg {
    font-family: var(--font-family);
    font-size: 48px;
    font-weight: 700;
    fill: #E0E0E0;
    text-anchor: middle;
    dominant-baseline: middle;
    pointer-events: none;
}

/* ========================================
   BUTTONS
======================================== */
.button-row {
    display: flex;
    gap: 12px;
    margin-top: 16px;
}

.action-btn {
    padding: 16px 28px;
    border-radius: 16px;
    border: 2px solid transparent;
    font-family: var(--font-family);
    font-size: 1rem;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.action-btn.primary {
    background: var(--primary);
    color: white;
    border-bottom: 4px solid #1899D6;
}

.action-btn.primary:hover {
    background: var(--primary-light);
    filter: brightness(1.1);
}

.action-btn.primary:active {
    border-bottom-width: 2px;
    transform: translateY(2px);
}

.action-btn.secondary {
    background: var(--card-bg);
    color: var(--text-primary);
    border: 2px solid #374151;
    border-bottom-width: 4px;
}

.action-btn.secondary:hover {
    background: var(--card-hover);
    border-color: var(--text-secondary);
}

.action-btn.secondary:active {
    border-bottom-width: 2px;
    transform: translateY(2px);
}

.action-btn.success {
    background: var(--secondary);
    color: white;
    border-bottom: 4px solid #4CAE00;
}

.action-btn.success:hover {
    background: #6FDC1F;
    filter: brightness(1.1);
}

.action-btn.success:active {
    border-bottom-width: 2px;
    transform: translateY(2px);
}

.action-btn.icon {
    padding: 14px;
    background: var(--primary);
    color: white;
    border-bottom: 4px solid #1899D6;
}

.action-btn.large {
    padding: 18px 40px;
    font-size: 1.1rem;
}

.task-nav {
    margin-top: 24px;
}

.task-feedback {
    min-height: 24px;
    margin-top: 16px;
    color: var(--primary);
    font-weight: 700;
    font-size: 0.95rem;
}

/* ========================================
   FEEDBACK OVERLAY
======================================== */
.feedback-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--overlay-bg);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease;
}

.feedback-overlay.active {
    display: flex;
}

.overlay-content {
    background: var(--card-bg);
    border-radius: 20px;
    padding: 48px;
    text-align: center;
    box-shadow: var(--shadow-strong);
    border: 3px solid var(--secondary);
    animation: popIn 0.4s ease;
}

@keyframes popIn {
    from {
        transform: scale(0.8);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

.success-emoji {
    font-size: 5rem;
    margin-bottom: 16px;
}

.feedback-message {
    font-size: 2rem;
    font-weight: 800;
    color: var(--secondary);
    margin-bottom: 24px;
}

/* ========================================
   CONFETTI
======================================== */
.confetti {
    position: fixed;
    width: 12px;
    height: 12px;
    border-radius: 2px;
    top: -20px;
    animation: confetti-fall linear forwards;
    z-index: 1001;
}

@keyframes confetti-fall {
    0% {
        transform: translateY(-100vh) rotate(0deg);
        opacity: 1;
    }

    100% {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

/* Perfect Badge */
.perfect-badge {
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-light) 100%);
    border: 3px solid var(--accent-light);
    border-radius: 16px;
    padding: 16px 28px;
    margin: 16px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    box-shadow: 0 8px 25px rgba(255, 150, 0, 0.5),
                0 0 30px rgba(255, 150, 0, 0.3);
    animation: badge-pop 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes badge-pop {
    0% {
        transform: scale(0) rotate(-180deg);
        opacity: 0;
    }
    70% {
        transform: scale(1.2) rotate(10deg);
    }
    100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

.badge-icon {
    font-size: 3rem;
    animation: star-spin 2s linear infinite;
}

@keyframes star-spin {
    0%, 100% { transform: rotate(0deg) scale(1); }
    50% { transform: rotate(180deg) scale(1.2); }
}

.badge-text {
    font-size: 1.8rem;
    font-weight: 900;
    color: white;
    text-transform: uppercase;
    letter-spacing: 2px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.badge-subtitle {
    font-size: 0.95rem;
    font-weight: 600;
    color: white;
    opacity: 0.9;
}

/* ========================================
   STROKE TRACING ANIMATIONS
======================================== */
.pulse-animation {
    animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.3);
        opacity: 0.8;
    }
}

.active-stroke {
    animation: dash-move 0.6s linear infinite;
}

@keyframes dash-move {
    0% {
        stroke-dashoffset: 0;
    }

    100% {
        stroke-dashoffset: 26;
    }
}

/* ========================================
   INTERACTIVE MASCOT
======================================== */
.mascot-container {
    position: fixed;
    bottom: 70px;
    left: 20px;
    z-index: 999;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
}

.mascot-character {
    background: var(--card-bg);
    border: 3px solid var(--primary);
    border-radius: 50%;
    width: 70px;
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-medium), 0 0 20px rgba(28, 176, 246, 0.3);
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    cursor: pointer;
}

.mascot-character:hover {
    transform: scale(1.1) rotate(5deg);
    border-color: var(--primary-light);
}

.mascot-emoji {
    font-size: 2.5rem;
    line-height: 1;
    transition: all 0.3s ease;
    position: relative;
    z-index: 1;
}

/* Eyelids for blinking effect */
.eyelid {
    position: absolute;
    width: 8px;
    height: 3px;
    background: var(--card-bg);
    border-radius: 50%;
    z-index: 2;
    animation: eyelid-blink 4s ease-in-out infinite;
}

.eyelid-left {
    top: 26px;
    left: 22px;
}

.eyelid-right {
    top: 26px;
    right: 22px;
}

/* Mascot States */
.mascot-character.happy {
    animation: mascot-container-bounce 0.8s ease;
}

.mascot-character.happy .mascot-emoji {
    animation: mascot-jump 0.6s ease;
}

.mascot-character.happy .eyelid {
    animation: eyelid-happy-blink 0.2s ease 5;
}

.mascot-character.thinking .mascot-emoji {
    animation: mascot-think 1s ease infinite;
}

.mascot-character.celebrating {
    animation: mascot-container-bounce 0.8s ease infinite;
}

.mascot-character.celebrating .mascot-emoji {
    animation: mascot-celebrate 0.8s ease;
}

.mascot-character.celebrating .eyelid {
    animation: eyelid-happy-blink 0.3s ease infinite;
}

.mascot-character.encouraging .mascot-emoji {
    animation: mascot-bounce 0.5s ease;
}

@keyframes mascot-jump {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    30% { transform: translateY(-20px) rotate(-10deg); }
    60% { transform: translateY(-10px) rotate(10deg); }
}

@keyframes mascot-think {
    0%, 100% { transform: rotate(-5deg); }
    50% { transform: rotate(5deg); }
}

@keyframes mascot-celebrate {
    0%, 100% { transform: scale(1) rotate(0deg); }
    25% { transform: scale(1.2) rotate(-15deg); }
    75% { transform: scale(1.2) rotate(15deg); }
}

@keyframes mascot-bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

@keyframes eyelid-blink {
    0%, 90%, 100% {
        transform: scaleY(0);
        opacity: 0;
    }
    92%, 98% {
        transform: scaleY(1);
        opacity: 1;
    }
}

@keyframes eyelid-happy-blink {
    0%, 100% {
        transform: scaleY(0);
        opacity: 0;
    }
    50% {
        transform: scaleY(1.5);
        opacity: 1;
    }
}

@keyframes mascot-container-bounce {
    0%, 100% { transform: scale(1); }
    25% { transform: scale(1.15) rotate(-8deg); }
    50% { transform: scale(1.1) rotate(8deg); }
    75% { transform: scale(1.15) rotate(-5deg); }
}

/* Speech Bubble */
.mascot-speech {
    background: white;
    color: var(--bg-dark);
    padding: 12px 16px;
    border-radius: 16px;
    box-shadow: var(--shadow-soft);
    position: relative;
    max-width: 180px;
    animation: speech-pop 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.mascot-speech::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 20px;
    width: 0;
    height: 0;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-top: 10px solid white;
}

@keyframes speech-pop {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.mascot-speech p {
    margin: 0;
    font-size: 0.9rem;
    font-weight: 700;
    line-height: 1.3;
}

/* ========================================
   ADMIN PANEL
======================================== */
#admin-toggle {
    display: none;
    position: fixed;
    bottom: 10px;
    right: 10px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid #374151;
    background: var(--card-bg);
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
    opacity: 0.5;
    transition: all 0.2s;
}

#admin-toggle:hover {
    opacity: 1;
    border-color: var(--primary);
    background: var(--card-hover);
}

#admin-panel {
    display: none;
    position: fixed;
    bottom: 60px;
    right: 10px;
    background: var(--card-bg);
    border-radius: 16px;
    padding: 16px;
    box-shadow: var(--shadow-strong);
    border: 2px solid #374151;
    max-height: 60vh;
    overflow-y: auto;
    z-index: 999;
}

#admin-panel.active {
    display: block;
}

#admin-panel h3 {
    margin-bottom: 12px;
    color: var(--text-primary);
}

#admin-panel button {
    display: block;
    width: 100%;
    padding: 8px 12px;
    margin-bottom: 8px;
    border: 2px solid #374151;
    border-radius: 12px;
    background: var(--bg-darker);
    color: var(--text-primary);
    cursor: pointer;
    font-family: var(--font-family);
    font-weight: 600;
}

#admin-panel button:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.admin-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #374151;
    font-size: 0.85rem;
}

/* ========================================
   SNAKE GAME
======================================== */
.snake-game-board {
    position: relative;
    width: 100%;
    height: 120px;
    background: linear-gradient(135deg, #1a3a1a 0%, #1f4a1f 100%);
    border-radius: 16px;
    border: 3px solid var(--secondary);
    border-bottom: 5px solid #4CAE00;
    margin-bottom: 20px;
    overflow: hidden;
}

.snake-emoji,
.apple-emoji {
    position: absolute;
    font-size: 3rem;
    top: 50%;
    transform: translateY(-50%);
}

.snake-emoji {
    left: 5%;
    transition: left 1.2s ease-out;
    z-index: 2;
}

.apple-emoji {
    right: 5%;
    z-index: 1;
}

.game-info {
    text-align: center;
    margin-bottom: 16px;
}

.game-info p {
    margin: 4px 0;
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text-primary);
}

.sound-status {
    margin-top: 12px;
    text-align: center;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    min-height: 24px;
}

.sound-status.active {
    color: var(--secondary);
    animation: pulse-text 0.8s ease-in-out infinite;
}

.sound-status.wrong {
    color: #E74C3C;
}

@keyframes pulse-text {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ========================================
   RESPONSIVE
======================================== */
@media (max-width: 480px) {
    header {
        padding: 10px 12px;
    }

    .header-left,
    .header-right {
        gap: 8px;
    }

    .icon-btn {
        width: 40px;
        height: 40px;
        border-radius: 10px;
    }

    .progress-pill {
        padding: 6px 12px;
        font-size: 0.8rem;
    }

    .logo-text {
        display: none;
    }

    .logo-icon {
        font-size: 1.25rem;
    }

    /* Hide sound toggle on mobile to save space */
    #sound-toggle {
        display: none;
    }

    .welcome-title {
        font-size: 1.5rem;
    }

    .task-card {
        padding: 24px 16px;
    }

    .task-progress-bar {
        height: 10px;
    }

    /* Mobile responsive - revert to centered stack */
    .level-grid {
        align-items: center;
    }

    .level-card:nth-child(odd),
    .level-card:nth-child(even) {
        align-self: center;
        margin-left: 0;
        margin-right: 0;
    }

    .level-grid::before {
        display: none; /* Hide path line on mobile */
    }

    .stage-header {
        padding: 16px 20px;
        margin: 16px 0 12px 0;
        border-radius: 16px;
        box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2),
                    0 3px 6px rgba(0, 0, 0, 0.1);
    }

    .stage-title {
        font-size: 1.3rem;
        margin-bottom: 4px;
        letter-spacing: 1.5px;
    }

    .stage-letters {
        font-size: 0.9rem;
        letter-spacing: 2px;
    }

    /* Mobile responsive for phonics pulse */
    .listen-header {
        flex-direction: column;
        gap: 12px;
    }

    .mouth-shape-container {
        padding: 12px 20px;
        min-width: 120px;
    }

    .mouth-icon {
        font-size: 2rem;
    }

    /* Hide mascot speech on mobile to save screen space */
    .mascot-container {
        bottom: 60px;
        left: 10px;
    }

    .mascot-character {
        width: 60px;
        height: 60px;
    }

    .mascot-emoji {
        font-size: 2rem;
    }

    .mascot-speech {
        display: none !important; /* Hide speech bubbles on mobile */
    }

    /* Mobile responsive for perfect badge */
    .perfect-badge {
        padding: 12px 20px;
    }

    .badge-icon {
        font-size: 2.5rem;
    }

    .badge-text {
        font-size: 1.4rem;
    }

    .choice-grid {
        grid-template-columns: 1fr;
    }

    .letter-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }

    .repeat-sound-btn {
        width: 120px;
        height: 120px;
    }

    .letter-display {
        font-size: 4rem;
    }

    .action-btn {
        padding: 12px 20px;
        font-size: 0.95rem;
    }
}

/* ========================================
   RESTART LEVEL MODAL
======================================== */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: var(--overlay-bg);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease;
}

.modal-card {
    background: var(--card-bg);
    border-radius: var(--radius-xl);
    padding: 40px 30px;
    max-width: 480px;
    width: 90%;
    text-align: center;
    box-shadow: var(--shadow-strong);
    animation: popIn 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.modal-icon {
    font-size: 64px;
    margin-bottom: 20px;
    animation: spin 0.6s ease;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.modal-title {
    font-size: 28px;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.modal-description {
    font-size: 18px;
    color: var(--text-secondary);
    margin-bottom: 30px;
    line-height: 1.5;
}

.modal-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.modal-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 18px 24px;
    border: none;
    border-radius: var(--radius-md);
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: var(--font-family);
}

.restart-btn {
    background: linear-gradient(135deg, var(--accent), var(--accent-light));
    color: white;
}

.restart-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 150, 0, 0.4);
}

.continue-btn {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: white;
}

.continue-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(28, 176, 246, 0.4);
}

.modal-btn .btn-icon {
    font-size: 24px;
}

.modal-btn .btn-text {
    font-size: 18px;
}

/* Mobile Styles for Modal */
@media (max-width: 480px) {
    .modal-card {
        padding: 30px 20px;
        width: 95%;
    }

    .modal-icon {
        font-size: 48px;
        margin-bottom: 16px;
    }

    .modal-title {
        font-size: 24px;
    }

    .modal-description {
        font-size: 16px;
        margin-bottom: 24px;
    }

    .modal-btn {
        padding: 16px 20px;
        font-size: 16px;
    }

    .modal-btn .btn-icon {
        font-size: 20px;
    }

    .modal-btn .btn-text {
        font-size: 16px;
    }
}