:root {
    --bg-sky: #f0f7ff;
    --bg-card: #ffffff;
    --ink: #1e293b;
    --ink-soft: #475569;
    --blue: #2563eb;
    --blue-dark: #1d4ed8;
    --green: #16a34a;
    --green-dark: #15803d;
    --orange: #f97316;
    --orange-dark: #c2410c;
    --purple: #7c3aed;
    --purple-dark: #6d28d9;
    --pink: #ec4899;
    --yellow: #facc15;
    --yellow-dark: #ca8a04;
    --red: #ef4444;
    --radius-lg: 24px;
    --radius-md: 18px;
    --radius-sm: 14px;
    --shadow-card: 0 8px 24px rgba(30, 41, 59, 0.08);
    --shadow-pop: 0 6px 0 rgba(15, 23, 42, 0.14);
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    margin: 0;
    padding: 0;
    font-family: 'Nunito', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: var(--ink);
    background: linear-gradient(180deg, #e6f2ff 0%, #f6faff 40%, #fffdf5 100%);
    min-height: 100vh;
    overflow-x: hidden;
}

h1, h2, h3, h4, .fun-font {
    font-family: 'Fredoka', 'Nunito', sans-serif;
    letter-spacing: 0.01em;
}

/* === LAYOUT & NAVIGATION === */
.app-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding-bottom: 86px; /* Space for mobile bottom tab bar */
}

.top-bar {
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(12px);
    border-bottom: 3px solid #dbeafe;
    padding: 10px 14px;
}

.top-bar-inner {
    max-width: 1080px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.brand-link {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: var(--ink);
}

.brand-badge {
    width: 40px;
    height: 40px;
    border-radius: 14px;
    background: linear-gradient(135deg, #38bdf8, #2563eb);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    box-shadow: 0 3px 0 #1d4ed8;
}

.brand-title {
    font-family: 'Fredoka', sans-serif;
    font-weight: 700;
    font-size: 1.05rem;
    line-height: 1.05;
    color: #1e3a8a;
}

.brand-sub {
    font-size: 0.72rem;
    font-weight: 800;
    color: #f97316;
    display: block;
}

.desktop-nav {
    display: none;
    align-items: center;
    gap: 6px;
}

.desktop-nav a {
    text-decoration: none;
    color: var(--ink-soft);
    font-weight: 800;
    font-size: 0.9rem;
    padding: 8px 12px;
    border-radius: 14px;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.desktop-nav a:hover {
    background: #eff6ff;
    color: var(--blue);
}

.desktop-nav a.active {
    background: #dbeafe;
    color: #1d4ed8;
}

.top-stats {
    display: flex;
    align-items: center;
    gap: 6px;
}

.stat-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 11px;
    border-radius: 999px;
    font-weight: 800;
    font-size: 0.85rem;
    text-decoration: none;
    border: 2px solid transparent;
    cursor: pointer;
    transition: transform 0.12s ease;
}

.stat-pill:active {
    transform: scale(0.95);
}

.pill-stars {
    background: #fef9c3;
    border-color: #fde047;
    color: #854d0e;
}

.pill-time {
    background: #eff6ff;
    border-color: #bfdbfe;
    color: #1e40af;
    display: none;
}

.pill-user {
    background: #f3e8ff;
    border-color: #d8b4fe;
    color: #6b21a8;
    max-width: 130px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.icon-btn {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    border: 2px solid #e2e8f0;
    background: #ffffff;
    font-size: 1.05rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 0 #cbd5e1;
}

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

.main-content {
    flex: 1;
    width: 100%;
    max-width: 1020px;
    margin: 0 auto;
    padding: 16px 14px 28px;
}

/* Mobile Bottom Tab Bar */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 60;
    background: rgba(255, 255, 255, 0.97);
    backdrop-filter: blur(12px);
    border-top: 3px solid #dbeafe;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -6px 20px rgba(15, 23, 42, 0.08);
}

.bottom-nav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    text-decoration: none;
    color: #64748b;
    font-weight: 800;
    font-size: 0.68rem;
    padding: 5px 2px;
    border-radius: 14px;
    transition: all 0.15s ease;
}

.bottom-nav a .nav-emoji {
    font-size: 1.35rem;
    line-height: 1.1;
}

.bottom-nav a.active {
    color: #1d4ed8;
    background: #eff6ff;
}

.bottom-nav a.active .nav-emoji {
    transform: scale(1.14);
}

@media (min-width: 820px) {
    .app-shell { padding-bottom: 20px; }
    .bottom-nav { display: none; }
    .desktop-nav { display: flex; }
    .pill-time { display: inline-flex; }
    .main-content { padding: 24px 20px 40px; }
}

/* === CARDS & BUTTONS (DUOLINGO-STYLE TACTILE) === */
.kid-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 3px solid #e2e8f0;
    box-shadow: var(--shadow-card);
    padding: 18px;
}

.kid-card-blue { border-color: #93c5fd; background: linear-gradient(180deg, #ffffff 0%, #f0f9ff 100%); }
.kid-card-green { border-color: #86efac; background: linear-gradient(180deg, #ffffff 0%, #f0fdf4 100%); }
.kid-card-orange { border-color: #fdba74; background: linear-gradient(180deg, #ffffff 0%, #fff7ed 100%); }
.kid-card-purple { border-color: #d8b4fe; background: linear-gradient(180deg, #ffffff 0%, #faf5ff 100%); }
.kid-card-yellow { border-color: #fde047; background: linear-gradient(180deg, #ffffff 0%, #fefce8 100%); }

.btn-fun {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 50px;
    padding: 10px 20px;
    border-radius: 16px;
    border: none;
    font-family: 'Fredoka', 'Nunito', sans-serif;
    font-size: 1.02rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: transform 0.1s ease, box-shadow 0.1s ease, filter 0.15s ease;
    user-select: none;
}

.btn-fun:active:not(:disabled) {
    transform: translateY(4px);
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.2) !important;
}

.btn-fun:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.btn-blue { background: #3b82f6; color: #fff; box-shadow: 0 5px 0 #1d4ed8; }
.btn-green { background: #22c55e; color: #fff; box-shadow: 0 5px 0 #15803d; }
.btn-orange { background: #f97316; color: #fff; box-shadow: 0 5px 0 #c2410c; }
.btn-purple { background: #8b5cf6; color: #fff; box-shadow: 0 5px 0 #6d28d9; }
.btn-pink { background: #ec4899; color: #fff; box-shadow: 0 5px 0 #be185d; }
.btn-yellow { background: #facc15; color: #422006; box-shadow: 0 5px 0 #ca8a04; }
.btn-white { background: #ffffff; color: var(--ink); border: 2.5px solid #cbd5e1; box-shadow: 0 4px 0 #cbd5e1; }

.btn-fun:hover:not(:disabled) {
    filter: brightness(1.04);
}

/* Mode tabs inside pages */
.mode-tabs {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 4px 2px 8px;
    scrollbar-width: none;
}

.mode-tabs::-webkit-scrollbar { display: none; }

.mode-tab {
    flex: 1 0 auto;
    min-height: 46px;
    padding: 8px 14px;
    border-radius: 15px;
    border: 2.5px solid #cbd5e1;
    background: #ffffff;
    color: var(--ink-soft);
    font-family: 'Fredoka', sans-serif;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 3px 0 #cbd5e1;
    transition: all 0.12s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.mode-tab.active {
    background: #2563eb;
    border-color: #1d4ed8;
    color: #ffffff;
    box-shadow: 0 3px 0 #1e40af;
}

.mode-tab.active-green {
    background: #16a34a;
    border-color: #15803d;
    color: #ffffff;
    box-shadow: 0 3px 0 #166534;
}

.mode-tab.active-orange {
    background: #ea580c;
    border-color: #c2410c;
    color: #ffffff;
    box-shadow: 0 3px 0 #9a3412;
}

.mode-tab.active-purple {
    background: #7c3aed;
    border-color: #6d28d9;
    color: #ffffff;
    box-shadow: 0 3px 0 #5b21b6;
}

/* === LEO MASCOT === */
.leo-box {
    display: flex;
    align-items: center;
    gap: 12px;
    background: linear-gradient(135deg, #fff7ed 0%, #fef3c7 100%);
    border: 3px solid #fdba74;
    border-radius: 22px;
    padding: 12px 16px;
}

.leo-avatar {
    flex-shrink: 0;
    width: 64px;
    height: 64px;
    animation: leoBounce 3s ease-in-out infinite;
}

.leo-bubble {
    font-weight: 700;
    font-size: 0.96rem;
    line-height: 1.38;
    color: #7c2d12;
}

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

/* === INTERACTIVE SVG MAPS === */
.map-wrapper {
    background: radial-gradient(circle at 50% 45%, #e0f2fe 0%, #bae6fd 100%);
    border: 3px solid #7dd3fc;
    border-radius: 24px;
    padding: 10px;
    position: relative;
    overflow: hidden;
}

.map-svg {
    width: 100%;
    height: auto;
    max-height: 480px;
    display: block;
    margin: 0 auto;
    filter: drop-shadow(0 6px 10px rgba(15, 23, 42, 0.14));
}

.map-shape {
    cursor: pointer;
    stroke: #ffffff;
    stroke-width: 2.4;
    stroke-linejoin: round;
    transition: transform 0.18s ease, filter 0.18s ease, opacity 0.18s ease;
    transform-box: fill-box;
    transform-origin: center;
}

.map-shape:hover {
    filter: brightness(1.09);
}

.map-shape.selected {
    stroke: #1e293b;
    stroke-width: 4;
    filter: brightness(1.08) drop-shadow(0 0 8px rgba(250, 204, 21, 0.85));
}

.map-shape.hint-pulse {
    animation: pulseGlow 0.9s ease-in-out infinite;
    stroke: #facc15;
    stroke-width: 5;
}

.map-shape.correct-flash {
    fill: #22c55e !important;
    stroke: #14532d;
    stroke-width: 4;
}

.map-shape.wrong-flash {
    fill: #ef4444 !important;
    stroke: #7f1d1d;
    stroke-width: 4;
}

.map-label {
    font-family: 'Fredoka', sans-serif;
    font-weight: 700;
    fill: #0f172a;
    paint-order: stroke;
    stroke: rgba(255, 255, 255, 0.92);
    stroke-width: 4px;
    stroke-linejoin: round;
    pointer-events: none;
    text-anchor: middle;
}

@keyframes pulseGlow {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.45; }
}

/* === QUIZ & GAME ELEMENTS === */
.score-hud {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    background: #1e293b;
    color: #ffffff;
    border-radius: 18px;
    padding: 10px 14px;
    margin-bottom: 14px;
}

.hud-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: rgba(255, 255, 255, 0.13);
    padding: 5px 11px;
    border-radius: 999px;
    font-weight: 800;
    font-size: 0.88rem;
}

.hud-combo {
    background: linear-gradient(135deg, #f97316, #ef4444);
    animation: popIn 0.25s ease;
}

@keyframes popIn {
    0% { transform: scale(0.75); }
    70% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

.progress-track {
    height: 14px;
    background: #e2e8f0;
    border-radius: 999px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, #38bdf8, #2563eb);
    transition: width 0.35s ease;
}

.progress-fill-green { background: linear-gradient(90deg, #4ade80, #16a34a); }
.progress-fill-orange { background: linear-gradient(90deg, #fb923c, #ea580c); }
.progress-fill-purple { background: linear-gradient(90deg, #c084fc, #7c3aed); }

.choice-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

@media (min-width: 600px) {
    .choice-grid.two-col {
        grid-template-columns: repeat(2, 1fr);
    }
    .choice-grid.three-col {
        grid-template-columns: repeat(3, 1fr);
    }
}

.choice-btn {
    width: 100%;
    min-height: 58px;
    padding: 12px 16px;
    border-radius: 18px;
    border: 3px solid #cbd5e1;
    background: #ffffff;
    color: var(--ink);
    font-family: 'Nunito', sans-serif;
    font-weight: 800;
    font-size: 1.02rem;
    text-align: left;
    cursor: pointer;
    box-shadow: 0 4px 0 #cbd5e1;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.12s ease;
}

.choice-btn:active:not(:disabled) {
    transform: translateY(3px);
    box-shadow: 0 1px 0 #cbd5e1;
}

.choice-btn.correct {
    background: #dcfce7;
    border-color: #22c55e;
    color: #14532d;
    box-shadow: 0 4px 0 #16a34a;
}

.choice-btn.wrong {
    background: #fee2e2;
    border-color: #ef4444;
    color: #7f1d1d;
    box-shadow: 0 4px 0 #dc2626;
}

.feedback-box {
    margin-top: 14px;
    padding: 14px 16px;
    border-radius: 18px;
    font-weight: 700;
    border: 3px solid;
    animation: popIn 0.2s ease;
}

.feedback-good {
    background: #dcfce7;
    border-color: #4ade80;
    color: #14532d;
}

.feedback-oops {
    background: #fef2f2;
    border-color: #fca5a5;
    color: #991b1b;
}

/* === GRAMMAR SENTENCE CHUNKS === */
.sentence-stage {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 20px 12px;
    background: #f8fafc;
    border: 3px dashed #cbd5e1;
    border-radius: 22px;
    margin: 14px 0;
}

.chunk-btn {
    min-height: 54px;
    padding: 10px 18px;
    border-radius: 16px;
    border: 3px solid #94a3b8;
    background: #ffffff;
    font-family: 'Fredoka', sans-serif;
    font-size: 1.2rem;
    font-weight: 600;
    color: #0f172a;
    cursor: pointer;
    box-shadow: 0 4px 0 #94a3b8;
    transition: all 0.14s ease;
}

.chunk-btn:hover:not(:disabled) {
    border-color: #3b82f6;
    background: #eff6ff;
}

.chunk-btn:active:not(:disabled) {
    transform: translateY(3px);
    box-shadow: 0 1px 0 #94a3b8;
}

.chunk-sujet { background: #dbeafe !important; border-color: #2563eb !important; color: #1e3a8a !important; box-shadow: 0 4px 0 #1d4ed8 !important; }
.chunk-verbe { background: #fee2e2 !important; border-color: #dc2626 !important; color: #7f1d1d !important; box-shadow: 0 4px 0 #b91c1c !important; }
.chunk-complement { background: #dcfce7 !important; border-color: #16a34a !important; color: #14532d !important; box-shadow: 0 4px 0 #15803d !important; }
.chunk-wrong { background: #fef3c7 !important; border-color: #f59e0b !important; animation: shake 0.3s ease; }

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

/* === GRAND EST 10 FINGERS === */
.fingers-bar {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
}

@media (min-width: 640px) {
    .fingers-bar {
        grid-template-columns: repeat(10, 1fr);
    }
}

.dept-chip {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px 4px;
    border-radius: 14px;
    border: 2.5px solid #cbd5e1;
    background: #ffffff;
    cursor: pointer;
    font-weight: 800;
    font-size: 0.78rem;
    transition: all 0.15s ease;
}

.dept-chip.visited {
    border-color: #22c55e;
    background: #dcfce7;
    color: #14532d;
}

.dept-chip.active {
    transform: scale(1.06);
    border-color: #1e293b;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

/* === LOGIN / USER MODAL === */
.login-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.login-card {
    width: 100%;
    max-width: 460px;
    max-height: 92vh;
    overflow-y: auto;
    background: #ffffff;
    border-radius: 28px;
    border: 4px solid #60a5fa;
    padding: 22px;
    box-shadow: 0 24px 48px rgba(15, 23, 42, 0.3);
}

.kid-input {
    width: 100%;
    min-height: 52px;
    padding: 12px 16px;
    border-radius: 16px;
    border: 3px solid #cbd5e1;
    font-family: 'Fredoka', 'Nunito', sans-serif;
    font-size: 1.15rem;
    font-weight: 600;
    outline: none;
}

.kid-input:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.15);
}

.avatar-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}

.avatar-opt {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    border: 3px solid #e2e8f0;
    background: #f8fafc;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.avatar-opt.picked {
    border-color: #2563eb;
    background: #dbeafe;
    transform: scale(1.1);
}

/* === GRID UTILITIES === */
.worlds-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
}

@media (min-width: 680px) {
    .worlds-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.two-pane {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    align-items: start;
}

@media (min-width: 820px) {
    .two-pane {
        grid-template-columns: 1.15fr 0.85fr;
    }
}

.badges-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

@media (min-width: 640px) {
    .badges-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

.badge-card {
    border-radius: 20px;
    border: 3px solid #e2e8f0;
    padding: 14px 10px;
    text-align: center;
    background: #f8fafc;
    transition: transform 0.15s ease;
}

.badge-card.unlocked {
    background: #ffffff;
    border-color: #facc15;
    box-shadow: 0 6px 16px rgba(250, 204, 21, 0.22);
}

.badge-card.locked {
    opacity: 0.58;
    filter: grayscale(0.75);
}

/* === DATA TABLES FOR TIME TRACKING === */
.stats-table-wrap {
    overflow-x: auto;
    border-radius: 16px;
    border: 2px solid #e2e8f0;
}

.stats-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    background: #ffffff;
}

.stats-table th {
    background: #f1f5f9;
    color: #334155;
    font-weight: 800;
    text-align: left;
    padding: 10px 12px;
    white-space: nowrap;
}

.stats-table td {
    padding: 10px 12px;
    border-top: 1px solid #e2e8f0;
    vertical-align: middle;
}

.tag-pill {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 999px;
    font-weight: 800;
    font-size: 0.78rem;
    white-space: nowrap;
}

/* === DIPLOMA === */
.diploma-card {
    background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 50%, #fff7ed 100%);
    border: 6px double #d97706;
    border-radius: 26px;
    padding: 24px 18px;
    text-align: center;
    box-shadow: 0 12px 30px rgba(217, 119, 6, 0.18);
}

/* Badge toast */
.badge-toast {
    position: fixed;
    top: 72px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 150;
    background: linear-gradient(135deg, #f59e0b, #ea580c);
    color: #ffffff;
    padding: 12px 18px;
    border-radius: 20px;
    box-shadow: 0 12px 30px rgba(234, 88, 12, 0.4);
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 800;
    max-width: 92vw;
    animation: popIn 0.25s ease;
}

.small-muted {
    font-size: 0.85rem;
    color: var(--ink-soft);
}
