/* ════════════════════════════════════════════════════════════════
   Neal School – Kid-friendly interactive learning app
   ════════════════════════════════════════════════════════════════ */

/* ── Reset & Globals ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg: #f0eaff;
    --bg2: #e4dcf5;
    --text: #333;
    --text-light: #777;
    --card: #fff;
    --shadow: 0 4px 16px rgba(0,0,0,.1);
    --radius: 20px;
    --radius-sm: 12px;
    --green: #4CAF50;
    --red: #ef5350;
    --gold: #FFD700;
    --font: 'Nunito', 'Segoe UI', system-ui, sans-serif;
}

html, body {
    height: 100%; width: 100%;
    overflow: hidden;
    font-family: var(--font);
    background: linear-gradient(135deg, var(--bg), var(--bg2));
    color: var(--text);
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    overscroll-behavior: none;
}

/* ── Screen system ───────────────────────────────────────────── */
#app { height: 100%; width: 100%; position: relative; }

.screen {
    display: none;
    flex-direction: column;
    align-items: center;
    height: 100%; width: 100%;
    padding: 16px;
    padding: 16px max(16px, env(safe-area-inset-right)) 16px max(16px, env(safe-area-inset-left));
    padding-top: max(16px, env(safe-area-inset-top));
    padding-bottom: max(16px, env(safe-area-inset-bottom));
    position: absolute; top: 0; left: 0;
    animation: screenIn .35s ease;
    overflow: hidden;
}
.screen.active { display: flex; }

@keyframes screenIn {
    from { opacity: 0; transform: translateY(24px) scale(.97); }
    to   { opacity: 1; transform: none; }
}

/* ── Typography ──────────────────────────────────────────────── */
.title-big {
    font-size: clamp(1.8rem, 5vw, 2.6rem);
    font-weight: 900;
    text-align: center;
    margin: 24px 0 20px;
}

h2 { font-size: 1.3rem; font-weight: 700; }

.hint { color: var(--text-light); text-align: center; margin-top: 12px; font-size: .95rem; }

/* ── Top bar ─────────────────────────────────────────────────── */
.top-bar {
    width: 100%; max-width: 600px;
    display: flex; align-items: center; justify-content: space-between;
    gap: 8px; padding: 4px 0;
    flex-shrink: 0;
}

.btn-icon {
    width: 48px; height: 48px;
    border: none; border-radius: 50%;
    background: rgba(255,255,255,.6);
    font-size: 1.4rem; cursor: pointer;
    display: grid; place-items: center;
    transition: transform .15s;
}
.btn-icon:active { transform: scale(.88); }

.star-badge {
    background: linear-gradient(135deg, #fff3bf, #ffe066);
    padding: 6px 14px; border-radius: 30px;
    font-weight: 700; font-size: 1rem;
    box-shadow: 0 2px 6px rgba(0,0,0,.1);
}

/* ── Profile selection ───────────────────────────────────────── */
.profile-grid {
    display: flex; gap: 32px;
    justify-content: center; flex-wrap: wrap;
    margin-top: 20px;
}

.profile-btn {
    display: flex; flex-direction: column; align-items: center; gap: 12px;
    background: none; border: none; cursor: pointer;
    animation: bounceIn .6s ease both;
}
.profile-btn:nth-child(2) { animation-delay: .15s; }
.profile-btn:active .avatar { transform: scale(.9); }

.avatar {
    width: 140px; height: 140px;
    border-radius: 50%;
    display: grid; place-items: center;
    font-size: 3.5rem; font-weight: 900; color: #fff;
    box-shadow: 0 8px 24px rgba(0,0,0,.15);
    transition: transform .2s;
}

.profile-btn span:last-child {
    font-size: 1.5rem; font-weight: 700; color: var(--text);
}

@keyframes bounceIn {
    0%   { opacity: 0; transform: scale(.3); }
    50%  { transform: scale(1.08); }
    100% { opacity: 1; transform: scale(1); }
}

/* ── Menu grid ───────────────────────────────────────────────── */
.menu-grid {
    display: grid; grid-template-columns: 1fr 1fr;
    gap: 16px; width: 100%; max-width: 400px;
    margin-top: 20px;
}

.menu-btn {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 8px; padding: 24px 12px;
    border: none; border-radius: var(--radius);
    background: var(--c, #5B9BD5);
    color: #fff; font-family: var(--font);
    font-size: 1.1rem; font-weight: 700;
    cursor: pointer;
    box-shadow: 0 6px 0 color-mix(in srgb, var(--c, #5B9BD5) 80%, #000),
                0 8px 20px rgba(0,0,0,.12);
    transition: transform .12s, box-shadow .12s;
}
.menu-btn:active {
    transform: translateY(4px);
    box-shadow: 0 2px 0 color-mix(in srgb, var(--c, #5B9BD5) 80%, #000),
                0 4px 8px rgba(0,0,0,.1);
}

.menu-icon { font-size: 2.2rem; }

/* ── Scroll area ─────────────────────────────────────────────── */
.scroll-area {
    flex: 1; width: 100%; max-width: 600px;
    overflow-y: auto; padding-bottom: 20px;
    -webkit-overflow-scrolling: touch;
}

/* ── Guide list ──────────────────────────────────────────────── */
.guide-list { display: flex; flex-direction: column; gap: 12px; padding: 8px 0; }

.guide-card {
    display: flex; align-items: center; gap: 14px;
    padding: 18px 20px;
    background: var(--card); border-radius: var(--radius-sm);
    box-shadow: var(--shadow); cursor: pointer;
    transition: transform .15s;
}
.guide-card:active { transform: scale(.97); }
.guide-card .g-icon { font-size: 2rem; }
.guide-card .g-info { flex: 1; }
.guide-card .g-title { font-weight: 700; font-size: 1.1rem; }
.guide-card .g-sub { font-size: .85rem; color: var(--text-light); }
.guide-card .g-arrow { font-size: 1.4rem; color: #bbb; }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn-round {
    padding: 14px 28px;
    border: none; border-radius: 40px;
    font-family: var(--font); font-size: 1.05rem; font-weight: 700;
    cursor: pointer; transition: transform .12s;
    display: inline-flex; align-items: center; gap: 6px;
}
.btn-round:active { transform: scale(.93); }
.btn-add { background: var(--green); color: #fff; margin-top: 12px; align-self: center; }
.btn-cancel { background: #ddd; color: #555; }
.btn-save { background: var(--green); color: #fff; }

/* ── Builder ─────────────────────────────────────────────────── */
.builder-content { width: 100%; max-width: 600px; }

.guide-header-edit {
    display: flex; gap: 10px; align-items: center;
    margin-bottom: 8px;
}

.input-big {
    flex: 1; padding: 14px 18px;
    border: 2px solid #ddd; border-radius: var(--radius-sm);
    font-family: var(--font); font-size: 1.1rem;
    outline: none; transition: border-color .2s;
}
.input-big:focus { border-color: #5B9BD5; }

.btn-emoji {
    width: 52px; height: 52px;
    border: 2px solid #ddd; border-radius: var(--radius-sm);
    background: var(--card); font-size: 1.6rem;
    cursor: pointer; display: grid; place-items: center;
}

.icon-picker {
    display: flex; flex-wrap: wrap; gap: 8px;
    padding: 10px; background: var(--card);
    border-radius: var(--radius-sm); margin-bottom: 10px;
    box-shadow: var(--shadow);
}
.icon-picker.hidden { display: none; }
.icon-option {
    width: 44px; height: 44px;
    border: none; border-radius: 8px;
    background: var(--bg); font-size: 1.4rem;
    cursor: pointer; display: grid; place-items: center;
}
.icon-option:active { background: #d0c4f0; }

.card-list { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }

.card-item {
    display: flex; align-items: center; gap: 12px;
    padding: 14px 16px;
    background: var(--card); border-radius: var(--radius-sm);
    box-shadow: 0 2px 8px rgba(0,0,0,.06);
    cursor: pointer; transition: transform .1s;
}
.card-item:active { transform: scale(.97); }
.card-item .c-num {
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--bg); display: grid; place-items: center;
    font-weight: 700; font-size: .9rem; flex-shrink: 0;
}
.card-item .c-text { flex: 1; font-size: .95rem; }
.card-item .c-text em { color: var(--text-light); font-style: normal; }
.card-item .c-del {
    width: 36px; height: 36px;
    border: none; border-radius: 50%;
    background: #fee; color: var(--red);
    font-size: 1.1rem; cursor: pointer;
    display: grid; place-items: center;
}

/* ── Flipbook ────────────────────────────────────────────────── */
.flipbook-area {
    flex: 1; display: flex; align-items: center; justify-content: center;
    gap: 12px; width: 100%; max-width: 600px;
}

.flip-arrow {
    width: 56px; height: 56px;
    border: none; border-radius: 50%;
    background: rgba(255,255,255,.7);
    font-size: 2rem; cursor: pointer;
    display: grid; place-items: center;
    transition: transform .15s; flex-shrink: 0;
}
.flip-arrow:active { transform: scale(.85); }

.flip-card {
    width: 280px; height: 360px;
    perspective: 800px; cursor: pointer;
}

.flip-inner {
    width: 100%; height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform .5s;
}
.flip-card.flipped .flip-inner { transform: rotateY(180deg); }

.flip-face {
    position: absolute; inset: 0;
    backface-visibility: hidden;
    border-radius: var(--radius);
    background: var(--card);
    box-shadow: var(--shadow);
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    padding: 24px; font-size: 1.4rem; font-weight: 700;
    text-align: center; overflow: hidden;
}
.flip-back {
    transform: rotateY(180deg);
    background: linear-gradient(135deg, #e8f5e9, #c8e6c9);
}

.flip-face img {
    max-width: 100%; max-height: 60%;
    border-radius: 12px; margin-bottom: 12px;
}

.flip-counter { font-weight: 700; font-size: 1rem; }

.flip-dots {
    display: flex; gap: 8px; margin-top: 12px; flex-shrink: 0;
}
.flip-dot {
    width: 12px; height: 12px; border-radius: 50%;
    background: #ccc; transition: background .2s;
}
.flip-dot.active { background: #5B9BD5; }

/* ── Game type select ────────────────────────────────────────── */
.game-type-grid {
    display: grid; grid-template-columns: 1fr 1fr;
    gap: 14px; width: 100%; max-width: 400px; margin-top: 20px;
}
.game-type { padding: 22px 12px; }
.game-type:disabled { opacity: .4; pointer-events: none; }
.game-type.full-width { grid-column: 1 / -1; }

/* ── Game play ───────────────────────────────────────────────── */
.game-progress { display: flex; align-items: center; gap: 6px; flex: 1; min-width: 0; }
.game-progress span { white-space: nowrap; font-size: .9rem; }
.progress-track {
    flex: 1; height: 10px; background: #ddd;
    border-radius: 5px; overflow: hidden;
}
.progress-fill {
    height: 100%; background: linear-gradient(90deg, var(--green), #81c784);
    border-radius: 5px; transition: width .4s;
    width: 0;
}

.game-area {
    flex: 1; width: 100%; max-width: 500px;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 20px; padding: 12px 0;
    overflow-y: auto; -webkit-overflow-scrolling: touch;
    min-height: 0;
}

/* Tap game */
.tap-question {
    font-size: 1.5rem; font-weight: 700;
    text-align: center; padding: 20px;
    background: var(--card); border-radius: var(--radius);
    box-shadow: var(--shadow); width: 100%;
    min-height: 100px; display: flex;
    align-items: center; justify-content: center;
    flex-direction: column; gap: 8px;
}
.tap-question img {
    max-height: 120px; border-radius: 12px;
}

.tap-answers {
    display: flex; flex-direction: column; gap: 14px;
    width: 100%;
}

.tap-btn {
    padding: 22px 20px;
    border: 3px solid transparent; border-radius: var(--radius-sm);
    background: var(--card);
    font-family: var(--font); font-size: 1.3rem; font-weight: 700;
    cursor: pointer; box-shadow: var(--shadow);
    transition: transform .12s, border-color .2s, background .2s;
}
.tap-btn:active { transform: scale(.96); }
.tap-btn.correct {
    border-color: var(--green); background: #e8f5e9;
    animation: popCorrect .5s ease;
}
.tap-btn.wrong {
    animation: shakeWrong .4s ease;
}
.tap-btn.reading, .sort-bucket.reading {
    border-color: #FFD166;
    background: #FFF8E1;
    transform: scale(1.06);
    box-shadow: 0 0 14px rgba(255, 209, 102, .5);
    transition: transform .2s, border-color .2s, background .2s, box-shadow .2s;
}
.btn-hear-answers {
    display: block;
    margin: 6px auto 0;
    padding: 8px 18px;
    border: 2px solid var(--accent);
    border-radius: 24px;
    background: rgba(91, 155, 213, .1);
    font-family: var(--font);
    font-size: 1rem;
    font-weight: 700;
    color: var(--accent);
    cursor: pointer;
    transition: transform .12s, background .15s;
}
.btn-hear-answers:active {
    transform: scale(.94);
    background: rgba(91, 155, 213, .25);
}

@keyframes popCorrect {
    0%, 100% { transform: scale(1); }
    40% { transform: scale(1.06); }
}
@keyframes shakeWrong {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-12px); }
    40% { transform: translateX(10px); }
    60% { transform: translateX(-8px); }
    80% { transform: translateX(6px); }
}

.tap-feedback {
    font-size: 1.2rem; font-weight: 700;
    text-align: center; min-height: 36px;
    transition: opacity .2s;
}
.tap-feedback.good, .match-feedback.good, .build-feedback.good { color: var(--green); }
.tap-feedback.try, .match-feedback.try, .build-feedback.try { color: #ff9800; }

/* Match game */
.match-area {
    display: flex; gap: 12px; width: 100%;
    justify-content: center;
}
.match-col {
    display: flex; flex-direction: column; gap: 10px; flex: 1;
    max-width: 200px; min-width: 0;
}
.match-col-label {
    text-align: center; font-weight: 700; font-size: .9rem;
    color: var(--text-light); margin-bottom: 4px;
}

.match-card {
    padding: 14px 10px;
    border: 3px solid #ddd; border-radius: var(--radius-sm);
    background: var(--card);
    font-family: var(--font); font-size: 1rem; font-weight: 700;
    text-align: center; cursor: pointer;
    transition: transform .12s, border-color .2s, opacity .3s;
    word-break: break-word; overflow-wrap: break-word;
}
.match-card:active { transform: scale(.95); }
.match-card.selected { border-color: #5B9BD5; background: #e3f2fd; }
.match-card.matched {
    border-color: var(--green); background: #e8f5e9;
    opacity: .6; pointer-events: none;
}
.match-card.wrong { animation: shakeWrong .4s ease; }

.match-feedback {
    font-size: 1.1rem; font-weight: 700;
    text-align: center; min-height: 30px;
}

/* Build game */
.build-prompt {
    font-size: 1.4rem; font-weight: 700;
    text-align: center; padding: 16px;
    background: var(--card); border-radius: var(--radius);
    box-shadow: var(--shadow); width: 100%;
}

.build-slots {
    display: flex; gap: 8px; justify-content: center;
    flex-wrap: wrap; margin: 16px 0;
}

.build-slot {
    width: 44px; height: 50px;
    border: 3px dashed #ccc; border-radius: 10px;
    display: grid; place-items: center;
    font-size: 1.4rem; font-weight: 900;
    background: var(--card);
    transition: border-color .2s;
}
.build-slot.filled { border-style: solid; border-color: var(--green); background: #e8f5e9; }
.build-slot.wrong-slot { animation: shakeWrong .4s ease; }

.build-letters {
    display: flex; gap: 10px; justify-content: center;
    flex-wrap: wrap;
}

.letter-btn {
    width: 48px; height: 52px;
    border: 2px solid #ddd; border-radius: 10px;
    background: var(--card);
    font-family: var(--font); font-size: 1.3rem; font-weight: 900;
    cursor: pointer; box-shadow: 0 3px 0 #ccc;
    transition: transform .1s, opacity .2s;
}
.letter-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #ccc; }
.letter-btn.used { opacity: .25; pointer-events: none; }

.build-feedback {
    font-size: 1.1rem; font-weight: 700;
    text-align: center; min-height: 30px;
}

/* Hint button */
.btn-hint {
    padding: 8px 22px;
    border: 2px solid var(--gold);
    border-radius: 24px;
    background: rgba(255, 215, 0, .12);
    font-family: var(--font);
    font-size: .95rem;
    font-weight: 700;
    color: #b8860b;
    cursor: pointer;
    transition: transform .12s, background .15s;
}
.btn-hint:active {
    transform: scale(.93);
    background: rgba(255, 215, 0, .3);
}

@keyframes hintPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(255, 215, 0, 0); border-color: #ddd; }
    30% { box-shadow: 0 0 14px 4px rgba(255, 215, 0, .6); border-color: var(--gold); transform: scale(1.12); }
    70% { box-shadow: 0 0 10px 2px rgba(255, 215, 0, .35); border-color: var(--gold); transform: scale(1.08); }
}
.letter-btn.hint-pulse {
    animation: hintPulse 1.2s ease;
    border-color: var(--gold);
}

/* ── Hear Again button ───────────────────────────────────────── */
.btn-hear-again {
    display: inline-flex; align-items: center; justify-content: center;
    width: 44px; height: 44px;
    border: none; border-radius: 50%;
    background: rgba(91, 155, 213, .15);
    font-size: 1.3rem; cursor: pointer;
    transition: transform .12s, background .15s;
    flex-shrink: 0; margin-left: 4px;
}
.btn-hear-again:active { transform: scale(.88); background: rgba(91, 155, 213, .3); }

/* ── Read game ───────────────────────────────────────────────── */
.read-story-card {
    width: 100%;
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
    display: flex; flex-direction: column; gap: 16px;
    max-height: 70vh; overflow-y: auto;
}

.read-story-text {
    font-size: 1.15rem;
    line-height: 1.8;
    color: var(--text);
}

.read-story-actions {
    display: flex; gap: 12px; justify-content: center;
    flex-wrap: wrap; flex-shrink: 0;
}

.read-btn-listen {
    background: #5B9BD5; color: #fff;
}

.read-btn-ready {
    background: var(--green); color: #fff;
}

.read-question-text {
    font-size: 1.3rem; font-weight: 700;
    text-align: center; padding: 20px;
    background: var(--card); border-radius: var(--radius);
    box-shadow: var(--shadow); width: 100%;
}

.read-answers {
    display: flex; flex-direction: column; gap: 12px;
    width: 100%;
}

.read-back-btn {
    background: none; border: none;
    font-family: var(--font); font-size: .95rem;
    color: #5B9BD5; text-decoration: underline;
    cursor: pointer; padding: 8px;
}

/* ── Celebration ─────────────────────────────────────────────── */
#screen-celebration {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff; justify-content: center; position: relative;
    overflow: hidden;
}

.celebration-body {
    display: flex; flex-direction: column;
    align-items: center; gap: 20px; z-index: 1;
}

.celebration-title {
    font-size: 2.8rem; font-weight: 900;
    animation: bounceIn .6s ease;
}

.stars-big {
    font-size: 1.8rem; font-weight: 700;
    animation: bounceIn .6s ease .2s both;
}

.sticker-reward {
    text-align: center;
    animation: bounceIn .6s ease .4s both;
}
.sticker-reward.hidden { display: none; }

.big-emoji { font-size: 4rem; display: block; margin: 8px 0; }

.celeb-btns {
    margin-top: 16px; max-width: 420px; width: 100%;
    grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
    gap: 10px;
}
.celeb-btns .menu-btn { padding: 16px 8px; font-size: .95rem; }
.celeb-btns .menu-icon { font-size: 1.6rem; }

.celeb-nudge {
    font-size: .95rem; font-weight: 700; color: #A78BFA;
    text-align: center; margin-top: 8px;
    animation: hintPulse 1.5s ease infinite;
}

/* ── Test Mode banner ────────────────────────────────────────── */
.test-mode-banner {
    position: fixed; top: 0; left: 0; right: 0;
    z-index: 9000;
    background: linear-gradient(135deg, #FF9800, #F57C00);
    color: #fff; text-align: center;
    padding: 8px 16px;
    font-weight: 900; font-size: .9rem;
    font-family: var(--font);
    display: flex; align-items: center; justify-content: center; gap: 12px;
}
.test-exit-btn {
    background: rgba(255,255,255,.25); border: 2px solid #fff;
    color: #fff; font-weight: 700; font-family: var(--font);
    padding: 4px 14px; border-radius: 20px; cursor: pointer;
    font-size: .85rem;
}
.test-exit-btn:active { background: rgba(255,255,255,.4); }
.test-mode-banner.hidden { display: none; }
.test-mode-label { font-size: .8em; opacity: .7; }
.practice-label { font-size: .8em; opacity: .7; font-style: italic; }
.practice-badge {
    display: inline-block; font-size: .6em; background: rgba(0,0,0,.15);
    border-radius: 8px; padding: 1px 7px; margin-left: 6px;
    vertical-align: middle; font-weight: 400; letter-spacing: .3px;
}
.btn-test { background: #FF9800; color: #fff; margin-top: 10px; }
.secondary-btn.toggled-off { opacity: .5; }
.profile-bottom {
    margin-top: 24px;
    display: flex; align-items: center; gap: 16px;
    flex-wrap: wrap; justify-content: center;
}
.guest-btn { opacity: .85; }
.guest-btn .avatar { font-size: 2rem; display: flex; align-items: center; justify-content: center; }

.guest-grade-modal { text-align: center; }
.guest-grade-grid {
    display: grid; grid-template-columns: 1fr 1fr;
    gap: 10px; margin-top: 16px;
}
.guest-grade-btn {
    padding: 14px 10px;
    border: 3px solid #ddd; border-radius: var(--radius-sm);
    background: var(--card); font-family: var(--font);
    font-size: 1rem; font-weight: 700; cursor: pointer;
    transition: transform .12s, border-color .15s, background .15s;
}
.guest-grade-btn:hover { border-color: #A78BFA; background: #f3f0ff; }
.guest-grade-btn:active { transform: scale(.95); }
.passphrase-entry {
    display: flex; flex-direction: column; align-items: center;
    gap: 12px; padding: 24px; max-width: 320px; margin: 0 auto;
}
.passphrase-entry p { font-size: 1.2rem; font-weight: 700; }
.passphrase-entry .input-big { text-align: center; width: 100%; }
.kid-pin-row {
    display: flex; align-items: center; gap: 8px; margin-bottom: 8px;
}
.kid-pin-input { max-width: 180px !important; }

/* ── Game Overrides grid ─────────────────────────────────────── */
.overrides-grid { font-size: .85rem; }
.overrides-header {
    display: grid; grid-template-columns: 120px repeat(8, 1fr);
    gap: 4px; padding: 4px 0; font-weight: 700; color: var(--text-light);
    text-align: center;
}
.overrides-row {
    display: grid; grid-template-columns: 120px repeat(8, 1fr);
    gap: 4px; padding: 4px 0; align-items: center;
}
.overrides-row input[type="checkbox"] {
    width: 20px; height: 20px; justify-self: center; cursor: pointer;
    accent-color: var(--green);
}
.ov-col-label { font-size: .7rem; text-align: center; }

/* ── Inline card editor ──────────────────────────────────────── */
.inline-card-editor {
    background: #f8f6ff; border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    padding: 10px 12px; margin-bottom: 8px;
    border-top: 2px solid #e4dcf5;
}
.inline-card-row {
    display: flex; align-items: center; gap: 8px; margin-bottom: 6px;
}
.inline-card-fields { flex: 1; display: flex; gap: 6px; }
.inline-card-input { font-size: .85rem !important; padding: 6px 8px !important; flex: 1; }

/* Mastery progress indicator in tier badges */
.mastery-progress {
    font-size: .7em; opacity: .8;
    margin-left: 2px;
}

/* Confetti */
.confetti {
    position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 0;
}
.confetti-piece {
    position: absolute; width: 10px; height: 10px;
    top: -20px; border-radius: 2px;
    animation: confettiFall linear forwards;
}
@keyframes confettiFall {
    0%   { transform: translateY(0) rotate(0deg); opacity: 1; }
    100% { transform: translateY(110vh) rotate(720deg); opacity: 0; }
}

/* ── Stickers grid ───────────────────────────────────────────── */
.sticker-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    gap: 16px; padding: 12px 0;
}

.sticker-cell {
    display: flex; flex-direction: column;
    align-items: center; gap: 4px;
    padding: 14px 8px;
    background: var(--card); border-radius: var(--radius-sm);
    box-shadow: 0 2px 8px rgba(0,0,0,.06);
}
.sticker-cell .s-emoji { font-size: 2.4rem; }
.sticker-cell .s-name { font-size: .75rem; color: var(--text-light); }

/* ── Parent PIN ──────────────────────────────────────────────── */
.pin-entry {
    display: flex; flex-direction: column; align-items: center;
    gap: 20px; margin-top: 24px;
}
.pin-entry > p { font-size: 1.2rem; font-weight: 700; }

.pin-dots { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.pin-dot {
    width: 16px; height: 16px;
    border: 3px solid #bbb; border-radius: 50%;
    transition: background .2s, border-color .2s;
}
.pin-dot.filled { background: var(--text); border-color: var(--text); }

.pin-pad {
    display: grid; grid-template-columns: repeat(3, 1fr);
    gap: 12px; max-width: 260px;
}

.pin-key {
    width: 72px; height: 72px;
    border: none; border-radius: 50%;
    background: var(--card);
    font-family: var(--font); font-size: 1.5rem; font-weight: 700;
    cursor: pointer; box-shadow: 0 3px 0 #ccc;
    transition: transform .1s;
}
.pin-key:active { transform: translateY(2px); box-shadow: 0 1px 0 #ccc; }
.pin-key.pin-back { font-size: 1.2rem; background: #eee; }

.pin-error {
    color: var(--red); font-weight: 700;
    animation: shakeWrong .4s ease;
}
.pin-error.hidden { display: none; }

/* ── Parent dashboard ────────────────────────────────────────── */
.parent-tabs {
    display: flex; gap: 4px; width: 100%; max-width: 600px;
    background: rgba(255,255,255,.4);
    border-radius: var(--radius-sm); padding: 4px; flex-shrink: 0;
}
.tab {
    flex: 1; padding: 10px;
    border: none; border-radius: 10px;
    background: transparent;
    font-family: var(--font); font-size: .95rem; font-weight: 700;
    cursor: pointer; color: var(--text-light);
}
.tab.active { background: var(--card); color: var(--text); box-shadow: 0 2px 6px rgba(0,0,0,.08); }

.parent-content { max-width: 600px; padding-top: 12px; }

.parent-card {
    background: var(--card); border-radius: var(--radius-sm);
    padding: 18px; margin-bottom: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,.06);
}
.parent-card h4 { margin-bottom: 8px; font-size: 1.1rem; }
.parent-card .stat-row {
    display: flex; justify-content: space-between;
    padding: 4px 0; font-size: .95rem;
}
.parent-card .stat-val { font-weight: 700; }

.parent-guide-row {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 16px;
    background: var(--card); border-radius: var(--radius-sm);
    margin-bottom: 8px; box-shadow: 0 2px 6px rgba(0,0,0,.05);
}
.parent-guide-row .g-icon { font-size: 1.4rem; }
.parent-guide-row .g-info { flex: 1; }
.parent-guide-row .g-title { font-weight: 700; }
.parent-guide-row .g-sub { font-size: .82rem; color: var(--text-light); }
.parent-guide-row .btn-sm { flex-shrink: 0; }
.parent-guide-row select {
    padding: 6px 8px; border-radius: 8px; border: 1px solid #ccc;
    font-family: var(--font); font-size: .9rem;
}

.progress-table {
    width: 100%; border-collapse: collapse; font-size: .9rem;
}
.progress-table th {
    text-align: left; padding: 8px 6px;
    border-bottom: 2px solid #ddd; font-size: .85rem; color: var(--text-light);
}
.progress-table td { padding: 8px 6px; border-bottom: 1px solid #eee; }

/* ── Modal ───────────────────────────────────────────────────── */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.4);
    display: flex; align-items: flex-end; justify-content: center;
    z-index: 100;
    animation: fadeIn .2s ease;
}
.modal-overlay.hidden { display: none; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
    background: var(--card);
    border-radius: var(--radius) var(--radius) 0 0;
    padding: 24px 20px 32px;
    width: 100%; max-width: 500px;
    max-height: 85vh; overflow-y: auto;
    animation: slideUp .3s ease;
}
@keyframes slideUp {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
}

.modal h3 { text-align: center; margin-bottom: 16px; font-size: 1.2rem; }

.modal label {
    display: block; margin-bottom: 12px;
    font-size: .9rem; font-weight: 700; color: var(--text-light);
}
.modal label input { margin-top: 4px; width: 100%; }

.type-btns { display: flex; gap: 8px; margin-bottom: 16px; justify-content: center; }
.type-btn {
    padding: 10px 20px;
    border: 2px solid #ddd; border-radius: var(--radius-sm);
    background: var(--card);
    font-family: var(--font); font-size: 1rem; font-weight: 700;
    cursor: pointer;
}
.type-btn.active { border-color: #5B9BD5; background: #e3f2fd; }

.modal-audio { margin: 12px 0; text-align: center; }
.modal-audio audio { width: 100%; margin-top: 8px; }

.modal-actions { display: flex; gap: 12px; margin-top: 16px; justify-content: center; }

/* ── Subject grid ───────────────────────────────────────────── */
.subject-grid {
    display: grid; grid-template-columns: 1fr 1fr;
    gap: 14px; padding: 8px 0; width: 100%; max-width: 600px;
}

.subject-card {
    display: flex; flex-direction: column; align-items: center;
    gap: 8px; padding: 20px 12px;
    border: none; border-radius: var(--radius);
    background: var(--sc, #5B9BD5);
    color: #fff; font-family: var(--font);
    cursor: pointer;
    box-shadow: 0 6px 0 color-mix(in srgb, var(--sc, #5B9BD5) 80%, #000),
                0 8px 20px rgba(0,0,0,.12);
    transition: transform .12s, box-shadow .12s;
}
.subject-card:active {
    transform: translateY(4px);
    box-shadow: 0 2px 0 color-mix(in srgb, var(--sc, #5B9BD5) 80%, #000),
                0 4px 8px rgba(0,0,0,.1);
}

.subject-icon { font-size: 2.4rem; }
.subject-name { font-size: 1.1rem; font-weight: 700; }
.subject-count { font-size: .8rem; opacity: .85; }

.subject-progress {
    width: 80%; height: 6px;
    background: rgba(255,255,255,.3);
    border-radius: 3px; overflow: hidden;
}
.subject-progress-bar {
    height: 100%;
    background: #fff;
    border-radius: 3px;
    transition: width .4s;
}

/* ── Topic list ─────────────────────────────────────────────── */
.topic-list {
    display: flex; flex-direction: column; gap: 10px;
    padding: 8px 0; width: 100%; max-width: 600px;
}

.topic-card {
    display: flex; align-items: center; gap: 14px;
    padding: 16px 18px;
    background: var(--card); border-radius: var(--radius-sm);
    box-shadow: var(--shadow); cursor: pointer;
    transition: transform .15s;
}
.topic-card:active { transform: scale(.97); }

.topic-info { flex: 1; }
.topic-name { font-weight: 700; font-size: 1.05rem; margin-bottom: 6px; }
.topic-tiers { display: flex; gap: 6px; flex-wrap: wrap; }

/* ── Difficulty badges ──────────────────────────────────────── */
.diff-badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 4px 10px;
    border: 2px solid transparent;
    border-radius: 20px;
    font-family: var(--font); font-size: .78rem; font-weight: 700;
    cursor: pointer; transition: transform .1s;
}
.diff-badge:active { transform: scale(.93); }

.diff-badge.easy { background: #e8f5e9; color: #2e7d32; border-color: #a5d6a7; }
.diff-badge.medium { background: #fff3e0; color: #e65100; border-color: #ffcc80; }
.diff-badge.hard { background: #fce4ec; color: #c62828; border-color: #ef9a9a; }

.diff-badge.locked {
    opacity: .45; cursor: default; pointer-events: none;
    filter: grayscale(0.5);
}
.diff-badge.completed {
    box-shadow: inset 0 0 0 1px currentColor;
}
.diff-badge .lock-icon { font-size: .7rem; }
.diff-badge .acc-pct { font-size: .7rem; opacity: .8; }

/* ── Home screen secondary ───────────────────────────────────── */
.home-subtitle {
    color: var(--text-light); font-size: 1.05rem;
    text-align: center; margin-bottom: 8px;
}

.home-secondary {
    display: flex; gap: 12px; justify-content: center;
    padding: 12px 0 4px; flex-shrink: 0;
}

.secondary-btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 10px 22px;
    border: none; border-radius: 30px;
    background: rgba(255,255,255,.7);
    font-family: var(--font); font-size: .95rem; font-weight: 700;
    color: var(--text); cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,.08);
    transition: transform .12s;
}
.secondary-btn:active { transform: scale(.93); }

.home-custom-section { margin-top: 16px; }
.home-custom-label {
    font-size: .9rem; font-weight: 700;
    color: var(--text-light); margin-bottom: 6px;
}

/* ── Parent section titles ──────────────────────────────────── */
.parent-section-title {
    font-size: 1.05rem; font-weight: 700;
    padding-bottom: 8px; margin-bottom: 10px;
    border-bottom: 2px solid #e0d8f0;
}

.btn-sm {
    padding: 6px 14px;
    border: none; border-radius: 8px;
    font-family: var(--font); font-size: .8rem; font-weight: 700;
    cursor: pointer; transition: transform .1s;
}
.btn-sm:active { transform: scale(.92); }
.btn-edit { background: #e3f2fd; color: #1976D2; }
.btn-del { background: #ffebee; color: #c62828; }

.btn-del-full {
    background: #ffebee; color: #c62828;
    border: none; border-radius: 40px;
    padding: 12px 24px;
    font-family: var(--font); font-size: .95rem; font-weight: 700;
    cursor: pointer;
}

.parent-filter-row { margin-bottom: 12px; }
.parent-filter-row select,
.parent-select {
    padding: 10px; border-radius: 10px; border: 1px solid #ccc;
    font-family: var(--font); font-size: 1rem; width: 100%;
}

/* ── Collapsible curriculum ─────────────────────────────────── */
.curriculum-subject-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 16px; margin-top: 8px;
    background: var(--card); border-radius: var(--radius-sm);
    box-shadow: 0 2px 6px rgba(0,0,0,.05);
    cursor: pointer; font-weight: 700; font-size: 1rem;
    transition: background .15s;
}
.curriculum-subject-header:active { background: #f0eaff; }
.curriculum-count { font-size: .8rem; color: var(--text-light); font-weight: 400; }
.curriculum-arrow { font-size: .75rem; color: var(--text-light); }

.curriculum-subject-body { padding-left: 8px; }
.curriculum-subject-body.collapsed { display: none; }

.curriculum-topic-name {
    font-size: .85rem; font-weight: 700;
    color: var(--text-light); padding: 8px 0 4px 8px;
}

/* ── Accuracy bars ──────────────────────────────────────────── */
.accuracy-bar-wrap {
    width: 60px; height: 8px;
    background: #eee; border-radius: 4px;
    overflow: hidden; display: inline-block;
    vertical-align: middle; margin-right: 6px;
}
.accuracy-bar {
    height: 100%; border-radius: 4px;
    transition: width .4s;
}
.accuracy-label { font-size: .85rem; font-weight: 700; }

/* ── Settings form ──────────────────────────────────────────── */
.settings-form {
    max-width: 320px;
}
.settings-label {
    display: block; margin-bottom: 14px;
    font-size: .9rem; font-weight: 700; color: var(--text-light);
}
.settings-label input { margin-top: 4px; width: 100%; }

.pin-change-msg {
    font-size: .9rem; font-weight: 700; margin-bottom: 12px;
}
.pin-change-msg.hidden { display: none; }
.pin-change-msg.error { color: var(--red); }
.pin-change-msg.success { color: var(--green); }

.settings-kid-grade-card {
    background: var(--card-bg); border-radius: 16px;
    padding: 16px; margin-bottom: 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,.06);
}
.settings-kid-grade-card h4 {
    margin-bottom: 12px; font-size: 1.1rem;
}
.grade-grid {
    display: grid; grid-template-columns: 1fr 1fr;
    gap: 8px 16px;
}
.grade-grid-row {
    display: flex; align-items: center; justify-content: space-between;
    gap: 8px; padding: 4px 0;
}
.grade-subject-label {
    font-size: .9rem; font-weight: 600; color: var(--text-light);
    min-width: 80px;
}
.grade-select {
    font-size: .85rem; padding: 4px 8px; border-radius: 8px;
    border: 2px solid var(--bg2); background: var(--bg);
    font-weight: 600; min-width: 110px;
}
.grade-save-msg {
    display: block; font-size: .85rem; font-weight: 700;
    margin-top: 8px; min-height: 1.2em;
}
.grade-save-msg.success { color: var(--green); }
.grade-save-msg.error { color: var(--red); }

@media (max-width: 480px) {
    .grade-grid { grid-template-columns: 1fr; }
}

/* ── Spelling test – kid home card ────────────────────────────── */
.spelling-test-home {
    width: 100%; max-width: 600px;
    margin-top: 14px;
}

.spelling-test-card {
    display: flex; align-items: center; gap: 14px;
    padding: 18px 20px;
    background: linear-gradient(135deg, #4CAF50, #66BB6A);
    border-radius: var(--radius-sm);
    box-shadow: 0 6px 0 #388E3C, 0 8px 20px rgba(0,0,0,.12);
    cursor: pointer; color: #fff;
    transition: transform .12s, box-shadow .12s;
}
.spelling-test-card:active {
    transform: translateY(4px);
    box-shadow: 0 2px 0 #388E3C, 0 4px 8px rgba(0,0,0,.1);
}

.spelling-test-icon { font-size: 2rem; }
.spelling-test-info { flex: 1; }
.spelling-test-title { font-weight: 900; font-size: 1.15rem; }
.spelling-test-sub { font-size: .85rem; opacity: .9; }
.spelling-test-card .g-arrow { font-size: 1.4rem; opacity: .8; }

/* ── Spelling test – game prompt ─────────────────────────────── */
.spell-test-prompt {
    display: flex; flex-direction: column; align-items: center;
    gap: 14px; padding: 20px;
    background: var(--card); border-radius: var(--radius);
    box-shadow: var(--shadow); width: 100%;
}

.spell-test-word-num {
    font-size: 1.1rem; font-weight: 700;
    color: var(--text-light);
}

.spell-test-listen {
    padding: 16px 36px;
    border: none; border-radius: 40px;
    background: linear-gradient(135deg, #5B9BD5, #42A5F5);
    color: #fff; font-family: var(--font);
    font-size: 1.3rem; font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 0 #1976D2, 0 6px 16px rgba(0,0,0,.12);
    transition: transform .12s, box-shadow .12s;
}
.spell-test-listen:active {
    transform: translateY(3px);
    box-shadow: 0 1px 0 #1976D2, 0 3px 6px rgba(0,0,0,.1);
}

/* ── Spelling test – parent editor ───────────────────────────── */
.spelling-test-editor {
    background: var(--card);
    border-radius: var(--radius-sm);
    padding: 18px;
    margin-bottom: 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,.06);
}

.spelling-textarea {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid #ddd;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 1rem;
    resize: vertical;
    outline: none;
    transition: border-color .2s;
}
.spelling-textarea:focus { border-color: #5B9BD5; }

.spelling-word-count {
    font-size: .85rem;
    font-weight: 700;
    color: var(--text-light);
    margin: 8px 0 6px;
}

.spelling-chips {
    display: flex; flex-wrap: wrap; gap: 6px;
}

.spelling-chip {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    background: #e8f5e9;
    color: #2e7d32;
    font-size: .82rem;
    font-weight: 700;
}

.spelling-save-msg {
    font-size: .85rem;
    font-weight: 700;
}
.spelling-save-msg.success { color: var(--green); }
.spelling-save-msg.error { color: var(--red); }

/* ── Sort It – kid home card ──────────────────────────────────── */
.sort-it-home {
    width: 100%; max-width: 600px;
    margin-top: 14px;
}

.sort-it-card {
    display: flex; align-items: center; gap: 14px;
    padding: 18px 20px;
    background: linear-gradient(135deg, #54A0FF, #2E86DE);
    border-radius: var(--radius-sm);
    box-shadow: 0 6px 0 #1B6FC2, 0 8px 20px rgba(0,0,0,.12);
    cursor: pointer; color: #fff;
    transition: transform .12s, box-shadow .12s;
}
.sort-it-card:active {
    transform: translateY(4px);
    box-shadow: 0 2px 0 #1B6FC2, 0 4px 8px rgba(0,0,0,.1);
}

.sort-it-icon { font-size: 2rem; }
.sort-it-info { flex: 1; }
.sort-it-title { font-weight: 900; font-size: 1.15rem; }
.sort-it-sub { font-size: .85rem; opacity: .9; }
.sort-it-card .g-arrow { font-size: 1.4rem; opacity: .8; }

/* ── Story Time – kid home card ─────────────────────────────── */
.story-time-home {
    width: 100%; max-width: 600px;
    margin-top: 14px;
}

.story-time-card {
    display: flex; align-items: center; gap: 14px;
    padding: 18px 20px;
    background: linear-gradient(135deg, #A78BFA, #7C3AED);
    border-radius: var(--radius-sm);
    box-shadow: 0 6px 0 #5B21B6, 0 8px 20px rgba(0,0,0,.12);
    cursor: pointer; color: #fff;
    transition: transform .12s, box-shadow .12s;
}
.story-time-card:active:not(.inactive) {
    transform: translateY(4px);
    box-shadow: 0 2px 0 #5B21B6, 0 4px 8px rgba(0,0,0,.1);
}
.story-time-card.inactive {
    background: linear-gradient(135deg, #bbb, #999);
    box-shadow: 0 6px 0 #777, 0 8px 20px rgba(0,0,0,.08);
    cursor: default;
    opacity: .7;
}

.story-time-icon { font-size: 2rem; }
.story-time-info { flex: 1; }
.story-time-title { font-weight: 900; font-size: 1.15rem; }
.story-time-sub { font-size: .85rem; opacity: .9; }
.story-time-card .g-arrow { font-size: 1.4rem; opacity: .8; }

/* ── Story Time – parent editor ────────────────────────────── */
.story-time-editor {
    background: var(--card);
    border-radius: var(--radius-sm);
    padding: 18px;
    margin-bottom: 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,.06);
}

.story-editor-preview-img {
    width: 100%; max-height: 200px;
    object-fit: contain;
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
    cursor: pointer;
}

.story-q-row {
    display: flex; align-items: flex-start; gap: 8px;
    margin-bottom: 10px;
}
.story-q-num {
    font-weight: 700; color: var(--text-light);
    padding-top: 10px; min-width: 22px;
}
.story-q-fields { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.story-q-input { font-size: .9rem !important; padding: 8px 10px !important; }
.story-q-row .c-del { margin-top: 8px; }

/* ── Story image overlay (zoom) ────────────────────────────── */
.story-img-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.85);
    z-index: 9999;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    animation: screenIn .2s ease;
}
.story-img-full {
    max-width: 95vw; max-height: 95vh;
    object-fit: contain;
    border-radius: 8px;
}

/* ── Read game – story image ───────────────────────────────── */
.read-story-img {
    width: 100%; max-height: 45vh;
    object-fit: contain;
    border-radius: var(--radius-sm);
    cursor: pointer;
}

/* ── Memory Flip game ────────────────────────────────────────── */
.memory-grid {
    display: grid;
    gap: 10px;
    width: 100%;
    justify-items: center;
}
.memory-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.memory-grid.cols-4 { grid-template-columns: repeat(4, 1fr); }

.memory-tile {
    width: 100%; max-width: 110px;
    aspect-ratio: 1;
    perspective: 600px;
    cursor: pointer;
}

.memory-tile-inner {
    width: 100%; height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform .4s;
}
.memory-tile.flipped .memory-tile-inner { transform: rotateY(180deg); }
.memory-tile.matched .memory-tile-inner { transform: rotateY(180deg); }

.memory-tile-face {
    position: absolute; inset: 0;
    backface-visibility: hidden;
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; text-align: center;
    padding: 6px; overflow: hidden;
    word-break: break-word;
}

.memory-tile-front {
    background: linear-gradient(135deg, #FF9FF3, #F368E0);
    color: #fff; font-size: 1.8rem;
}

.memory-tile-back {
    transform: rotateY(180deg);
    background: var(--card);
    border: 3px solid #ddd;
    font-size: .85rem; color: var(--text);
}

.memory-tile.matched .memory-tile-back {
    border-color: var(--green);
    background: #e8f5e9;
}

.memory-feedback {
    font-size: 1.1rem; font-weight: 700;
    text-align: center; min-height: 30px;
}

/* ── True or False game ──────────────────────────────────────── */
.tf-statement {
    width: 100%;
    padding: 24px;
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    text-align: center;
    font-size: 1.3rem; font-weight: 700;
}

.tf-prompt {
    font-size: .95rem; color: var(--text-light);
    margin-bottom: 8px; font-weight: 400;
}

.tf-buttons {
    display: flex; gap: 16px; justify-content: center;
    width: 100%;
}

.tf-btn {
    flex: 1; max-width: 160px;
    padding: 22px 16px;
    border: 3px solid transparent;
    border-radius: var(--radius-sm);
    font-family: var(--font); font-size: 1.4rem; font-weight: 900;
    cursor: pointer;
    box-shadow: var(--shadow);
    transition: transform .12s, border-color .2s, background .2s;
}
.tf-btn:active { transform: scale(.95); }

.tf-btn-true { background: #e8f5e9; color: #2e7d32; }
.tf-btn-false { background: #ffebee; color: #c62828; }

.tf-btn.correct { border-color: var(--green); animation: popCorrect .5s ease; }
.tf-btn.wrong { animation: shakeWrong .4s ease; }

.tf-feedback {
    font-size: 1.1rem; font-weight: 700;
    text-align: center; min-height: 30px;
}
.tf-feedback.good { color: var(--green); }
.tf-feedback.try { color: #ff9800; }

/* ── Pop It game ─────────────────────────────────────────────── */
.pop-question {
    font-size: 1.3rem; font-weight: 700;
    text-align: center; padding: 16px;
    background: var(--card); border-radius: var(--radius);
    box-shadow: var(--shadow); width: 100%;
}

.pop-field {
    display: grid;
    gap: 12px;
    width: 100%;
    justify-items: center;
}
.pop-field.cols-2 { grid-template-columns: repeat(2, 1fr); }
.pop-field.cols-3 { grid-template-columns: repeat(3, 1fr); }

.pop-bubble {
    width: 100%; max-width: 130px;
    aspect-ratio: 1;
    border: none; border-radius: 50%;
    background: linear-gradient(135deg, #FF6348, #FF4757);
    color: #fff;
    font-family: var(--font); font-size: 1.1rem; font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(255,99,72,.3);
    transition: transform .15s;
    animation: popAppear .3s ease both;
    display: flex; align-items: center; justify-content: center;
    text-align: center; padding: 8px;
    word-break: break-word;
}
.pop-bubble:active { transform: scale(.9); }

.pop-bubble.correct {
    background: var(--green);
    animation: popCorrect .5s ease;
}
.pop-bubble.wrong {
    animation: shakeWrong .4s ease;
}
.pop-bubble.shrink {
    animation: popShrink .4s ease forwards;
}

@keyframes popAppear {
    from { transform: scale(0); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}
@keyframes popShrink {
    from { transform: scale(1); opacity: 1; }
    to { transform: scale(0); opacity: 0; }
}

.pop-feedback {
    font-size: 1.1rem; font-weight: 700;
    text-align: center; min-height: 30px;
}
.pop-feedback.good { color: var(--green); }
.pop-feedback.try { color: #ff9800; }
.pop-feedback.miss { color: var(--red); }

/* ── Sort It game ────────────────────────────────────────────── */
.sort-item-display {
    width: 100%;
    padding: 28px;
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    text-align: center;
    font-size: 1.8rem; font-weight: 900;
}

.sort-item-counter {
    font-size: .95rem; color: var(--text-light);
    font-weight: 400; margin-bottom: 6px;
}

.sort-buckets {
    display: flex; gap: 16px; justify-content: center;
    width: 100%;
}

.sort-bucket {
    flex: 1; max-width: 180px;
    padding: 24px 16px;
    border: 3px solid #ddd;
    border-radius: var(--radius);
    background: var(--card);
    font-family: var(--font); font-size: 1.2rem; font-weight: 900;
    cursor: pointer;
    box-shadow: var(--shadow);
    transition: transform .12s, border-color .2s, background .2s;
    text-align: center;
}
.sort-bucket:active { transform: scale(.95); }

.sort-bucket.correct {
    border-color: var(--green); background: #e8f5e9;
    animation: popCorrect .5s ease;
}
.sort-bucket.wrong {
    animation: shakeWrong .4s ease;
}

.sort-feedback {
    font-size: 1.1rem; font-weight: 700;
    text-align: center; min-height: 30px;
}
.sort-feedback.good { color: var(--green); }
.sort-feedback.try { color: #ff9800; }

/* ── Utilities ───────────────────────────────────────────────── */
.hidden { display: none !important; }

.bounce-in { animation: bounceIn .6s ease; }

/* Star float animation */
.star-float {
    position: fixed; font-size: 2rem; pointer-events: none; z-index: 200;
    animation: starUp 1s ease forwards;
}
@keyframes starUp {
    0%   { opacity: 1; transform: translateY(0) scale(1); }
    100% { opacity: 0; transform: translateY(-80px) scale(1.5); }
}

/* ── Responsive ──────────────────────────────────────────────── */

/* Small phones (≤360px) */
@media (max-width: 360px) {
    .screen { padding: 10px; }
    .title-big { font-size: 1.5rem; margin: 14px 0 12px; }
    .avatar { width: 90px; height: 90px; font-size: 2.2rem; }
    .profile-grid { gap: 20px; }
    .menu-grid { gap: 10px; }
    .menu-btn { padding: 16px 8px; font-size: .9rem; }
    .menu-icon { font-size: 1.6rem; }
    .home-subtitle { font-size: .9rem; }
    .secondary-btn { padding: 8px 16px; font-size: .85rem; }

    .tap-question { font-size: 1.2rem; padding: 14px; min-height: 70px; }
    .tap-btn { padding: 14px 12px; font-size: 1rem; }
    .tap-answers { gap: 10px; }

    .match-area { gap: 8px; }
    .match-card { padding: 10px 6px; font-size: .85rem; }

    .build-prompt { font-size: 1.1rem; padding: 12px; }
    .build-slots { gap: 4px; }
    .build-slot { width: 36px; height: 42px; font-size: 1.2rem; border-radius: 8px; }
    .build-letters { gap: 6px; }
    .letter-btn { width: 38px; height: 42px; font-size: 1.1rem; border-radius: 8px; }

    .subject-grid { gap: 10px; }
    .subject-card { padding: 12px 6px; }
    .subject-icon { font-size: 1.5rem; }
    .subject-name { font-size: .95rem; }

    .topic-card { padding: 12px; gap: 10px; }
    .diff-badge { padding: 3px 7px; font-size: .7rem; }

    .read-story-card { padding: 16px; }
    .read-story-text { font-size: 1rem; line-height: 1.6; }
    .read-question-text { font-size: 1.1rem; padding: 14px; }

    .btn-hear-again { width: 36px; height: 36px; font-size: 1.1rem; }

    .spelling-test-card { padding: 14px 16px; }
    .spelling-test-icon { font-size: 1.5rem; }
    .spelling-test-title { font-size: 1rem; }
    .spell-test-prompt { padding: 14px; }
    .spell-test-listen { padding: 12px 28px; font-size: 1.1rem; }
    .spelling-textarea { font-size: .9rem; }

    .game-type-grid { gap: 10px; }
    .game-type { padding: 16px 8px; font-size: .9rem; }

    .memory-tile-front { font-size: 1.4rem; }
    .memory-tile-back { font-size: .75rem; }
    .tf-statement { font-size: 1.1rem; padding: 16px; }
    .tf-btn { padding: 16px 10px; font-size: 1.2rem; }
    .pop-bubble { font-size: .9rem; }
    .sort-item-display { font-size: 1.4rem; padding: 20px; }
    .sort-bucket { font-size: 1rem; padding: 18px 10px; }
    .sort-it-card { padding: 14px 16px; }
    .sort-it-icon { font-size: 1.5rem; }
    .sort-it-title { font-size: 1rem; }

    .flip-card { width: 200px; height: 260px; }
    .flip-arrow { width: 40px; height: 40px; font-size: 1.4rem; }

    .celebration-title { font-size: 2rem; }
    .celeb-btns { gap: 8px; }
    .celeb-btns .menu-btn { padding: 12px 6px; font-size: .85rem; }
    .celeb-btns .menu-icon { font-size: 1.3rem; }

    .pin-key { width: 60px; height: 60px; font-size: 1.3rem; }
    .pin-pad { gap: 8px; }
}

/* Regular phones (≤480px) */
@media (max-width: 480px) {
    .avatar { width: 110px; height: 110px; font-size: 2.8rem; }
    .menu-btn { padding: 20px 10px; font-size: 1rem; }
    .menu-icon { font-size: 1.8rem; }
    .flip-card { width: 240px; height: 300px; }
    .tap-btn { padding: 16px 14px; font-size: 1.1rem; }
    .tap-answers { gap: 10px; }
    .subject-card { padding: 16px 8px; }
    .subject-icon { font-size: 1.8rem; }

    .build-slot { width: 40px; height: 46px; font-size: 1.3rem; }
    .letter-btn { width: 42px; height: 46px; font-size: 1.2rem; }
    .build-slots { gap: 6px; }
    .build-letters { gap: 8px; }

    .match-card { font-size: .95rem; padding: 12px 8px; }

    .celebration-title { font-size: 2.2rem; }
}

/* Tablets and up */
@media (min-width: 768px) {
    .menu-grid { max-width: 440px; gap: 20px; }
    .flip-card { width: 320px; height: 400px; }
    .game-area { max-width: 560px; }
    .match-card { padding: 18px 12px; font-size: 1.1rem; }
    .build-slot { width: 52px; height: 58px; font-size: 1.6rem; }
    .letter-btn { width: 56px; height: 60px; font-size: 1.5rem; }
}

/* Landscape phone — reduce vertical spacing */
@media (max-height: 500px) {
    .title-big { font-size: 1.4rem; margin: 8px 0 10px; }
    .tap-question { padding: 10px; min-height: 50px; font-size: 1.2rem; }
    .tap-btn { padding: 12px 10px; }
    .tap-answers { gap: 8px; }
    .game-area { gap: 10px; }
    .build-prompt { padding: 10px; font-size: 1.1rem; }
    .build-slots { margin: 8px 0; }
    .celebration-title { font-size: 2rem; }
    .celebration-body { gap: 12px; }
    .celeb-btns .menu-btn { padding: 10px 6px; }

    .read-story-card { max-height: 55vh; padding: 14px; }
    .read-story-text { font-size: 1rem; line-height: 1.5; }
    .read-question-text { font-size: 1.1rem; padding: 10px; }
    .read-answers { gap: 8px; }

    .spell-test-prompt { padding: 10px; gap: 8px; }
    .spell-test-listen { padding: 10px 24px; font-size: 1.1rem; }
}

/* ── Quest Adventure ─────────────────────────────────────────── */
.quest-home-card { margin: 12px 0; }
.quest-home-btn {
    display: flex; align-items: center; gap: 12px;
    background: linear-gradient(135deg, #6C3483, #8E44AD);
    color: #fff; border-radius: var(--radius-sm);
    padding: 14px 18px; cursor: pointer;
    box-shadow: var(--shadow); transition: transform 0.12s;
}
.quest-home-btn:hover { transform: scale(1.02); }
.quest-home-icon { font-size: 28px; }
.quest-home-title { font-weight: 800; font-size: 16px; }
.quest-home-sub { font-size: 13px; opacity: 0.85; }
.quest-home-btn .g-arrow { margin-left: auto; font-size: 24px; opacity: 0.7; }

.quest-section-title { margin: 16px 0 8px; font-size: 15px; color: var(--text); }

/* Character Grid */
.quest-char-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.quest-char-card {
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    padding: 12px 6px; border-radius: var(--radius-sm);
    border: 3px solid transparent; background: var(--card);
    box-shadow: 0 2px 8px rgba(0,0,0,.06); cursor: pointer;
    transition: transform 0.12s, border-color 0.12s;
}
.quest-char-card:hover { transform: scale(1.05); }
.quest-char-card.selected { border-color: #6C3483; background: #f3e8ff; }
.quest-char-icon { font-size: 32px; }
.quest-char-name { font-size: 12px; font-weight: 700; }

/* Animal Grid */
.quest-animal-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.quest-animal-card {
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    padding: 10px; border-radius: var(--radius-sm);
    border: 3px solid transparent; background: var(--card);
    box-shadow: 0 2px 8px rgba(0,0,0,.06); cursor: pointer;
    transition: transform 0.12s, border-color 0.12s;
}
.quest-animal-card:hover { transform: scale(1.05); }
.quest-animal-card.selected { border-color: #E74C3C; background: #fde8e8; }
.quest-animal-emoji { font-size: 28px; }
.quest-animal-name { font-size: 12px; font-weight: 700; }

/* Subject Grid */
.quest-subject-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.quest-subj-card {
    padding: 10px; border-radius: var(--radius-sm); text-align: center;
    border: 3px solid transparent; background: var(--card);
    box-shadow: 0 2px 8px rgba(0,0,0,.06); cursor: pointer;
    font-weight: 700; font-size: 13px;
    transition: transform 0.12s, border-color 0.12s;
}
.quest-subj-card:hover { transform: scale(1.05); }
.quest-subj-card.selected { border-color: #2980B9; background: #e8f4fd; }

.quest-start-btn { margin: 20px auto; display: block; background: #6C3483; color: #fff; font-size: 16px; padding: 12px 40px; }
.quest-start-btn:hover { background: #8E44AD; }

/* Continue Quest Cards */
.quest-continue-card {
    display: flex; align-items: center; gap: 12px;
    background: var(--card); border-radius: var(--radius-sm);
    padding: 12px 16px; margin-bottom: 10px;
    box-shadow: var(--shadow); cursor: pointer;
    transition: transform 0.12s;
}
.quest-continue-card:hover { transform: scale(1.02); }
.quest-continue-char { font-size: 28px; }
.quest-continue-info { flex: 1; }
.quest-continue-title { font-weight: 800; font-size: 14px; }
.quest-continue-sub { font-size: 12px; color: var(--text-light); }
.quest-continue-badge { background: #6C3483; color: #fff; border-radius: 12px; padding: 4px 12px; font-size: 12px; font-weight: 700; }

/* ── Quest Map ──────────────────────────────────────────────── */
.quest-map-container {
    flex: 1; overflow-y: auto; overflow-x: hidden;
    display: flex; justify-content: center;
    padding: 10px 0;
}
.quest-map-container svg { max-width: 380px; width: 100%; height: auto; }

.quest-map-actions {
    padding: 10px 20px 16px; text-align: center;
}

.quest-stop-circle { cursor: pointer; transition: transform 0.2s; }
.quest-stop-circle:hover { transform: scale(1.1); }

.quest-char-sprite {
    transition: transform 1.2s ease-in-out;
}

@keyframes questPulse {
    0%, 100% { r: 18; opacity: 0.6; }
    50% { r: 24; opacity: 0.3; }
}

@keyframes questBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

.quest-char-bouncing { animation: questBounce 0.5s ease-in-out 3; }

/* ── Quest Encounter Overlay ────────────────────────────────── */
.quest-encounter-overlay {
    position: fixed; inset: 0; z-index: 950;
    background: rgba(0,0,0,0.6);
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
}
.quest-encounter-overlay.hidden { display: none; }
.quest-encounter-box {
    background: #fff; border-radius: var(--radius);
    padding: 24px; max-width: 400px; width: 100%;
    box-shadow: 0 8px 32px rgba(0,0,0,.25);
    text-align: center;
    animation: screenIn 0.35s ease;
}
.quest-encounter-title {
    font-size: 18px; font-weight: 800; color: #6C3483;
    margin-bottom: 16px;
}
.quest-encounter-tries {
    margin-top: 12px; font-size: 13px; color: var(--text-light); font-weight: 700;
}
.quest-encounter-body .tap-btn {
    margin: 6px 0; width: 100%;
}

/* Boss HP Bar */
.boss-hp-bar {
    display: flex; gap: 4px; justify-content: center; margin: 10px 0;
}
.boss-hp-seg {
    width: 28px; height: 12px; border-radius: 4px;
    background: #E74C3C; transition: background 0.3s, opacity 0.3s;
}
.boss-hp-seg.depleted { background: #ddd; opacity: 0.4; }

.boss-timer-bar {
    height: 6px; background: #E74C3C; border-radius: 3px;
    transition: width 0.1s linear; margin: 8px 0;
}

/* ── Floating Sound Toggle ──────────────────────────────────── */
.floating-sound-btn {
    position: fixed;
    top: 14px;
    left: 14px;
    z-index: 800;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 2px solid var(--text-light);
    background: rgba(255,255,255,0.92);
    font-size: 20px;
    line-height: 40px;
    text-align: center;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,.12);
    transition: transform 0.15s, background 0.15s;
    padding: 0;
}
.floating-sound-btn:hover { transform: scale(1.1); }
.floating-sound-btn:active { transform: scale(0.95); }
.floating-sound-btn.off {
    background: rgba(200,200,200,0.9);
    border-color: #aaa;
}
.floating-sound-btn.hidden { display: none; }

/* ── Create Profile Modal ────────────────────────────────────── */
.create-profile-modal {
    max-width: 380px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
}
.cp-label {
    display: block;
    font-weight: 700;
    font-size: 14px;
    color: var(--text);
    margin: 12px 0 6px;
}
.cp-label input {
    display: block;
    width: 100%;
    margin-top: 4px;
}
.cp-color-grid {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
    margin-bottom: 4px;
}
.cp-color-swatch {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 3px solid transparent;
    cursor: pointer;
    transition: transform 0.12s, border-color 0.12s;
}
.cp-color-swatch:hover { transform: scale(1.1); }
.cp-color-swatch.selected { border-color: var(--text); transform: scale(1.15); }

.cp-grade-grid {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: center;
    margin-bottom: 4px;
}
.cp-grade.selected {
    background: #4A90D9;
    color: #fff;
    border-color: #3A7BC8;
}

.cp-pin-dots {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin: 8px 0;
}
.cp-pin-dot {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid var(--text-light);
    background: transparent;
    transition: background 0.15s;
}
.cp-pin-dot.filled { background: var(--text); }

.cp-pin-pad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    max-width: 220px;
    margin: 0 auto 8px;
}
.cp-pin-key {
    padding: 10px;
    border: 2px solid #ddd;
    border-radius: 12px;
    background: #fff;
    font-family: inherit;
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.1s;
}
.cp-pin-key:hover { background: #f0eaff; }
.cp-pin-key:active { background: #e4dcf5; }

.cp-error {
    color: var(--red);
    font-size: 13px;
    font-weight: 700;
    text-align: center;
    margin: 4px 0;
}

.floating-answers-btn {
    top: 66px;
    font-size: 13px;
    font-weight: 800;
    font-family: 'Nunito', system-ui, sans-serif;
    line-height: 40px;
    color: #4A7FA3;
}
.floating-answers-btn.off {
    color: #aaa;
    text-decoration: line-through;
}
