:root {
    --primary: #10b981;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --shadow-border: #cbd5e1;
}

* {
    box-sizing: border-box;
    font-family: 'Nunito', 'Microsoft YaHei', sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background: linear-gradient(135deg, #a1c4fd 0%, #c2e9fb 100%);
    margin: 0;
    padding: 15px;
    color: var(--text-main);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    min-height: 100vh;
    overflow-x: hidden;
    transition: background 0.65s ease;
}

/* ── Hub tier light wash (body.hub-tier-*) ── */
body.hub-tier-bronze  { --hub-tier-rgb: 205, 127, 50;  --hub-tier-deep: #8a5a35; }
body.hub-tier-silver  { --hub-tier-rgb: 148, 163, 184; --hub-tier-deep: #64748b; }
body.hub-tier-gold    { --hub-tier-rgb: 234, 179, 8;   --hub-tier-deep: #b45309; }
body.hub-tier-diamond { --hub-tier-rgb: 56, 189, 248;  --hub-tier-deep: #0369a1; }
body.hub-tier-legend  { --hub-tier-rgb: 192, 132, 252; --hub-tier-deep: #7e22ce; }

body.hub-tier-bronze {
    background: linear-gradient(145deg, rgba(205, 127, 50, 0.36) 0%, #a1c4fd 42%, #c2e9fb 100%);
}
body.hub-tier-silver {
    background: linear-gradient(145deg, rgba(148, 163, 184, 0.42) 0%, #a1c4fd 40%, #dbeafe 100%);
}
body.hub-tier-gold {
    background: linear-gradient(145deg, rgba(234, 179, 8, 0.34) 0%, #93c5fd 38%, #bae6fd 100%);
}
body.hub-tier-diamond {
    background: linear-gradient(145deg, rgba(56, 189, 248, 0.38) 0%, #7dd3fc 35%, #e0f2fe 100%);
}
body.hub-tier-legend {
    background: linear-gradient(145deg, rgba(192, 132, 252, 0.34) 0%, #a5b4fc 38%, #ddd6fe 100%);
}

body[class*="hub-tier-"] .container {
    border-color: rgba(var(--hub-tier-rgb), 0.72);
    box-shadow:
        0 20px 50px rgba(var(--hub-tier-rgb), 0.22),
        0 0 0 1px rgba(var(--hub-tier-rgb), 0.14),
        inset 0 1px 0 rgba(255, 255, 255, 0.85);
    transition: border-color 0.65s ease, box-shadow 0.65s ease;
}

body[class*="hub-tier-"] .hero-calendar {
    color: var(--hub-tier-deep);
}

body[class*="hub-tier-"] .term-date {
    color: var(--hub-tier-deep);
    opacity: 0.72;
}

body[class*="hub-tier-"] .term-name,
body[class*="hub-tier-"] .term-week,
body[class*="hub-tier-"] .term-label--solo {
    color: var(--hub-tier-deep);
}

body[class*="hub-tier-"] .section-title--pending {
    color: var(--hub-tier-deep);
    opacity: 0.82;
}

.container {
    position: relative;
    width: 100%;
    max-width: 700px;
    background: rgba(255, 255, 255, 0.95);
    padding: 22px 15px 40px;
    border-radius: 40px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.1);
    text-align: center;
    border: 4px solid #fff;
    backdrop-filter: blur(12px);
    transition: border-color 0.65s ease, box-shadow 0.65s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 1.5vh;
    margin-bottom: auto;
    animation: bounceIn 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes bounceIn {
    0%   { opacity: 0; transform: scale(0.95); }
    100% { opacity: 1; transform: scale(1); }
}

.screen {
    display: none;
    width: 100%;
    flex-direction: column;
    align-items: center;
    animation: bounceIn 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.screen.is-visible {
    display: flex;
}

.screen.is-hidden {
    display: none;
}

/* ── Global tools (lang toggle) ── */
.global-tools {
    position: absolute;
    top: 14px;
    right: 14px;
    z-index: 5;
}

.global-tools.is-hidden {
    display: none;
}

.hub-notice-overlay {
    position: fixed;
    inset: 0;
    z-index: 1100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(15, 23, 42, 0.45);
}

.hub-notice-overlay.is-hidden {
    display: none;
}

.hub-notice-card {
    width: 100%;
    max-width: 340px;
    background: #fff;
    border-radius: 22px;
    border: 4px solid #e2e8f0;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.15);
    padding: 22px 20px;
    text-align: center;
}

.hub-notice-text {
    margin: 0;
    font-size: 15px;
    font-weight: 800;
    color: #334155;
    line-height: 1.5;
}

.top-nav-btn {
    background: white;
    border: 2px solid var(--border);
    border-radius: 20px;
    padding: 6px 14px;
    font-size: 12px;
    font-weight: 900;
    color: var(--text-muted);
    cursor: pointer;
    font-family: inherit;
    box-shadow: 0 2px 0 var(--shadow-border);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: background 0.15s;
}

.top-nav-btn:active { transform: translateY(2px); box-shadow: none; }

.parent-login-btn {
    color: #7c3aed;
    border-color: #ddd6fe;
    box-shadow: 0 2px 0 #ddd6fe;
    text-decoration: none;
}

/* ── Calendar (dashboard hero, left) ── */
.hero-calendar,
#school-term-display {
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 2px;
    user-select: none;
    min-width: 0;
    text-align: left;
}

.term-date {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 800;
    line-height: 1.2;
}

.term-label {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 2px 4px;
    max-width: 100%;
    line-height: 1.15;
}

.term-name,
.term-week {
    font-size: 15px;
    color: #3b82f6;
    font-weight: 900;
}

.term-week {
    flex: 1 1 100%;
}

.term-label--solo {
    display: block;
    font-size: 15px;
    color: #3b82f6;
    font-weight: 900;
}

/* ── Dashboard hero: calendar | identity | level ── */
.dashboard-hero {
    display: grid;
    grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.35fr) minmax(0, 1.15fr);
    align-items: center;
    gap: 8px 6px;
    width: 100%;
    margin-bottom: 14px;
}

.hero-calendar--clickable {
    cursor: pointer;
}

.hero-calendar {
    align-self: center;
}

.hero-identity {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-width: 0;
    text-align: center;
    padding-top: 0;
}

.hero-level {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    align-self: center;
    min-width: 0;
}

.hero-identity .avatar-btn .avatar {
    width: 64px;
    height: 64px;
}

.hero-identity h2 {
    margin: 0;
    font-size: clamp(18px, 4.8vw, 26px);
    color: #0f172a;
    font-weight: 900;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.15;
}

/* ── Subject section title (includes check-in hint) ── */
.section-title {
    width: 100%;
    text-align: left;
    margin: 0 0 15px 5px;
    font-size: clamp(15px, 4vw, 18px);
    font-weight: 900;
    color: #334155;
    line-height: 1.35;
}

.section-title--pending {
    color: #64748b;
}

.section-title--done {
    color: #0369a1;
}

/* lang-toggle lives in .global-tools */
.footer-actions {
    display: flex;
    gap: 10px;
    width: 100%;
    margin-top: 4px;
}

.footer-btn {
    margin-bottom: 0;
    padding: 14px 12px;
    font-size: 15px;
    text-decoration: none;
}

.footer-btn--switch {
    flex: 3;
    min-width: 0;
}

.footer-btn--parent {
    flex: 1;
    min-width: 0;
    color: #7c3aed;
    background: #faf5ff;
    border-color: #ddd6fe;
    box-shadow: 0 4px 0 #ddd6fe;
}

.footer-btn--parent:active {
    box-shadow: none;
}

.footer-actions--single .footer-btn--parent {
    flex: 1;
}

.registered-empty-msg {
    margin: 12px 0 20px;
    color: #64748b;
    font-size: 15px;
    font-weight: 800;
    line-height: 1.5;
    text-align: center;
}

/* ── User picker ── */
.user-screen-title {
    margin: 0 0 5px;
    color: #0f172a;
    font-size: 30px;
    font-weight: 900;
}

@keyframes popPulse {
    0%   { transform: scale(1); }
    100% { transform: scale(1.15) translateY(-3px); text-shadow: 0 0 15px rgba(234, 179, 8, 0.5); }
}

button.name-btn {
    width: 100%;
    max-width: 320px;
    padding: 20px;
    border-radius: 30px;
    border: 4px solid var(--border);
    background: white;
    cursor: pointer;
    font-weight: 900;
    font-size: 26px;
    color: #475569;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    box-shadow: 0 8px 0 var(--shadow-border);
    outline: none;
    margin-bottom: 20px;
    font-family: inherit;
}

button.name-btn:active {
    transform: translateY(8px);
    box-shadow: none;
}

.name-btn .avatar {
    font-size: 46px;
    filter: drop-shadow(0 4px 4px rgba(0, 0, 0, 0.1));
}

/* ── Dashboard header (legacy selectors → hero) ── */
.dashboard-header .avatar,
.hero-identity .avatar {
    font-size: 50px;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.15));
}

.avatar-btn {
    border: none;
    background: transparent;
    padding: 0;
    cursor: pointer;
    flex-shrink: 0;
}

.avatar-btn .avatar {
    width: 67px;
    height: 67px;
    border-radius: 50%;
    background: white;
    border: 3px solid #dbeafe;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.avatar-btn .avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scale(1.05);
}

.dash-avatar-emoji {
    display: inline-block;
    line-height: 1;
}

.hero-level-btn {
    display: none; /* shown by JS once level loads */
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    border: none;
    background: transparent;
    padding: 0;
    cursor: pointer;
    font-family: inherit;
    flex-shrink: 0;
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

.level-num {
    display: block;
    font-size: clamp(28px, 7.5vw, 36px);
    font-weight: 900;
    line-height: 1;
    letter-spacing: -0.03em;
    color: #0f172a;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.65);
}

.tier-plate {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px 14px 9px;
    min-width: 92px;
    max-width: 120px;
    background: linear-gradient(145deg, #f8fafc 0%, #e2e8f0 45%, #cbd5e1 100%);
    border: 3px solid #94a3b8;
    border-radius: 16px;
    font-weight: 900;
    font-size: clamp(15px, 4vw, 18px);
    letter-spacing: 0.02em;
    white-space: nowrap;
    color: #334155;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.72),
        inset 0 -2px 0 rgba(15, 23, 42, 0.14),
        0 6px 14px rgba(15, 23, 42, 0.2);
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.55);
    position: relative;
    overflow: hidden;
    line-height: 1.1;
    transition: transform 0.12s, box-shadow 0.12s, filter 0.12s;
}

.hero-level-btn:active .tier-plate {
    transform: scale(0.96);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.56),
        inset 0 -1px 0 rgba(15, 23, 42, 0.18),
        0 2px 5px rgba(15, 23, 42, 0.14);
}

.tier-plate::before {
    content: '';
    position: absolute;
    left: 8%;
    top: 8%;
    width: 84%;
    height: 42%;
    border-radius: 10px;
    background: linear-gradient(180deg, rgba(255,255,255,0.62) 0%, rgba(255,255,255,0) 100%);
    pointer-events: none;
}

.tier-plate::after {
    content: '';
    position: absolute;
    top: -40%;
    left: -18%;
    width: 36%;
    height: 190%;
    transform: rotate(22deg);
    background: linear-gradient(90deg, rgba(255,255,255,0) 0%, rgba(255,255,255,0.45) 48%, rgba(255,255,255,0) 100%);
    pointer-events: none;
}

.hero-level-btn.tier-bronze .level-num { color: #7a4f2c; }
.hero-level-btn.tier-bronze .tier-plate {
    background: linear-gradient(145deg, #f7e0c2 0%, #d9a56e 45%, #9a6a3d 100%);
    border-color: #8a5a35;
    color: #5c3b21;
    box-shadow:
        inset 0 1px 0 rgba(255, 241, 223, 0.7),
        inset 0 -2px 0 rgba(92, 59, 33, 0.28),
        0 7px 16px rgba(92, 59, 33, 0.32);
}

.hero-level-btn.tier-silver .level-num { color: #475569; }
.hero-level-btn.tier-silver .tier-plate {
    background: linear-gradient(145deg, #f8fafc 0%, #d1d9e5 42%, #96a3b5 100%);
    border-color: #7b889b;
    color: #334155;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.74),
        inset 0 -2px 0 rgba(51, 65, 85, 0.24),
        0 7px 16px rgba(51, 65, 85, 0.26);
}

.hero-level-btn.tier-gold .level-num { color: #a16207; }
.hero-level-btn.tier-gold .tier-plate {
    background: linear-gradient(145deg, #fff8c6 0%, #f5c542 42%, #c9830d 100%);
    border-color: #b87000;
    color: #7c4100;
    box-shadow:
        inset 0 1px 0 rgba(255, 248, 201, 0.74),
        inset 0 -2px 0 rgba(124, 65, 0, 0.28),
        0 7px 16px rgba(124, 65, 0, 0.28);
}

.hero-level-btn.tier-diamond .level-num { color: #0e7490; }
.hero-level-btn.tier-diamond .tier-plate {
    background: linear-gradient(145deg, #eefcff 0%, #b5f0ff 45%, #4bb8db 100%);
    border-color: #2d8bb1;
    color: #0b4f69;
    box-shadow:
        inset 0 1px 0 rgba(240, 253, 255, 0.75),
        inset 0 -2px 0 rgba(11, 79, 105, 0.24),
        0 7px 16px rgba(11, 79, 105, 0.27);
}

.hero-level-btn.tier-legend .level-num { color: #7b1fa2; }
.hero-level-btn.tier-legend .tier-plate {
    background: linear-gradient(145deg, #fce4f3 0%, #ce93d8 42%, #8e24aa 100%);
    border-color: #7b1fa2;
    color: #4a148c;
    box-shadow:
        inset 0 1px 0 rgba(252, 228, 243, 0.74),
        inset 0 -2px 0 rgba(74, 20, 140, 0.26),
        0 7px 16px rgba(74, 20, 140, 0.28);
}

.streak-info-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.streak-badge {
    font-size: 15px;
    padding: 8px 20px;
    border-radius: 16px;
    font-weight: 900;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.streak-badge.pending {
    background: #f8fafc;
    color: var(--text-muted);
    border: 2px solid #e2e8f0;
    box-shadow: 0 3px 0 #e2e8f0;
    filter: grayscale(40%);
    opacity: 0.92;
}

.streak-badge.completed {
    background: #f0f9ff;
    color: #64748b;
    border: 2px solid #dbeafe;
    box-shadow: 0 3px 0 #dbeafe;
    filter: grayscale(0%);
    opacity: 1;
    animation: bounceIn 0.5s ease-out;
}

/* lang-toggle lives in .global-tools */

/* ── Subject grid ── */
.grid-cards {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    width: 100%;
    margin-bottom: 25px;
}

.card-btn {
    background: white;
    border: 4px solid var(--border);
    border-radius: 25px;
    padding: 20px 5px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    color: #475569;
    font-weight: 900;
    font-size: 18px;
    box-shadow: 0 6px 0 var(--shadow-border);
    font-family: inherit;
    outline: none;
}

.card-btn:active {
    transform: translateY(6px);
    box-shadow: none;
}

.card-btn .emoji {
    font-size: 38px;
    filter: drop-shadow(0 3px 3px rgba(0, 0, 0, 0.1));
}

.card-btn.eng { border-color: #bae6fd; }
.card-btn.math { border-color: #fbcfe8; }
.card-btn.cn  { border-color: #e9d5ff; }
.card-btn.sci { border-color: #a7f3d0; }

/* ── Honor wall (legacy) ── */
.honor-wall {
    width: 100%;
    background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
    border: 4px solid #fde68a;
    border-radius: 30px;
    padding: 15px;
    margin-bottom: 30px;
    text-align: left;
    box-shadow: inset 0 4px 15px rgba(245, 158, 11, 0.1), 0 10px 20px rgba(0, 0, 0, 0.05);
    position: relative;
    overflow: hidden;
}

.honor-wall::after {
    content: '✨';
    position: absolute;
    top: -15px;
    right: -5px;
    font-size: 100px;
    opacity: 0.15;
    transform: rotate(15deg);
    pointer-events: none;
}

.honor-wall-heading {
    margin: 0 0 15px;
    font-size: 22px;
    color: #d97706;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    font-weight: 900;
    z-index: 2;
    position: relative;
}

.honor-wall-heading-left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.total-trophies {
    font-size: 14px;
    background: white;
    padding: 6px 12px;
    border-radius: 20px;
    color: #f59e0b;
    border: 2px solid #fcd34d;
    box-shadow: 0 4px 0 #fde68a;
    display: flex;
    align-items: center;
    gap: 5px;
}

.total-number {
    font-size: 18px;
    font-weight: 900;
    color: #d97706;
}

.shop-btn {
    background: #f59e0b;
    color: white;
    border: none;
    padding: 10px 18px;
    border-radius: 20px;
    font-weight: 900;
    font-size: 16px;
    cursor: pointer;
    box-shadow: 0 6px 0 #d97706;
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: inherit;
    white-space: nowrap;
}

.shop-btn:active {
    transform: translateY(6px);
    box-shadow: none;
}

.badges-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
    position: relative;
    z-index: 2;
}

.badge-category { width: 100%; }

.badge-category-title {
    font-size: 15px;
    color: #b45309;
    font-weight: 900;
    margin-bottom: 12px;
    border-bottom: 2px dashed #fde68a;
    padding-bottom: 5px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.badge-category-title.easter {
    color: #9333ea;
    border-bottom-color: #d8b4fe;
}

.badge-category-title.streak {
    color: #64748b;
    border-bottom-color: #dbeafe;
}

.badge-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 15px 8px;
    width: 100%;
}

.badge-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    transition: 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    width: 75px;
    flex-shrink: 0;
}

.badge-item.locked {
    opacity: 0.45;
    filter: grayscale(100%);
    transform: scale(0.95);
}

.badge-item.unlocked {
    opacity: 1;
    filter: grayscale(0%);
    transform: scale(1.05);
}

.badge-icon-wrapper {
    position: relative;
    display: flex;
    justify-content: center;
}

.badge-icon {
    width: 48px;
    height: 48px;
    border-radius: 16px;
    background: white;
    border: 3px solid #cbd5e1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    box-shadow: 0 4px 0 #94a3b8;
    transition: 0.3s;
}

.badge-item.unlocked .badge-icon {
    border-color: #f59e0b;
    background: #fffbeb;
    box-shadow: 0 4px 0 #d97706, 0 0 10px rgba(245, 158, 11, 0.3);
}

.badge-item.unlocked.bronze .badge-icon {
    border-color: #cd7f32;
    box-shadow: 0 4px 0 #8b5a2b;
    background: #fdf5e6;
}

.badge-item.unlocked.silver .badge-icon {
    border-color: #94a3b8;
    box-shadow: 0 4px 0 #64748b;
    background: #f1f5f9;
}

.badge-item.unlocked.gold .badge-icon {
    border-color: #fbbf24;
    box-shadow: 0 4px 0 #d97706;
    background: #fffbeb;
}

/* Streak / check-in badges — soft crystal frame */
.badge-item.streak .badge-icon {
    border-color: #dbeafe;
    background: linear-gradient(145deg, #f8fcff 0%, #f0f9ff 55%, #e0f2fe 100%);
    box-shadow: 0 3px 0 #cbd5e1, 0 0 6px rgba(186, 230, 253, 0.35);
}

.badge-item.streak.unlocked .badge-icon {
    border-color: #bfdbfe;
    background: linear-gradient(145deg, #f8fcff 0%, #f0f9ff 50%, #e0f2fe 100%);
    box-shadow: 0 3px 0 #cbd5e1, 0 0 8px rgba(186, 230, 253, 0.4);
}

.badge-item.streak.locked .badge-icon {
    border: 3px dashed #dbeafe;
    background: linear-gradient(145deg, #fafcff 0%, #f0f9ff 100%);
    box-shadow: none;
}

.badge-icon .badge-streak-num {
    display: block;
    font-weight: 900;
    color: #0369a1;
    line-height: 1;
    letter-spacing: -0.04em;
    font-variant-numeric: tabular-nums;
    max-width: 100%;
    text-align: center;
    white-space: nowrap;
}

.badge-streak-num.streak-num-d1 { font-size: 28px; }
.badge-streak-num.streak-num-d2 { font-size: 22px; }
.badge-streak-num.streak-num-d3 { font-size: 16px; }
.badge-streak-num.streak-num-d4 { font-size: 12px; letter-spacing: -0.06em; }

.badge-item.locked .badge-icon {
    border: 3px dashed #94a3b8;
    background: #f1f5f9;
    box-shadow: none;
    font-size: 24px;
}

.badge-count {
    position: absolute;
    top: -6px;
    right: -6px;
    background: #ef4444;
    color: white;
    font-size: 11px;
    font-weight: 900;
    padding: 2px 6px;
    border-radius: 10px;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    animation: popPulse 2s infinite alternate;
    z-index: 3;
    white-space: nowrap;
}

.badge-name {
    font-size: 11px;
    font-weight: 900;
    color: #64748b;
    text-align: center;
    line-height: 1.2;
    width: 100%;
    min-height: 2.4em;
    display: block;
}

.badge-item.unlocked .badge-name {
    color: #d97706;
}

.badge-item.streak.unlocked .badge-name {
    color: #64748b;
}

.badge-progress {
    font-size: 10px;
    color: #94a3b8;
    font-weight: 800;
    margin-top: 2px;
    text-align: center;
    width: 100%;
}

/* ── Submenus ── */
.submenu-title {
    margin: 0 0 20px;
    font-size: 26px;
    font-weight: 900;
    color: #0f172a;
}

.menu-row {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    width: 100%;
    margin-bottom: 15px;
}

.menu-btn {
    flex: 1 1 40%;
    min-width: 120px;
    background: white;
    border: 4px solid var(--border);
    border-radius: 20px;
    padding: 20px 10px;
    font-size: 18px;
    font-weight: 900;
    color: #475569;
    cursor: pointer;
    box-shadow: 0 6px 0 var(--shadow-border);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    font-family: inherit;
    outline: none;
}

.menu-btn:active {
    transform: translateY(6px);
    box-shadow: none;
}

.menu-btn .emoji { font-size: 32px; }
.menu-btn--eng { border-color: #bae6fd; color: #0284c7; }
.menu-btn--cn  { border-color: #e9d5ff; color: #be185d; }

/* ── Actions ── */
.btn-action {
    width: 100%;
    border-radius: 20px;
    font-weight: 900;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    outline: none;
    padding: 18px;
    box-shadow: 0 6px 0 rgba(0, 0, 0, 0.1);
    background: #f1f5f9;
    color: var(--text-muted);
    border: 4px solid var(--border);
    font-family: inherit;
}

.btn-action:active {
    transform: translateY(6px);
    box-shadow: none;
}

/* ── Name gate (new user entry) ── */
.name-gate {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: min(100%, 400px);
    gap: clamp(14px, 3vw, 20px);
    padding: 10px 0 4px;
}

.name-gate-input {
    width: 100%;
    padding: 16px 20px;
    border: 4px solid var(--border);
    border-radius: 20px;
    font-size: 20px;
    font-weight: 900;
    font-family: inherit;
    color: var(--text-main);
    background: #f8fafc;
    outline: none;
    text-align: center;
    box-shadow: 0 4px 0 var(--shadow-border);
    transition: border-color 0.2s;
}

.name-gate-input:focus { border-color: #93c5fd; background: #eff6ff; }
.name-gate-input.error  { border-color: #fca5a5; background: #fef2f2; }

.grade-picker {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: clamp(10px, 2.5vw, 14px);
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
}

.grade-picker .grade-btn {
    width: 100%;
    min-height: clamp(40px, 10vw, 46px);
    padding: clamp(8px, 2vw, 10px) 14px;
    font-size: clamp(16px, 4.2vw, 19px);
    border-radius: 999px;
    line-height: 1.1;
}

.avatar-picker-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: clamp(8px, 2vw, 12px);
    width: 100%;
    max-width: 320px;
    margin: 0 auto;
}

.avatar-pick-btn {
    aspect-ratio: 1;
    padding: 0;
    border: 3px solid var(--border);
    border-radius: 16px;
    background: white;
    cursor: pointer;
    box-shadow: 0 4px 0 var(--shadow-border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: inherit;
    transition: border-color 0.15s, transform 0.1s;
    overflow: hidden;
}

.avatar-pick-btn:active { transform: translateY(4px); box-shadow: none; }

.avatar-pick-btn.selected {
    border-color: #3b82f6;
    background: #eff6ff;
    box-shadow: 0 4px 0 #2563eb;
}

.avatar-pick-btn .avatar-pick-emoji {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(28px, 8vw, 36px);
    line-height: 1;
    background: transparent;
    box-sizing: border-box;
}

.gender-picker {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: clamp(10px, 2.5vw, 14px);
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
}

.gender-btn {
    padding: 14px 10px;
    border: 3px solid var(--border);
    border-radius: 16px;
    background: white;
    font-size: 15px;
    font-weight: 900;
    font-family: inherit;
    color: var(--text-muted);
    cursor: pointer;
    box-shadow: 0 4px 0 var(--shadow-border);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    transition: background 0.15s, border-color 0.15s;
}

.gender-btn .gender-emoji { font-size: 32px; line-height: 1; }

.gender-btn:active { transform: translateY(4px); box-shadow: none; }

.gender-btn.selected {
    background: #eff6ff;
    border-color: #3b82f6;
    color: #1d4ed8;
    box-shadow: 0 4px 0 #2563eb;
}

.gender-btn.selected.boy {
    background: #eff6ff;
    border-color: #3b82f6;
}

.gender-btn.selected.girl {
    background: #fdf2f8;
    border-color: #f472b6;
    color: #be185d;
    box-shadow: 0 4px 0 #db2777;
}

.name-gate-label {
    font-size: 14px;
    font-weight: 900;
    color: var(--text-muted);
    margin: 0 0 8px;
    text-align: center;
}

.grade-btn {
    padding: 12px 8px;
    border: 3px solid var(--border);
    border-radius: 16px;
    background: white;
    font-size: 17px;
    font-weight: 900;
    font-family: inherit;
    color: var(--text-muted);
    cursor: pointer;
    box-shadow: 0 5px 0 var(--shadow-border);
    transition: background 0.15s, border-color 0.15s;
    touch-action: manipulation;
}

.grade-btn:active  { transform: translateY(4px); box-shadow: none; }

.grade-btn.selected {
    background: #3b82f6;
    border-color: #2563eb;
    color: white;
    box-shadow: 0 4px 0 #1d4ed8;
}

.name-gate-error {
    font-size: 13px;
    color: #ef4444;
    font-weight: 800;
    min-height: 20px;
}

.btn-start {
    width: 100%;
    padding: 18px;
    background: #3b82f6;
    color: white;
    border: none;
    border-radius: 20px;
    font-size: 20px;
    font-weight: 900;
    font-family: inherit;
    cursor: pointer;
    box-shadow: 0 6px 0 #1d4ed8;
}

.btn-start:active { transform: translateY(6px); box-shadow: none; }

.btn-start:disabled {
    background: #94a3b8;
    box-shadow: 0 6px 0 #64748b;
    cursor: not-allowed;
}

/* Profile pick: add-profile button */
.name-btn-add {
    width: 100%;
    max-width: 320px;
    padding: 14px 20px;
    border-radius: 30px;
    border: 4px dashed var(--border);
    background: #f8fafc;
    cursor: pointer;
    font-weight: 900;
    font-size: 18px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-family: inherit;
    margin-bottom: 12px;
    transition: border-color 0.15s;
}

.name-btn-add:active { transform: translateY(6px); }
.name-btn-add:hover  { border-color: #93c5fd; color: #3b82f6; }

@media (min-width: 480px) {
    .name-gate { max-width: 420px; }

    .grade-picker .grade-btn {
        min-height: 44px;
        font-size: 18px;
    }

    .gender-btn {
        min-height: 88px;
        font-size: 16px;
    }

    .gender-btn .gender-emoji { font-size: 36px; }
}

@media (min-width: 768px) {
    .container { padding: 40px 50px; max-width: 750px; }
    .grid-cards { grid-template-columns: repeat(4, 1fr); }
    .badge-grid { gap: 15px 10px; }
    .badge-icon { width: 56px; height: 56px; font-size: 30px; border-radius: 18px; }
    .badge-name { font-size: 13px; }
    .badge-count { font-size: 12px; padding: 2px 8px; top: -8px; right: -8px; }

    .name-gate { max-width: 440px; }

    .grade-picker .grade-btn {
        min-height: 46px;
        font-size: 19px;
    }
}

/* Narrow phones: keep tap targets large without overflowing */
@media (max-width: 360px) {
    .name-gate { padding: 8px 4px 4px; }

    .grade-picker { gap: 8px; }

    .grade-picker .grade-btn {
        min-height: 38px;
        font-size: 16px;
        padding: 8px 10px;
    }
}

/* ── Child PIN gate ── */
.kid-pin-header { margin-bottom: 8px; }

.kid-pin-avatar {
    font-size: 48px;
    line-height: 1;
    margin-bottom: 8px;
}

.kid-pin-title {
    margin: 0 0 4px;
    font-size: 22px;
    font-weight: 900;
    color: var(--text-main);
}

.kid-pin-subtitle {
    margin: 0 0 12px;
    font-size: 14px;
    font-weight: 800;
    color: var(--text-muted);
}

.kid-pin-dots {
    display: flex;
    gap: 16px;
    justify-content: center;
    margin: 8px 0;
}

.kid-pin-dot {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 3px solid #34d399;
    background: #fff;
    transition: background 0.15s, transform 0.15s;
}

.kid-pin-dot.filled {
    background: var(--primary);
    border-color: var(--primary);
    transform: scale(1.12);
}

.kid-pin-dot.error {
    background: #ef4444;
    border-color: #ef4444;
    animation: kidPinShake 0.4s ease;
}

@keyframes kidPinShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.kid-pin-msg {
    min-height: 20px;
    font-size: 13px;
    font-weight: 900;
    color: #ef4444;
    margin: 4px 0 8px;
}

.kid-pin-hidden-input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    width: 1px;
    height: 1px;
}

.kid-pin-keypad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    width: 100%;
    max-width: 280px;
    margin: 12px 0 16px;
}

.kid-pin-key {
    padding: 16px 0;
    background: white;
    border: 3px solid var(--border);
    border-radius: 16px;
    font-size: 20px;
    font-weight: 900;
    font-family: inherit;
    color: var(--text-main);
    cursor: pointer;
    box-shadow: 0 4px 0 var(--shadow-border);
}

.kid-pin-key:active {
    transform: translateY(4px);
    box-shadow: none;
}

.kid-pin-key-blank {
    background: transparent;
    border: none;
    box-shadow: none;
    cursor: default;
}

.kid-pin-key-del { color: var(--text-muted); font-size: 17px; }

#kid-pin-cancel-btn { margin-top: 4px; }

/* ── Avatar Modal (student index only) ── */
.avatar-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.42);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 30;
    padding: 16px;
}

.avatar-modal-overlay.is-hidden {
    display: none;
}

.avatar-modal-card {
    width: min(560px, 96vw);
    background: #ffffff;
    border: 4px solid #e2e8f0;
    border-radius: 22px;
    padding: 14px;
}

.avatar-modal-title {
    font-size: 20px;
    font-weight: 900;
    color: #0f172a;
    text-align: center;
    margin-bottom: 10px;
}

.avatar-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 12px;
    max-height: 58vh;
    overflow-y: auto;
    padding-right: 2px;
}

.avatar-group-section {
    border: 2px solid #e2e8f0;
    border-radius: 16px;
    padding: 8px;
    background: #f8fafc;
}

.avatar-group-title {
    font-size: 14px;
    font-weight: 900;
    color: #334155;
    margin-bottom: 8px;
    text-align: left;
}

.avatar-group-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 10px;
}


.avatar-pick {
    aspect-ratio: 1;
    border: 3px solid #cbd5e1;
    border-radius: 16px;
    background: #fff;
    padding: 0;
    overflow: hidden;
    cursor: pointer;
}

/* Premium/custom PNG tiles: 90% size, centered (emoji default group unchanged). */
.avatar-pick--image {
    display: flex;
    align-items: center;
    justify-content: center;
}

.avatar-pick:disabled {
    cursor: not-allowed;
}

.avatar-pick.selected {
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2) inset;
}

.avatar-pick--image img {
    width: 90%;
    height: 90%;
    object-fit: contain;
    object-position: center;
    display: block;
    flex-shrink: 0;
}

.avatar-pick .avatar-pick-emoji {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 34px;
    line-height: 1;
    background: #fff;
}

.avatar-group-section--default .avatar-pick-emoji {
    font-size: 68px; /* 200% of 34px base size */
    padding-top: 0.1em;
}

.avatar-group-section--locked {
    position: relative;
}

.avatar-group-section--locked .avatar-pick {
    filter: grayscale(100%);
    opacity: 0.55;
}

.avatar-premium-hint {
    margin-top: 8px;
    font-size: 12px;
    font-weight: 900;
    color: #64748b;
    text-align: center;
}

/* ── Streak break modal ── */
.streak-break-overlay {
    position: fixed;
    inset: 0;
    z-index: 1200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(15, 23, 42, 0.45);
}

.streak-break-overlay.is-hidden {
    display: none;
}

.streak-break-card {
    width: 100%;
    max-width: 360px;
    background: #fff;
    border-radius: 24px;
    border: 4px solid #e2e8f0;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.15);
    padding: 22px 20px 18px;
    text-align: center;
}

.streak-break-title {
    margin: 0 0 10px;
    font-size: 22px;
    font-weight: 900;
    color: #0f172a;
}

.streak-break-body {
    margin: 0 0 12px;
    font-size: 14px;
    font-weight: 800;
    color: #64748b;
    line-height: 1.45;
}

.streak-break-hint {
    margin: 0 0 14px;
    padding: 10px 12px;
    font-size: 12px;
    font-weight: 800;
    color: #475569;
    line-height: 1.45;
    background: #f8fafc;
    border-radius: 12px;
    border: 2px dashed #cbd5e1;
    text-align: left;
}

.streak-break-meta {
    margin: 0 0 14px;
    font-size: 13px;
    font-weight: 900;
    color: #0369a1;
}

.streak-break-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.streak-break-actions .btn-action {
    width: 100%;
    font-size: 15px;
    padding: 14px 12px;
}

.streak-break-actions .btn-action--secondary {
    background: #f1f5f9;
    color: #475569;
    border-color: #cbd5e1;
    box-shadow: 0 4px 0 #94a3b8;
}

.streak-break-actions .btn-action--shield {
    background: linear-gradient(135deg, #e0f2fe 0%, #bae6fd 100%);
    color: #0369a1;
    border-color: #7dd3fc;
    box-shadow: 0 4px 0 #0284c7;
}

