/* Denoise — FunSlop.com
   Diffusion-reveal guess-race. Canvas sprite emerges from neon static; tap
   the right label before the sampler finishes. Self-contained styling that
   matches the FunSlop neon-on-near-black house aesthetic. */

:root {
    --bg-dark: #090b10;
    --bg-panel: #0e111a;
    --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: -90px;
    left: -90px;
    width: 380px;
    height: 380px;
    background: radial-gradient(circle, var(--cyan) 0%, transparent 70%);
    opacity: 0.13;
    z-index: -1;
    filter: blur(64px);
    pointer-events: none;
    animation: float 13s infinite alternate;
}

@keyframes float {
    0% { transform: translate(0, 0); }
    100% { transform: translate(120px, 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: 2rem 1.1rem 6rem;
    max-width: 560px;
    width: 100%;
    margin: 0 auto;
}

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

/* HUD row */
.hud {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin: 0 auto 0.85rem;
    max-width: 400px;
    min-height: 1.5rem;
}

.hud-item {
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 500;
    white-space: nowrap;
}

.hud-score { color: var(--neon-green); text-shadow: 0 0 10px rgba(57, 255, 20, 0.4); }
.hud-combo { color: var(--gold); text-shadow: 0 0 10px rgba(255, 213, 74, 0.4); }
.hud-lives { letter-spacing: 2px; font-size: 1.15rem; }
.hud-lives .life.on { color: var(--pink); text-shadow: 0 0 10px rgba(255, 42, 109, 0.7); }
.hud-lives .life.off { color: rgba(139, 155, 180, 0.4); }

/* Hide HUD details before a run starts */
.state-idle .hud { visibility: hidden; }

/* The canvas — the denoising stage */
.canvas-wrapper {
    width: min(86vw, 400px);
    max-width: 400px;
    aspect-ratio: 1;
    margin: 0 auto;
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid rgba(5, 217, 232, 0.28);
    box-shadow:
        0 0 30px rgba(189, 0, 255, 0.25),
        inset 0 0 20px rgba(5, 217, 232, 0.12);
    position: relative;
}

#canvas {
    display: block;
    width: 100%;
    height: 100%;
    background: #0c0f17;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    touch-action: manipulation;
}

#canvas.flash-correct {
    animation: flash-correct 0.45s ease-out;
}

#canvas.flash-wrong {
    animation: flash-wrong 0.45s ease-out;
}

@keyframes flash-correct {
    0% { box-shadow: inset 0 0 0 4px var(--neon-green); }
    100% { box-shadow: inset 0 0 0 0 transparent; }
}

@keyframes flash-wrong {
    0%, 100% { transform: translateX(0); box-shadow: inset 0 0 0 4px var(--pink); }
    20% { transform: translateX(-6px); }
    60% { transform: translateX(6px); }
}

.best {
    font-size: 0.9rem;
    color: var(--cyan);
    margin: 0.75rem 0 0.4rem;
    min-height: 1.2em;
}

.prompt {
    font-size: 1.05rem;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    min-height: 1.3em;
    line-height: 1.35;
}

.feedback {
    font-size: 0.95rem;
    color: var(--text-muted);
    margin-bottom: 0.9rem;
    min-height: 2.6em;
    line-height: 1.4;
    max-width: 420px;
    margin-left: auto;
    margin-right: auto;
}

.feedback strong { color: var(--text-primary); font-weight: 700; }
.feedback .fb-good { color: var(--neon-green); font-weight: 700; }
.feedback .fb-bad { color: var(--pink); font-weight: 700; }
.feedback .fb-score {
    color: var(--gold);
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.15rem;
}

/* Multiple-choice grid */
.options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.65rem;
    max-width: 420px;
    margin: 0 auto 1rem;
}

.state-idle .options,
.state-gameover .options {
    display: none;
}

.option-btn {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    font-family: var(--font-body);
    font-size: 1.05rem;
    font-weight: 500;
    text-align: left;
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 0.8rem 0.9rem;
    cursor: pointer;
    transition: transform 0.1s, border-color 0.15s, box-shadow 0.15s, background 0.15s;
    min-height: 3.1rem;
}

.option-btn .opt-num {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 7px;
    background: rgba(5, 217, 232, 0.14);
    color: var(--cyan);
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.85rem;
}

.option-btn .opt-label {
    flex: 1 1 auto;
    line-height: 1.15;
}

.option-btn:hover:not(.disabled) {
    border-color: var(--cyan);
    box-shadow: 0 0 16px rgba(5, 217, 232, 0.3);
    background: rgba(5, 217, 232, 0.08);
}

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

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

.option-btn.disabled {
    cursor: default;
    opacity: 0.7;
}

.option-btn.is-correct {
    border-color: var(--neon-green);
    background: rgba(57, 255, 20, 0.14);
    box-shadow: 0 0 18px rgba(57, 255, 20, 0.4);
    opacity: 1;
}

.option-btn.is-correct .opt-num {
    background: rgba(57, 255, 20, 0.2);
    color: var(--neon-green);
}

.option-btn.is-wrong {
    border-color: var(--pink);
    background: rgba(255, 42, 109, 0.14);
    box-shadow: 0 0 18px rgba(255, 42, 109, 0.35);
    opacity: 1;
    animation: shake 0.25s ease-in-out;
}

.option-btn.is-wrong .opt-num {
    background: rgba(255, 42, 109, 0.2);
    color: var(--pink);
}

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

/* Start / restart button */
.start-btn {
    display: none;
    margin: 0 auto 0.5rem;
    font-family: var(--font-display);
    background: linear-gradient(135deg, var(--cyan), var(--neon-purple));
    color: #04070d;
    border: none;
    padding: 0.95rem 2.6rem;
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    border-radius: 999px;
    cursor: pointer;
    box-shadow: 0 0 24px rgba(5, 217, 232, 0.4);
    transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
}

.state-idle .start-btn,
.state-gameover .start-btn {
    display: inline-block;
}

.start-btn:hover {
    transform: scale(1.04);
    filter: brightness(1.08);
    box-shadow: 0 0 34px rgba(189, 0, 255, 0.55);
}

.start-btn:active {
    transform: scale(0.97);
}

.start-btn:focus-visible {
    outline: 3px solid var(--gold);
    outline-offset: 3px;
}

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

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

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

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

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

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

.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.2rem;
    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: 520px;
    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 blocks during active play / reveal to keep focus on the canvas */
.state-playing .how-to-play,
.state-playing .related-games,
.state-reveal .how-to-play,
.state-reveal .related-games {
    display: none;
}

/* Home link */
.home-link {
    position: fixed;
    bottom: 1.1rem;
    bottom: calc(1.1rem + env(safe-area-inset-bottom, 0px));
    left: 50%;
    transform: translateX(-50%);
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.9rem;
    padding: 0.5rem 1.1rem;
    background: rgba(14, 17, 26, 0.85);
    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; }
    .prompt { font-size: 0.98rem; }
    .feedback { font-size: 0.88rem; }
    .hud-item { font-size: 0.9rem; }
    .option-btn { font-size: 0.98rem; padding: 0.7rem 0.75rem; }
    .start-btn { padding: 0.85rem 2.1rem; font-size: 1.05rem; }
}

@media (max-width: 360px) {
    .option-btn { font-size: 0.9rem; gap: 0.4rem; }
    .option-btn .opt-num { width: 1.3rem; height: 1.3rem; }
}
