/* === Questia.it — Design System v3 === */
:root {
    /* Nuova palette */
    --navy:       #1E3A5F;
    --navy-light: #2A4E7F;
    --navy-dark:  #152C4A;
    --teal:       #00B4A6;
    --teal-light: #00CFC0;
    --teal-dim:   rgba(0,180,166,0.12);
    --orange:     #FF6B35;
    --orange-dim: rgba(255,107,53,0.12);
    --bg:         #F4F7FB;
    --bg-card:    #FFFFFF;
    --text:       #1a2a3a;
    --text-muted: #6b7f96;
    --border:     #e2eaf4;

    /* Alias retrocompatibili — vecchi nomi puntano ai nuovi valori */
    --q-blue: var(--navy);
    --q-blue-light: var(--navy-light);
    --q-blue-dark: var(--navy-dark);
    --q-teal: var(--teal);
    --q-teal-light: var(--teal-light);
    --q-teal-bg: var(--teal-dim);
    --q-orange: var(--orange);
    --q-orange-light: #ff8a5c;
    --q-orange-bg: var(--orange-dim);
    --q-white: var(--bg-card);
    --q-gray-light: var(--bg);
    --q-gray: var(--text-muted);
    --q-gray-dark: #495057;
    --q-border: var(--border);
    --q-shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --q-shadow: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
    --q-shadow-lg: 0 10px 25px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.05);
    --q-radius: 12px;
    --q-radius-sm: 8px;
    --q-radius-lg: 16px;
}

/* === Tipografia === */

html, body {
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    color: #1a1a2e;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    color: var(--q-blue-dark);
    letter-spacing: -0.01em;
}

h1 { font-size: 2rem; }
h3 { font-size: 1.5rem; }
h5 { font-size: 1.1rem; font-weight: 600; }

h1:focus { outline: none; }

p { color: #374151; }

.lead { font-size: 1.15rem; color: var(--q-gray-dark); font-weight: 400; }

/* === Link e bottoni === */

a, .btn-link {
    color: var(--q-blue);
    transition: color 0.15s ease;
}

a:hover { color: var(--q-teal); }

.btn {
    font-weight: 500;
    border-radius: var(--q-radius-sm);
    transition: all 0.2s ease;
    letter-spacing: 0.01em;
}

.btn-lg {
    padding: 0.65rem 1.75rem;
    font-size: 1.05rem;
}

.btn-primary {
    color: #fff;
    background: linear-gradient(135deg, var(--q-blue) 0%, var(--q-blue-light) 100%);
    border: none;
    box-shadow: 0 2px 4px rgba(30, 58, 95, 0.25);
}

.btn-primary:hover, .btn-primary:active {
    background: linear-gradient(135deg, var(--q-blue-light) 0%, var(--q-blue) 100%);
    box-shadow: 0 4px 8px rgba(30, 58, 95, 0.3);
    transform: translateY(-1px);
}

.btn-outline-primary {
    color: var(--q-blue);
    border: 2px solid var(--q-blue);
    background: transparent;
}

.btn-outline-primary:hover {
    background-color: var(--q-blue);
    border-color: var(--q-blue);
    color: #fff;
    transform: translateY(-1px);
}

.btn-cta {
    color: #fff;
    background: linear-gradient(135deg, var(--q-orange) 0%, var(--q-orange-light) 100%);
    border: none;
    box-shadow: 0 2px 4px rgba(255, 107, 53, 0.25);
}

.btn-cta:hover {
    background: linear-gradient(135deg, var(--q-orange-light) 0%, var(--q-orange) 100%);
    box-shadow: 0 4px 8px rgba(255, 107, 53, 0.3);
    color: #fff;
    transform: translateY(-1px);
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
    box-shadow: 0 0 0 0.15rem white, 0 0 0 0.3rem rgba(0, 180, 166, 0.4);
}

/* === Form === */

.form-control {
    border-radius: var(--q-radius-sm);
    border: 1.5px solid var(--q-border);
    padding: 0.6rem 0.9rem;
    transition: border-color 0.2s, box-shadow 0.2s;
    font-size: 0.95rem;
}

.form-control:focus {
    border-color: var(--q-teal);
}

.form-label {
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--q-gray-dark);
    margin-bottom: 0.35rem;
}

.content { padding-top: 1.1rem; }

.valid.modified:not([type=checkbox]) { outline: 1px solid var(--q-teal); }
.invalid { outline: 1px solid #ef4444; }
.validation-message { color: #ef4444; font-size: 0.85rem; }

/* === Card globale === */

.card {
    border: 1px solid var(--q-border);
    border-radius: var(--q-radius);
    box-shadow: var(--q-shadow-sm);
    transition: box-shadow 0.25s ease, transform 0.25s ease;
    overflow: hidden;
}

.card:hover {
    box-shadow: var(--q-shadow);
}

.card-body { padding: 1.25rem; }
.card-footer { padding: 0.85rem 1.25rem; }

.card-title {
    font-weight: 600;
    color: var(--q-blue-dark);
}

/* === Badge === */

.badge {
    font-weight: 600;
    letter-spacing: 0.02em;
    border-radius: 6px;
}

.badge.bg-primary { background-color: var(--q-blue) !important; }
.badge.bg-warning { background-color: var(--q-orange) !important; color: #fff !important; }
.badge.bg-secondary { background: #e5e7eb !important; color: #374151 !important; }

/* === Progress bar === */

.progress {
    border-radius: 99px;
    background-color: #f0f0f0;
    overflow: hidden;
}

.progress-bar {
    border-radius: 99px;
    transition: width 0.6s ease;
}

.progress-bar.bg-primary { background-color: var(--q-blue) !important; }
.progress-bar.bg-warning { background-color: var(--q-orange) !important; }

/* === Alert === */

.alert {
    border-radius: var(--q-radius-sm);
    border: none;
    font-size: 0.95rem;
}

.alert-info {
    background: linear-gradient(135deg, rgba(0, 180, 166, 0.1) 0%, rgba(0, 180, 166, 0.05) 100%);
    color: var(--q-blue-dark);
    border-left: 4px solid var(--q-teal);
}

.alert-danger {
    background: #fef2f2;
    color: #991b1b;
    border-left: 4px solid #ef4444;
}

.alert-light {
    background: #fff;
    border: 1px solid var(--q-border) !important;
    border-left: 4px solid var(--q-orange) !important;
}

/* === Table === */

.table {
    border-radius: var(--q-radius);
    overflow: hidden;
}

.table thead th {
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--q-gray);
    border-bottom: 2px solid var(--q-border);
}

.table-hover tbody tr:hover {
    background-color: rgba(0, 180, 166, 0.04);
}

/* === Errori Blazor === */

#blazor-error-ui {
    background: #fffbeb;
    bottom: 0;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.1);
    display: none;
    left: 0;
    padding: 0.75rem 1.5rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
    border-top: 2px solid #f59e0b;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
    border-radius: var(--q-radius-sm);
}

.blazor-error-boundary::after { content: "Si e' verificato un errore." }

/* === Loading === */

.loading-progress {
    position: relative;
    display: block;
    width: 8rem;
    height: 8rem;
    margin: 20vh auto 1rem auto;
}

.loading-progress circle {
    fill: none;
    stroke: #e0e0e0;
    stroke-width: 0.6rem;
    transform-origin: 50% 50%;
    transform: rotate(-90deg);
}

.loading-progress circle:last-child {
    stroke: var(--q-teal);
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
    transition: stroke-dasharray 0.05s ease-in-out;
}

.loading-progress-text {
    position: absolute;
    text-align: center;
    font-weight: 600;
    inset: calc(20vh + 3.25rem) 0 auto 0.2rem;
    color: var(--q-blue);
}

.loading-progress-text:after { content: var(--blazor-load-percentage-text, "Loading"); }

code { color: #c02d76; }

/* === Hero Landing Page === */

.hero-section {
    background: linear-gradient(135deg, var(--q-blue-dark) 0%, var(--q-blue) 50%, var(--q-blue-light) 100%);
    border-radius: var(--q-radius-lg);
    padding: 3.5rem 2.5rem;
    color: #fff;
    text-align: center;
    margin: -1.1rem -1.5rem 2rem -1.5rem;
    position: relative;
    overflow: hidden;
}

.hero-section::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -20%;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(0, 180, 166, 0.15) 0%, transparent 70%);
    border-radius: 50%;
}

.hero-section::after {
    content: '';
    position: absolute;
    bottom: -30%;
    left: -10%;
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(255, 107, 53, 0.1) 0%, transparent 70%);
    border-radius: 50%;
}

.hero-section h1 {
    color: #fff;
    font-size: 2.5rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    position: relative;
    z-index: 1;
}

.hero-section p {
    color: rgba(255, 255, 255, 0.85);
    position: relative;
    z-index: 1;
}

.hero-section .btn {
    position: relative;
    z-index: 1;
}

.hero-section .btn-primary {
    background: #fff;
    color: var(--q-blue);
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.hero-section .btn-primary:hover {
    background: var(--q-teal-bg);
    color: var(--q-blue-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.hero-section .btn-outline-primary {
    border-color: rgba(255,255,255,0.5);
    color: #fff;
}

.hero-section .btn-outline-primary:hover {
    background: rgba(255,255,255,0.15);
    border-color: #fff;
    color: #fff;
}

.hero-logo {
    max-width: 120px;
    height: auto;
    margin-bottom: 1.5rem;
}

/* Feature cards sulla landing */
.feature-card {
    text-align: center;
    padding: 1.5rem;
    border-radius: var(--q-radius);
    background: #fff;
    border: 1px solid var(--q-border);
    box-shadow: var(--q-shadow-sm);
    transition: all 0.3s ease;
}

.feature-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--q-shadow-lg);
}

.feature-icon {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
    display: block;
}

.feature-card h6 { font-weight: 600; color: var(--q-blue); }
.feature-card p { font-size: 0.9rem; color: var(--q-gray); margin-bottom: 0; }

/* === Home Authenticated === */

.welcome-section {
    background: linear-gradient(135deg, rgba(0, 180, 166, 0.06) 0%, rgba(30, 58, 95, 0.04) 100%);
    border-radius: var(--q-radius-lg);
    padding: 2.5rem;
    margin-bottom: 1.5rem;
}

.welcome-section h1 {
    font-size: 1.8rem;
    margin-bottom: 0.5rem;
}

/* === Auth Pages (Login/Register) === */

.auth-card {
    border: none;
    box-shadow: var(--q-shadow-lg);
    border-radius: var(--q-radius-lg);
    overflow: hidden;
}

.auth-card .card-body {
    padding: 2.5rem;
}

.auth-card h3 {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
}

.auth-header {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-header img {
    width: 48px;
    margin-bottom: 0.75rem;
}

/* === Dashboard === */

.stat-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 1rem;
    border-radius: 99px;
    font-weight: 600;
    font-size: 0.9rem;
}

.stat-badge.xp {
    background: linear-gradient(135deg, var(--q-orange-bg), rgba(255, 107, 53, 0.15));
    color: var(--q-orange);
    border: 1px solid rgba(255, 107, 53, 0.2);
}

.stat-badge.streak {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.08), rgba(239, 68, 68, 0.15));
    color: #dc2626;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

/* Card materia con bordo laterale */
.subject-card {
    border-left: 4px solid var(--q-teal);
    transition: all 0.25s ease;
}

.subject-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--q-shadow-lg);
    border-left-color: var(--q-orange);
}

/* Progress bar dashboard — più spesse */
.progress-thick {
    height: 8px !important;
    border-radius: 99px;
}

/* Ricompense card */
.reward-card {
    border: 1px solid var(--q-border);
    border-left: 4px solid var(--q-teal);
    background: linear-gradient(135deg, rgba(0, 180, 166, 0.03) 0%, #fff 100%);
}

.reward-card:hover {
    border-left-color: var(--q-orange);
}

.section-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--q-blue-dark);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--q-border);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* === Story Arc cards (Dashboard) === */

.story-arc-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-left: 4px solid var(--navy);
    border-radius: 12px;
    padding: 1.25rem;
    transition: all 0.25s ease;
}

.story-arc-card:hover {
    box-shadow: 0 4px 16px rgba(30, 58, 95, 0.12);
    border-left-color: var(--teal);
}

.story-arc-card.completed {
    border-left-color: var(--teal);
    background: linear-gradient(135deg, rgba(0, 180, 166, 0.04) 0%, #fff 100%);
}

.story-arc-premise {
    font-style: italic;
    color: var(--navy);
    font-size: 0.95rem;
    line-height: 1.5;
}

.story-arc-state {
    color: var(--text-muted);
    font-size: 0.875rem;
    line-height: 1.4;
    border-top: 1px solid var(--border);
    padding-top: 0.75rem;
}

/* === Subjects page === */

.subject-grid-card {
    cursor: pointer;
    transition: all 0.25s ease;
}

.subject-grid-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--q-shadow-lg);
}

.subject-grid-card .card-body {
    position: relative;
}

.subject-grid-card .topic-count {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    background: var(--q-teal-bg);
    color: var(--q-teal);
    padding: 0.25rem 0.7rem;
    border-radius: 99px;
    font-size: 0.8rem;
    font-weight: 600;
}

/* === Empty Subjects Guide === */

.empty-subjects-guide {
    max-width: 680px;
    margin: 0 auto;
    padding: 2rem 0;
}

.guide-header {
    text-align: center;
    margin-bottom: 2rem;
}

.guide-icon {
    font-size: 3rem;
    margin-bottom: 0.5rem;
}

.guide-header h4 {
    color: var(--navy);
    font-family: var(--q-font-heading);
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.guide-steps {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.guide-step {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    background: var(--q-bg-card);
    border: 1px solid var(--q-border);
    border-radius: 12px;
    padding: 1.25rem;
}

.step-number {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--teal);
    color: #fff;
    font-weight: 700;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.step-content h5 {
    color: var(--navy);
    font-weight: 600;
    margin-bottom: 0.3rem;
    font-size: 1rem;
}

.step-content p {
    color: var(--q-text-muted);
    font-size: 0.9rem;
    margin-bottom: 0;
    line-height: 1.5;
}

.step-example {
    margin-top: 0.75rem;
    background: var(--q-bg);
    border: 1px solid var(--q-border);
    border-radius: 8px;
    padding: 0.75rem 1rem;
}

.example-label {
    font-size: 0.8rem;
    color: var(--q-teal);
    font-weight: 600;
    margin-bottom: 0.4rem;
}

.example-text {
    font-size: 0.85rem;
    color: var(--q-text);
    line-height: 1.6;
    font-family: var(--q-font-body);
}

@media (max-width: 576px) {
    .guide-step {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
}

/* === Sessione di Studio === */

.session-progress-bar {
    height: 3px;
    background: var(--q-border);
    border-radius: 99px;
    margin-bottom: 1rem;
    overflow: hidden;
}

.session-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--q-teal) 0%, var(--q-teal-light) 100%);
    border-radius: 99px;
    transition: width 0.6s ease;
}

.session-header {
    padding: 0.5rem 0;
}

/* Scene container */
.scene-container {
    background: var(--bg-card);
    border-radius: 14px;
    padding: 50px 28px 28px;
    color: var(--text);
    position: relative;
    animation: slideIn 0.4s ease-out;
    border: 1px solid var(--border);
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

/* Immagini narrative inline — float alternato */
.narrative-figure {
    max-width: 380px;
    width: 45%;
}
.narrative-figure.float-right { float: right; margin: 0 0 16px 24px; }
.narrative-figure.float-left  { float: left;  margin: 0 24px 16px 0; }
.narrative-image {
    display: block;
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.1);
}
.narrative-caption {
    font-size: 11px;
    color: var(--text-muted);
    text-align: center;
    font-style: italic;
    margin-top: 6px;
}
.narrative-clearfix { clear: both; }

/* Lightbox immagini */
.lightbox-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.85);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    animation: fadeIn 0.2s ease;
}
.lightbox-img {
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.scene-tag {
    position: absolute;
    top: 14px;
    left: 14px;
    background: var(--teal-dim);
    border: 1px solid var(--teal);
    backdrop-filter: blur(8px);
    border-radius: 8px;
    padding: 5px 12px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    color: var(--teal);
}
.scene-with-image .scene-tag {
    background: rgba(0,0,0,0.4);
    border: 1px solid rgba(255,255,255,0.15);
    color: rgba(255,255,255,0.8);
}

.scene-body {
    font-style: italic;
    font-size: 1.05rem;
    line-height: 1.8;
}

.scene-body .typewriter {
    overflow: hidden;
    animation: typewriter-reveal 1.5s steps(60, end) forwards;
}

.scene-body p { color: var(--text); margin-bottom: 0.8rem; }
.scene-body .dialogue { border-left-color: var(--q-teal); background: var(--teal-dim); }
.scene-body .dialogue-speaker { color: var(--q-teal); }
.scene-body .dialogue-text { color: var(--text); }
.scene-body .scene-desc { color: var(--text-muted); }

.btn-scene-continue {
    background: linear-gradient(135deg, var(--q-teal) 0%, #009E92 100%);
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 10px 24px;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-scene-continue:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,180,166,0.4);
}

@keyframes typewriter-reveal {
    from { max-height: 0; opacity: 0.3; }
    to { max-height: 500px; opacity: 1; }
}

/* ChoicePoint — opzioni con lettera */
.choice-point {
    animation: slideIn 0.4s ease-out;
}

.choice-situation {
    margin-bottom: 1.25rem;
}

.choice-label {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--q-gray);
    margin-bottom: 0.5rem;
}

.choice-situation-text {
    font-size: 1.05rem;
    line-height: 1.7;
}

.choice-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.choice-option-card {
    display: flex;
    align-items: center;
    gap: 14px;
    border: 1.5px solid var(--q-border);
    border-radius: 12px;
    padding: 14px 18px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: #fff;
}

.choice-option-card:hover {
    border-color: var(--q-teal);
    background: var(--q-teal-bg);
    transform: translateX(4px);
}

.choice-option-card:hover .choice-letter {
    background: var(--q-teal);
    color: #fff;
    border-color: var(--q-teal);
}

.choice-letter {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1.5px solid var(--q-border);
    background: var(--q-gray-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.8rem;
    color: var(--q-blue);
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.choice-letter.active {
    background: var(--q-teal);
    color: #fff;
    border-color: var(--q-teal);
}

.choice-text {
    font-weight: 500;
    font-size: 0.95rem;
}

.choice-selected {
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--q-teal-bg);
    border: 1.5px solid var(--q-teal);
    border-radius: 12px;
    padding: 14px 18px;
}

/* Explanation — testo narrativo */
.explanation {
    animation: slideIn 0.4s ease-out;
}

.explanation .card {
    background: linear-gradient(135deg, #fff 0%, rgba(30, 58, 95, 0.02) 100%);
}

.explanation-text {
    font-size: 1.05rem;
    line-height: 1.8;
}

.explanation-text p { margin-bottom: 1rem; }

/* TestReady */
.test-ready .btn-primary {
    transition: all 0.25s ease;
    background: linear-gradient(135deg, var(--q-orange) 0%, var(--q-orange-light) 100%);
    border: none;
    box-shadow: 0 4px 12px rgba(255, 107, 53, 0.3);
}

.test-ready .btn-primary:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(255, 107, 53, 0.4);
}

/* === Test — Domande classiche === */

.choice-option {
    padding: 0.85rem 1.15rem;
    border: 2px solid var(--q-border);
    border-radius: var(--q-radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    background: #fff;
}

.choice-option:hover {
    border-color: var(--q-blue);
    background: rgba(30, 58, 95, 0.03);
    transform: translateX(4px);
}

.choice-option.selected {
    border-color: var(--q-blue);
    background: rgba(30, 58, 95, 0.08);
}

.choice-option.correct {
    border-color: var(--q-teal);
    background: var(--q-teal-bg);
}

.choice-option.wrong {
    border-color: #ef4444;
    background: #fef2f2;
}

/* TrueFalse */
.tf-btn {
    border: 2px solid var(--q-border);
    background: white;
    transition: all 0.2s ease;
    border-radius: var(--q-radius-sm);
    font-weight: 600;
}

.tf-btn.selected {
    border-color: var(--q-blue);
    background: rgba(30, 58, 95, 0.08);
    color: var(--q-blue);
}

.tf-btn.correct {
    border-color: var(--q-teal);
    background: var(--q-teal-bg);
    color: var(--q-teal);
}

.tf-btn.wrong {
    border-color: #ef4444;
    background: #fef2f2;
    color: #ef4444;
}

/* === Mini-giochi === */

.match-item {
    padding: 0.7rem 1rem;
    border: 2px solid var(--q-border);
    border-radius: var(--q-radius-sm);
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    background: #fff;
}

.match-item:hover { border-color: var(--q-gray); transform: translateX(2px); }
.match-item.selected {
    border-color: var(--q-teal);
    background: var(--q-teal-bg);
    box-shadow: 0 0 0 3px rgba(0, 180, 166, 0.15);
}
.match-item.matched {
    border-color: var(--q-border);
    background: var(--q-gray-light);
    cursor: default;
    opacity: 0.7;
}

.pair-item { padding: 0.3rem 0.6rem; border-radius: 6px; }
.pair-item.text-success { background: var(--q-teal-bg); color: var(--q-teal) !important; }
.pair-item.text-danger { background: #fef2f2; }

/* Sequence */
.sequence-block {
    padding: 0.85rem 1.25rem;
    border: 2px solid var(--q-border);
    border-radius: var(--q-radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    min-width: 120px;
    text-align: center;
    position: relative;
    background: #fff;
}

.sequence-block:hover { border-color: var(--q-blue); background: rgba(30, 58, 95, 0.03); }
.sequence-block.selected { border-color: var(--q-blue); background: rgba(30, 58, 95, 0.08); }
.sequence-block.correct { border-color: var(--q-teal); background: var(--q-teal-bg); }
.sequence-block.wrong { border-color: #ef4444; background: #fef2f2; }

.sequence-order {
    position: absolute;
    top: -10px;
    left: -10px;
    width: 26px;
    height: 26px;
    background: linear-gradient(135deg, var(--q-blue) 0%, var(--q-blue-light) 100%);
    color: white;
    border-radius: 50%;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    box-shadow: 0 2px 4px rgba(30, 58, 95, 0.3);
}

.shake { animation: shake 0.5s ease-in-out; }

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-8px); }
    40% { transform: translateX(8px); }
    60% { transform: translateX(-6px); }
    80% { transform: translateX(6px); }
}

/* === Pagina Risultati === */

.fade-in { animation: fadeIn 0.8s ease-out; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.score-circle {
    position: relative;
    width: 170px;
    height: 170px;
    margin: 0 auto;
}

.score-svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.score-bg { fill: none; stroke: #f0f0f0; stroke-width: 8; }
.score-fill {
    fill: none;
    stroke: currentColor;
    stroke-width: 8;
    stroke-linecap: round;
    transition: stroke-dashoffset 1.5s ease-in-out;
}

.score-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

.score-number {
    font-family: 'Playfair Display', serif;
    font-size: 2.8rem;
    font-weight: 700;
    line-height: 1;
}

.score-label { font-size: 0.95rem; opacity: 0.5; font-weight: 500; }

.score-green { color: var(--q-teal) !important; }
.score-orange { color: var(--q-orange) !important; }
.score-red { color: #ef4444 !important; }

.result-verdict { font-size: 1.1rem; }

.result-reward {
    display: inline-block;
    background: var(--q-teal-bg);
    color: var(--q-teal);
    border: 1px solid rgba(0,180,166,0.2);
    border-radius: 10px;
    padding: 8px 18px;
    font-weight: 600;
    font-size: 0.88rem;
    margin-top: 0.5rem;
}

/* Finale narrativo dark */
.result-narrative {
    background: linear-gradient(135deg, #1E3A5F, #2A4E7F);
    border-radius: 16px;
    padding: 28px;
    margin-bottom: 1.5rem;
}

.result-narrative-text {
    color: rgba(255,255,255,0.9);
    font-style: italic;
    font-size: 1rem;
    line-height: 1.8;
}

.result-narrative-text p { color: rgba(255,255,255,0.85); margin-bottom: 0.6rem; }
.result-narrative-text .dialogue { border-left-color: var(--q-teal); background: rgba(255,255,255,0.05); }
.result-narrative-text .dialogue-speaker { color: var(--q-teal); }
.result-narrative-text .dialogue-text { color: rgba(255,255,255,0.8); }
.result-narrative-text .scene-desc { color: rgba(255,255,255,0.5); }

/* Dettaglio domande */
.result-questions {
    margin-bottom: 1.5rem;
}

.result-questions-title {
    font-weight: 700;
    font-size: 1rem;
    color: var(--q-blue-dark);
    margin-bottom: 0.75rem;
}

.result-question-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 8px 14px;
    border-radius: 10px;
    margin-bottom: 3px;
}

.result-question-row.correct { background: rgba(0,180,166,0.06); }
.result-question-row.wrong { background: rgba(239,68,68,0.06); }

.result-question-icon {
    font-weight: 700;
    font-size: 1rem;
    flex-shrink: 0;
    width: 20px;
    text-align: center;
}

.result-question-row.correct .result-question-icon { color: var(--q-teal); }
.result-question-row.wrong .result-question-icon { color: #ef4444; }

/* Bottoni azione */
.result-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    margin-bottom: 2rem;
}

.btn-result {
    border-radius: 10px;
    padding: 10px 24px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    text-align: center;
    border: none;
}

.btn-result.outline {
    background: #fff;
    border: 1.5px solid var(--q-border);
    color: var(--q-blue);
}

.btn-result.outline:hover {
    border-color: var(--q-blue);
    background: rgba(30,58,95,0.04);
    transform: translateY(-1px);
}

.btn-result.teal {
    background: linear-gradient(135deg, var(--q-teal), #009E92);
    color: #fff;
    box-shadow: 0 2px 8px rgba(0,180,166,0.3);
}

.btn-result.teal:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(0,180,166,0.4);
    color: #fff;
}

.btn-result.navy {
    background: linear-gradient(135deg, var(--q-blue), var(--q-blue-light));
    color: #fff;
    box-shadow: 0 2px 8px rgba(30,58,95,0.3);
}

.btn-result.navy:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(30,58,95,0.4);
    color: #fff;
}

.text-success { color: var(--q-teal) !important; }
.text-warning { color: var(--q-orange) !important; }

/* Dashboard badge XP */
.badge-xp { background-color: var(--q-orange) !important; color: #fff; }

/* Ricompense bordo */
.card.border-warning { border-color: var(--q-teal) !important; }

/* === Landing (legacy, kept for fallback) === */
.landing-logo { max-width: 200px; height: auto; margin-bottom: 1.5rem; }

/* === Footer === */

.site-footer {
    border-top: 1px solid var(--q-border);
    background-color: #fff;
    margin-top: 3rem;
}

.site-footer a:hover { color: var(--q-teal) !important; }

/* === Livelli completati === */

.level-completed { position: relative; font-weight: 600; }

.level-completed .level-check {
    color: var(--q-teal);
    font-weight: 700;
    margin-right: 0.2rem;
}

.btn-outline-primary.level-completed { background-color: rgba(30, 58, 95, 0.08); }
.btn-outline-warning.level-completed { background-color: rgba(255, 107, 53, 0.08); }
.btn-outline-danger.level-completed { background-color: rgba(220, 53, 69, 0.08); }

/* === Accordion (Subject Detail) === */

.accordion-item {
    border: 1px solid var(--q-border);
    border-radius: var(--q-radius) !important;
    margin-bottom: 0.5rem;
    overflow: hidden;
}

.accordion-button {
    font-weight: 600;
    color: var(--q-blue-dark);
    background: #fff;
    border-radius: var(--q-radius) !important;
}

.accordion-button:not(.collapsed) {
    background: linear-gradient(135deg, rgba(0, 180, 166, 0.05) 0%, #fff 100%);
    color: var(--q-blue-dark);
    box-shadow: none;
}

.accordion-button:focus { box-shadow: none; border-color: var(--q-teal); }

/* === Narrativa: Dialoghi e Atmosfera === */

.dialogue {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    border-left: 3px solid;
    padding: 0.5rem 0.75rem;
    margin: 0.4rem 0;
    background: rgba(0, 0, 0, 0.02);
    border-radius: 0 var(--q-radius-sm) var(--q-radius-sm) 0;
}

.dialogue-speaker {
    font-weight: 700;
    white-space: nowrap;
    font-size: 0.9rem;
}

.dialogue-speaker::after {
    content: ':';
    margin-right: 0.25rem;
}

.dialogue-text {
    font-style: italic;
    color: #374151;
    line-height: 1.6;
}

.scene-desc {
    display: block;
    color: var(--q-gray);
    font-style: italic;
    padding: 0.3rem 0;
    font-size: 0.95rem;
    letter-spacing: 0.01em;
}

/* Scene Header — banner tematico */
.scene-header {
    height: 80px;
    border-radius: var(--q-radius-lg) var(--q-radius-lg) 0 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    color: #fff;
    overflow: hidden;
    position: relative;
}

.scene-header-emoji { font-size: 2rem; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2)); }
.scene-header-label {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    opacity: 0.9;
}

/* Varianti gradient per tipo di scena */
.scene-header.laboratorio { background: linear-gradient(135deg, #1e40af 0%, #3b82f6 100%); }
.scene-header.biblioteca { background: linear-gradient(135deg, #92400e 0%, #d97706 100%); }
.scene-header.ufficio { background: linear-gradient(135deg, #374151 0%, #6b7280 100%); }
.scene-header.montagna { background: linear-gradient(135deg, #065f46 0%, #34d399 100%); }
.scene-header.oceano { background: linear-gradient(135deg, #0e7490 0%, #22d3ee 100%); }
.scene-header.spazio { background: linear-gradient(135deg, #1e1b4b 0%, #6366f1 100%); }
.scene-header.aula { background: linear-gradient(135deg, #1e3a5f 0%, #2a4f7a 100%); }
.scene-header.foresta { background: linear-gradient(135deg, #14532d 0%, #22c55e 100%); }
.scene-header.citta { background: linear-gradient(135deg, #1f2937 0%, #9ca3af 100%); }
.scene-header.ospedale { background: linear-gradient(135deg, #991b1b 0%, #f87171 100%); }
.scene-header.cantiere { background: linear-gradient(135deg, #78350f 0%, #fbbf24 100%); }
.scene-header.tribunale { background: linear-gradient(135deg, #3f3f46 0%, #a1a1aa 100%); }
.scene-header.teatro { background: linear-gradient(135deg, #7e22ce 0%, #c084fc 100%); }
.scene-header.nave { background: linear-gradient(135deg, #164e63 0%, #67e8f9 100%); }

/* === Responsive === */

@media (max-width: 768px) {
    .hero-section {
        padding: 2rem 1.5rem;
        margin: -1.1rem -1rem 1.5rem -1rem;
    }

    .hero-section h1 { font-size: 1.8rem; }

    .welcome-section { padding: 1.5rem; }

    .match-terms .row { flex-direction: column; }
    .match-terms .col-6 { width: 100%; margin-bottom: 1rem; }
    .choice-option-card { padding: 12px 14px; }

    .sequence-block { min-width: 100%; padding: 1rem; font-size: 1rem; }
    .sequence-blocks { flex-direction: column; }

    .score-circle { width: 140px; height: 140px; margin-bottom: 1rem; }
    .col-md-6.mb-4 { margin-bottom: 0.5rem !important; }
    .table-responsive { font-size: 0.875rem; }

    .auth-card .card-body { padding: 1.5rem; }

    /* Immagini narrative: NO float su mobile, full width */
    .narrative-figure {
        float: none !important;
        width: 100% !important;
        max-width: 100% !important;
        margin: 12px 0 !important;
    }
    .narrative-figure.float-right,
    .narrative-figure.float-left {
        float: none !important;
        margin: 12px 0 !important;
    }

    /* Scene container più compatto */
    .scene-container {
        padding: 40px 16px 16px;
    }
    .scene-body {
        font-size: 0.95rem;
        line-height: 1.7;
    }

    /* Dialoghi più compatti */
    .dialogue {
        flex-direction: column;
        gap: 0.2rem;
        padding: 0.4rem 0.6rem;
    }

    /* Explanation testo più piccolo */
    .explanation-text {
        font-size: 0.95rem;
        line-height: 1.7;
    }
    .explanation-text.fs-5 {
        font-size: 0.95rem !important;
    }

    /* Dashboard tabella: nascondi colonna punteggio e azioni, compatta il resto */
    .dash-table thead th:nth-child(4),
    .dash-table thead th:nth-child(5),
    .dash-table tbody td:nth-child(4),
    .dash-table tbody td:nth-child(5) {
        display: none;
    }
    .dash-table thead th,
    .dash-table tbody td {
        padding: 8px 10px;
        font-size: 0.82rem;
    }
    .dash-table thead th:first-child,
    .dash-table tbody td:first-child {
        white-space: nowrap;
        font-size: 0.78rem;
    }

    /* Session header compatto */
    .session-header h4 {
        font-size: 1.1rem;
    }
}

/* Touch-friendly */
@media (pointer: coarse) {
    .choice-option, .match-item, .sequence-block, .tf-btn {
        min-height: 48px;
        display: flex;
        align-items: center;
    }
    .choice-card { min-height: 60px; }
}

/* === Transizioni e animazioni === */

.session-phase-enter { animation: slideIn 0.4s ease-out; }

@keyframes slideIn {
    from { opacity: 0; transform: translateX(30px); }
    to { opacity: 1; transform: translateX(0); }
}

.scenario-intro, .choice-point, .explanation, .test-ready {
    animation: slideIn 0.4s ease-out;
}

/* Page fade-in globale */
.content > * { animation: pageFadeIn 0.3s ease-out; }

@keyframes pageFadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* === Admin Panel === */

.admin-stat-card {
    border: none;
    background: linear-gradient(135deg, #fff 0%, var(--q-gray-light) 100%);
}

.admin-stat-number {
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--q-blue);
    line-height: 1.2;
}

.admin-stat-label {
    font-size: 0.85rem;
    color: var(--q-gray);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.admin-action-card {
    cursor: pointer;
    transition: all 0.25s ease;
    color: inherit;
}

.admin-action-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--q-shadow-lg);
    border-color: var(--q-teal);
}

/* === MathKeyboard === */

.math-kb-toggle {
    font-weight: 600;
    font-size: 0.8rem;
    padding: 0.25rem 0.7rem;
    border-radius: 6px;
    border: 1.5px solid var(--q-border);
    background: #fff;
}

.math-kb-toggle:hover { border-color: var(--q-teal); }

.math-kb-icon {
    font-style: italic;
    font-family: 'Georgia', 'Times New Roman', serif;
}

.math-kb-panel {
    background: #fff;
    border: 1.5px solid var(--q-border) !important;
    border-radius: var(--q-radius-sm);
    box-shadow: var(--q-shadow);
    animation: fadeIn 0.2s ease-out;
}

.math-kb-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.3rem;
}

.math-kb-label {
    font-size: 0.65rem;
    color: var(--q-gray);
    min-width: 50px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.math-kb-btn {
    font-size: 0.85rem;
    padding: 0.2rem 0.45rem;
    min-width: 32px;
    text-align: center;
    line-height: 1.4;
    border-radius: 6px;
    border: 1.5px solid var(--q-border);
    background: #fff;
}

.math-kb-btn:hover {
    background-color: var(--q-blue);
    color: #fff;
    border-color: var(--q-blue);
}

.math-kb-latex {
    font-size: 0.75rem;
    font-family: 'Georgia', serif;
    font-style: italic;
}

.math-kb-preview { background: #fff; border-radius: 6px; min-height: 2rem; }

.math-preview {
    background: #fff;
    border: 1.5px dashed var(--q-teal);
    border-radius: var(--q-radius-sm);
    padding: 0.5rem 0.85rem;
    margin-top: 0.35rem;
    margin-bottom: 0.5rem;
}

.math-preview small { display: block; margin-bottom: 0.25rem; }
.math-preview-content { font-size: 1.1rem; min-height: 1.5rem; word-wrap: break-word; }

@media (max-width: 768px) {
    .math-kb-label { min-width: 100%; margin-bottom: 0.15rem; }
    .math-kb-btn { min-width: 36px; min-height: 36px; font-size: 0.9rem; }
}

/* === Dashboard Progressi === */
.dash-card {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 1.25rem;
    height: 100%;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    transition: box-shadow 0.2s;
}
.dash-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.10); }

.dash-card-emoji { font-size: 1.6rem; margin-bottom: 0.5rem; }
.dash-card-percent {
    font-size: 0.8rem; font-weight: 700; color: var(--teal);
    background: var(--teal-dim); padding: 2px 10px; border-radius: 20px;
}

.dash-progress-row { margin-bottom: 6px; }
.dash-progress-track {
    height: 6px; background: var(--border); border-radius: 3px; overflow: hidden;
}
.dash-progress-fill {
    height: 100%; border-radius: 3px; transition: width 0.4s ease;
}
.dash-progress-fill.teal   { background: var(--teal); }
.dash-progress-fill.orange { background: var(--orange); }
.dash-progress-fill.navy   { background: var(--navy); }

/* Tabella sessioni */
.dash-table-wrapper {
    border-radius: 12px; overflow: hidden;
    border: 1px solid var(--border);
    background: var(--bg-card);
}
.dash-table {
    width: 100%; border-collapse: collapse; margin: 0;
}
.dash-table thead th {
    background: var(--bg); color: var(--text-muted);
    font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px;
    padding: 10px 14px; border: none; font-weight: 600;
}
.dash-table tbody td {
    padding: 10px 14px; border-top: 1px solid var(--border);
    vertical-align: middle; font-size: 0.9rem;
}
.dash-table tbody tr:hover { background: var(--bg); }

.score-pill {
    display: inline-block; padding: 2px 12px; border-radius: 20px;
    font-size: 0.8rem; font-weight: 700;
}
.score-pill.green  { background: rgba(0,180,166,0.12); color: #059669; }
.score-pill.orange { background: rgba(255,107,53,0.12); color: #d97706; }
.score-pill.red    { background: rgba(239,68,68,0.12); color: #dc2626; }
.score-pill.grey   { background: var(--bg); color: var(--text-muted); }

/* === Mini Chat IA === */

.chat-fab {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--q-teal) 0%, var(--q-teal-light) 100%);
    color: #fff;
    border: none;
    font-size: 1.4rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 180, 166, 0.4);
    z-index: 1100;
    transition: all 0.25s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-fab:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 180, 166, 0.5);
}

.chat-popup {
    position: fixed;
    bottom: 5rem;
    right: 1.5rem;
    width: 350px;
    height: 450px;
    background: #fff;
    border-radius: var(--q-radius-lg);
    box-shadow: var(--q-shadow-lg), 0 8px 32px rgba(0, 0, 0, 0.12);
    z-index: 1099;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: chatSlideUp 0.3s ease-out;
}

@keyframes chatSlideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.chat-header {
    background: linear-gradient(135deg, var(--q-blue) 0%, var(--q-blue-light) 100%);
    color: #fff;
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.chat-header small {
    font-size: 0.7rem;
    display: block;
    opacity: 0.8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.chat-bubble-user {
    align-self: flex-end;
    background: linear-gradient(135deg, var(--q-blue) 0%, var(--q-blue-light) 100%);
    color: #fff;
    padding: 0.5rem 0.85rem;
    border-radius: var(--q-radius-sm) var(--q-radius-sm) 4px var(--q-radius-sm);
    max-width: 85%;
    font-size: 0.88rem;
    line-height: 1.5;
    word-wrap: break-word;
}

.chat-bubble-assistant {
    align-self: flex-start;
    background: var(--q-gray-light);
    color: #1a1a2e;
    padding: 0.5rem 0.85rem;
    border-radius: var(--q-radius-sm) var(--q-radius-sm) var(--q-radius-sm) 4px;
    max-width: 85%;
    font-size: 0.88rem;
    line-height: 1.5;
    word-wrap: break-word;
}

.chat-bubble-assistant p { margin-bottom: 0.4rem; color: inherit; }
.chat-bubble-assistant p:last-child { margin-bottom: 0; }

.chat-input {
    display: flex;
    border-top: 1px solid var(--q-border);
    flex-shrink: 0;
}

.chat-input input {
    flex: 1;
    border: none;
    padding: 0.7rem 0.85rem;
    font-size: 0.88rem;
    outline: none;
    background: transparent;
}

.chat-input input::placeholder { color: #adb5bd; }

.chat-input button {
    background: none;
    border: none;
    color: var(--q-teal);
    font-size: 1.2rem;
    padding: 0 0.85rem;
    cursor: pointer;
    transition: color 0.15s;
}

.chat-input button:hover { color: var(--q-blue); }
.chat-input button:disabled { color: #ccc; cursor: default; }

/* Typing animation */
.chat-typing {
    display: flex;
    gap: 4px;
    padding: 0.2rem 0;
}

.chat-typing span {
    width: 7px;
    height: 7px;
    background: #adb5bd;
    border-radius: 50%;
    animation: chatTyping 1.2s infinite ease-in-out;
}

.chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes chatTyping {
    0%, 60%, 100% { opacity: 0.3; transform: scale(0.8); }
    30% { opacity: 1; transform: scale(1); }
}

/* Responsive mobile */
@media (max-width: 768px) {
    .chat-popup {
        width: calc(100% - 2rem);
        right: 1rem;
        bottom: 4.5rem;
        height: 400px;
    }
    .chat-fab {
        bottom: 1rem;
        right: 1rem;
        width: 48px;
        height: 48px;
        font-size: 1.2rem;
    }
}

/* === Tutor Chat (modale lezione) === */

.btn-tutor-explain {
    display: inline-block;
    margin-top: 6px;
    padding: 4px 12px;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--orange);
    background: var(--orange-dim);
    border: 1px solid rgba(255,107,53,0.25);
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-tutor-explain:hover {
    background: var(--orange);
    color: #fff;
}

.tutor-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

.tutor-modal {
    width: 600px;
    max-width: calc(100% - 2rem);
    height: 75vh;
    max-height: 650px;
    background: var(--bg-card);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.25);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: chatSlideUp 0.3s ease-out;
}

.tutor-header {
    background: linear-gradient(135deg, var(--orange) 0%, #ff8a5c 100%);
    color: #fff;
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.tutor-header strong { font-size: 1rem; }
.tutor-header small { font-size: 0.75rem; opacity: 0.85; }

.tutor-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 1.5rem;
    cursor: pointer;
    opacity: 0.8;
    transition: opacity 0.15s;
    line-height: 1;
}

.tutor-close:hover { opacity: 1; }

.tutor-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.tutor-bubble-user {
    align-self: flex-end;
    background: linear-gradient(135deg, var(--navy) 0%, var(--navy-light) 100%);
    color: #fff;
    padding: 0.6rem 1rem;
    border-radius: 12px 12px 4px 12px;
    max-width: 80%;
    font-size: 0.9rem;
    line-height: 1.6;
    word-wrap: break-word;
}

.tutor-bubble-assistant {
    align-self: flex-start;
    background: var(--bg);
    color: var(--text);
    padding: 0.75rem 1rem;
    border-radius: 12px 12px 12px 4px;
    max-width: 90%;
    font-size: 0.9rem;
    line-height: 1.7;
    word-wrap: break-word;
    border-left: 3px solid var(--orange);
}

.tutor-bubble-assistant p { margin-bottom: 0.5rem; color: inherit; }
.tutor-bubble-assistant p:last-child { margin-bottom: 0; }

.tutor-input {
    display: flex;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.tutor-input input {
    flex: 1;
    border: none;
    padding: 0.85rem 1rem;
    font-size: 0.9rem;
    outline: none;
    background: transparent;
}

.tutor-input input::placeholder { color: #adb5bd; }

.tutor-input button {
    background: none;
    border: none;
    color: var(--orange);
    font-size: 1.3rem;
    padding: 0 1rem;
    cursor: pointer;
    transition: color 0.15s;
}

.tutor-input button:hover { color: var(--navy); }
.tutor-input button:disabled { color: #ccc; cursor: default; }

@media (max-width: 768px) {
    .tutor-modal {
        width: calc(100% - 1rem);
        height: 85vh;
        max-height: none;
        border-radius: 12px;
    }
}

/* === Mappa Mentale === */

.mindmap-container {
    position: relative;
    background: var(--bg);
    border-radius: var(--q-radius);
    border: 1px solid var(--border);
    overflow: hidden;
}

.mindmap-svg {
    width: 100%;
    height: 65vh;
    min-height: 400px;
    display: block;
}

.mindmap-toolbar {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 4px;
    background: rgba(255,255,255,0.95);
    border-radius: 10px;
    padding: 6px 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    border: 1px solid var(--border);
    flex-wrap: wrap;
}

.mm-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    font-weight: 600;
    color: var(--navy);
    transition: all 0.15s;
}

.mm-btn:hover {
    background: var(--bg);
    border-color: var(--teal);
}

.mm-btn-action {
    width: auto;
    padding: 0 10px;
    font-size: 0.8rem;
    font-weight: 500;
}

.mm-btn-danger {
    width: auto;
    padding: 0 10px;
    font-size: 0.8rem;
    color: #dc2626;
    border-color: rgba(220,38,38,0.3);
}

.mm-btn-danger:hover {
    background: #fef2f2;
    border-color: #dc2626;
}

.mm-separator {
    width: 1px;
    height: 24px;
    background: var(--border);
    margin: 0 4px;
}

.mm-node rect {
    transition: opacity 0.2s;
}

.mm-node:hover rect {
    opacity: 1 !important;
}

.mm-node.selected rect {
    opacity: 1 !important;
}

.mm-rename-overlay {
    position: absolute;
    top: 56px;
    left: 12px;
    z-index: 20;
}

.mm-rename-box {
    background: #fff;
    border-radius: 10px;
    padding: 12px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
    border: 1px solid var(--border);
    display: flex;
    gap: 8px;
    align-items: center;
}

.mm-color-box {
    background: #fff;
    border-radius: 10px;
    padding: 16px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
    border: 1px solid var(--border);
}

.mm-color-swatch {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    border: 3px solid transparent;
    transition: all 0.15s;
}

.mm-color-swatch:hover {
    transform: scale(1.15);
}

.mm-color-swatch.active {
    border-color: #FFD700;
    box-shadow: 0 0 0 2px rgba(255,215,0,0.4);
}

@media (max-width: 768px) {
    .mindmap-svg {
        height: 50vh;
        min-height: 300px;
    }

    .mindmap-toolbar {
        top: 8px;
        left: 8px;
        padding: 4px 8px;
        gap: 3px;
    }

    .mm-btn {
        width: 28px;
        height: 28px;
        font-size: 0.85rem;
    }

    .mm-btn-action, .mm-btn-danger {
        font-size: 0.7rem;
        padding: 0 6px;
    }
}

/* === Top Bar === */

.topbar-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    gap: 1rem;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
}

.topbar-greeting {
    font-size: 0.88rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-greeting strong {
    color: var(--navy);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-shrink: 0;
}

.topbar-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.2rem 0.65rem;
    border-radius: 99px;
    font-weight: 600;
    font-size: 0.78rem;
    white-space: nowrap;
}

.topbar-badge.xp {
    background: var(--orange-dim);
    color: var(--orange);
    border: 1px solid rgba(255, 107, 53, 0.2);
}

.topbar-badge.streak {
    background: rgba(239, 68, 68, 0.08);
    color: #dc2626;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.topbar-link {
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-muted);
    text-decoration: none;
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    transition: all 0.15s;
    white-space: nowrap;
}

.topbar-link:hover {
    color: var(--navy);
    background: rgba(30, 58, 95, 0.06);
}

.topbar-link.accent {
    color: var(--teal);
    font-weight: 600;
}

.topbar-link.accent:hover {
    background: var(--teal-dim);
    color: var(--teal);
}

@media (max-width: 768px) {
    .topbar-greeting {
        display: none;
    }

    .topbar-right {
        gap: 0.4rem;
    }

    .topbar-badge {
        font-size: 0.72rem;
        padding: 0.15rem 0.5rem;
    }

    .topbar-link {
        font-size: 0.75rem;
        padding: 0.2rem 0.35rem;
    }
}

/* ==========================================
   TYPEWRITER EFFECT + IMPROVED LOADING
   ========================================== */

.typewriter-container {
    cursor: pointer;
    position: relative;
}

.typewriter-cursor {
    display: inline-block;
    color: var(--teal);
    font-weight: 300;
    font-size: 1.2em;
    animation: blink-cursor 0.8s step-end infinite;
    margin-left: 2px;
    vertical-align: baseline;
}

@keyframes blink-cursor {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

.typewriter-skip-hint {
    text-align: center;
    margin-top: 1rem;
    opacity: 0;
    animation: fade-in-hint 0.5s ease 2s forwards;
}

.typewriter-skip-hint small {
    color: var(--text-muted);
    font-size: 0.75rem;
    background: var(--bg-card);
    padding: 4px 12px;
    border-radius: 12px;
    border: 1px solid var(--border);
}

@keyframes fade-in-hint {
    to { opacity: 0.7; }
}

.fade-in {
    animation: fadeInUp 0.4s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Adventure Loading */
.adventure-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    min-height: 300px;
}

.loading-icon-container {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--teal-dim) 0%, rgba(30, 58, 95, 0.08) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.5rem;
    animation: pulse-glow 2s ease-in-out infinite;
}

.loading-quill {
    font-size: 2rem;
    color: var(--teal);
    animation: spin-slow 4s linear infinite;
}

@keyframes pulse-glow {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(0, 180, 166, 0.2);
        transform: scale(1);
    }
    50% {
        box-shadow: 0 0 20px 8px rgba(0, 180, 166, 0.15);
        transform: scale(1.05);
    }
}

@keyframes spin-slow {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.loading-text {
    font-size: 1.05rem;
    color: var(--text);
    font-weight: 500;
    margin-bottom: 0.75rem;
    transition: opacity 0.3s ease;
    text-align: center;
    min-height: 1.6em;
}

.loading-dots {
    display: flex;
    gap: 6px;
}

.loading-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--teal);
    opacity: 0.3;
    animation: dot-bounce 1.4s ease-in-out infinite;
}

.loading-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.loading-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes dot-bounce {
    0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
    30% { opacity: 1; transform: translateY(-6px); }
}

/* ==========================================
   MICRO-INTERAZIONI
   ========================================== */

.micro-interaction {
    background: linear-gradient(135deg, var(--teal-dim) 0%, rgba(0, 180, 166, 0.05) 100%);
    border: 1px solid rgba(0, 180, 166, 0.25);
    border-radius: 12px;
    padding: 1.25rem;
    margin: 1.5rem 0;
    animation: fadeInUp 0.4s ease-out;
}

.micro-interaction.correct {
    border-color: rgba(16, 185, 129, 0.4);
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.08) 0%, rgba(16, 185, 129, 0.02) 100%);
}

.micro-interaction.wrong {
    border-color: rgba(239, 68, 68, 0.3);
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.06) 0%, rgba(239, 68, 68, 0.02) 100%);
}

.micro-question {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    font-weight: 600;
    font-size: 1rem;
    color: var(--text);
    margin-bottom: 0.75rem;
}

.micro-icon {
    font-size: 1.2rem;
    flex-shrink: 0;
    margin-top: 1px;
}

.micro-options {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-left: 1.8rem;
}

.micro-option {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.6rem 1rem;
    font-size: 0.9rem;
    color: var(--text);
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
}

.micro-option:hover {
    border-color: var(--teal);
    background: var(--teal-dim);
    transform: translateX(4px);
}

.micro-feedback {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    margin-left: 1.8rem;
    font-size: 0.92rem;
    color: var(--text);
    font-style: italic;
}

.micro-feedback-icon {
    font-weight: 700;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.micro-interaction.correct .micro-feedback-icon {
    color: #10b981;
}

.micro-interaction.wrong .micro-feedback-icon {
    color: #ef4444;
}

/* ==========================================
   CHARACTER SELECTION
   ========================================== */

.character-selection {
    max-width: 800px;
    margin: 2rem auto;
    padding: 0 1rem;
}

.character-title {
    font-family: 'Playfair Display', serif;
    color: var(--navy);
    font-size: 1.8rem;
}

.character-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
}

.character-card {
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: 14px;
    padding: 1.5rem 1.25rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.25s ease;
}

.character-card:hover {
    border-color: var(--teal);
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0, 180, 166, 0.15);
}

.character-card.selected {
    border-color: var(--teal);
    background: var(--teal-dim);
    box-shadow: 0 4px 16px rgba(0, 180, 166, 0.2);
}

.character-emoji {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
}

.character-name {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--navy);
    margin-bottom: 0.4rem;
}

.character-desc {
    font-size: 0.82rem;
    color: var(--text-muted);
    line-height: 1.5;
}

@media (max-width: 576px) {
    .character-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }

    .character-card {
        padding: 1rem 0.75rem;
    }

    .character-emoji {
        font-size: 2rem;
    }

    .character-desc {
        font-size: 0.75rem;
    }
}

/* ==========================================
   GAMIFICATION — LIVELLI, STREAK, SFIDE, ACHIEVEMENT
   ========================================== */

.gamification-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 1.5rem 2rem;
    gap: 2rem;
}

.level-display {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex: 1;
}

.level-badge {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--navy) 0%, var(--navy-light) 100%);
    color: #fff;
    font-weight: 800;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.level-info {
    flex: 1;
    min-width: 0;
}

.level-info h4 {
    font-family: 'Playfair Display', serif;
    color: var(--navy);
}

.xp-bar {
    height: 8px;
    background: rgba(30, 58, 95, 0.1);
    border-radius: 4px;
    overflow: hidden;
    margin-top: 0.4rem;
}

.xp-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--teal) 0%, var(--teal-light) 100%);
    border-radius: 4px;
    transition: width 0.5s ease;
}

.streak-display {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-align: center;
}

.streak-flame {
    font-size: 2rem;
    transition: all 0.3s ease;
}

.streak-flame.cold { opacity: 0.4; }
.streak-flame.started { animation: pulse-soft 2s ease infinite; }
.streak-flame.warm { animation: pulse-soft 1.5s ease infinite; }
.streak-flame.hot { animation: flame-dance 1s ease infinite; }
.streak-flame.epic { animation: flame-dance 0.7s ease infinite; font-size: 2.5rem; }
.streak-flame.legendary { animation: legendary-glow 2s ease infinite; font-size: 2.5rem; }

@keyframes pulse-soft {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

@keyframes flame-dance {
    0%, 100% { transform: scale(1) rotate(0deg); }
    25% { transform: scale(1.1) rotate(-3deg); }
    75% { transform: scale(1.1) rotate(3deg); }
}

@keyframes legendary-glow {
    0%, 100% { transform: scale(1); filter: drop-shadow(0 0 4px rgba(168, 85, 247, 0.4)); }
    50% { transform: scale(1.15); filter: drop-shadow(0 0 12px rgba(168, 85, 247, 0.7)); }
}

.challenges-grid {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.challenge-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1rem 1.25rem;
    transition: all 0.2s ease;
}

.challenge-card.completed {
    border-color: rgba(16, 185, 129, 0.3);
    background: rgba(16, 185, 129, 0.04);
}

.challenge-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
    width: 40px;
    text-align: center;
}

.challenge-info {
    flex: 1;
    min-width: 0;
}

.challenge-type-badge {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 2px 8px;
    border-radius: 4px;
}

.challenge-type-badge.daily {
    background: var(--teal-dim);
    color: var(--teal);
}

.challenge-type-badge.weekly {
    background: var(--orange-dim);
    color: var(--orange);
}

.challenge-progress-bar {
    height: 4px;
    background: rgba(0, 0, 0, 0.06);
    border-radius: 2px;
    overflow: hidden;
}

.challenge-progress-fill {
    height: 100%;
    background: var(--teal);
    border-radius: 2px;
    transition: width 0.4s ease;
}

.challenge-card.completed .challenge-progress-fill {
    background: #10b981;
}

.challenge-reward {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex-shrink: 0;
    color: var(--orange);
    font-size: 0.85rem;
}

.achievements-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 0.75rem;
}

.achievement-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem;
    text-align: center;
    transition: all 0.2s ease;
}

.achievement-card.locked {
    opacity: 0.45;
    filter: grayscale(0.8);
}

.achievement-card.unlocked {
    border-color: rgba(0, 180, 166, 0.3);
}

.achievement-card.unlocked:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 180, 166, 0.15);
}

.achievement-emoji {
    font-size: 2rem;
    margin-bottom: 0.4rem;
}

.achievement-name {
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--navy);
    margin-bottom: 0.2rem;
}

.achievement-desc {
    font-size: 0.72rem;
    color: var(--text-muted);
    line-height: 1.4;
}

.achievement-date {
    display: block;
    margin-top: 0.3rem;
    color: var(--teal);
    font-size: 0.68rem;
}

.topbar-badge.level {
    background: rgba(30, 58, 95, 0.08);
    color: var(--navy);
    border: 1px solid rgba(30, 58, 95, 0.15);
}

@media (max-width: 768px) {
    .gamification-header {
        flex-direction: column;
        gap: 1rem;
        padding: 1rem;
    }

    .achievements-grid {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    }
}
