@import url('https://fonts.googleapis.com/css2?family=Fredoka+One&family=Nunito:wght@700;800&display=swap');

*, *::before, *::after {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
}

body {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    font-family: 'Fredoka One', 'Comic Sans MS', cursive;
    background: var(--gradient, linear-gradient(160deg, #FFB3D9 0%, #E8CCFF 40%, #B3D9FF 70%, #C8FFE8 100%));
    background-attachment: fixed;
    overflow-x: hidden;
}

/* Floating sparkles */
.sparkles {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}
.sparkle {
    position: absolute;
    animation: float-up linear infinite;
    opacity: 0;
}
@keyframes float-up {
    0%   { transform: translateY(110vh) rotate(0deg);   opacity: 0; }
    8%   { opacity: 1; }
    92%  { opacity: 1; }
    100% { transform: translateY(-80px) rotate(360deg); opacity: 0; }
}

/* Layout */
.container {
    position: relative;
    z-index: 1;
    max-width: 860px;
    margin: 0 auto;
    padding: 16px 16px 40px;
}

/* Back button */
.back-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: white;
    color: var(--primary, #9B59B6);
    border: none;
    border-radius: 50px;
    padding: 12px 24px;
    font-family: inherit;
    font-size: 1.2rem;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0,0,0,0.18);
    margin-bottom: 16px;
    text-decoration: none;
    transition: transform 0.15s;
}
.back-btn:active { transform: scale(0.94); }

/* Star bar */
.star-bar {
    position: fixed;
    top: 14px;
    right: 14px;
    background: rgba(255,255,255,0.93);
    border-radius: 30px;
    padding: 8px 18px;
    font-size: 1.25rem;
    color: var(--primary, #9B59B6);
    box-shadow: 0 4px 15px rgba(0,0,0,0.18);
    z-index: 200;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Page title */
.page-title {
    text-align: center;
    font-size: clamp(1.8rem, 6vw, 3rem);
    color: white;
    text-shadow: 3px 3px 0 var(--primary, #9B59B6);
    margin: 0 0 20px;
}

/* Progress bar */
.progress-bar {
    background: rgba(255,255,255,0.45);
    border-radius: 20px;
    height: 18px;
    margin: 10px 0 18px;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent, #FF6EB4), var(--primary, #9B59B6));
    border-radius: 20px;
    transition: width 0.5s ease;
}

/* Confetti canvas */
#confetti-canvas {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 999;
    display: none;
}

/* Primary button */
.btn {
    background: linear-gradient(135deg, var(--accent, #FF6EB4), var(--primary, #9B59B6));
    color: white;
    border: none;
    border-radius: 50px;
    padding: 16px 34px;
    font-family: inherit;
    font-size: 1.35rem;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(155,89,182,0.38);
    transition: transform 0.15s;
}
.btn:active { transform: scale(0.94); }
.btn:disabled {
    opacity: 0.5;
    cursor: default;
}

/* Home cards */
.cards-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
    padding: 4px;
}
.card {
    background: white;
    border-radius: 28px;
    padding: 28px 16px;
    text-align: center;
    box-shadow: 0 8px 28px rgba(0,0,0,0.13);
    cursor: pointer;
    transition: transform 0.25s, box-shadow 0.25s;
    text-decoration: none;
    color: inherit;
    display: block;
}
.card:active { transform: scale(0.94); }
.card-emoji  { font-size: clamp(2.4rem, 9vw, 4rem); margin-bottom: 8px; }
.card-title  { font-size: clamp(1.1rem, 4vw, 1.5rem); color: var(--primary, #9B59B6); margin: 0; }
.card-sub    { font-size: 0.88rem; color: #BB8FCE; margin: 4px 0 0; font-family: 'Nunito', sans-serif; }

/* Letter grid */
.letter-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 9px;
}
.letter-btn {
    background: linear-gradient(135deg, #FF9EC9, #C9A0E8);
    color: white;
    border: none;
    border-radius: 16px;
    padding: 16px 4px 12px;
    font-family: inherit;
    font-size: clamp(1.5rem, 5vw, 2.1rem);
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.14);
    transition: transform 0.12s;
    line-height: 1.1;
}
.letter-btn .sub { display: block; font-size: 0.45em; margin-top: 3px; }
.letter-btn:active   { transform: scale(0.86); }
.letter-btn.learned  { background: linear-gradient(135deg, #FFD700, #FFA500); }

/* Popup overlay */
.popup-overlay {
    position: fixed;
    inset: 0;
    background: rgba(80,20,130,0.58);
    z-index: 499;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}
.popup-overlay.show { opacity: 1; pointer-events: all; }

/* Letter popup */
.letter-popup {
    position: fixed;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%) scale(0);
    background: white;
    border-radius: 36px;
    padding: 36px 48px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0,0,0,0.28);
    z-index: 500;
    min-width: 270px;
    max-width: 88vw;
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.letter-popup.show { transform: translate(-50%, -50%) scale(1); }
.popup-big-letter {
    font-size: clamp(5rem, 18vw, 8rem);
    background: linear-gradient(135deg, #FF6EB4, #9B59B6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1;
    margin-bottom: 6px;
}
.popup-emoji   { font-size: 3.5rem; margin: 6px 0; }
.popup-word    { font-size: 2rem; color: #9B59B6; margin: 4px 0; }
.popup-phrase  { font-size: 1rem; color: #BB8FCE; font-family: 'Nunito', sans-serif; margin: 4px 0 18px; }
.popup-close {
    background: linear-gradient(135deg, #FF6EB4, #9B59B6);
    color: white;
    border: none;
    border-radius: 50px;
    padding: 14px 36px;
    font-family: inherit;
    font-size: 1.25rem;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(155,89,182,0.38);
    transition: transform 0.12s;
}
.popup-close:active { transform: scale(0.94); }

/* Numbers page */
.big-number {
    font-size: clamp(5rem, 20vw, 8rem);
    color: white;
    text-shadow: 4px 4px 0 #9B59B6;
    line-height: 1;
    text-align: center;
}
.number-word {
    font-size: clamp(1.6rem, 5vw, 2.4rem);
    color: #9B59B6;
    background: white;
    border-radius: 18px;
    display: inline-block;
    padding: 8px 28px;
    box-shadow: 0 4px 14px rgba(0,0,0,0.1);
}
.items-display {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 12px;
    min-height: 160px;
    padding: 18px 10px;
    background: rgba(255,255,255,0.45);
    border-radius: 26px;
    margin: 16px 0;
}
.count-item {
    font-size: clamp(2.4rem, 8vw, 3.5rem);
    cursor: pointer;
    transition: transform 0.25s;
    filter: grayscale(0.55) brightness(0.85);
    opacity: 0.6;
}
.count-item.counted {
    filter: none;
    opacity: 1;
    transform: scale(1.25);
    animation: pop 0.3s ease;
}
@keyframes pop {
    0%   { transform: scale(0.7); }
    60%  { transform: scale(1.4); }
    100% { transform: scale(1.25); }
}
.nav-row {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 24px;
    margin-top: 18px;
}

/* Colors page */
.color-prompt {
    text-align: center;
    margin: 10px 0 20px;
}
.color-name {
    font-size: clamp(2.2rem, 8vw, 3.5rem);
    color: white;
    text-shadow: 3px 3px 0 rgba(0,0,0,0.25);
    margin: 0 0 6px;
}
.color-hint { font-size: 3.5rem; }
.color-choices {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
    max-width: 480px;
    margin: 0 auto;
}
.color-btn {
    aspect-ratio: 1;
    border: none;
    border-radius: 28px;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(0,0,0,0.18);
    transition: transform 0.15s;
    position: relative;
    overflow: hidden;
}
.color-btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.3) 0%, transparent 60%);
    border-radius: inherit;
    pointer-events: none;
}
.color-btn:active { transform: scale(0.93); }
.color-btn.correct { animation: correct-flash 0.55s ease; }
.color-btn.wrong   { animation: shake 0.5s ease; }
@keyframes correct-flash {
    0%, 100% { transform: scale(1); }
    45%       { transform: scale(1.12); box-shadow: 0 0 30px rgba(255,215,0,0.85); }
}
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%       { transform: translateX(-14px); }
    60%       { transform: translateX(14px); }
}
.score-display {
    text-align: center;
    font-size: 1.3rem;
    color: white;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.25);
    margin-bottom: 10px;
}

/* Tracing page */
.name-letters-row {
    display: flex;
    justify-content: center;
    gap: clamp(8px, 3vw, 18px);
    margin: 14px 0 18px;
}
.al {
    width: clamp(44px, 12vw, 62px);
    height: clamp(44px, 12vw, 62px);
    border-radius: 14px;
    background: rgba(255,255,255,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(1.4rem, 5vw, 1.9rem);
    color: #9B59B6;
    transition: background 0.3s, transform 0.3s;
    box-shadow: 0 3px 10px rgba(0,0,0,0.1);
}
.al.active {
    background: linear-gradient(135deg, #FF6EB4, #9B59B6);
    color: white;
    transform: scale(1.18);
}
.al.done {
    background: linear-gradient(135deg, #FFD700, #FFA500);
    color: white;
}
.tracing-wrap {
    position: relative;
    background: white;
    border-radius: 28px;
    overflow: hidden;
    box-shadow: 0 10px 36px rgba(0,0,0,0.18);
    touch-action: none;
}
.ghost-letter {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(10rem, 35vw, 16rem);
    color: rgba(180,140,220,0.22);
    pointer-events: none;
    z-index: 1;
    animation: ghost-pulse 2.5s ease-in-out infinite;
    line-height: 1;
}
@keyframes ghost-pulse {
    0%, 100% { color: rgba(180,140,220,0.22); }
    50%       { color: rgba(180,140,220,0.35); }
}
#trace-canvas {
    display: block;
    width: 100%;
    height: clamp(260px, 45vw, 400px);
    position: relative;
    z-index: 2;
    touch-action: none;
    cursor: crosshair;
}
.trace-hint {
    text-align: center;
    color: #BB8FCE;
    font-size: 1rem;
    font-family: 'Nunito', sans-serif;
    padding: 10px;
}
.trace-controls {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-top: 16px;
}
.btn-clear {
    background: rgba(255,255,255,0.7);
    color: #9B59B6;
    border: 2px solid #D7A8F0;
    border-radius: 50px;
    padding: 14px 28px;
    font-family: inherit;
    font-size: 1.2rem;
    cursor: pointer;
    transition: transform 0.12s;
}
.btn-clear:active { transform: scale(0.94); }

/* Celebration popup — a centered card so the message is always readable
   over busy game screens. The large box-shadow spread doubles as a
   full-screen dim "scrim" behind the card, with no extra HTML element. */
.celebration-overlay {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.85);
    width: min(86vw, 400px);
    background: #fff;
    border-radius: 32px;
    padding: 32px 28px 26px;
    box-shadow: 0 24px 60px rgba(45,12,70,0.40),
                0 0 0 100vmax rgba(45,12,70,0.50);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    z-index: 900;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease,
                transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.celebration-overlay.show {
    opacity: 1;
    pointer-events: all;
    transform: translate(-50%, -50%) scale(1);
}
.celebrate-text {
    font-size: clamp(1.9rem, 7vw, 2.8rem);
    color: #6A2C91;
    line-height: 1.12;
    animation: bounce-in 0.5s ease;
    margin: 0 0 10px;
}
.celebrate-sub {
    font-size: clamp(1.05rem, 4vw, 1.5rem);
    color: #6E5F86;
    margin: 0 0 22px;
    font-family: 'Nunito', sans-serif;
    font-weight: 700;
    line-height: 1.3;
}
@keyframes bounce-in {
    0%   { transform: scale(0) rotate(-10deg); }
    60%  { transform: scale(1.2) rotate(5deg); }
    100% { transform: scale(1) rotate(0); }
}

@media (max-width: 420px) {
    .cards-grid { gap: 12px; }
    .card { padding: 20px 10px; }
    .letter-grid { gap: 7px; }
}

/* ============================================================
   Phase 1: Guided learning path
   ============================================================ */

/* Today's Magic Lesson banner */
.lesson-banner {
    display: block;
    background: linear-gradient(135deg, #FFD700 0%, #FF8E53 55%, #FF6EB4 100%);
    border-radius: 28px;
    padding: 22px 22px 24px;
    margin: 0 4px 22px;
    text-align: center;
    color: white;
    box-shadow: 0 10px 32px rgba(255,140,80,0.45);
    text-decoration: none;
    position: relative;
    overflow: hidden;
    transition: transform 0.2s;
}
.lesson-banner:active { transform: scale(0.97); }
.lesson-banner::before {
    content: '✨';
    position: absolute;
    top: 8px; left: 12px;
    font-size: 1.4rem;
    opacity: 0.85;
    animation: ghost-pulse 2.4s ease-in-out infinite;
}
.lesson-banner::after {
    content: '✨';
    position: absolute;
    bottom: 8px; right: 14px;
    font-size: 1.4rem;
    opacity: 0.85;
    animation: ghost-pulse 2.4s ease-in-out infinite 0.6s;
}
.lesson-eyebrow {
    font-family: 'Nunito', sans-serif;
    font-size: 0.85rem;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    opacity: 0.95;
    margin: 0 0 4px;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.18);
}
.lesson-title {
    font-size: clamp(1.4rem, 5.5vw, 2rem);
    margin: 4px 0 12px;
    text-shadow: 2px 2px 0 rgba(0,0,0,0.18);
    line-height: 1.15;
}
.lesson-emoji { font-size: 2.4rem; display: block; margin-bottom: 4px; }
.lesson-cta {
    display: inline-block;
    background: white;
    color: #9B59B6;
    border-radius: 50px;
    padding: 12px 26px;
    font-family: inherit;
    font-size: 1.1rem;
    box-shadow: 0 4px 14px rgba(0,0,0,0.18);
}
.lesson-banner.complete {
    background: linear-gradient(135deg, #A29BFE 0%, #6C5CE7 100%);
    box-shadow: 0 8px 24px rgba(108,92,231,0.4);
}
.lesson-banner.complete .lesson-eyebrow::after { content: ' — done!'; }

/* 6-card activity path */
.path-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
    padding: 0 4px;
}
@media (min-width: 720px) {
    .path-grid { grid-template-columns: repeat(3, 1fr); }
}

.path-card {
    position: relative;
    background: white;
    border-radius: 24px;
    padding: 22px 14px 16px;
    text-align: center;
    box-shadow: 0 6px 22px rgba(0,0,0,0.12);
    text-decoration: none;
    color: inherit;
    transition: transform 0.2s, box-shadow 0.2s;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    min-height: 160px;
}
.path-card:active { transform: scale(0.95); }
.path-card-emoji {
    font-size: clamp(2.4rem, 9vw, 3.4rem);
    margin-bottom: 6px;
    line-height: 1;
}
.path-card-title {
    font-size: clamp(1rem, 3.5vw, 1.25rem);
    color: #9B59B6;
    margin: 0 0 6px;
    line-height: 1.15;
}
.path-progress {
    margin-top: auto;
    background: linear-gradient(135deg, #FFE5F1, #EAD5FF);
    color: #7D3C98;
    font-family: 'Nunito', sans-serif;
    font-weight: 700;
    font-size: 0.85rem;
    padding: 5px 12px;
    border-radius: 50px;
    display: inline-block;
    line-height: 1.2;
}

/* "Coming Soon" disabled card variant */
.path-card.disabled {
    background: rgba(255,255,255,0.55);
    cursor: not-allowed;
    pointer-events: none;
    opacity: 0.7;
}
.path-card.disabled .path-card-title { color: #B395C8; }
.coming-soon-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    background: #9B59B6;
    color: white;
    font-family: 'Nunito', sans-serif;
    font-weight: 800;
    font-size: 0.65rem;
    letter-spacing: 0.7px;
    text-transform: uppercase;
    padding: 4px 9px;
    border-radius: 50px;
    box-shadow: 0 2px 6px rgba(155,89,182,0.45);
}

/* ============================================================
   Phase 1: Sticker board
   ============================================================ */
.sticker-summary {
    background: rgba(255,255,255,0.85);
    border-radius: 22px;
    padding: 18px;
    text-align: center;
    box-shadow: 0 6px 20px rgba(0,0,0,0.12);
    margin-bottom: 16px;
}
.sticker-summary .count {
    font-size: clamp(2rem, 8vw, 3rem);
    color: #9B59B6;
    margin: 0;
    line-height: 1;
}
.sticker-summary .label {
    font-family: 'Nunito', sans-serif;
    font-size: 1rem;
    color: #7D3C98;
    margin: 6px 0 0;
}
.sticker-next {
    margin-top: 10px;
    background: linear-gradient(135deg,#FFD700,#FF8E53);
    color: white;
    border-radius: 50px;
    padding: 6px 18px;
    font-family: 'Nunito', sans-serif;
    font-weight: 800;
    font-size: 0.95rem;
    display: inline-block;
    box-shadow: 0 3px 10px rgba(255,140,80,0.4);
}

.sticker-board {
    background: white;
    border-radius: 26px;
    padding: 18px;
    box-shadow: 0 8px 26px rgba(0,0,0,0.14);
    background-image:
        radial-gradient(rgba(155,89,182,0.06) 1.5px, transparent 1.5px),
        radial-gradient(rgba(255,110,180,0.06) 1.5px, transparent 1.5px);
    background-size: 18px 18px;
    background-position: 0 0, 9px 9px;
}
.sticker-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}
@media (min-width: 560px) {
    .sticker-grid { grid-template-columns: repeat(5, 1fr); }
}
@media (min-width: 760px) {
    .sticker-grid { grid-template-columns: repeat(6, 1fr); }
}
.sticker-slot {
    aspect-ratio: 1;
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(1.8rem, 7vw, 2.6rem);
    position: relative;
    transition: transform 0.2s;
}
.sticker-slot.filled {
    background: linear-gradient(135deg, #FFF6F9, #F4E8FF);
    box-shadow: 0 4px 12px rgba(155,89,182,0.18);
    animation: sticker-pop 0.5s ease;
}
.sticker-slot.empty {
    background: rgba(155,89,182,0.06);
    border: 2.5px dashed rgba(155,89,182,0.32);
    color: rgba(155,89,182,0.35);
}
.sticker-slot.new::after {
    content: 'NEW';
    position: absolute;
    top: -6px;
    right: -4px;
    background: #FF3B30;
    color: white;
    font-family: 'Nunito', sans-serif;
    font-weight: 800;
    font-size: 0.55rem;
    letter-spacing: 0.5px;
    padding: 3px 7px;
    border-radius: 50px;
    box-shadow: 0 2px 6px rgba(255,59,48,0.4);
    animation: bounce-in 0.5s ease;
}
@keyframes sticker-pop {
    0%   { transform: scale(0) rotate(-20deg); }
    60%  { transform: scale(1.2) rotate(10deg); }
    100% { transform: scale(1) rotate(0); }
}
.sticker-empty-msg {
    text-align: center;
    color: white;
    font-size: 1.15rem;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.25);
    margin: 16px 0 0;
}

/* ============================================================
   Phase 1: Lesson page
   ============================================================ */
.lesson-page {
    text-align: center;
    padding: 40px 24px;
    background: white;
    border-radius: 32px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.14);
    margin: 12px 4px;
}
.lesson-page-eyebrow {
    font-family: 'Nunito', sans-serif;
    color: #BB8FCE;
    letter-spacing: 2px;
    text-transform: uppercase;
    font-weight: 800;
    font-size: 0.9rem;
}
.lesson-page-emoji  { font-size: clamp(4rem, 16vw, 6rem); line-height: 1; margin: 10px 0; }
.lesson-page-title  {
    font-size: clamp(1.8rem, 7vw, 2.6rem);
    color: #9B59B6;
    margin: 6px 0 22px;
}
.lesson-page-encouragement {
    font-family: 'Nunito', sans-serif;
    color: #7D3C98;
    font-size: 1.05rem;
    margin: 0 0 22px;
    line-height: 1.5;
}
.lesson-go-btn {
    background: linear-gradient(135deg, #FF6EB4, #9B59B6);
    color: white;
    border: none;
    border-radius: 50px;
    padding: 18px 42px;
    font-family: inherit;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: 0 8px 22px rgba(155,89,182,0.4);
    text-decoration: none;
    display: inline-block;
    transition: transform 0.15s;
}
.lesson-go-btn:active { transform: scale(0.95); }
.lesson-page.done .lesson-page-title::after { content: ' ✓'; color: #4CD964; }
.lesson-alt-link {
    display: block;
    margin-top: 18px;
    color: #9B59B6;
    text-decoration: underline;
    font-family: 'Nunito', sans-serif;
    font-size: 0.95rem;
}

/* ============================================================
   Phase 2: Name Mastery
   ============================================================ */

.hub-intro {
    text-align: center;
    color: white;
    font-size: clamp(1rem, 3.8vw, 1.3rem);
    text-shadow: 1px 1px 3px rgba(0,0,0,0.25);
    margin: 8px 0 14px;
}

.name-progress-pill {
    display: block;
    text-align: center;
    background: linear-gradient(135deg, #FFD700, #FF8E53);
    color: white;
    border-radius: 50px;
    padding: 8px 22px;
    font-family: 'Nunito', sans-serif;
    font-weight: 800;
    font-size: 1rem;
    margin: 0 auto 22px;
    width: fit-content;
    box-shadow: 0 4px 12px rgba(255,140,80,0.4);
    text-shadow: 1px 1px 2px rgba(0,0,0,0.18);
}

.level-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
    padding: 0 4px;
}

.level-card {
    position: relative;
    background: white;
    border-radius: 24px;
    padding: 18px 12px;
    text-align: center;
    box-shadow: 0 6px 22px rgba(0,0,0,0.14);
    text-decoration: none;
    color: inherit;
    transition: transform 0.2s;
    min-height: 160px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
.level-card:active { transform: scale(0.95); }

.level-card.locked {
    background: rgba(255,255,255,0.55);
    cursor: not-allowed;
    pointer-events: none;
    opacity: 0.7;
}

.level-card.complete {
    background: linear-gradient(135deg, #FFD700, #FFA500);
    color: white;
    box-shadow: 0 6px 22px rgba(255,165,0,0.4);
}
.level-card.complete .level-title,
.level-card.complete .level-num,
.level-card.complete .level-sub { color: white; }

.level-num {
    font-family: 'Nunito', sans-serif;
    font-weight: 800;
    font-size: 0.72rem;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: #BB8FCE;
    margin-bottom: 4px;
}
.level-emoji { font-size: clamp(2rem, 7vw, 2.8rem); margin: 4px 0; line-height: 1; }
.level-title {
    font-size: clamp(0.95rem, 3.5vw, 1.15rem);
    color: #9B59B6;
    margin: 4px 0 4px;
    line-height: 1.2;
}
.level-sub {
    font-size: 0.78rem;
    color: #BB8FCE;
    font-family: 'Nunito', sans-serif;
    margin: 0;
    line-height: 1.3;
    padding: 0 4px;
}
.level-check {
    margin-top: 8px;
    background: rgba(255,255,255,0.32);
    border-radius: 50px;
    padding: 3px 12px;
    font-family: 'Nunito', sans-serif;
    font-weight: 800;
    font-size: 0.75rem;
}

.all-mastered-banner {
    text-align: center;
    background: linear-gradient(135deg, #FF6EB4, #9B59B6);
    color: white;
    border-radius: 22px;
    padding: 18px;
    margin-top: 22px;
    font-size: 1.3rem;
    box-shadow: 0 6px 22px rgba(155,89,182,0.4);
    text-shadow: 1px 1px 3px rgba(0,0,0,0.2);
}

/* Level 1 — Recognize the name */
.name-word-grid {
    display: flex;
    flex-direction: column;
    gap: 14px;
    max-width: 420px;
    margin: 0 auto;
}
.name-word-btn {
    background: white;
    color: #9B59B6;
    border: 4px solid transparent;
    border-radius: 24px;
    padding: 22px 24px;
    font-family: inherit;
    font-size: clamp(2rem, 7vw, 2.8rem);
    cursor: pointer;
    box-shadow: 0 6px 18px rgba(0,0,0,0.14);
    transition: transform 0.15s, border-color 0.2s, background 0.2s;
    letter-spacing: 0.06em;
}
.name-word-btn:active { transform: scale(0.96); }
.name-word-btn.reading {
    border-color: #FFD700;
    background: linear-gradient(135deg, #FFF6CC, #FFE9CC);
}
.name-word-btn.correct {
    background: linear-gradient(135deg, #FFD700, #FF8E53);
    color: white;
    animation: correct-flash 0.55s ease;
}
.name-word-btn.wrong {
    animation: shake 0.5s ease;
    border-color: #FF6B6B;
}

/* Level 2 — Spell the name */
.spell-target {
    display: flex;
    justify-content: center;
    gap: clamp(6px, 2vw, 14px);
    margin: 14px 0 4px;
    flex-wrap: wrap;
}
.spell-slot {
    width: clamp(46px, 13vw, 68px);
    height: clamp(58px, 16vw, 82px);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(1.9rem, 7vw, 2.8rem);
    background: rgba(255,255,255,0.55);
    color: rgba(155,89,182,0.32);
    box-shadow: inset 0 0 0 3px rgba(155,89,182,0.25);
    transition: all 0.3s;
}
.spell-slot.filled {
    background: linear-gradient(135deg, #FFD700, #FFA500);
    color: white;
    box-shadow: 0 6px 16px rgba(255,165,0,0.45);
    animation: bounce-in 0.4s ease;
}

.spell-tiles {
    display: flex;
    justify-content: center;
    gap: clamp(8px, 2.5vw, 16px);
    flex-wrap: wrap;
    margin: 24px 0 16px;
    padding: 18px 12px;
    background: rgba(255,255,255,0.45);
    border-radius: 26px;
}
.spell-tile {
    width: clamp(56px, 15vw, 76px);
    height: clamp(56px, 15vw, 76px);
    border-radius: 18px;
    background: linear-gradient(135deg, #FF9EC9, #C9A0E8);
    color: white;
    border: none;
    font-family: inherit;
    font-size: clamp(1.9rem, 6.5vw, 2.6rem);
    cursor: pointer;
    box-shadow: 0 5px 14px rgba(155,89,182,0.32);
    transition: transform 0.15s, opacity 0.2s;
}
.spell-tile:active { transform: scale(0.9); }
.spell-tile.used {
    background: rgba(155,89,182,0.18);
    color: transparent;
    box-shadow: none;
    cursor: default;
}
.spell-tile.wrong { animation: shake 0.5s ease; }

/* Level 4 — Full-name tracing (overrides single-letter ghost size) */
.ghost-letter.ghost-full-name {
    font-size: clamp(2.4rem, 9vw, 4.5rem);
    letter-spacing: 0.08em;
}

/* Shared feedback line for Phase 2 games */
.phase2-feedback {
    text-align: center;
    font-size: clamp(1.1rem, 4vw, 1.5rem);
    color: white;
    text-shadow: 2px 2px 0 rgba(0,0,0,0.2);
    min-height: 1.8em;
    margin: 10px 0;
    transition: opacity 0.3s;
}

/* ============================================================
   Phase 3: Alphabet — Find the Letter game + AUBREY highlights
   ============================================================ */

.find-prompt {
    text-align: center;
    color: white;
    font-size: clamp(1.3rem, 5vw, 1.8rem);
    text-shadow: 2px 2px 0 #9B59B6;
    margin: 6px 0 8px;
}
.find-prompt strong {
    color: #FFD700;
    font-size: 1.3em;
}

.streak-row {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}
.streak-pill {
    background: linear-gradient(135deg, #FF6EB4, #9B59B6);
    color: white;
    border-radius: 50px;
    padding: 6px 16px;
    font-family: 'Nunito', sans-serif;
    font-weight: 800;
    font-size: 0.95rem;
    box-shadow: 0 4px 12px rgba(155,89,182,0.35);
}
.streak-hear {
    background: rgba(255,255,255,0.92);
    color: #9B59B6;
    border: none;
    border-radius: 50px;
    padding: 6px 16px;
    font-family: inherit;
    font-size: 0.95rem;
    cursor: pointer;
    box-shadow: 0 3px 10px rgba(0,0,0,0.12);
}
.streak-hear:active { transform: scale(0.95); }

.find-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
    max-width: 460px;
    margin: 0 auto;
}
.find-tile {
    background: linear-gradient(135deg, #FFA5D2, #C9A0E8);
    color: white;
    border: 4px solid transparent;
    border-radius: 22px;
    padding: 28px 10px;
    font-family: inherit;
    font-size: clamp(3.2rem, 13vw, 5rem);
    cursor: pointer;
    box-shadow: 0 6px 18px rgba(155,89,182,0.32);
    transition: transform 0.15s, border-color 0.2s, background 0.3s;
    line-height: 1;
}
.find-tile:active { transform: scale(0.94); }
.find-tile.correct {
    background: linear-gradient(135deg, #FFD700, #FF8E53);
    border-color: #FFD700;
    animation: correct-flash 0.55s ease;
}
.find-tile.wrong {
    animation: shake 0.5s ease;
    border-color: #FF6B6B;
}

/* ============================================================
   Phase 4: Numbers — find-the-number tile variants
   ============================================================ */

/* Number tiles show digit + emoji stacked */
.find-tile.num-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 18px 10px;
}
.num-tile-digit {
    font-size: clamp(2.8rem, 11vw, 4.2rem);
    line-height: 1;
}
.num-tile-emoji {
    font-size: clamp(1.4rem, 5vw, 2rem);
    line-height: 1;
}

/* Highlight AUBREY's own letters on the Learn page */
.letter-btn.is-name-letter {
    box-shadow: 0 0 0 3px #FFD700, 0 5px 14px rgba(255,215,0,0.5);
}
.letter-btn.is-name-letter::before {
    content: '💖';
    position: absolute;
    top: 4px;
    left: 6px;
    font-size: 0.75rem;
}
