/* Distillation — FunSlop.com
   Knowledge distillation as a memory-compression puzzle. A teacher flashes a
   weighted grid; the tiny student reproduces its essence on a budget.
   Self-contained: no parent theme stylesheet required. */

: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);
    --cell-bg: rgba(255, 255, 255, 0.035);
    --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, matching FunSlop's house style. */
.glow-bg {
    position: fixed;
    top: -80px;
    left: -80px;
    width: 380px;
    height: 380px;
    background: radial-gradient(circle, var(--cyan) 0%, transparent 70%);
    opacity: 0.14;
    z-index: -1;
    filter: blur(60px);
    pointer-events: none;
    animation: float 14s infinite alternate;
}

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

.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.25rem 6rem;
    max-width: 640px;
    width: 100%;
    margin: 0 auto;
}

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

/* HUD: round / budget / phase */
.hud {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 0.9rem;
}

.hud-item {
    display: inline-flex;
    align-items: center;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--glass-border);
    border-radius: 999px;
    padding: 0.35rem 0.85rem;
    font-family: var(--font-display);
}

.hud-round { color: var(--neon-purple); }
.hud-phase { color: var(--cyan); min-width: 6.5em; justify-content: center; }
.hud-budget { color: var(--neon-green); }

.hud-budget.flash {
    animation: budget-flash 0.4s ease-out;
}

@keyframes budget-flash {
    0% { transform: scale(1); }
    35% { transform: scale(1.18); color: var(--pink); box-shadow: 0 0 16px rgba(255, 42, 109, 0.6); }
    100% { transform: scale(1); }
}

.instruction {
    font-size: 1.1rem;
    color: var(--text-primary);
    margin-bottom: 0.9rem;
    min-height: 2.6em;
    line-height: 1.35;
}

/* The board */
.board-wrap {
    position: relative;
    width: min(86vw, 420px);
    margin: 0.5rem auto 1rem;
    aspect-ratio: 1;
}

.board {
    display: grid;
    grid-template-columns: repeat(var(--cols, 4), 1fr);
    gap: clamp(4px, 1.4vw, 9px);
    width: 100%;
    height: 100%;
    padding: clamp(6px, 1.6vw, 10px);
    background: rgba(255, 255, 255, 0.025);
    border: 1px solid var(--glass-border);
    border-radius: 18px;
    box-shadow:
        0 0 30px rgba(5, 217, 232, 0.12),
        inset 0 0 22px rgba(189, 0, 255, 0.06);
}

.cell {
    position: relative;
    width: 100%;
    aspect-ratio: 1;
    border-radius: clamp(6px, 1.6vw, 11px);
    background: var(--cell-bg);
    border: 1px solid rgba(255, 255, 255, 0.05);
    cursor: pointer;
    transition: background 0.12s ease, box-shadow 0.18s ease, transform 0.08s ease, border-color 0.15s ease;
    -webkit-appearance: none;
    appearance: none;
    touch-action: manipulation;
    font: inherit;
    color: inherit;
    padding: 0;
}

.cell:focus-visible {
    outline: 2px solid var(--cyan);
    outline-offset: 1px;
}

/* During recall, give cells a hover/active affordance. */
.state-recall .cell:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(5, 217, 232, 0.4);
}

.state-recall .cell:active {
    transform: scale(0.92);
}

/* The teacher's lit cells — brightness driven by --sal (salience 0..1).
   We blend green->cyan with the salience and scale glow + opacity by it. */
.cell.teacher {
    --sal: 0.5;
    background:
        radial-gradient(circle at 50% 45%,
            rgba(57, 255, 20, calc(0.25 + var(--sal) * 0.75)) 0%,
            rgba(5, 217, 232, calc(0.12 + var(--sal) * 0.45)) 70%,
            rgba(5, 217, 232, 0.04) 100%);
    border-color: rgba(57, 255, 20, calc(0.25 + var(--sal) * 0.55));
    box-shadow:
        0 0 calc(4px + var(--sal) * 20px) rgba(57, 255, 20, calc(var(--sal) * 0.65)),
        inset 0 0 calc(2px + var(--sal) * 8px) rgba(255, 255, 255, calc(var(--sal) * 0.35));
    animation: teacher-in 0.25s ease-out;
}

@keyframes teacher-in {
    from { opacity: 0.2; transform: scale(0.8); }
    to { opacity: 1; transform: scale(1); }
}

/* Student picks during recall — purple marks. */
.cell.picked {
    background: radial-gradient(circle at 50% 45%, rgba(189, 0, 255, 0.85) 0%, rgba(189, 0, 255, 0.3) 75%);
    border-color: var(--neon-purple);
    box-shadow: 0 0 16px rgba(189, 0, 255, 0.6), inset 0 0 8px rgba(255, 255, 255, 0.3);
}

.cell.picked::after {
    content: '';
    position: absolute;
    inset: 32%;
    border-radius: 50%;
    background: #fff;
    opacity: 0.9;
    box-shadow: 0 0 8px rgba(255, 255, 255, 0.8);
}

/* Reveal annotations. Target = the cells you should've kept (cyan ring). */
.cell.target {
    border: 2px solid var(--cyan);
    box-shadow:
        0 0 14px rgba(5, 217, 232, 0.7),
        inset 0 0 8px rgba(5, 217, 232, 0.3);
}

/* A correct pick (you marked an optimal cell): green check pip. */
.cell.hit::after {
    content: '';
    position: absolute;
    inset: 30%;
    border-radius: 50%;
    background: var(--neon-green);
    box-shadow: 0 0 10px rgba(57, 255, 20, 0.9);
    opacity: 1;
}

/* A wasted pick (you marked a non-optimal cell): pink ring of shame. */
.cell.miss {
    border: 2px solid var(--pink);
    box-shadow: 0 0 14px rgba(255, 42, 109, 0.6);
}

.cell.miss::after {
    content: '';
    position: absolute;
    inset: 34%;
    border-radius: 50%;
    background: var(--pink);
    box-shadow: 0 0 8px rgba(255, 42, 109, 0.9);
    opacity: 0.95;
}

/* Idle demo board cells are non-interactive. */
.cell.demo {
    cursor: default;
}

/* Phase banner overlaid faintly behind the board label area. */
.phase-banner {
    position: absolute;
    top: -1.55rem;
    left: 50%;
    transform: translateX(-50%);
    font-family: var(--font-display);
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 3px;
    color: var(--text-muted);
    opacity: 0.55;
    pointer-events: none;
    transition: color 0.2s, opacity 0.2s;
}

.state-watch .phase-banner { color: var(--neon-green); opacity: 0.85; }
.state-recall .phase-banner { color: var(--neon-purple); opacity: 0.85; }

/* Readout line(s) under the board. */
.readout {
    font-size: 0.98rem;
    color: var(--text-primary);
    margin-bottom: 0.6rem;
    min-height: 2.6em;
    line-height: 1.4;
}

.readout .muted { color: var(--text-muted); font-size: 0.9rem; }
.readout .ok { color: var(--neon-green); font-weight: 700; }
.readout .bad { color: var(--pink); font-weight: 700; }
.readout strong { color: var(--text-primary); }

/* Submit / advance button. */
.buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 0.4rem;
    min-height: 3.4rem;
}

/* The button is hidden on idle (tap-to-start), shown otherwise. */
.state-idle .buttons {
    visibility: hidden;
}

.game-btn {
    font-family: var(--font-display);
    padding: 0.9rem 2.4rem;
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    border: none;
    border-radius: 999px;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.15s, filter 0.15s, opacity 0.15s;
    color: #04130a;
    background: linear-gradient(135deg, var(--neon-green), var(--cyan));
    box-shadow: 0 0 20px rgba(57, 255, 20, 0.3);
}

.game-btn:hover:not(:disabled) {
    transform: scale(1.04);
    box-shadow: 0 0 30px rgba(57, 255, 20, 0.55);
}

.game-btn:active:not(:disabled) {
    transform: scale(0.97);
}

.game-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    filter: grayscale(0.5);
}

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

.game-btn.ready {
    animation: btn-ready 1.6s ease-in-out infinite;
}

@keyframes btn-ready {
    0%, 100% { box-shadow: 0 0 20px rgba(57, 255, 20, 0.3); }
    50% { box-shadow: 0 0 30px rgba(57, 255, 20, 0.6); }
}

/* On a failed reveal, the advance button shifts to a "retrain" pink. */
.state-reveal.failed .game-btn {
    background: linear-gradient(135deg, var(--pink), var(--neon-purple));
    color: #fff;
    box-shadow: 0 0 20px rgba(255, 42, 109, 0.4);
}

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

.state-idle,
.state-gameover {
    cursor: pointer;
}

/* New-best celebration. */
.state-gameover.new-best .instruction {
    color: var(--gold);
    text-shadow: 0 0 14px rgba(255, 213, 74, 0.5);
}

.state-gameover.new-best .readout .ok {
    color: var(--gold);
    animation: score-pop 0.45s ease-out;
}

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

/* Hide the HUD phase chip's clock noise on idle/gameover by leaving it static. */

/* SEO / how-to content */
.how-to-play {
    text-align: left;
    margin: 3rem auto 0;
    max-width: 560px;
    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 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; }
.fun-fact strong { color: var(--neon-purple); }

.related-games {
    margin: 2rem auto 0;
    max-width: 560px;
    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);
}

/* Hide SEO content during active gameplay phases. */
.state-watch .how-to-play,
.state-watch .related-games,
.state-recall .how-to-play,
.state-recall .related-games,
.state-reveal .how-to-play,
.state-reveal .related-games {
    display: none;
}

/* 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.85rem; }
    .instruction { font-size: 1rem; min-height: 3em; }
    .game-btn {
        padding: 0.8rem 1.8rem;
        font-size: 1.05rem;
    }
    .hud-item { font-size: 0.78rem; padding: 0.3rem 0.7rem; }
    .readout { font-size: 0.92rem; }
}

@media (max-width: 360px) {
    .board-wrap { width: 92vw; }
    .hud { gap: 0.35rem; }
}
