:root {
    --primary-color: #8b5cf6;
    --primary-hover: #7c3aed;
    --primary-light: rgba(139, 92, 246, 0.15);
    --secondary-color: #06b6d4;
    --secondary-light: rgba(6, 182, 212, 0.15);
    --success-color: #10b981;
    --success-hover: #059669;
    --success-light: rgba(16, 185, 129, 0.15);
    --warning-color: #f59e0b;
    --warning-hover: #d97706;
    --warning-light: rgba(245, 158, 11, 0.15);
    --danger-color: #ef4444;
    --accent-pink: #ec4899;
    --accent-orange: #f97316;
    --accent-yellow: #fbbf24;
    --accent-green: #22c55e;
    --accent-blue: #3b82f6;
    --surface-color: #ffffff;
    --surface-elevated: #f8fafc;
    --surface-gradient: linear-gradient(135deg, #fef7ff 0%, #f0f9ff 50%, #fef3c7 100%);
    --border-color: #e2e8f0;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --shadow-glow: 0 0 20px rgba(139, 92, 246, 0.3);
    --shadow-glow-success: 0 0 20px rgba(16, 185, 129, 0.3);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-xl: 28px;
    --radius-full: 9999px;
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 350ms ease;
    --transition-bounce: 400ms cubic-bezier(0.68, -0.55, 0.265, 1.55);
    --child-font-size: 1.4rem;
    --touch-target-min: 52px;
}

.dark-mode {
    --primary-color: #a78bfa;
    --primary-hover: #8b5cf6;
    --primary-light: rgba(167, 139, 250, 0.2);
    --secondary-color: #22d3ee;
    --secondary-light: rgba(34, 211, 238, 0.2);
    --surface-color: #1e1b4b;
    --surface-elevated: #312e81;
    --surface-gradient: linear-gradient(135deg, #1e1b4b 0%, #0f172a 50%, #1e3a5f 100%);
    --border-color: #4c1d95;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
}


.tool-main {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 20px 40px;
    position: relative;
    min-height: 100vh;
}

.tool-main::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--surface-gradient);
    z-index: -2;
}


.floating-elements {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: -1;
    overflow: hidden;
}

.floating-star,
.floating-cloud,
.floating-heart {
    position: absolute;
    opacity: 0.6;
    animation: float-around 20s ease-in-out infinite;
}

.floating-star {
    font-size: 1.5rem;
    color: var(--accent-yellow);
    text-shadow: 0 0 10px rgba(251, 191, 36, 0.5);
}

.floating-cloud {
    font-size: 2rem;
    color: #cbd5e1;
}

.floating-heart {
    font-size: 1.2rem;
    color: var(--accent-pink);
}

.floating-star:nth-child(1) {
    top: 10%;
    left: 5%;
    animation-delay: 0s;
    animation-duration: 15s;
}

.floating-star:nth-child(2) {
    top: 20%;
    right: 10%;
    animation-delay: 2s;
    animation-duration: 18s;
}

.floating-star:nth-child(3) {
    top: 60%;
    left: 8%;
    animation-delay: 4s;
    animation-duration: 22s;
}

.floating-cloud:nth-child(4) {
    top: 15%;
    left: 20%;
    animation-delay: 1s;
    animation-duration: 25s;
}

.floating-cloud:nth-child(5) {
    top: 40%;
    right: 5%;
    animation-delay: 3s;
    animation-duration: 20s;
}

.floating-heart:nth-child(6) {
    top: 70%;
    right: 15%;
    animation-delay: 5s;
    animation-duration: 17s;
}

.floating-heart:nth-child(7) {
    top: 30%;
    left: 3%;
    animation-delay: 6s;
    animation-duration: 19s;
}

.floating-star:nth-child(8) {
    top: 80%;
    left: 15%;
    animation-delay: 7s;
    animation-duration: 21s;
}

@keyframes float-around {

    0%,
    100% {
        transform: translate(0, 0) rotate(0deg);
    }

    25% {
        transform: translate(10px, -15px) rotate(5deg);
    }

    50% {
        transform: translate(-5px, 10px) rotate(-3deg);
    }

    75% {
        transform: translate(15px, 5px) rotate(8deg);
    }
}


.tool-header {
    text-align: center;
    padding: 50px 20px 35px;
    margin-bottom: 24px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.9) 0%, transparent 100%);
    border-radius: 0 0 var(--radius-xl) var(--radius-xl);
}

.header-content {
    max-width: 720px;
    margin: 0 auto;
}

.language-toggle {
    display: inline-flex;
    gap: 12px;
    margin-top: 18px;
    padding: 8px 14px;
    background: var(--surface-color);
    border-radius: var(--radius-full);
    border: 2px solid var(--border-color);
    box-shadow: var(--shadow-md);
}

.lang-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 3px solid transparent;
    font-size: 1.6rem;
    background: var(--surface-elevated);
    cursor: pointer;
    transition: all var(--transition-bounce);
    display: flex;
    align-items: center;
    justify-content: center;
}

.lang-btn:hover {
    transform: translateY(-4px) scale(1.1);
    box-shadow: var(--shadow-lg);
}

.lang-btn.active {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px var(--primary-light), var(--shadow-glow);
    background: var(--primary-light);
}

.header-icon {
    margin-bottom: 20px;
    position: relative;
    display: inline-block;
}

.icon-reading {
    font-size: 5rem;
    display: inline-block;
    animation: bounce 2s ease-in-out infinite;
    filter: drop-shadow(0 8px 16px rgba(139, 92, 246, 0.3));
}

.header-icon::after {
    content: '✨';
    position: absolute;
    top: -10px;
    right: -20px;
    font-size: 1.8rem;
    animation: sparkle 1.5s ease-in-out infinite;
}

@keyframes sparkle {

    0%,
    100% {
        opacity: 1;
        transform: scale(1) rotate(0deg);
    }

    50% {
        opacity: 0.5;
        transform: scale(1.2) rotate(15deg);
    }
}

@keyframes bounce {

    0%,
    100% {
        transform: translateY(0) rotate(-3deg);
    }

    50% {
        transform: translateY(-12px) rotate(3deg);
    }
}

.tool-header h1 {
    font-size: 2.8rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary-color), var(--accent-pink), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 14px;
    letter-spacing: -0.02em;
    text-shadow: none;
}

.tool-header .subtitle {
    font-size: 1.25rem;
    color: var(--text-secondary);
    margin-bottom: 24px;
    line-height: 1.7;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}


.achievements-bar {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.achievement-badge {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 12px 16px;
    background: var(--surface-color);
    border-radius: var(--radius-lg);
    border: 2px solid var(--border-color);
    transition: all var(--transition-bounce);
    cursor: default;
    min-width: 80px;
}

.achievement-badge:hover {
    transform: none;
    box-shadow: none;
}

.achievement-badge.earned {
    border-color: var(--accent-yellow);
    background: linear-gradient(135deg, #fef9c3, #fde68a);
    box-shadow: 0 0 16px rgba(251, 191, 36, 0.4);
}

.achievement-badge.locked {
    opacity: 0.5;
    filter: grayscale(0.8);
}

.badge-icon {
    font-size: 2rem;
}

.badge-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}


.progress-summary {
    background: var(--surface-color);
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-xl);
    padding: 22px;
    margin-bottom: 28px;
    box-shadow: var(--shadow-md);
}

.summary-header {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: var(--surface-elevated);
    border-radius: var(--radius-full);
    padding: 8px 16px;
    border: 2px solid var(--border-color);
    font-weight: 800;
    color: var(--text-primary);
    margin: 0 auto 18px;
    box-shadow: var(--shadow-sm);
}

.summary-icon {
    font-size: 1.2rem;
}

.summary-title {
    font-size: 0.95rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.progress-summary .achievements-bar,
.progress-summary .stats-bar,
.progress-summary .streak-indicator {
    margin-bottom: 18px;
}

.progress-summary .stats-bar {
    margin-bottom: 0;
}


.progress-section {
    margin-bottom: 28px;
}

.phase-indicators {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    padding: 24px;
    background: var(--surface-color);
    border-radius: var(--radius-xl);
    border: 2px solid var(--border-color);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    box-sizing: border-box;
}

.phase-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 16px 24px;
    border-radius: var(--radius-lg);
    background: var(--surface-elevated);
    border: 3px solid var(--border-color);
    transition: all var(--transition-bounce);
    cursor: pointer;
    min-width: 100px;
    position: relative;
    overflow: hidden;
    box-sizing: border-box;
}

.phase-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(180deg, transparent 60%, rgba(139, 92, 246, 0.1) 100%);
    opacity: 0;
    transition: opacity var(--transition-normal);
}

.phase-item:hover::before {
    opacity: 1;
}

.phase-item:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: var(--shadow-lg);
}

.phase-item:focus-visible {
    outline: 4px solid var(--primary-color);
    outline-offset: 4px;
    box-shadow: 0 0 0 6px var(--primary-light), var(--shadow-lg);
}

.phase-item.active {
    border-color: var(--primary-color);
    background: var(--primary-light);
    box-shadow: var(--shadow-glow);
}

.phase-item.active .phase-icon {
    animation: pulse-icon 1.5s ease-in-out infinite;
}

@keyframes pulse-icon {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.15);
    }
}

.phase-item.completed {
    border-color: var(--success-color);
    background: var(--success-light);
}

.phase-item.completed::after {
    content: '✓';
    position: absolute;
    top: 8px;
    right: 8px;
    font-size: 0.8rem;
    color: var(--success-color);
    font-weight: bold;
}

.phase-item.locked {
    opacity: 0.5;
    cursor: not-allowed;
}

.phase-icon {
    font-size: 2.2rem;
    position: relative;
    z-index: 1;
}

.phase-label {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-primary);
    position: relative;
    z-index: 1;
}

.phase-action {
    display: none;
    align-items: center;
    gap: 6px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-secondary);
    background: var(--secondary-light);
    padding: 4px 10px;
    border-radius: var(--radius-full);
    position: relative;
    z-index: 1;
}

.phase-connector {
    width: 40px;
    height: 4px;
    background: linear-gradient(90deg, var(--border-color), var(--border-color));
    border-radius: var(--radius-full);
    position: relative;
}

.phase-connector::before {
    content: '→';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--text-muted);
    font-size: 0.9rem;
    background: var(--surface-color);
    padding: 0 4px;
}

.phase-connector.completed {
    background: linear-gradient(90deg, var(--success-color), var(--success-color));
}

.phase-connector.completed::before {
    color: var(--success-color);
}

.phase-hint {
    margin-top: 12px;
    text-align: center;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-secondary);
}


.stats-bar {
    display: flex;
    justify-content: center;
    gap: 20px;
    padding: 20px 28px;
    background: var(--surface-color);
    border-radius: var(--radius-xl);
    margin-bottom: 28px;
    flex-wrap: wrap;
    box-shadow: var(--shadow-md);
    border: 2px solid var(--border-color);
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 18px;
    background: var(--surface-elevated);
    border-radius: var(--radius-lg);
    border: 2px solid transparent;
    transition: all var(--transition-bounce);
    cursor: default;
}

.stat-item:hover {
    transform: none;
    border-color: transparent;
    box-shadow: none;
}

.stat-icon {
    font-size: 1.6rem;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary-color), var(--accent-pink));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.stat-label {
    font-size: 0.95rem;
    color: var(--text-secondary);
    font-weight: 600;
}


.streak-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: linear-gradient(135deg, #fef3c7, #fed7aa);
    border-radius: var(--radius-full);
    border: 2px solid var(--accent-orange);
    margin-bottom: 24px;
    width: fit-content;
    margin-left: auto;
    margin-right: auto;
}

.streak-icon {
    font-size: 1.4rem;
    animation: flame-flicker 0.5s ease-in-out infinite alternate;
}

@keyframes flame-flicker {
    0% {
        transform: scale(1) rotate(-3deg);
    }

    100% {
        transform: scale(1.1) rotate(3deg);
    }
}

.streak-text {
    font-size: 1rem;
    font-weight: 700;
    color: var(--accent-orange);
}


.character-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 28px;
    position: relative;
}

#character-canvas {
    border-radius: 50%;
    background: linear-gradient(135deg, #fef3c7, #fbbf24, #f59e0b);
    box-shadow: var(--shadow-xl), 0 0 40px rgba(251, 191, 36, 0.3);
    border: 4px solid rgba(255, 255, 255, 0.8);
    transition: transform var(--transition-bounce);
}

#character-canvas:hover {
    transform: scale(1.05) rotate(5deg);
}

.character-speech {
    position: relative;
    background: var(--surface-color);
    border: 3px solid var(--primary-color);
    border-radius: var(--radius-xl);
    padding: 18px 28px;
    margin-top: 20px;
    max-width: 440px;
    text-align: center;
    font-size: var(--child-font-size);
    color: var(--text-primary);
    box-shadow: var(--shadow-lg), var(--shadow-glow);
    display: none;
    line-height: 1.5;
}

.character-speech.visible {
    display: block;
    animation: speech-pop 0.4s var(--transition-bounce);
}

@keyframes speech-pop {
    0% {
        opacity: 0;
        transform: translateY(20px) scale(0.8);
    }

    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.character-speech::before {
    content: '';
    position: absolute;
    top: -14px;
    left: 50%;
    transform: translateX(-50%);
    border-left: 14px solid transparent;
    border-right: 14px solid transparent;
    border-bottom: 14px solid var(--primary-color);
}

.character-speech::after {
    content: '';
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    border-left: 11px solid transparent;
    border-right: 11px solid transparent;
    border-bottom: 11px solid var(--surface-color);
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}


.content-card {
    background: var(--surface-color);
    border-radius: var(--radius-xl);
    border: 2px solid var(--border-color);
    box-shadow: var(--shadow-lg);
    margin-bottom: 28px;
    overflow: hidden;
    position: relative;
}

.content-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary-color), var(--accent-pink), var(--secondary-color), var(--accent-green));
}

.reaction-face {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, #fff7d6, #fde68a 45%, #fbbf24 85%);
    border: 5px solid #f97316;
    box-shadow: var(--shadow-xl), 0 0 26px rgba(249, 115, 22, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.6);
    transition: opacity var(--transition-fast), transform var(--transition-fast);
    pointer-events: none;
    z-index: 2;
}

.reaction-face::before,
.reaction-face::after {
    content: '';
    position: absolute;
    width: 18px;
    height: 12px;
    border-radius: 999px;
    background: rgba(248, 113, 113, 0.55);
    filter: blur(0.5px);
}

.reaction-face::before {
    left: 18px;
    top: 64px;
}

.reaction-face::after {
    right: 18px;
    top: 64px;
}

.reaction-face.show {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
    animation: reaction-pop 0.5s ease-out, reaction-wobble 0.8s ease-in-out 0.1s 2;
}

.reaction-emoji {
    font-size: 3.4rem;
    transform-origin: center;
}

.reaction-face.show .reaction-emoji {
    animation: reaction-bounce 0.9s ease-in-out;
}

@keyframes reaction-pop {
    0% {
        transform: translate(-50%, -50%) scale(0.4);
    }

    60% {
        transform: translate(-50%, -50%) scale(1.1);
    }

    100% {
        transform: translate(-50%, -50%) scale(1);
    }
}

@keyframes reaction-wobble {
    0% {
        transform: translate(-50%, -50%) scale(1) rotate(0deg);
    }

    25% {
        transform: translate(-50%, -50%) scale(1.02) rotate(-8deg);
    }

    50% {
        transform: translate(-50%, -50%) scale(1.04) rotate(6deg);
    }

    75% {
        transform: translate(-50%, -50%) scale(1.02) rotate(-4deg);
    }

    100% {
        transform: translate(-50%, -50%) scale(1) rotate(0deg);
    }
}

@keyframes reaction-bounce {
    0% {
        transform: translateY(0) rotate(0deg);
    }

    35% {
        transform: translateY(-6px) rotate(-6deg);
    }

    70% {
        transform: translateY(2px) rotate(6deg);
    }

    100% {
        transform: translateY(0) rotate(0deg);
    }
}

@keyframes nod-no {
    0% {
        transform: rotate(0deg);
    }

    20% {
        transform: rotate(-12deg);
    }

    40% {
        transform: rotate(10deg);
    }

    60% {
        transform: rotate(-8deg);
    }

    80% {
        transform: rotate(6deg);
    }

    100% {
        transform: rotate(0deg);
    }
}

.fullscreen-exit-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    height: 44px;
    padding: 0 16px;
    border-radius: var(--radius-full);
    border: none;
    background: rgba(15, 23, 42, 0.85);
    color: #ffffff;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    display: none;
    transition: transform var(--transition-fast), background var(--transition-fast), box-shadow var(--transition-fast);
    z-index: 10001;

    align-items: center;
    gap: 8px;
}

.fullscreen-exit-btn:hover {
    transform: scale(1.05);
    background: rgba(15, 23, 42, 0.9);
    box-shadow: var(--shadow-lg);
}

.fullscreen-exit-btn::after {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: inherit;
    box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.15);
    opacity: 0;
    transition: opacity var(--transition-fast), box-shadow var(--transition-fast);
}

.fullscreen-exit-btn:hover::after,
.fullscreen-exit-btn:focus-visible::after {
    opacity: 1;
    box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.2);
}

.fullscreen-exit-btn:focus-visible {
    outline: 3px solid var(--primary-color);
    outline-offset: 3px;
}

#activity-card:fullscreen .fullscreen-exit-btn,
#activity-card:-webkit-full-screen .fullscreen-exit-btn,
#activity-card.is-fullscreen .fullscreen-exit-btn {
    top: calc(12px + env(safe-area-inset-top));
    right: calc(12px + env(safe-area-inset-right));
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

body.activity-fullscreen #activity-card .fullscreen-exit-btn {
    display: inline-flex;
}

body.activity-fullscreen {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
    touch-action: none;
    user-select: none;
}

body.activity-fullscreen * {
    user-select: none;
}


body.activity-fullscreen nav {
    display: none;
}

#activity-card:fullscreen,
#activity-card:-webkit-full-screen,
#activity-card.is-fullscreen {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    margin: 0;
    border-radius: 0;
    border: none;
    box-shadow: none;
    position: fixed;
    inset: 0;
    z-index: 10000;

}

#activity-card:fullscreen .card-header,
#activity-card:-webkit-full-screen .card-header,
#activity-card.is-fullscreen .card-header {
    padding: calc(20px + env(safe-area-inset-top)) 32px 20px;
    font-size: 1.4rem;
}

#activity-card:fullscreen .card-body,
#activity-card:-webkit-full-screen .card-body,
#activity-card.is-fullscreen .card-body {
    height: calc(100vh - 96px - env(safe-area-inset-top));
    height: calc(100dvh - 96px - env(safe-area-inset-top));
    padding: 28px 32px calc(36px + env(safe-area-inset-bottom));
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

#activity-card:fullscreen #activity-area,
#activity-card:-webkit-full-screen #activity-area,
#activity-card.is-fullscreen #activity-area {
    width: min(1100px, 96vw);
}

#activity-card:fullscreen .sounds-stage,
#activity-card:-webkit-full-screen .sounds-stage,
#activity-card.is-fullscreen .sounds-stage {
    grid-template-columns: minmax(220px, 1fr) minmax(320px, 2fr);
    gap: 40px;
}

#activity-card:fullscreen .letter-card,
#activity-card:-webkit-full-screen .letter-card,
#activity-card.is-fullscreen .letter-card {
    width: 220px;
    min-height: 240px;
}

#activity-card:fullscreen .letter-display,
#activity-card:-webkit-full-screen .letter-display,
#activity-card.is-fullscreen .letter-display {
    font-size: 6rem;
}

#activity-card:fullscreen .shape-body,
#activity-card:-webkit-full-screen .shape-body,
#activity-card.is-fullscreen .shape-body {
    width: 150px;
    height: 150px;
}

#activity-card:fullscreen .shape-instructions,
#activity-card:-webkit-full-screen .shape-instructions,
#activity-card.is-fullscreen .shape-instructions {
    font-size: 1.2rem;
}

@media (max-width: 900px) {

    #activity-card:fullscreen .fullscreen-exit-btn,
    #activity-card:-webkit-full-screen .fullscreen-exit-btn,
    #activity-card.is-fullscreen .fullscreen-exit-btn {
        width: 56px;
        height: 56px;
        padding: 0;
        border-radius: 50%;
        font-size: 1.6rem;
        top: calc(20px + env(safe-area-inset-top));
        right: calc(20px + env(safe-area-inset-right));
        background: rgba(15, 23, 42, 0.95);
        z-index: 9999;
    }

    #activity-card:fullscreen .fullscreen-exit-btn .btn-text,
    #activity-card:-webkit-full-screen .fullscreen-exit-btn .btn-text,
    #activity-card.is-fullscreen .fullscreen-exit-btn .btn-text {
        display: none;
    }

    #activity-card:fullscreen .card-header,
    #activity-card:-webkit-full-screen .card-header,
    #activity-card.is-fullscreen .card-header {
        padding: calc(10px + env(safe-area-inset-top)) 12px 8px;
        font-size: 1rem;
    }

    #activity-card:fullscreen .card-body,
    #activity-card:-webkit-full-screen .card-body,
    #activity-card.is-fullscreen .card-body {
        height: calc(100vh - 56px - env(safe-area-inset-top));
        height: calc(100dvh - 56px - env(safe-area-inset-top));
        padding: 8px 12px calc(12px + env(safe-area-inset-bottom));
        align-items: center;
        justify-content: center;
        overflow: hidden;
    }

    #activity-card:fullscreen #activity-area,
    #activity-card:-webkit-full-screen #activity-area,
    #activity-card.is-fullscreen #activity-area {
        width: 100%;
        height: 100%;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        overflow: hidden;
    }

    #activity-card:fullscreen .sounds-stage,
    #activity-card:-webkit-full-screen .sounds-stage,
    #activity-card.is-fullscreen .sounds-stage {
        grid-template-columns: 1fr;
        gap: 12px;
        transform: scale(var(--fullscreen-scale, 1));
        transform-origin: center center;
    }

    #activity-card:fullscreen .letter-card,
    #activity-card:-webkit-full-screen .letter-card,
    #activity-card.is-fullscreen .letter-card {
        width: 100%;
        min-height: auto;
        padding: 12px;
    }

    #activity-card:fullscreen .letter-display,
    #activity-card:-webkit-full-screen .letter-display,
    #activity-card.is-fullscreen .letter-display {
        font-size: clamp(2.5rem, 10vw, 4rem);
    }

    #activity-card:fullscreen .shape-body,
    #activity-card:-webkit-full-screen .shape-body,
    #activity-card.is-fullscreen .shape-body {
        width: clamp(60px, 18vw, 100px);
        height: clamp(60px, 18vw, 100px);
    }

    #activity-card:fullscreen .shape-instructions,
    #activity-card:-webkit-full-screen .shape-instructions,
    #activity-card.is-fullscreen .shape-instructions {
        font-size: 0.9rem;
        margin-bottom: 12px;
    }

    #activity-card:fullscreen .shape-row,
    #activity-card:-webkit-full-screen .shape-row,
    #activity-card.is-fullscreen .shape-row {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 16px;
        justify-content: space-evenly;
    }

    #activity-card:fullscreen .shape-zone,
    #activity-card:-webkit-full-screen .shape-zone,
    #activity-card.is-fullscreen .shape-zone {
        padding: 12px;
    }

    #activity-card:fullscreen .word-builder,
    #activity-card:-webkit-full-screen .word-builder,
    #activity-card.is-fullscreen .word-builder {
        padding: 8px;
    }

    #activity-card:fullscreen .target-word,
    #activity-card:-webkit-full-screen .target-word,
    #activity-card.is-fullscreen .target-word {
        padding: 12px;
        margin-bottom: 12px;
    }

    #activity-card:fullscreen .word-slots,
    #activity-card:-webkit-full-screen .word-slots,
    #activity-card.is-fullscreen .word-slots {
        gap: 8px;
        margin-bottom: 16px;
        flex-wrap: nowrap;
        width: 100%;
        max-width: 720px;
        margin-left: auto;
        margin-right: auto;
    }

    #activity-card:fullscreen .word-slot,
    #activity-card:-webkit-full-screen .word-slot,
    #activity-card.is-fullscreen .word-slot {
        width: var(--slot-size, clamp(40px, 12vw, 60px));
        height: calc(var(--slot-size, 48px) * 1.2);
        font-size: clamp(0.8rem, calc(var(--slot-size, 48px) * 0.5), 1.8rem);
    }

    #activity-card:fullscreen .letter-bank,
    #activity-card:-webkit-full-screen .letter-bank,
    #activity-card.is-fullscreen .letter-bank {
        gap: 8px;
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        max-width: 100%;
    }

    #activity-card:fullscreen .letter-tile,
    #activity-card:-webkit-full-screen .letter-tile,
    #activity-card.is-fullscreen .letter-tile {
        width: clamp(36px, 10vw, 48px);
        height: clamp(42px, 12vw, 55px);
        font-size: clamp(1rem, 4vw, 1.3rem);
    }

    #activity-card:fullscreen .story-container,
    #activity-card:-webkit-full-screen .story-container,
    #activity-card.is-fullscreen .story-container {
        padding: 8px;
    }

    #activity-card:fullscreen .story-title,
    #activity-card:-webkit-full-screen .story-title,
    #activity-card.is-fullscreen .story-title {
        font-size: 1.2rem;
        margin-bottom: 12px;
    }

    #activity-card:fullscreen .story-sentence,
    #activity-card:-webkit-full-screen .story-sentence,
    #activity-card.is-fullscreen .story-sentence {
        font-size: clamp(1rem, 4vw, 1.4rem);
        gap: 8px;
        margin-bottom: 16px;
    }

    #activity-card:fullscreen .story-letter-slot,
    #activity-card:-webkit-full-screen .story-letter-slot,
    #activity-card.is-fullscreen .story-letter-slot {
        width: var(--slot-size, clamp(32px, 9vw, 44px));
        height: calc(var(--slot-size, 38px) * 1.2);
        font-size: clamp(0.7rem, calc(var(--slot-size, 38px) * 0.5), 1.1rem);
    }

    #activity-card:fullscreen .story-blank,
    #activity-card:-webkit-full-screen .story-blank,
    #activity-card.is-fullscreen .story-blank {
        flex-wrap: nowrap;
        max-width: 100%;
    }

    #activity-card:fullscreen .story-speech-btn,
    #activity-card:-webkit-full-screen .story-speech-btn,
    #activity-card.is-fullscreen .story-speech-btn {
        padding: 10px 16px;
        font-size: 0.95rem;
    }

    #activity-card:fullscreen .blend-instructions,
    #activity-card:-webkit-full-screen .blend-instructions,
    #activity-card.is-fullscreen .blend-instructions,
    #activity-card:fullscreen .story-instructions,
    #activity-card:-webkit-full-screen .story-instructions,
    #activity-card.is-fullscreen .story-instructions {
        font-size: 0.9rem;
        margin-bottom: 12px;
    }

    #activity-card:fullscreen .sound-btn,
    #activity-card:-webkit-full-screen .sound-btn,
    #activity-card.is-fullscreen .sound-btn {
        width: 56px;
        height: 56px;
        font-size: 1.5rem;
    }
}

@media (max-width: 720px) {
    .fullscreen-enter-btn {
        width: 44px;
        height: 44px;
        padding: 0;
        border-radius: 50%;
        justify-content: center;
    }

    .fullscreen-enter-btn .btn-text {
        display: none;
    }
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 28px;
    background: linear-gradient(135deg, var(--primary-light) 0%, var(--secondary-light) 100%);
    border-bottom: 2px solid var(--border-color);
}

.card-header h2 {
    margin-right: auto;
}

.fullscreen-enter-btn {
    height: 40px;
    padding: 0 14px;
    border-radius: var(--radius-full);
    border: 2px solid var(--border-color);
    background: linear-gradient(135deg, #ffffff, var(--surface-elevated));
    color: var(--text-primary);
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-bounce);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    position: relative;
}

.fullscreen-enter-btn:hover {
    transform: scale(1.1);
    box-shadow: var(--shadow-md);
    border-color: var(--primary-color);
}

.fullscreen-enter-btn:focus-visible {
    outline: 3px solid var(--primary-color);
    outline-offset: 3px;
}

.fullscreen-enter-btn::after {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: inherit;
    box-shadow: 0 0 0 0 rgba(139, 92, 246, 0.2);
    opacity: 0;
    transition: opacity var(--transition-fast), box-shadow var(--transition-fast);
}

.fullscreen-enter-btn:hover::after,
.fullscreen-enter-btn:focus-visible::after {
    opacity: 1;
    box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.2);
}

.fullscreen-enter-btn .btn-icon,
.fullscreen-exit-btn .btn-icon {
    font-size: 1.1rem;
}

.fullscreen-enter-btn .btn-text,
.fullscreen-exit-btn .btn-text {
    font-size: 0.85rem;
    letter-spacing: 0.02em;
}

#activity-card:fullscreen .fullscreen-enter-btn,
#activity-card:-webkit-full-screen .fullscreen-enter-btn,
#activity-card.is-fullscreen .fullscreen-enter-btn {
    display: none;
}

body.activity-fullscreen #activity-card .fullscreen-enter-btn {
    display: none;
}

.card-header h2 {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0;
}

.card-icon {
    font-size: 1.6rem;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.card-body {
    padding: 36px 28px;
    min-height: 320px;
    background: linear-gradient(180deg, transparent 0%, rgba(139, 92, 246, 0.02) 100%);
}


#loading-message {
    text-align: center;
    font-size: 1.2rem;
    color: var(--text-secondary);
    padding: 60px 20px;
}

.loading-spinner {
    display: inline-block;
    width: 28px;
    height: 28px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 12px;
    vertical-align: middle;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}


.sounds-stage {
    display: grid;
    grid-template-columns: minmax(200px, 1fr) minmax(280px, 2fr);
    align-items: center;
    gap: 32px;
    padding: 12px 8px;
    position: relative;
}

.drag-layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.drag-line {
    position: absolute;
    height: 8px;
    width: 0;
    background: linear-gradient(90deg, rgba(139, 92, 246, 0.1), rgba(139, 92, 246, 0.8), rgba(139, 92, 246, 0.1));
    border-radius: var(--radius-full);
    transform-origin: 0 50%;
    opacity: 0;
    transition: opacity var(--transition-fast);
    box-shadow: 0 0 12px rgba(139, 92, 246, 0.5);
}

.drag-line.visible {
    opacity: 1;
}

.letter-zone {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.letter-card {
    width: 180px;
    min-height: 200px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-radius: var(--radius-xl);
    border: 4px solid var(--primary-color);
    background: linear-gradient(160deg, #fef7ff, #fae8ff, #e9d5ff);
    box-shadow: var(--shadow-xl), var(--shadow-glow);
    transition: all var(--transition-bounce);
    cursor: grab;
    touch-action: none;
    position: relative;
    overflow: hidden;
}

.letter-card::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.3) 0%, transparent 60%);
    animation: shimmer 3s ease-in-out infinite;
}

@keyframes shimmer {

    0%,
    100% {
        transform: translate(-30%, -30%);
    }

    50% {
        transform: translate(30%, 30%);
    }
}

.letter-card.dragging {
    cursor: grabbing;
    transform: scale(1.05);
    box-shadow: var(--shadow-xl), 0 0 30px rgba(139, 92, 246, 0.5);
}

.letter-card.hovered {
    box-shadow: 0 0 0 6px rgba(59, 130, 246, 0.25), var(--shadow-xl);
}

.letter-card.matched {
    border-color: var(--success-color);
    background: linear-gradient(160deg, #ecfdf5, #d1fae5, #a7f3d0);
    box-shadow: 0 0 0 6px var(--success-light), var(--shadow-xl), var(--shadow-glow-success);
    transform: translateY(-6px);
}

.letter-title {
    font-size: 0.9rem;
    font-weight: 800;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--primary-color);
    position: relative;
    z-index: 1;
}

.letter-display {
    font-size: 5rem;
    font-weight: 900;
    background: linear-gradient(135deg, var(--primary-color), var(--accent-pink));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1;
    position: relative;
    z-index: 1;
    filter: drop-shadow(2px 4px 6px rgba(139, 92, 246, 0.3));
}

.letter-example {
    font-size: 1rem;
    color: var(--text-secondary);
    font-weight: 600;
    position: relative;
    z-index: 1;
}

.letter-progress {
    font-size: 0.95rem;
    color: var(--text-secondary);
}

.sound-connection {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    opacity: 0.4;
    transition: opacity var(--transition-normal);
}

.sound-connection .connection-line {
    width: 8px;
    height: 120px;
    border-radius: 6px;
    background: repeating-linear-gradient(to bottom,
            var(--border-color),
            var(--border-color) 10px,
            transparent 10px,
            transparent 18px);
}

.sound-connection .connection-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 3px solid var(--border-color);
    background: var(--surface-color);
}

.sound-connection.linked {
    opacity: 1;
}

.sound-connection.linked .connection-line {
    background: repeating-linear-gradient(to bottom,
            var(--success-color),
            var(--success-color) 10px,
            transparent 10px,
            transparent 18px);
}

.sound-connection.linked .connection-dot {
    border-color: var(--success-color);
    background: var(--success-color);
}

.shape-zone {
    background: linear-gradient(135deg, var(--surface-elevated), rgba(139, 92, 246, 0.05));
    border-radius: var(--radius-xl);
    border: 3px dashed var(--primary-light);
    padding: 24px 22px;
    box-shadow: var(--shadow-md);
}

.shape-instructions {
    text-align: center;
    font-size: 1.15rem;
    color: var(--text-secondary);
    margin-bottom: 22px;
    font-weight: 500;
}

.shape-row {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 22px;
}

.shape-choice {
    border: none;
    background: transparent;
    padding: 0;
    cursor: pointer;
    transition: transform var(--transition-bounce);
}

.shape-choice:focus-visible {
    outline: 4px solid var(--primary-color);
    outline-offset: 10px;
    border-radius: var(--radius-xl);
}

.shape-body {
    width: 130px;
    height: 130px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 4px solid transparent;
    box-shadow: var(--shadow-lg);
    transition: transform var(--transition-bounce), box-shadow var(--transition-fast);
    animation: floaty 3.4s ease-in-out infinite;
}

.shape-choice:hover .shape-body {
    transform: translateY(-8px) scale(1.08);
    box-shadow: var(--shadow-xl);
}

.shape-choice:active .shape-body {
    transform: translateY(0) scale(0.95);
}

.shape-choice:hover .shape-body {
    animation: bobble 0.6s ease-in-out infinite;
}

.shape-choice.hovered .shape-body {
    box-shadow: 0 0 0 6px rgba(139, 92, 246, 0.3), var(--shadow-xl);
}

.shape-choice.matched .shape-body {
    border-color: var(--success-color);
    box-shadow: 0 0 0 8px var(--success-light), var(--shadow-xl), var(--shadow-glow-success);
}

.shape-choice.wrong .shape-body {
    animation: wiggle 0.35s ease;
}

.shape-circle {
    border-radius: 50%;
    border-color: var(--accent-yellow);
    background: radial-gradient(circle at 30% 30%, #fffbeb, #fef08a, #fbbf24);
}

.shape-squircle {
    border-radius: 35px;
    border-color: var(--secondary-color);
    background: radial-gradient(circle at 30% 30%, #ecfeff, #a5f3fc, #22d3ee);
}

.shape-blob {
    border-radius: 60% 40% 55% 45% / 55% 45% 55% 45%;
    border-color: var(--accent-pink);
    background: radial-gradient(circle at 30% 30%, #fdf2f8, #fbcfe8, #ec4899);
}

.shape-face {
    position: absolute;
    width: 80px;
    height: 56px;
    top: 46%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.shape-face .eye {
    position: absolute;
    top: 0;
    width: 16px;
    height: 16px;
    background: #1f2937;
    border-radius: 50%;
    box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.8) inset;
    transition: transform var(--transition-fast);
}

.shape-face .eye:first-child {
    left: 6px;
}

.shape-face .eye:nth-child(2) {
    right: 6px;
}

.shape-choice:hover .shape-face .eye {
    transform: scale(1.15);
}

.shape-face .mouth {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 34px;
    height: 16px;
    border: 4px solid #1f2937;
    border-top: 0;
    border-radius: 0 0 20px 20px;
    transition: all var(--transition-fast);
}

.shape-choice:hover .shape-face .mouth {
    width: 38px;
    height: 20px;
}

.shape-choice.speaking .shape-face .mouth {
    animation: mouth-talk 0.3s ease-in-out infinite;
}

.shape-face .blush {
    position: absolute;
    top: 20px;
    width: 18px;
    height: 12px;
    border-radius: 50%;
    background: rgba(244, 114, 182, 0.7);
    transition: opacity var(--transition-fast);
}

.shape-face .blush-left {
    left: -10px;
}

.shape-face .blush-right {
    right: -10px;
}

.shape-choice:hover .shape-face .blush {
    opacity: 1;
}

.shape-face::after {
    content: "✦";
    position: absolute;
    top: -10px;
    right: 4px;
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.9);
    opacity: 0.8;
    animation: twinkle 2s ease-in-out infinite;
}

@keyframes twinkle {

    0%,
    100% {
        opacity: 0.6;
        transform: scale(1);
    }

    50% {
        opacity: 1;
        transform: scale(1.2);
    }
}

@keyframes wiggle {
    0% {
        transform: rotate(0deg);
    }

    25% {
        transform: rotate(-6deg);
    }

    50% {
        transform: rotate(6deg);
    }

    75% {
        transform: rotate(-4deg);
    }

    100% {
        transform: rotate(0deg);
    }
}

@keyframes mouth-talk {

    0%,
    100% {
        height: 10px;
        width: 22px;
    }

    50% {
        height: 16px;
        width: 28px;
    }
}

@keyframes floaty {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-6px);
    }
}

@keyframes bobble {

    0%,
    100% {
        transform: translateY(-3px) scale(1.03);
    }

    50% {
        transform: translateY(-8px) scale(1.05);
    }
}


.sound-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 72px;
    height: 72px;
    font-size: 2rem;
    background: linear-gradient(135deg, var(--primary-color), var(--accent-pink));
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: all var(--transition-bounce);
    box-shadow: var(--shadow-lg), 0 0 20px rgba(139, 92, 246, 0.3);
    position: relative;
    overflow: hidden;
}

.sound-btn::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.3) 0%, transparent 50%);
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.sound-btn:hover::before {
    opacity: 1;
}

.sound-btn:hover {
    transform: scale(1.15) rotate(10deg);
}

.sound-btn:active {
    transform: scale(0.9);
}

.sound-btn.playing {
    animation: pulse-sound 0.5s ease-in-out infinite;
}

@keyframes pulse-sound {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }
}


.word-builder {
    text-align: center;
    padding: 24px;
}

.word-dragger .blend-instructions {
    font-size: 1.15rem;
    color: var(--text-secondary);
    margin-bottom: 20px;
    font-weight: 500;
}

.drag-slots {
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.drag-slot {
    background: var(--surface-color);
    border-style: dashed;
    transition: all var(--transition-bounce);
}

.drag-slot.drag-over {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 6px var(--primary-light), var(--shadow-glow);
    transform: scale(1.05);
}


.letter-bank {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(52px, 1fr));
    gap: 14px;
    margin: 0 auto;
    max-width: 560px;
}

.letter-tile {
    width: 52px;
    height: 60px;
    border-radius: var(--radius-md);
    border: 3px solid var(--border-color);
    background: linear-gradient(180deg, var(--surface-color), var(--surface-elevated));
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--text-primary);
    cursor: grab;
    transition: all var(--transition-bounce);
    box-shadow: var(--shadow-sm);
    position: relative;
}

.letter-tile::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 50%;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.5), transparent);
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    pointer-events: none;
}

.letter-tile:active {
    cursor: grabbing;
}

.letter-tile:hover {
    transform: translateY(-4px) scale(1.08);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-light);
}

.letter-tile.used {
    opacity: 0.35;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
    filter: grayscale(0.5);
}

.letter-tile.picked {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 5px var(--primary-light), var(--shadow-glow);
    cursor: grabbing;
    transform: scale(1.1) rotate(-3deg);
    background: var(--primary-light);
}

.letter-picked,
.letter-picked * {
    cursor: grabbing;
}

.story-letter-slot,
.drag-slot {
    cursor: pointer;
}


.needs-guidance .letter-card,
.needs-guidance .sound-btn,
.needs-guidance .letter-tile,
.needs-guidance .drag-slot,
.needs-guidance .story-letter-slot {
    animation: guidance-glow 1.8s ease-in-out infinite;
}

.needs-guidance .shape-choice .shape-body {
    animation: floaty 3.4s ease-in-out infinite, guidance-glow 1.8s ease-in-out infinite;
}

.needs-guidance .sound-btn.playing {
    animation: guidance-glow 1.8s ease-in-out infinite, pulse-sound 0.5s ease-in-out infinite;
}

.needs-guidance .letter-tile.used,
.needs-guidance .drag-slot.filled,
.needs-guidance .story-letter-slot.filled {
    animation: none;
}

@keyframes guidance-glow {

    0%,
    100% {
        box-shadow: var(--shadow-md);
    }

    50% {
        box-shadow: 0 0 0 6px var(--primary-light), var(--shadow-md);
    }
}


.story-container {
    text-align: center;
    padding: 16px 12px;
}

.story-instructions {
    font-size: 1.15rem;
    color: var(--text-secondary);
    margin-bottom: 20px;
    font-weight: 500;
}

.story-sentence {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 14px;
    margin-bottom: 24px;
    line-height: 2;
}

.story-speech-btn {
    margin: 16px auto 24px;
}

.story-blank {
    display: inline-flex;
    gap: 10px;
}

.story-letter-slot {
    width: 52px;
    height: 62px;
    border-radius: var(--radius-lg);
    border: 4px dashed var(--border-color);
    background: var(--surface-elevated);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-primary);
    transition: all var(--transition-bounce);
}

.story-letter-slot.drag-over {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 5px var(--primary-light), var(--shadow-glow);
    transform: scale(1.05);
}

.story-letter-slot.filled {
    border-style: solid;
    border-color: var(--primary-color);
    background: linear-gradient(135deg, #fef7ff, #fae8ff);
    box-shadow: var(--shadow-md);
}


.drag-slot.ready,
.story-letter-slot.ready {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px var(--primary-light), var(--shadow-sm);
}

.drag-slot.hover-fill,
.story-letter-slot.hover-fill {
    border-color: var(--accent-pink);
    box-shadow: 0 0 0 5px rgba(236, 72, 153, 0.2), var(--shadow-md);
    transform: scale(1.04);
}

.story-bank {
    max-width: 400px;
}

.target-word {
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 24px;
    padding: 24px;
    background: linear-gradient(135deg, var(--surface-elevated), rgba(139, 92, 246, 0.05));
    border-radius: var(--radius-xl);
    border: 3px dashed var(--primary-light);
    box-shadow: var(--shadow-sm);
}

.word-slots {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-bottom: 36px;
    flex-wrap: wrap;
}

.word-slot {
    width: 76px;
    height: 88px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.8rem;
    font-weight: 800;
    background: var(--surface-color);
    border: 4px dashed var(--border-color);
    border-radius: var(--radius-lg);
    color: var(--text-primary);
    transition: all var(--transition-bounce);
    box-shadow: var(--shadow-sm);
}

.word-slot.filled {
    border-style: solid;
    border-color: var(--primary-color);
    background: var(--primary-light);
    box-shadow: var(--shadow-md), var(--shadow-glow);
    transform: scale(1.02);
}

.word-slot.correct {
    border-color: var(--success-color);
    background: var(--success-light);
    box-shadow: var(--shadow-md), var(--shadow-glow-success);
}

.letter-choices {
    display: flex;
    justify-content: center;
    gap: 16px;
    flex-wrap: wrap;
}

.choice-btn {
    width: 76px;
    height: 76px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--text-primary);
    background: linear-gradient(180deg, var(--surface-color), var(--surface-elevated));
    border: 4px solid var(--border-color);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition-bounce);
    box-shadow: var(--shadow-sm);
    position: relative;
}

.choice-btn::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 50%;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.5), transparent);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    pointer-events: none;
}

.choice-btn:hover {
    transform: scale(1.12) translateY(-4px);
    border-color: var(--primary-color);
    box-shadow: var(--shadow-lg);
}

.choice-btn:active {
    transform: scale(0.92);
}

.choice-btn.used {
    opacity: 0.35;
    cursor: not-allowed;
    transform: none;
    filter: grayscale(0.5);
}


.story-container {
    padding: 24px;
}

.story-title {
    font-size: 1.8rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary-color), var(--accent-pink));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-align: center;
    margin-bottom: 28px;
}

.story-text {
    font-size: var(--child-font-size);
    line-height: 2.4;
    color: var(--text-primary);
    padding: 28px;
    background: linear-gradient(135deg, var(--surface-elevated), rgba(139, 92, 246, 0.03));
    border-radius: var(--radius-xl);
    border: 2px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.story-word {
    display: inline;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-bounce);
}

.story-word:hover {
    background: var(--primary-light);
    transform: scale(1.05);
}

.story-word.highlighted {
    background: linear-gradient(135deg, var(--primary-color), var(--accent-pink));
    color: white;
    box-shadow: var(--shadow-md), var(--shadow-glow);
}

.story-controls {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 28px;
}


.navigation-buttons {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 28px;
}

.nav-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 36px;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
    background: var(--surface-color);
    border: 3px solid var(--border-color);
    border-radius: var(--radius-xl);
    cursor: pointer;
    transition: all var(--transition-bounce);
    min-height: var(--touch-target-min);
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}

.nav-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 50%;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.5), transparent);
    pointer-events: none;
}

.nav-btn:hover:not(:disabled) {
    border-color: var(--primary-color);
    background: var(--primary-light);
    transform: translateY(-4px) scale(1.02);
    box-shadow: var(--shadow-lg);
}

.nav-btn:active:not(:disabled) {
    transform: translateY(0) scale(0.98);
}

.nav-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.nav-btn.primary {
    background: linear-gradient(135deg, var(--primary-color), var(--accent-pink));
    color: white;
    border-color: transparent;
    box-shadow: var(--shadow-md), 0 0 20px rgba(139, 92, 246, 0.3);
}

.nav-btn.primary:hover:not(:disabled) {
    background: linear-gradient(135deg, var(--primary-hover), #db2777);
    transform: translateY(-4px) scale(1.02);
    box-shadow: var(--shadow-xl), 0 0 30px rgba(139, 92, 246, 0.4);
}

.btn-icon {
    font-size: 1.4rem;
    transition: transform var(--transition-fast);
}

.nav-btn:hover .btn-icon {
    transform: translateX(4px);
}

.nav-btn:hover .btn-icon:first-child {
    transform: translateX(-4px);
}


.toast-container {
    position: fixed;
    bottom: 28px;
    right: 28px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

body.activity-fullscreen .toast-container {
    z-index: 10003;
}

.toast {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px 28px;
    background: var(--surface-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    border-left: 5px solid var(--primary-color);
    animation: slideIn 0.4s var(--transition-bounce), fadeOut 0.4s ease 2.6s forwards;
}

.toast.success {
    border-left-color: var(--success-color);
    background: linear-gradient(135deg, var(--surface-color), var(--success-light));
}

.toast.error {
    border-left-color: var(--danger-color);
}

.toast-icon {
    font-size: 1.6rem;
}

.toast-message {
    font-size: 1.05rem;
    color: var(--text-primary);
    font-weight: 600;
}

@keyframes slideIn {
    from {
        transform: translateX(100%) scale(0.8);
        opacity: 0;
    }

    to {
        transform: translateX(0) scale(1);
        opacity: 1;
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
        transform: scale(1);
    }

    to {
        opacity: 0;
        transform: scale(0.9);
    }
}


.help-box {
    background: linear-gradient(135deg, #fff6d8 0%, #fffaf0 45%, #fef3c7 100%);
    border: 2px solid rgba(245, 179, 0, 0.25);
    border-radius: calc(var(--radius-xl) + 8px);
    padding: 28px;
    margin-top: 28px;
    box-shadow: 0 18px 40px rgba(247, 170, 0, 0.16);
    position: relative;
    overflow: hidden;
}

.help-box::after {
    content: "";
    position: absolute;
    top: -60px;
    right: -80px;
    width: 220px;
    height: 220px;
    background: radial-gradient(circle, rgba(249, 115, 22, 0.18) 0%, rgba(249, 115, 22, 0) 70%);
    pointer-events: none;
}

.help-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.help-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.help-icon {
    font-size: 1.6rem;
    background: rgba(245, 158, 11, 0.18);
    padding: 10px 12px;
    border-radius: 16px;
}

.help-title strong {
    display: block;
    font-size: 1.35rem;
    color: #7a4b00;
    letter-spacing: 0.3px;
}

.help-stats {
    margin-top: 18px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.help-stat {
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(124, 58, 237, 0.08);
    border-radius: 18px;
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
}

.help-stat-label {
    font-size: 0.95rem;
    font-weight: 700;
    color: #92400e;
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

.help-stat-value {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
}

.help-divider {
    height: 2px;
    background: linear-gradient(90deg, rgba(245, 158, 11, 0) 0%, rgba(245, 158, 11, 0.45) 50%, rgba(245, 158, 11, 0) 100%);
    margin: 22px 0;
}

.help-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px 18px;
}

.help-list li {
    padding: 12px 14px 12px 42px;
    position: relative;
    color: #5b4b38;
    font-size: 1.02rem;
    line-height: 1.6;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 16px;
    border: 1px solid rgba(251, 146, 60, 0.15);
}

.help-list li::before {
    content: "✨";
    position: absolute;
    left: 14px;
    top: 12px;
    font-size: 1.05rem;
}

.help-footer {
    margin-top: 20px;
    display: flex;
    justify-content: flex-end;
}

.reset-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 14px 28px;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--danger-color);
    background: rgba(239, 68, 68, 0.1);
    border: 3px solid var(--danger-color);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition-bounce);
}

.reset-btn:hover {
    background: var(--danger-color);
    color: white;
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

@media (max-width: 900px) {
    .help-stats {
        grid-template-columns: 1fr;
    }

    .help-list {
        grid-template-columns: 1fr;
    }

    .help-footer {
        justify-content: center;
    }
}


.celebration {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10002;
}

.celebration.in-card {
    position: absolute;
    inset: 0;
    z-index: 10002;
}

.celebration.in-card .confetti {
    position: absolute;
}

.star-burst {
    position: absolute;
    font-size: 2.5rem;
    animation: starBurst 1.5s ease-out forwards;
    filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.8));
}

@keyframes starBurst {
    0% {
        opacity: 1;
        transform: scale(0) rotate(0deg);
    }

    40% {
        opacity: 1;
        transform: scale(1.8) rotate(180deg);
    }

    100% {
        opacity: 0;
        transform: scale(0.5) rotate(400deg) translateY(-150px);
    }
}


.confetti {
    position: fixed;
    width: 12px;
    height: 12px;
    border-radius: 2px;
    animation: confetti-fall 3s ease-out forwards;
}

@keyframes confetti-fall {
    0% {
        opacity: 1;
        transform: translateY(-100%) rotate(0deg);
    }

    100% {
        opacity: 0;
        transform: translateY(100vh) rotate(720deg);
    }
}


.mini-game-timer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 16px 28px;
    background: linear-gradient(135deg, var(--warning-light), rgba(251, 191, 36, 0.2));
    border-radius: var(--radius-full);
    border: 3px solid var(--warning-color);
    margin-bottom: 24px;
    width: fit-content;
    margin-left: auto;
    margin-right: auto;
}

.timer-icon {
    font-size: 1.5rem;
    animation: pulse-timer 1s ease-in-out infinite;
}

@keyframes pulse-timer {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.2);
    }
}

.timer-value {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--warning-color);
    font-family: monospace;
}

.timer-label {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
}


.category-pills {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
    margin-bottom: 24px;
}

.category-pill {
    padding: 10px 20px;
    border-radius: var(--radius-full);
    border: 2px solid var(--border-color);
    background: var(--surface-color);
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-bounce);
}

.category-pill:hover {
    border-color: var(--primary-color);
    background: var(--primary-light);
    transform: translateY(-2px);
}

.category-pill.active {
    border-color: var(--primary-color);
    background: linear-gradient(135deg, var(--primary-color), var(--accent-pink));
    color: white;
    box-shadow: var(--shadow-md), var(--shadow-glow);
}


.picture-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
}

.picture-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 20px;
    background: var(--surface-color);
    border-radius: var(--radius-xl);
    border: 4px solid var(--border-color);
    cursor: pointer;
    transition: all var(--transition-bounce);
}

.picture-card:hover {
    transform: translateY(-6px) scale(1.03);
    box-shadow: var(--shadow-xl);
    border-color: var(--primary-color);
}

.picture-card.selected {
    border-color: var(--primary-color);
    background: var(--primary-light);
    box-shadow: var(--shadow-glow);
}

.picture-card.matched {
    border-color: var(--success-color);
    background: var(--success-light);
}

.picture-emoji {
    font-size: 4rem;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.1));
}

.picture-label {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
}


@media (max-width: 768px) {
    .tool-header h1 {
        font-size: 2.2rem;
    }

    .tool-header .subtitle {
        font-size: 1.1rem;
    }

    .icon-reading {
        font-size: 4rem;
    }

    .phase-indicators {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 12px;
        padding: 16px;
        overflow: visible;
    }

    .phase-item {
        padding: 12px 10px;
        min-width: 0;
        width: 100%;
    }

    .phase-icon {
        font-size: 1.8rem;
    }

    .phase-label {
        font-size: 0.8rem;
    }

    .phase-action {
        display: inline-flex;
    }

    .phase-connector {
        display: none;
    }

    .stats-bar {
        gap: 14px;
        padding: 16px 18px;
    }

    .stat-item {
        flex-direction: column;
        gap: 6px;
        text-align: center;
        padding: 10px 14px;
    }

    .card-body {
        padding: 24px 18px;
    }

    .sounds-stage {
        grid-template-columns: 1fr;
        gap: 24px;
    }

    .sound-connection {
        flex-direction: row;
        width: 100%;
        justify-content: center;
    }

    .sound-connection .connection-line {
        width: 120px;
        height: 8px;
        background: repeating-linear-gradient(to right,
                var(--border-color),
                var(--border-color) 10px,
                transparent 10px,
                transparent 18px);
    }

    .sound-connection.linked .connection-line {
        background: repeating-linear-gradient(to right,
                var(--success-color),
                var(--success-color) 10px,
                transparent 10px,
                transparent 18px);
    }

    .shape-body {
        width: 110px;
        height: 110px;
    }

    .word-slot,
    .choice-btn {
        width: 62px;
        height: 72px;
        font-size: 2rem;
    }

    .navigation-buttons {
        flex-direction: column;
    }

    .nav-btn {
        justify-content: center;
    }

    .achievements-bar {
        gap: 12px;
    }

    .achievement-badge {
        padding: 10px 12px;
        min-width: 70px;
    }

    .badge-icon {
        font-size: 1.6rem;
    }

    .picture-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 14px;
    }

    .picture-emoji {
        font-size: 3rem;
    }
}

@media (max-width: 480px) {
    .tool-main {
        padding: 0 14px 36px;
    }

    .tool-header {
        padding: 28px 18px;
    }

    .tool-header h1 {
        font-size: 1.8rem;
    }

    .icon-reading {
        font-size: 3.5rem;
    }

    .header-icon::after {
        font-size: 1.4rem;
        top: -5px;
        right: -15px;
    }

    .phase-indicators {
        grid-template-columns: 1fr;
        gap: 10px;
        padding: 12px;
    }

    .phase-connector {
        display: none;
    }

    .phase-item {
        width: 100%;
        flex-direction: row;
        justify-content: flex-start;
        gap: 12px;
        padding: 12px 14px;
    }

    .phase-action {
        margin-left: auto;
    }

    .letter-card {
        width: 150px;
        min-height: 170px;
    }

    .letter-display {
        font-size: 4rem;
    }

    .shape-body {
        width: 100px;
        height: 100px;
    }

    .shape-face {
        width: 70px;
        height: 48px;
    }

    .shape-instructions {
        font-size: 1rem;
    }

    .toast-container {
        left: 14px;
        right: 14px;
        bottom: 14px;
    }

    .toast {
        padding: 14px 18px;
    }

    .lang-btn {
        width: 42px;
        height: 42px;
        font-size: 1.4rem;
    }

    .story-sentence {
        font-size: 1.4rem;
    }

    .story-letter-slot {
        width: 44px;
        height: 52px;
        font-size: 1.2rem;
    }

    .letter-tile {
        width: 46px;
        height: 52px;
        font-size: 1.2rem;
    }

    .nav-btn {
        padding: 14px 24px;
        font-size: 1.05rem;
    }

    .picture-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .picture-card {
        padding: 14px;
    }

    .picture-emoji {
        font-size: 2.5rem;
    }

    .picture-label {
        font-size: 1rem;
    }
}