/* Catastrophic Forgetting — FunSlop.com
   Continual learning as a game. Learn task after task while the old ones
   decay from interference. Neon-on-near-black house style. */

:root {
    --bg-dark: #090b10;
    --neon-green: #39ff14;
    --neon-purple: #bd00ff;
    --cyan: #05d9e8;
    --pink: #ff2a6d;
    --gold: #ffd54a;
    --text-primary: #f0f4f8;
    --text-muted: #8b9bb4;
    --glass-border: rgba(255, 255, 255, 0.08);
    --font-body: 'Outfit', system-ui, -apple-system, sans-serif;
    --font-display: 'Space Grotesk', 'Outfit', system-ui, sans-serif;
}

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

html, body { min-height: 100%; }

body {
    font-family: var(--font-body);
    background: var(--bg-dark);
    color: var(--text-primary);
}

/* Ambient neon glow */
.glow-bg {
    position: fixed;
    top: -80px;
    left: -80px;
    width: 360px;
    height: 360px;
    background: radial-gradient(circle, var(--neon-purple) 0%, transparent 70%);
    opacity: 0.14;
    z-index: -1;
    filter: blur(60px);
    pointer-events: none;
    animation: float 12s infinite alternate;
}

@keyframes float {
    0% { transform: translate(0, 0); }
    100% { transform: translate(120px, 60px); }
}

.game-container {
    position: relative;
    width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    user-select: none;
    -webkit-user-select: none;
}

.content {
    text-align: center;
    padding: 2.25rem 1.1rem 6rem;
    max-width: 660px;
    width: 100%;
    margin: 0 auto;
}

.title {
    font-family: var(--font-display);
    font-size: 2.2rem;
    font-weight: 700;
    letter-spacing: -1px;
    margin-bottom: 0.85rem;
    background: linear-gradient(45deg, var(--neon-purple), var(--cyan));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Control hints */
.controls-inline {
    display: flex;
    gap: 0.55rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 1.1rem;
}

.control-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.82rem;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: 999px;
    padding: 0.35rem 0.78rem;
}

.control-pill .key {
    font-weight: 700;
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.06);
    border-radius: 6px;
    padding: 0.1rem 0.45rem;
    font-size: 0.78rem;
}

.control-pill.action .key { color: var(--neon-green); }
.control-pill.special .key { color: var(--gold); }
.control-pill.go .key { color: var(--cyan); }

/* HUD telemetry */
.hud {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
    margin: 0 auto 0.9rem;
    max-width: 460px;
}

.hud-cell {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 0.5rem 0.3rem;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.hud-label {
    font-size: 0.62rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.hud-value {
    font-family: var(--font-display);
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

#hud-retained { color: var(--neon-green); }
#hud-accuracy { color: var(--cyan); }
#hud-rehearsals { color: var(--gold); }

/* Coherence (lives) bar */
.coherence-wrap {
    max-width: 460px;
    margin: 0 auto 1rem;
    text-align: left;
}

.coherence-label {
    font-size: 0.62rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.coherence-bar {
    height: 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    overflow: hidden;
}

.coherence-fill {
    height: 100%;
    width: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--neon-green), var(--cyan));
    transition: width 0.35s ease, background 0.35s ease;
}

.coherence-fill.low {
    background: linear-gradient(90deg, var(--gold), var(--pink));
}

.coherence-fill.critical {
    background: linear-gradient(90deg, var(--pink), #ff0033);
    animation: coherence-flicker 0.6s infinite alternate;
}

@keyframes coherence-flicker {
    0% { opacity: 0.55; }
    100% { opacity: 1; }
}

/* Phase / status line */
.phase-line {
    font-size: 0.95rem;
    color: var(--cyan);
    font-weight: 500;
    min-height: 1.3em;
    margin-bottom: 0.6rem;
}

/* The stimulus glyph */
.stimulus {
    font-family: var(--font-display);
    font-size: 4.5rem;
    font-weight: 700;
    line-height: 1;
    margin: 0.5rem auto 0.75rem;
    width: 7rem;
    height: 7rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 22px;
    border: 2px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.025);
    color: var(--text-primary);
    text-shadow: 0 0 18px currentColor, 0 0 2px rgba(9, 11, 16, 0.9);
    transition: transform 0.12s ease, border-color 0.2s ease, box-shadow 0.2s ease, color 0.2s ease;
}

.stimulus.learn {
    border-color: var(--neon-purple);
    box-shadow: 0 0 26px rgba(189, 0, 255, 0.4);
}

.stimulus.quiz {
    border-color: var(--cyan);
    box-shadow: 0 0 26px rgba(5, 217, 232, 0.3);
}

.stimulus.correct { animation: pop-good 0.22s ease-out; }
.stimulus.wrong { animation: shake 0.24s ease-in-out; }

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

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

/* Prompt line (the instruction above the keypad) */
.prompt-line {
    font-size: 1.05rem;
    color: var(--text-primary);
    min-height: 1.4em;
    margin-bottom: 0.9rem;
    line-height: 1.4;
}

/* Response keypad */
.responses {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.7rem;
    max-width: 460px;
    margin: 0 auto;
}

.resp-btn {
    position: relative;
    font-family: var(--font-body);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1rem 0.6rem;
    font-size: 1.1rem;
    font-weight: 700;
    border-radius: 14px;
    cursor: pointer;
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--glass-border);
    transition: transform 0.1s ease, box-shadow 0.15s ease, border-color 0.15s ease, background 0.15s ease, opacity 0.15s ease;
    min-height: 60px;
}

.resp-btn[data-resp="0"] { --rc: var(--neon-green); }
.resp-btn[data-resp="1"] { --rc: var(--cyan); }
.resp-btn[data-resp="2"] { --rc: var(--neon-purple); }
.resp-btn[data-resp="3"] { --rc: var(--gold); }

.resp-btn .resp-name { color: var(--rc); text-shadow: 0 0 10px var(--rc); }

.resp-key {
    font-family: var(--font-display);
    font-size: 0.78rem;
    color: var(--bg-dark);
    background: var(--rc);
    border-radius: 6px;
    width: 1.35rem;
    height: 1.35rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    box-shadow: 0 0 10px var(--rc);
}

.resp-btn:hover {
    border-color: var(--rc);
    box-shadow: 0 0 18px -4px var(--rc);
}

.resp-btn:active { transform: scale(0.96); }

.resp-btn:focus-visible {
    outline: 3px solid var(--cyan);
    outline-offset: 2px;
}

.resp-btn:disabled {
    cursor: default;
    opacity: 0.4;
}

/* highlight the correct answer during a teach/reveal moment */
.resp-btn.reveal {
    border-color: var(--rc);
    background: rgba(255, 255, 255, 0.08);
    box-shadow: 0 0 24px -2px var(--rc);
    animation: reveal-pulse 0.9s ease-in-out infinite alternate;
}

@keyframes reveal-pulse {
    0% { box-shadow: 0 0 14px -4px var(--rc); }
    100% { box-shadow: 0 0 30px 0 var(--rc); }
}

.resp-btn.flash-right {
    border-color: var(--neon-green);
    box-shadow: 0 0 26px -2px var(--neon-green);
}

.resp-btn.flash-wrong {
    border-color: var(--pink);
    box-shadow: 0 0 26px -2px var(--pink);
}

/* Action row */
.action-row {
    display: flex;
    gap: 0.7rem;
    justify-content: center;
    max-width: 460px;
    margin: 0.9rem auto 0;
}

.act-btn {
    font-family: var(--font-body);
    padding: 0.8rem 1.3rem;
    font-size: 1rem;
    font-weight: 700;
    border-radius: 12px;
    cursor: pointer;
    border: 1px solid var(--glass-border);
    transition: transform 0.1s ease, box-shadow 0.15s ease, filter 0.15s ease, opacity 0.15s ease;
    flex: 1 1 auto;
}

.act-btn:active { transform: scale(0.96); }

.act-btn:focus-visible {
    outline: 3px solid var(--cyan);
    outline-offset: 2px;
}

.rehearse-btn {
    color: var(--bg-dark);
    background: var(--gold);
    box-shadow: 0 0 16px rgba(255, 213, 74, 0.32);
}

.rehearse-btn:hover { filter: brightness(1.08); box-shadow: 0 0 24px rgba(255, 213, 74, 0.5); }

.rehearse-btn:disabled {
    cursor: default;
    opacity: 0.35;
    box-shadow: none;
}

.rehearse-count {
    font-family: var(--font-display);
    font-size: 0.85rem;
    opacity: 0.85;
}

.continue-btn {
    color: var(--bg-dark);
    background: var(--cyan);
    box-shadow: 0 0 16px rgba(5, 217, 232, 0.32);
}

.continue-btn:hover { filter: brightness(1.08); box-shadow: 0 0 24px rgba(5, 217, 232, 0.5); }

/* Memory shelf: one chip per learned task showing its strength */
.memory-shelf {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    justify-content: center;
    max-width: 520px;
    margin: 1.3rem auto 0;
    min-height: 0.5rem;
}

.mem-chip {
    width: 2.4rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.mem-glyph {
    font-family: var(--font-display);
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-muted);
    line-height: 1;
    transition: color 0.3s ease, text-shadow 0.3s ease;
}

.mem-meter {
    width: 100%;
    height: 6px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.07);
    overflow: hidden;
}

.mem-meter-fill {
    height: 100%;
    width: 100%;
    border-radius: 999px;
    transition: width 0.4s ease, background 0.4s ease;
}

/* strength tiers, applied by JS */
.mem-chip.tier-strong .mem-glyph { color: var(--neon-green); text-shadow: 0 0 8px rgba(57,255,20,0.5); }
.mem-chip.tier-strong .mem-meter-fill { background: var(--neon-green); }
.mem-chip.tier-ok .mem-glyph { color: var(--cyan); text-shadow: 0 0 8px rgba(5,217,232,0.45); }
.mem-chip.tier-ok .mem-meter-fill { background: var(--cyan); }
.mem-chip.tier-weak .mem-glyph { color: var(--gold); text-shadow: 0 0 8px rgba(255,213,74,0.5); }
.mem-chip.tier-weak .mem-meter-fill { background: var(--gold); }
.mem-chip.tier-lost .mem-glyph { color: var(--pink); text-shadow: 0 0 8px rgba(255,42,109,0.55); }
.mem-chip.tier-lost .mem-meter-fill { background: var(--pink); }

.mem-chip.active .mem-glyph { transform: scale(1.18); }
.mem-chip.active .mem-meter { box-shadow: 0 0 10px -2px currentColor; }

/* Feedback + best + hint */
.feedback-line {
    font-size: 0.98rem;
    color: var(--text-primary);
    min-height: 1.3em;
    margin-top: 1.1rem;
    line-height: 1.4;
}

.best-line {
    font-size: 0.9rem;
    color: var(--text-muted);
    min-height: 1.2em;
    margin-top: 0.35rem;
}

.hint {
    font-size: 0.95rem;
    color: var(--text-muted);
    margin-top: 0.6rem;
    min-height: 1.2em;
}

/* ---- State-driven visibility ---- */

/* idle: hide gameplay chrome */
.state-idle .hud,
.state-idle .coherence-wrap,
.state-idle .responses,
.state-idle .action-row,
.state-idle .memory-shelf,
.state-idle .controls-inline {
    display: none;
}

/* gameover: hide live keypad + action row, keep HUD + shelf for the report */
.state-gameover .responses,
.state-gameover .action-row,
.state-gameover .controls-inline {
    display: none;
}

/* learning a brand-new task: continue is the path forward, keypad is for drilling */
.state-idle, .state-gameover { cursor: pointer; }

/* New-best celebration */
.state-gameover.new-best .feedback-line {
    color: var(--gold);
    font-weight: 700;
    text-shadow: 0 0 14px rgba(255, 213, 74, 0.5);
    animation: score-pop 0.4s ease-out;
}

.state-gameover.new-best .stimulus {
    color: var(--gold);
    border-color: var(--gold);
    box-shadow: 0 0 30px rgba(255, 213, 74, 0.5);
}

@keyframes score-pop {
    0% { transform: scale(0.85); opacity: 0; }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); opacity: 1; }
}

/* ---- SEO / how-to content ---- */
.how-to-play {
    text-align: left;
    margin: 3rem auto 0;
    max-width: 580px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 1.75rem;
}

.how-to-play h2 {
    font-family: var(--font-display);
    font-size: 1.4rem;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
}

.how-to-play h3 {
    font-family: var(--font-display);
    font-size: 1.1rem;
    margin: 1.25rem 0 0.5rem;
    color: var(--cyan);
}

.how-to-play p {
    font-weight: 300;
    line-height: 1.6;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.how-to-play strong { color: var(--text-primary); font-weight: 500; }
.how-to-play em { color: var(--text-primary); font-style: italic; }

.how-to-play ol {
    margin: 0.5rem 0 0.75rem 1.25rem;
    color: var(--text-muted);
    line-height: 1.7;
}

.fun-fact {
    margin-top: 1.25rem;
    padding: 1rem;
    border-left: 3px solid var(--neon-purple);
    background: rgba(189, 0, 255, 0.06);
    border-radius: 0 10px 10px 0;
}

.fun-fact p { margin: 0; }

.related-games {
    margin: 2rem auto 0;
    max-width: 580px;
    text-align: center;
}

.related-games h3 {
    font-family: var(--font-display);
    font-size: 1.1rem;
    margin-bottom: 0.75rem;
    color: var(--text-muted);
}

.related-games-list {
    display: flex;
    gap: 0.6rem;
    justify-content: center;
    flex-wrap: wrap;
}

.related-game-link {
    text-decoration: none;
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--glass-border);
    border-radius: 999px;
    padding: 0.45rem 1rem;
    font-size: 0.9rem;
    transition: border-color 0.2s, color 0.2s;
}

.related-game-link:hover {
    border-color: var(--neon-green);
    color: var(--neon-green);
}

/* Home link */
.home-link {
    position: fixed;
    bottom: 1.25rem;
    left: 50%;
    transform: translateX(-50%);
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.9rem;
    padding: 0.5rem 1.1rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 999px;
    backdrop-filter: blur(8px);
    transition: border-color 0.2s, color 0.2s;
    z-index: 10;
}

.home-link:hover {
    border-color: var(--neon-purple);
    color: var(--neon-purple);
}

.home-link:active { transform: translateX(-50%) scale(0.95); }

.home-link:focus-visible {
    outline: 3px solid var(--cyan);
    outline-offset: 2px;
}

/* ---- Responsive ---- */
@media (max-width: 600px) {
    .title { font-size: 1.7rem; }
    .hud-value { font-size: 1.05rem; }
    .stimulus {
        font-size: 3.6rem;
        width: 5.8rem;
        height: 5.8rem;
    }
    .resp-btn { font-size: 1rem; padding: 0.85rem 0.5rem; }
    .prompt-line { font-size: 0.98rem; }
    .act-btn { font-size: 0.95rem; padding: 0.75rem 1rem; }
    .mem-chip { width: 2.1rem; }
}

@media (max-width: 360px) {
    .hud { gap: 0.35rem; }
    .hud-cell { padding: 0.4rem 0.2rem; }
    .hud-label { font-size: 0.55rem; }
    .resp-btn { gap: 0.35rem; }
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
    .glow-bg,
    .coherence-fill.critical,
    .resp-btn.reveal,
    .stimulus.correct,
    .stimulus.wrong,
    .state-gameover.new-best .feedback-line {
        animation: none !important;
    }
}
