/* ============================================================
   MULTIPLICATIONS.EU — Site éducatif pour enfants
   Tables de multiplication — Thème École & Craie
   ============================================================ */

:root {
    --primary:   #E8475F;   /* Crayon rouge-corail */
    --secondary: #FF9F1C;   /* Orané-crayon      */
    --accent:    #2EC4B6;   /* Teal crayon        */
    --bg:        #FAF6EF;
    --surface:   #FFFFFF;
    --surface2:  #F7F2E8;
    --surface3:  #EDE5D8;
    --text:      #2A1A0E;
    --text-dim:  rgba(42,26,14,0.52);
    --font-mono: 'Nunito', sans-serif;
    --font-disp: 'Patrick Hand', 'Nunito', cursive;
    --glow-p:    0 3px 10px rgba(232,71,95,0.32);
    --glow-s:    0 3px 10px rgba(255,159,28,0.32);
    --glow-a:    0 3px 10px rgba(46,196,182,0.32);
    --radius:    16px;
    --transition: 0.2s ease;
}

/* ==================== RESET ==================== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
}

html, body {
    width: 100%;
    height: 100%;
    background: var(--bg);
    background-image:
        radial-gradient(circle, rgba(232,71,95,0.055) 1px, transparent 1px),
        radial-gradient(ellipse 70% 55% at 15% 15%, rgba(232,71,95,0.09) 0%, transparent 55%),
        radial-gradient(ellipse 55% 70% at 85% 85%, rgba(46,196,182,0.08) 0%, transparent 55%);
    background-size: 24px 24px, auto, auto;
    color: var(--text);
    font-family: var(--font-mono);
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* ==================== SCROLLBAR ==================== */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(232,71,95,0.30); border-radius: 2px; }

/* ==================== APP ==================== */
#app {
    position: relative;
    width: 100%;
    height: 100%;
    max-width: 480px;
    max-height: 900px;
    background: var(--surface);
    overflow: hidden;
    box-shadow:
        0 8px 40px rgba(42,26,14,0.12),
        0 2px 10px rgba(42,26,14,0.06);
    border: 1px solid rgba(232,71,95,0.12);
}

/* Corner decorations */
#app::before, #app::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border-color: var(--primary);
    border-style: solid;
    opacity: 0.5;
    z-index: 1000;
    pointer-events: none;
}
#app::before { top: 8px; left: 8px; border-width: 2px 0 0 2px; }
#app::after  { top: 8px; right: 8px; border-width: 2px 2px 0 0; }

/* ==================== SCREENS ==================== */
.screen {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px 22px;
    opacity: 0;
    pointer-events: none;
    transform: translateY(16px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    overflow-y: auto;
    overflow-x: hidden;
}

.screen.active {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
    z-index: 1;
}

.screen.leaving {
    opacity: 0;
    transform: translateY(-16px);
    pointer-events: none;
}

/* ==================== HOME SCREEN ==================== */
.logo-area {
    text-align: center;
    margin-bottom: 18px;
}

.logo-title {
    font-family: var(--font-disp);
    font-size: clamp(2.8rem, 12vw, 3.8rem);
    font-weight: 800;
    color: var(--primary);
    text-shadow: var(--glow-p);
    letter-spacing: 2px;
    line-height: 1;
    animation: glitch-anim 6s infinite;
}

.logo-sub {
    font-family: var(--font-disp);
    font-size: clamp(0.9rem, 4vw, 1.15rem);
    font-weight: 700;
    color: var(--secondary);
    text-shadow: var(--glow-s);
    letter-spacing: 3px;
    margin-top: 4px;
    text-transform: uppercase;
}

.logo-domain {
    font-family: var(--font-disp);
    font-size: 0.85rem;
    color: var(--accent);
    opacity: 0.8;
    letter-spacing: 4px;
    margin-top: 4px;
}

.logo-star {
    width: 52px;
    height: 52px;
    margin: 12px auto 0;
    animation: spin-slow 10s linear infinite;
    filter: drop-shadow(0 0 6px var(--primary));
}

.star-svg { width: 100%; height: 100%; }

.home-tagline {
    font-size: 0.9rem;
    color: var(--text-dim);
    text-align: center;
    margin-bottom: 28px;
    letter-spacing: 0.5px;
    line-height: 1.5;
}

.home-stats {
    display: flex;
    gap: 10px;
    margin-top: 18px;
    flex-wrap: wrap;
    justify-content: center;
}

.stat-pill {
    background: rgba(232,71,95,0.08);
    border: 1px solid rgba(232,71,95,0.28);
    border-radius: 20px;
    padding: 6px 12px;
    font-size: 0.8rem;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 5px;
}

.stat-pill span { font-weight: bold; }

.home-features {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 20px;
    width: 100%;
    max-width: 260px;
}

.feature-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.82rem;
    color: var(--text-dim);
}

/* ==================== BUTTONS ==================== */
.btn-neon {
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 2px solid var(--primary);
    color: var(--primary);
    padding: 15px 40px;
    font-size: 1.25rem;
    font-family: var(--font-disp);
    font-weight: 700;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 3px;
    box-shadow: var(--glow-p);
    transition: all var(--transition);
    border-radius: var(--radius);
    width: 280px;
    max-width: 90%;
    position: relative;
    overflow: hidden;
}

.btn-neon::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(232,71,95,0.10);
    opacity: 0;
    transition: opacity 0.12s;
}

.btn-neon:active { transform: scale(0.97); }
.btn-neon:active::after { opacity: 1; }
.btn-neon:disabled { opacity: 0.3; cursor: not-allowed; box-shadow: none; }

.btn-neon.btn-secondary {
    border-color: var(--secondary);
    color: var(--secondary);
    box-shadow: var(--glow-s), inset 0 0 15px rgba(255,0,85,0.04);
}

.btn-neon.btn-secondary::after { background: rgba(255,159,28,0.12); }

.btn-small {
    background: transparent;
    border: 1px solid var(--primary);
    color: var(--primary);
    padding: 9px 18px;
    font-size: 0.8rem;
    font-family: var(--font-mono);
    cursor: pointer;
    letter-spacing: 1px;
    border-radius: var(--radius);
    transition: all var(--transition);
}

.btn-small:active { transform: scale(0.95); background: rgba(0,243,255,0.1); }
.btn-small.btn-ghost { border-color: #333; color: #555; }
.btn-small.btn-ghost:active { background: rgba(255,255,255,0.05); }

.btn-ghost {
    background: transparent;
    border: none;
    color: var(--text-dim);
    font-size: 0.9rem;
    font-family: var(--font-mono);
    cursor: pointer;
    padding: 10px 15px;
    letter-spacing: 1px;
    transition: color var(--transition);
}

.btn-ghost:hover, .btn-ghost:active { color: var(--text); }

.btn-danger {
    display: flex;
    align-items: center;
    gap: 8px;
    background: transparent;
    border: 1px solid var(--secondary);
    color: var(--secondary);
    padding: 10px 20px;
    font-size: 0.8rem;
    font-family: var(--font-mono);
    cursor: pointer;
    letter-spacing: 1px;
    border-radius: var(--radius);
    transition: all var(--transition);
}

.btn-danger:active { background: rgba(255,0,85,0.15); }

.btn-quit {
    background: rgba(255,0,85,0.12);
    border: 1px solid rgba(255,0,85,0.5);
    color: var(--secondary);
    width: 34px;
    height: 34px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    flex-shrink: 0;
    margin-left: auto;
}

.btn-quit:active {
    transform: scale(0.88);
    background: var(--secondary);
    color: #000;
}

/* ==================== SELECT SCREEN ==================== */
.screen-title {
    font-family: var(--font-disp);
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--primary);
    text-shadow: var(--glow-p);
    letter-spacing: 2px;
    margin-bottom: 6px;
    text-align: center;
}

.screen-hint {
    font-size: 0.78rem;
    color: var(--text-dim);
    text-align: center;
    margin-bottom: 20px;
    letter-spacing: 0.5px;
}

.table-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    width: 100%;
    max-width: 340px;
    margin-bottom: 16px;
}

.table-chip {
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--surface3);
    border-radius: var(--radius);
    background: var(--surface2);
    cursor: pointer;
    transition: all 0.15s;
    position: relative;
    overflow: hidden;
}

.table-chip .chip-num {
    font-family: var(--font-disp);
    font-size: 1.45rem;
    font-weight: 700;
    color: var(--text-dim);
    line-height: 1;
    transition: color 0.15s, text-shadow 0.15s;
}

.table-chip .chip-label {
    font-size: 0.58rem;
    color: var(--text-dim);
    opacity: 0.7;
    margin-top: 2px;
    letter-spacing: 1px;
    transition: color 0.15s;
}

.chip-check {
    position: absolute;
    top: 4px;
    right: 5px;
    opacity: 0;
    transition: opacity 0.15s;
}

.table-chip.selected {
    border-color: var(--primary);
    background: var(--surface);
    box-shadow: 0 4px 14px var(--glow-p);
}

.table-chip.selected .chip-num {
    color: var(--primary);
    text-shadow: var(--glow-p);
}

.table-chip.selected .chip-label { color: var(--primary); opacity: 0.7; }
.table-chip.selected .chip-check { opacity: 1; }
.table-chip:active { transform: scale(0.9); }

.select-actions {
    display: flex;
    gap: 12px;
    margin-bottom: 6px;
}

/* ==================== GAME SCREEN ==================== */
#screen-game {
    padding: 0;
    justify-content: flex-start;
}

.game-status-bar {
    width: 100%;
    height: 58px;
    background: rgba(255,255,255,0.96);
    border-bottom: 3px solid var(--primary);
    box-shadow: 0 2px 12px rgba(42,26,14,0.10);
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0 12px 0 14px;
    flex-shrink: 0;
}

.status-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 1.05rem;
    color: var(--text);
    font-weight: bold;
}

.status-item.correct-count span { color: var(--accent); text-shadow: 0 0 5px var(--accent); }

.icon-inline {
    width: 17px;
    height: 17px;
    flex-shrink: 0;
}

.question-zone {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px 20px 0;
    min-height: 0;
    position: relative;
}

.question-table-hint {
    font-size: 0.75rem;
    color: var(--text-dim);
    letter-spacing: 2px;
    margin-bottom: 8px;
    text-align: center;
}

.question-display {
    font-family: var(--font-disp);
    font-size: clamp(2.5rem, 11vw, 4.2rem);
    font-weight: 900;
    color: var(--primary);
    text-shadow: var(--glow-p);
    text-align: center;
    letter-spacing: 2px;
    line-height: 1.15;
}

.question-display.pop-in { animation: pop-in 0.22s cubic-bezier(0.175, 0.885, 0.32, 1.275); }

.streak-display {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    color: var(--accent);
    font-size: 0.82rem;
    letter-spacing: 2px;
    text-align: center;
    animation: bounce-in 0.3s ease;
    padding: 5px 12px;
    border: 1px solid var(--accent);
    border-radius: 20px;
    background: var(--surface);
}

.feedback-flash {
    position: absolute;
    inset: 58px 0 0 0;
    pointer-events: none;
    opacity: 0;
    z-index: 5;
}

.feedback-flash.flash-good { animation: flash-good 0.4s forwards; }
.feedback-flash.flash-bad  { animation: flash-bad  0.4s forwards; }

.answer-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    width: 100%;
    padding: 10px 14px 8px;
    flex-shrink: 0;
}

.answer-btn {
    background: var(--surface2);
    border: 2px solid var(--surface3);
    border-radius: var(--radius);
    padding: 18px 6px;
    font-family: var(--font-disp);
    font-size: 1.7rem;
    font-weight: 700;
    color: var(--text);
    cursor: pointer;
    transition: border-color 0.12s, color 0.12s, transform 0.12s;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.answer-btn:active { transform: scale(0.95); }
.answer-btn:disabled { cursor: default; }

.answer-btn.correct {
    border-color: #22C55E;
    color: #166534;
    box-shadow: 0 4px 14px rgba(34,197,94,0.30);
    background: rgba(34,197,94,0.10);
    animation: pop-correct 0.28s ease;
}

.answer-btn.wrong {
    border-color: var(--secondary);
    color: var(--secondary);
    box-shadow: 0 4px 14px rgba(232,71,95,0.30);
    background: rgba(232,71,95,0.10);
    animation: shake-btn 0.32s ease;
}

.answer-btn.reveal-correct {
    border-color: #22C55E;
    background: rgba(34,197,94,0.10);
    color: #166534;
}

.game-progress-bar {
    width: 100%;
    height: 5px;
    background: var(--surface3);
    flex-shrink: 0;
}

.game-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    box-shadow: 0 0 6px var(--primary);
    transition: width 0.5s ease;
    width: 0%;
}

/* Timer Ring */
.timer-ring-wrap {
    position: relative;
    width: 36px;
    height: 36px;
    flex-shrink: 0;
}

.timer-ring-svg {
    width: 36px;
    height: 36px;
    transform: rotate(-90deg);
}

.timer-ring-bg {
    fill: none;
    stroke: var(--surface3);
    stroke-width: 3;
}

.timer-ring-progress {
    fill: none;
    stroke: var(--primary);
    stroke-width: 3;
    stroke-linecap: round;
    stroke-dasharray: 94.25; /* 2π × 15 */
    stroke-dashoffset: 0;
    transition: stroke-dashoffset 0.12s linear, stroke 0.25s;
    filter: drop-shadow(0 0 3px var(--primary));
}

.timer-ring-progress.urgent { stroke: var(--secondary); filter: drop-shadow(0 0 3px var(--secondary)); }

.timer-ring-text {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.72rem;
    font-weight: bold;
    color: var(--primary);
    transition: color 0.25s;
}

.timer-ring-text.urgent { color: var(--secondary); }

/* ==================== RESULT SCREEN ==================== */
.result-header {
    text-align: center;
    margin-bottom: 20px;
}

.result-emoji {
    margin-bottom: 8px;
}

.result-title {
    font-family: var(--font-disp);
    font-size: 1.7rem;
    font-weight: 900;
    letter-spacing: 3px;
    margin-bottom: 10px;
}

.result-score {
    font-family: var(--font-disp);
    font-size: 4rem;
    font-weight: 900;
    color: var(--primary);
    text-shadow: var(--glow-p);
    line-height: 1;
}

.result-score .score-denom {
    font-size: 1.4rem;
    color: var(--text-dim);
}

.result-breakdown {
    width: 100%;
    max-width: 320px;
    background: var(--surface2);
    border: 1px solid var(--surface3);
    border-radius: var(--radius);
    padding: 12px 16px;
    margin-bottom: 16px;
}

.breakdown-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 7px 0;
    border-bottom: 1px solid var(--surface3);
}

.breakdown-row:last-child { border-bottom: none; }

.breakdown-label {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 0.82rem;
    color: var(--text-dim);
    letter-spacing: 0.5px;
}

.breakdown-val { font-size: 1rem; font-weight: bold; color: var(--text); }
.val-good { color: #0F9B6E; }
.val-bad  { color: var(--secondary); }

.errors-section {
    width: 100%;
    max-width: 320px;
    margin-bottom: 16px;
}

.errors-title {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 0.75rem;
    letter-spacing: 2px;
    color: var(--secondary);
    text-shadow: 0 0 5px var(--secondary);
    margin-bottom: 10px;
    justify-content: center;
}

.errors-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}

.error-chip {
    background: rgba(255,0,85,0.08);
    border: 1px solid rgba(255,0,85,0.35);
    border-radius: 6px;
    padding: 5px 12px;
    font-size: 0.88rem;
    color: var(--secondary);
    position: relative;
    font-family: var(--font-disp);
    letter-spacing: 1px;
}

.error-chip .repeat-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    background: var(--secondary);
    color: #000;
    border-radius: 50%;
    width: 16px;
    height: 16px;
    font-size: 0.58rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

.result-actions {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    width: 100%;
}

/* ==================== HISTORY SCREEN ==================== */
.history-list {
    width: 100%;
    max-width: 380px;
    max-height: 55vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 4px 2px;
    margin-bottom: 14px;
}

.history-card {
    background: var(--surface);
    border: 1px solid var(--surface3);
    border-top: 3px solid var(--primary);
    border-radius: var(--radius);
    padding: 12px 14px;
    position: relative;
    transition: box-shadow var(--transition);
    box-shadow: 0 2px 8px rgba(42,26,14,0.06);
}

.history-card:hover { box-shadow: 0 4px 16px rgba(42,26,14,0.12); }

.hc-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 10px;
    gap: 8px;
}

.hc-tables {
    font-size: 0.72rem;
    color: var(--primary);
    letter-spacing: 1px;
    line-height: 1.4;
}

.hc-date {
    font-size: 0.68rem;
    color: var(--text-dim);
    flex-shrink: 0;
}

.hc-body {
    display: flex;
    align-items: center;
    gap: 14px;
}

.hc-score {
    font-family: var(--font-disp);
    font-size: 1.9rem;
    font-weight: 900;
    color: var(--primary);
    text-shadow: 0 0 8px var(--primary);
    line-height: 1;
    flex-shrink: 0;
}

.hc-score small { font-size: 0.75rem; color: var(--text-dim); }

.hc-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.hc-detail {
    font-size: 0.72rem;
    color: var(--text-dim);
}

.hc-detail strong { color: var(--text); }

.hc-errors {
    font-size: 0.68rem;
    color: var(--secondary);
    margin-top: 4px;
    opacity: 0.7;
    line-height: 1.4;
}

.hc-delete {
    position: absolute;
    top: 8px;
    right: 8px;
    background: transparent;
    border: none;
    color: #2a2a2a;
    font-size: 0.9rem;
    cursor: pointer;
    transition: color 0.15s;
    padding: 4px 6px;
    border-radius: 4px;
}

.hc-delete:hover { color: var(--secondary); background: rgba(255,0,85,0.1); }

.history-empty {
    text-align: center;
    color: var(--text-dim);
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.history-empty .empty-svg { width: 90px; height: 90px; }

.history-actions {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

/* ==================== ANIMATIONS ==================== */
@keyframes glitch-anim {
    0%,88%,100% { text-shadow: var(--glow-p); letter-spacing: 2px; }
    89% {
        text-shadow: 4px 0 6px var(--secondary), -4px 0 6px var(--primary);
        letter-spacing: 4px;
    }
    91% {
        text-shadow: -3px 0 6px var(--secondary), 3px 0 6px var(--primary);
        letter-spacing: 1px;
    }
    93% { text-shadow: var(--glow-p); letter-spacing: 2px; }
}

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

@keyframes pop-in {
    0%   { transform: scale(0.65); opacity: 0; }
    80%  { transform: scale(1.06); }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes bounce-in {
    0%   { transform: scale(0.6) translateY(8px); opacity: 0; }
    100% { transform: scale(1) translateY(0); opacity: 1; }
}

@keyframes flash-good {
    0%   { opacity: 1; background: radial-gradient(ellipse at center, rgba(204,255,0,0.2) 0%, transparent 70%); }
    100% { opacity: 0; }
}

@keyframes flash-bad {
    0%   { opacity: 1; background: radial-gradient(ellipse at center, rgba(255,0,85,0.25) 0%, transparent 70%); }
    100% { opacity: 0; }
}

@keyframes pop-correct {
    0%   { transform: scale(1); }
    50%  { transform: scale(1.07); }
    100% { transform: scale(1); }
}

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

/* ==================== UTILITIES ==================== */
.hidden { display: none !important; }

/* ==================== REWARDS NAV BUTTON ==================== */
.btn-rewards-nav {
    border-color: #ffd700;
    color: #ffd700;
    box-shadow: 0 0 12px rgba(255,215,0,0.4), inset 0 0 15px rgba(255,215,0,0.04);
    font-size: 1rem;
    padding: 12px 30px;
    position: relative;
}

.btn-rewards-nav::after { background: rgba(255,215,0,0.1); }

.btn-rewards-small {
    border-color: #ffd700 !important;
    color: #ffd700 !important;
    display: flex;
    align-items: center;
}

.reward-notif {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #ffd700;
    color: #000;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 0.65rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: pulse-badge 2s infinite;
    box-shadow: 0 0 8px rgba(255,215,0,0.6);
}

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

/* ==================== REWARDS SCREEN ==================== */
#screen-rewards {
    justify-content: flex-start;
    padding-top: 28px;
    padding-bottom: 20px;
}

.rewards-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    width: 100%;
    max-width: 420px;
    max-height: 62vh;
    overflow-y: auto;
    padding: 4px 2px;
    margin-bottom: 6px;
}

/* ── Reward Cards ── */
.reward-card {
    border-radius: 10px;
    padding: 12px 10px 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    position: relative;
    text-align: center;
    transition: transform 0.18s, box-shadow 0.18s;
    background: var(--surface2);
    border: 2px solid transparent;
    cursor: default;
}

.reward-card.unlocked { cursor: pointer; }
.reward-card.unlocked:hover { transform: translateY(-2px); }

/* Rarities */
.reward-card.rarity-bronze.unlocked {
    border-color: #cd7f32;
    box-shadow: 0 4px 12px rgba(205,127,50,0.22);
    background: linear-gradient(160deg, #FFF8EC 0%, var(--surface) 100%);
}
.reward-card.rarity-silver.unlocked {
    border-color: #a0a0b0;
    box-shadow: 0 4px 12px rgba(160,160,176,0.22);
    background: linear-gradient(160deg, #F8F8FC 0%, var(--surface) 100%);
}
.reward-card.rarity-gold.unlocked {
    border-color: #e8b400;
    box-shadow: 0 4px 16px rgba(232,180,0,0.28);
    background: linear-gradient(160deg, #FFFBEE 0%, var(--surface) 100%);
    animation: shimmer-gold 3s infinite;
}
.reward-card.rarity-platinum.unlocked {
    border-color: #8080d8;
    box-shadow: 0 4px 16px rgba(128,128,216,0.25);
    background: linear-gradient(160deg, #F2F2FF 0%, var(--surface) 100%);
}
.reward-card.rarity-legendary.unlocked {
    border: 2px solid transparent;
    background-clip: padding-box;
    box-shadow: 0 6px 24px rgba(168,85,247,0.22), 0 2px 8px rgba(255,215,0,0.12);
    background: linear-gradient(160deg, #FFF0FF 0%, #FFFFF8 100%);
    position: relative;
}
.reward-card.rarity-legendary.unlocked::before {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: 12px;
    background: linear-gradient(135deg, #ffd700, #a855f7, #ec4899, #ffd700);
    background-size: 200% 200%;
    animation: rainbow-border 3s linear infinite;
    z-index: -1;
}

.reward-card.locked {
    opacity: 0.58;
    border-color: var(--surface3);
    filter: grayscale(0.4);
}

.reward-icon {
    font-size: 1.8rem;
    line-height: 1;
    margin-bottom: 2px;
}

.reward-card.locked .reward-icon { filter: grayscale(1); opacity: 0.5; }

.reward-title {
    font-family: var(--font-disp);
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--text);
    line-height: 1.3;
}

.reward-card.locked .reward-title { color: var(--text-dim); }

.reward-desc {
    font-size: 0.6rem;
    color: var(--text-dim);
    line-height: 1.4;
}

.reward-card.locked .reward-desc { color: var(--text-dim); }

.reward-progress {
    font-size: 0.58rem;
    color: var(--accent);
    letter-spacing: 0.5px;
    margin-top: 2px;
    font-weight: bold;
}

.reward-card.locked .reward-progress { color: #2a2a2a; }

.reward-type-badge {
    font-size: 0.55rem;
    color: var(--text-dim);
    opacity: 0.65;
    margin-top: 2px;
}

.reward-apply-btn {
    margin-top: 6px;
    background: rgba(255,215,0,0.1);
    border: 1px solid rgba(255,215,0,0.5);
    color: #ffd700;
    border-radius: 5px;
    padding: 4px 10px;
    font-size: 0.58rem;
    font-family: var(--font-mono);
    cursor: pointer;
    letter-spacing: 1px;
    transition: all 0.15s;
}

.reward-apply-btn:active { background: rgba(255,215,0,0.25); transform: scale(0.95); }

.reward-sound-btn {
    background: rgba(0,243,255,0.1);
    border-color: rgba(0,243,255,0.5);
    color: var(--primary);
}

.reward-wp-btn {
    background: rgba(168,85,247,0.1);
    border-color: rgba(168,85,247,0.5);
    color: #a855f7;
}

/* ── Reset row ── */
.rewards-reset-row {
    grid-column: 1 / -1;
    background: var(--surface2);
    border: 1px solid var(--surface3);
    border-radius: 10px;
    padding: 10px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}

.reset-row-label {
    font-size: 0.67rem;
    color: var(--text-dim);
    letter-spacing: 1px;
    flex-shrink: 0;
}

.reset-row-btns {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ==================== REWARD MODAL ==================== */
.reward-modal {
    position: absolute;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.85);
    backdrop-filter: blur(6px);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.reward-modal.show {
    opacity: 1;
    pointer-events: auto;
}

.reward-modal-inner {
    background: linear-gradient(160deg, var(--surface2) 0%, var(--surface) 100%);
    border: 2px solid transparent;
    border-radius: 16px;
    padding: 32px 28px;
    width: 88%;
    max-width: 340px;
    text-align: center;
    position: relative;
    box-shadow: 0 0 40px rgba(168,85,247,0.4), 0 0 80px rgba(255,215,0,0.15);
    animation: modal-pop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.reward-modal-inner::before {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: 18px;
    background: linear-gradient(135deg, #ffd700, #a855f7, #00f3ff, #ffd700);
    background-size: 300% 300%;
    animation: rainbow-border 2s linear infinite;
    z-index: -1;
}

.reward-modal-anim {
    margin-bottom: 12px;
}

.modal-icon-burst {
    font-size: 4rem;
    animation: icon-burst 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: block;
    filter: drop-shadow(0 0 12px rgba(255,215,0,0.8));
}

.reward-modal-title {
    font-family: var(--font-disp);
    font-size: 1.1rem;
    font-weight: 900;
    color: #ffd700;
    text-shadow: 0 0 15px rgba(255,215,0,0.7);
    letter-spacing: 2px;
    margin-bottom: 10px;
}

.reward-modal-desc {
    font-size: 0.82rem;
    color: var(--text-dim);
    line-height: 1.5;
    margin-bottom: 6px;
}

/* ==================== CONFETTI ==================== */
.confetti-burst {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 300;
    overflow: hidden;
}

.confetti-p {
    position: absolute;
    top: -20px;
    border-radius: 2px;
    animation: confetti-fall linear forwards;
}

@keyframes confetti-fall {
    0%   { transform: translateY(0) rotate(0deg); opacity: 1; }
    100% { transform: translateY(110vh) rotate(720deg); opacity: 0; }
}

/* ==================== WALLPAPER OVERLAY ==================== */
.wp-layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    opacity: 0;
    transition: opacity 0.5s ease;
    background-size: cover;
    background-position: center;
}

/* ==================== ANIMATIONS (rewards) ==================== */
@keyframes shimmer-gold {
    0%, 100% { box-shadow: 0 0 14px rgba(255,215,0,0.35); }
    50%       { box-shadow: 0 0 22px rgba(255,215,0,0.6), 0 0 6px rgba(255,215,0,0.3) inset; }
}

@keyframes rainbow-border {
    0%   { background-position: 0% 50%; }
    50%  { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

@keyframes modal-pop {
    0%   { transform: scale(0.5) translateY(30px); opacity: 0; }
    80%  { transform: scale(1.04); }
    100% { transform: scale(1); opacity: 1; }
}


@keyframes icon-burst {
    0%   { transform: scale(0) rotate(-20deg); }
    60%  { transform: scale(1.3) rotate(10deg); }
    100% { transform: scale(1) rotate(0deg); }
}

/* ═══════════════════════════════════════════════════════════
   PROFILES SCREEN
═══════════════════════════════════════════════════════════ */
#screen-profiles {
    justify-content: flex-start;
    padding-top: 26px;
    padding-bottom: 20px;
}

.profiles-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    width: 100%;
    max-width: 400px;
    max-height: 65vh;
    overflow-y: auto;
    padding: 4px 2px;
    margin-bottom: 4px;
}

/* ── Profile Card ── */
.profile-card {
    border-radius: 12px;
    padding: 16px 12px 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    background: var(--surface2);
    border: 2px solid var(--surface3);
    cursor: pointer;
    transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
    position: relative;
    text-align: center;
    min-height: 140px;
    justify-content: center;
}

.profile-card:active { transform: scale(0.95); }

.profile-card.active {
    border-color: var(--profile-color, var(--primary));
    box-shadow: 0 0 16px color-mix(in srgb, var(--profile-color, var(--primary)) 40%, transparent);
    animation: profile-active-pulse 3s infinite;
}

@keyframes profile-active-pulse {
    0%, 100% { box-shadow: 0 0 12px color-mix(in srgb, var(--profile-color, var(--primary)) 35%, transparent); }
    50%       { box-shadow: 0 0 22px color-mix(in srgb, var(--profile-color, var(--primary)) 55%, transparent); }
}

.profile-card:not(.active):hover {
    border-color: rgba(42,26,14,0.18);
}

.profile-card-add {
    border: 2px dashed #2a2a2a;
    opacity: 0.6;
    transition: opacity 0.15s, border-color 0.15s;
    min-height: 140px;
}

.profile-card-add:hover { opacity: 1; border-color: var(--primary); }

.profile-add-icon {
    font-size: 2.2rem;
    color: var(--text-dim);
    line-height: 1;
    margin-bottom: 4px;
}

/* ── Profile Avatar ── */
.profile-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: 2px solid;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    flex-shrink: 0;
    line-height: 1;
}

.profile-avatar-sm {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1.5px solid;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
    line-height: 1;
}

.profile-card-name {
    font-family: var(--font-disp);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--text);
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.profile-card-stats {
    display: flex;
    flex-direction: column;
    gap: 2px;
    align-items: center;
}

.profile-card-stats span {
    font-size: 0.6rem;
    color: var(--text-dim);
    letter-spacing: 0.5px;
}

.profile-card-active-badge {
    position: absolute;
    top: 6px;
    left: 8px;
    font-size: 0.5rem;
    letter-spacing: 1px;
    color: var(--profile-color, var(--primary));
    font-family: var(--font-disp);
    font-weight: 700;
    opacity: 0.8;
}

.profile-card-delete {
    position: absolute;
    top: 5px;
    right: 6px;
    background: transparent;
    border: none;
    color: rgba(42,26,14,0.25);
    font-size: 0.8rem;
    cursor: pointer;
    padding: 4px 5px;
    border-radius: 4px;
    transition: color 0.15s, background 0.15s;
    line-height: 1;
}

.profile-card-delete:hover { color: var(--secondary); background: rgba(232,71,95,0.10); }

.profile-card-edit {
    position: absolute;
    bottom: 5px;
    left: 6px;
    background: transparent;
    border: none;
    color: #2a2a2a;
    font-size: 0.75rem;
    cursor: pointer;
    padding: 4px 5px;
    border-radius: 4px;
    transition: color 0.15s, background 0.15s;
    line-height: 1;
}

.profile-card-edit:hover { color: var(--primary); background: rgba(0,243,255,0.08); }

/* ══════════════════════════════════════════════════════════ */
/* HOME PROFILE BADGE                                        */
/* ══════════════════════════════════════════════════════════ */
.home-profile-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--surface2);
    border: 1px solid var(--surface3);
    border-radius: 20px;
    padding: 6px 12px 6px 7px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    margin-bottom: 14px;
    max-width: 220px;
}

.home-profile-badge:hover {
    background: var(--surface);
    border-color: var(--profile-color, var(--primary));
}

.home-profile-name {
    font-family: var(--font-disp);
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: 1px;
    flex: 1;
    text-align: left;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 120px;
}

.home-profile-badge svg { color: var(--text-dim); flex-shrink: 0; }

/* Secondary button row */
.home-secondary-btns {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 10px;
}

.home-secondary-btns .btn-neon {
    width: auto;
    flex: 1;
    min-width: 120px;
    max-width: 180px;
    font-size: 0.78rem;
    padding: 10px 16px;
    letter-spacing: 1.5px;
}

/* Scores nav button */
.btn-scores-nav {
    border-color: #ec4899;
    color: #ec4899;
    box-shadow: 0 0 12px rgba(236,72,153,0.35), inset 0 0 15px rgba(236,72,153,0.04);
}

.btn-scores-nav::after { background: rgba(236,72,153,0.1); }

/* ══════════════════════════════════════════════════════════ */
/* PROFILE CREATE MODAL                                      */
/* ══════════════════════════════════════════════════════════ */
.profile-create-modal {
    position: absolute;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.88);
    backdrop-filter: blur(6px);
}

.profile-create-inner {
    background: linear-gradient(160deg, var(--surface2) 0%, var(--surface) 100%);
    border: 1px solid var(--surface3);
    border-radius: 16px;
    padding: 24px 20px;
    width: 88%;
    max-width: 320px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    max-height: 88vh;
    overflow-y: auto;
}

.profile-create-title {
    font-family: var(--font-disp);
    font-size: 1rem;
    font-weight: 900;
    color: var(--primary);
    text-shadow: var(--glow-p);
    letter-spacing: 3px;
    text-align: center;
}

/* Avatar picker */
.avatar-picker {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
    width: 100%;
}

.avatar-btn {
    font-size: 1.35rem;
    background: var(--surface2);
    border: 2px solid transparent;
    border-radius: 8px;
    padding: 6px 2px;
    cursor: pointer;
    transition: all 0.15s;
    text-align: center;
    line-height: 1;
}

.avatar-btn:hover  { border-color: var(--surface3); transform: scale(1.1); }
.avatar-btn.selected {
    border-color: var(--primary);
    background: rgba(0,243,255,0.1);
    box-shadow: 0 0 8px rgba(0,243,255,0.3);
    transform: scale(1.12);
}

/* Color picker */
.color-picker {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
    width: 100%;
}

.color-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid var(--surface3);
    cursor: pointer;
    transition: transform 0.15s;
    flex-shrink: 0;
}

.color-btn:hover    { transform: scale(1.15); }
.color-btn.selected { border-color: var(--text); transform: scale(1.2); }

/* Name input */
.profile-name-input {
    width: 100%;
    background: var(--surface2);
    border: 1px solid var(--surface3);
    border-radius: 8px;
    padding: 12px 14px;
    font-family: var(--font-disp);
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: 2px;
    text-align: center;
    outline: none;
    user-select: auto;
    -webkit-user-select: auto;
    touch-action: auto;
    transition: border-color 0.15s;
}

.profile-name-input:focus { border-color: var(--primary); box-shadow: 0 0 8px rgba(0,243,255,0.2); }
.profile-name-input::placeholder { color: var(--text-dim); opacity: 0.6; font-weight: 400; letter-spacing: 1px; }

/* Delete modal desc */
.profile-delete-desc {
    font-size: 0.82rem;
    color: var(--text);
    text-align: center;
    line-height: 1.5;
}

/* ══════════════════════════════════════════════════════════ */
/* SCORES / PALMARÈS SCREEN                                  */
/* ══════════════════════════════════════════════════════════ */
#screen-scores {
    justify-content: flex-start;
    padding-top: 26px;
    padding-bottom: 20px;
}

.scores-content {
    width: 100%;
    max-width: 420px;
    max-height: 66vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 4px 2px;
    margin-bottom: 4px;
}

.score-section {
    background: var(--surface2);
    border: 1px solid var(--surface3);
    border-radius: 10px;
    padding: 12px 14px;
}

.score-section-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--surface3);
}

.score-cat-icon { font-size: 1.6rem; line-height: 1; flex-shrink: 0; }

.score-cat-title {
    font-family: var(--font-disp);
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: 1.5px;
    text-shadow: 0 0 6px var(--primary);
}

.score-cat-desc {
    font-size: 0.6rem;
    color: var(--text-dim);
    margin-top: 2px;
    letter-spacing: 0.5px;
}

.score-no-data {
    font-size: 0.7rem;
    color: var(--text-dim);
    opacity: 0.7;
    text-align: center;
    padding: 8px 0;
}

.score-podium {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.score-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 8px;
    border-radius: 8px;
    background: rgba(42,26,14,0.03);
    transition: background 0.15s;
}

.score-row-active {
    background: color-mix(in srgb, var(--profile-color, var(--primary)) 8%, transparent);
    border: 1px solid color-mix(in srgb, var(--profile-color, var(--primary)) 30%, transparent);
}

.score-rank {
    font-size: 1.1rem;
    width: 28px;
    text-align: center;
    flex-shrink: 0;
}

.score-profile-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1.5px solid;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    flex-shrink: 0;
    line-height: 1;
}

.score-profile-name {
    flex: 1;
    font-family: var(--font-disp);
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: 0.5px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.score-me {
    color: var(--profile-color, var(--primary));
    text-shadow: 0 0 6px color-mix(in srgb, var(--profile-color, var(--primary)) 60%, transparent);
}

.score-value {
    font-family: var(--font-disp);
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text);
    flex-shrink: 0;
    text-align: right;
}

.score-value-empty { color: var(--text-dim); opacity: 0.6; }
