/* ============================================================
   MULTIPLICATIONS.EU — Site éducatif indépendant
   Tables de multiplication pour enfants
   Design : neon sombre, inspiré QuickyGame
   ============================================================ */

:root {
    --primary:   #00f3ff;   /* Cyan neon      */
    --secondary: #ff0055;   /* Rose neon      */
    --accent:    #ccff00;   /* Lime neon      */
    --bg:        #050505;
    --surface:   #0f0f0f;
    --surface2:  #161616;
    --surface3:  #1e1e1e;
    --text:      #ffffff;
    --text-dim:  rgba(255,255,255,0.45);
    --font-mono: 'Share Tech Mono', 'Courier New', monospace;
    --font-disp: 'Orbitron', 'Courier New', monospace;
    --glow-p:    0 0 12px var(--primary), 0 0 24px rgba(0,243,255,0.4);
    --glow-s:    0 0 12px var(--secondary), 0 0 24px rgba(255,0,85,0.4);
    --glow-a:    0 0 10px var(--accent), 0 0 20px rgba(204,255,0,0.4);
    --radius:    8px;
    --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(ellipse 80% 60% at 20% 20%, rgba(0,243,255,0.05) 0%, transparent 60%),
        radial-gradient(ellipse 60% 80% at 80% 80%, rgba(255,0,85,0.04) 0%, transparent 60%);
    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(0,243,255,0.2); 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 0 0 1px rgba(0,243,255,0.08),
        0 0 60px rgba(0,243,255,0.05),
        inset 0 0 80px rgba(0,0,0,0.5);
}

/* Corner decorations */
#app::before, #app::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border-color: var(--primary);
    border-style: solid;
    opacity: 0.3;
    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: 900;
    color: var(--primary);
    text-shadow: var(--glow-p);
    letter-spacing: 4px;
    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: 6px;
    margin-top: 4px;
    text-transform: uppercase;
}

.logo-domain {
    font-family: var(--font-disp);
    font-size: 0.85rem;
    color: rgba(0,243,255,0.35);
    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(0,243,255,0.07);
    border: 1px solid rgba(0,243,255,0.25);
    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; text-shadow: 0 0 5px var(--primary); }

.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), inset 0 0 15px rgba(0,243,255,0.05);
    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(0,243,255,0.1);
    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,0,85,0.1); }

.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: rgba(255,255,255,0.3);
    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: rgba(255,255,255,0.7); }

.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: 700;
    color: var(--primary);
    text-shadow: var(--glow-p);
    letter-spacing: 4px;
    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 #222;
    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: #3a3a3a;
    line-height: 1;
    transition: color 0.15s, text-shadow 0.15s;
}

.table-chip .chip-label {
    font-size: 0.58rem;
    color: #2a2a2a;
    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: rgba(0,243,255,0.07);
    box-shadow: 0 0 12px rgba(0,243,255,0.25);
}

.table-chip.selected .chip-num {
    color: var(--primary);
    text-shadow: 0 0 10px var(--primary);
}

.table-chip.selected .chip-label { color: rgba(0,243,255,0.45); }
.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(0,0,0,0.92);
    border-bottom: 2px solid var(--primary);
    box-shadow: 0 2px 15px rgba(0,243,255,0.1);
    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: #fff;
    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: rgba(0,243,255,0.35);
    letter-spacing: 3px;
    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;
    text-shadow: var(--glow-a);
    animation: bounce-in 0.3s ease;
    padding: 5px 12px;
    border: 1px solid rgba(204,255,0,0.3);
    border-radius: 20px;
    background: rgba(204,255,0,0.05);
}

.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 #272727;
    border-radius: var(--radius);
    padding: 18px 6px;
    font-family: var(--font-disp);
    font-size: 1.7rem;
    font-weight: 700;
    color: #ccc;
    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: var(--accent);
    color: var(--accent);
    box-shadow: 0 0 20px rgba(204,255,0,0.45);
    background: rgba(204,255,0,0.06);
    animation: pop-correct 0.28s ease;
}

.answer-btn.wrong {
    border-color: var(--secondary);
    color: var(--secondary);
    box-shadow: 0 0 18px rgba(255,0,85,0.4);
    background: rgba(255,0,85,0.06);
    animation: shake-btn 0.32s ease;
}

.answer-btn.reveal-correct {
    border-color: var(--accent);
    background: rgba(204,255,0,0.08);
    color: var(--accent);
}

.game-progress-bar {
    width: 100%;
    height: 5px;
    background: #111;
    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: #1e1e1e;
    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: rgba(0,243,255,0.4);
}

.result-breakdown {
    width: 100%;
    max-width: 320px;
    background: var(--surface2);
    border: 1px solid #222;
    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 #181818;
}

.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: #fff; }
.val-good { color: var(--accent); text-shadow: 0 0 5px var(--accent); }
.val-bad  { color: var(--secondary); text-shadow: 0 0 5px 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(--surface2);
    border: 1px solid #222;
    border-radius: var(--radius);
    padding: 12px 14px;
    position: relative;
    transition: border-color var(--transition);
}

.history-card:hover { border-color: rgba(0,243,255,0.25); }

.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: rgba(255,255,255,0.25);
    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: rgba(0,243,255,0.35); }

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

.hc-detail {
    font-size: 0.72rem;
    color: rgba(255,255,255,0.4);
}

.hc-detail strong { color: rgba(255,255,255,0.75); }

.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: rgba(255,255,255,0.25);
    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: 4px; }
    89% {
        text-shadow: 4px 0 8px var(--secondary), -4px 0 8px var(--primary);
        letter-spacing: 6px;
    }
    91% {
        text-shadow: -4px 0 8px var(--secondary), 4px 0 8px var(--primary);
        letter-spacing: 2px;
    }
    93% { text-shadow: var(--glow-p); letter-spacing: 4px; }
}

@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; }
