/* Mode Collapse — FunSlop.com
   Keep the generator's output distribution diverse. Neon-on-near-black,
   histogram + entropy meter + candidate tray. Self-contained. */

: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;
    right: -80px;
    width: 360px;
    height: 360px;
    background: radial-gradient(circle, var(--cyan) 0%, transparent 70%);
    opacity: 0.13;
    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, 70px); }
}

.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: 600px;
    width: 100%;
    margin: 0 auto;
}

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

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

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

.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.8rem;
}

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

/* ===================== HUD: entropy meter + readouts ===================== */
.hud {
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
    max-width: 460px;
    margin: 0 auto 0.5rem;
}

.entropy-wrap {
    text-align: left;
}

.entropy-labels {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 0.3rem;
}

.entropy-name {
    font-family: var(--font-display);
    font-size: 0.8rem;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--text-muted);
}

.entropy-val {
    font-family: var(--font-display);
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--cyan);
}

.entropy-bar {
    position: relative;
    height: 14px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--glass-border);
    overflow: hidden;
}

.entropy-fill {
    height: 100%;
    width: 0%;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--cyan), var(--neon-green));
    box-shadow: 0 0 14px rgba(57, 255, 20, 0.5);
    transition: width 0.12s linear, background 0.25s, box-shadow 0.25s;
}

/* Going red as collapse nears */
.entropy-fill.low {
    background: linear-gradient(90deg, var(--gold), var(--pink));
    box-shadow: 0 0 16px rgba(255, 42, 109, 0.6);
}

/* Dashed threshold marker — collapse line */
.entropy-threshold {
    position: absolute;
    top: -3px;
    bottom: -3px;
    width: 0;
    border-left: 2px dashed rgba(255, 255, 255, 0.55);
    z-index: 2;
    pointer-events: none;
}

.readouts {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: var(--font-display);
}

.readout.clock {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text-primary);
}

.readout.combo {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-muted);
    min-height: 1.2em;
    transition: color 0.15s, transform 0.15s;
}

.readout.combo.active {
    color: var(--gold);
    text-shadow: 0 0 12px rgba(255, 213, 74, 0.5);
}

.instruction {
    font-size: 1.05rem;
    color: var(--text-primary);
    margin: 0.75rem 0 0.5rem;
    min-height: 1.4em;
}

/* ===================== Histogram (the distribution) ===================== */
.histogram {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 0.55rem;
    height: 120px;
    max-width: 460px;
    margin: 0.5rem auto 1.25rem;
    padding: 0 0.25rem;
}

.hist-bar {
    flex: 1 1 0;
    max-width: 70px;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    gap: 0.35rem;
}

.hist-track {
    width: 100%;
    flex: 1;
    display: flex;
    align-items: flex-end;
    background: rgba(255, 255, 255, 0.035);
    border-radius: 8px 8px 4px 4px;
    overflow: hidden;
}

.hist-fill {
    width: 100%;
    height: 0%;
    border-radius: 6px 6px 0 0;
    transition: height 0.18s ease-out;
}

.hist-glyph {
    font-size: 1.15rem;
    line-height: 1;
    opacity: 0.85;
    transition: transform 0.2s, opacity 0.2s;
}

/* The generator's current obsession gets a subtle pulse + a dot */
.hist-bar.favorite .hist-glyph {
    opacity: 1;
    transform: scale(1.2);
    animation: favorite-pulse 1.1s ease-in-out infinite;
}

@keyframes favorite-pulse {
    0%, 100% { filter: drop-shadow(0 0 2px currentColor); }
    50% { filter: drop-shadow(0 0 9px currentColor); }
}

/* ===================== Candidate tray ===================== */
.candidates {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.85rem;
    max-width: 460px;
    margin: 0 auto;
    min-height: 168px;
}

.candidate {
    position: relative;
    appearance: none;
    -webkit-appearance: none;
    font-family: var(--font-display);
    background: rgba(255, 255, 255, 0.035);
    border: 1.5px solid var(--glass-border);
    border-radius: 16px;
    padding: 1.1rem 0.5rem;
    cursor: pointer;
    color: var(--mode-color, var(--text-primary));
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 76px;
    transition: transform 0.1s, border-color 0.15s, box-shadow 0.15s, background 0.15s, opacity 0.2s;
    touch-action: manipulation;
    overflow: hidden;
}

.candidate:hover {
    border-color: var(--mode-color);
    box-shadow: 0 0 20px -4px var(--mode-color);
    background: rgba(255, 255, 255, 0.05);
}

.candidate:active {
    transform: scale(0.95);
}

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

.cand-glyph {
    font-size: 2.6rem;
    line-height: 1;
    text-shadow: 0 0 1px rgba(9, 11, 16, 0.9), 0 0 16px currentColor;
}

.cand-key {
    position: absolute;
    top: 0.45rem;
    left: 0.6rem;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.06);
    border-radius: 6px;
    padding: 0.05rem 0.4rem;
}

/* Pick feedback */
.candidate.correct {
    border-color: var(--neon-green);
    box-shadow: 0 0 26px -2px var(--neon-green);
    animation: pop 0.18s ease-out;
}

.candidate.wrong {
    border-color: var(--pink);
    box-shadow: 0 0 26px -2px var(--pink);
    animation: shake 0.2s ease-in-out;
}

/* The one you SHOULD have tapped, revealed after a wrong pick */
.candidate.reveal {
    border-color: var(--neon-green);
    box-shadow: 0 0 22px -4px var(--neon-green);
}

.candidate.dead {
    opacity: 0.4;
    pointer-events: none;
}

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

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

/* Urgency: when the round is nearly out of time, the tray pulses red */
.candidates.hurry .candidate {
    border-color: rgba(255, 42, 109, 0.45);
}

.candidates.hurry {
    animation: tray-urgent 0.5s ease-in-out infinite;
}

@keyframes tray-urgent {
    0%, 100% { filter: none; }
    50% { filter: drop-shadow(0 0 8px rgba(255, 42, 109, 0.35)); }
}

/* Whole-screen danger tint near collapse */
.game-container.danger .entropy-bar {
    box-shadow: 0 0 18px rgba(255, 42, 109, 0.5);
}

/* ===================== Misc text ===================== */
.best-score {
    font-size: 0.95rem;
    color: var(--text-muted);
    margin-top: 1.25rem;
    min-height: 1.2em;
    line-height: 1.5;
}

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

/* ===================== State-driven visibility ===================== */
/* Candidate tray only shows during play / gameover (dimmed). */
.state-idle .candidates { display: none; }

/* Hide control hints + combo once a run starts or ends. */
.state-playing .controls-inline,
.state-gameover .controls-inline {
    display: none;
}

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

/* New-best celebration */
.state-gameover.new-best .instruction {
    color: var(--gold);
}

.state-gameover.new-best .best-score {
    color: var(--gold);
    text-shadow: 0 0 12px rgba(255, 213, 74, 0.4);
    animation: score-pop 0.4s ease-out;
}

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

/* ===================== SEO / how-to ===================== */
.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; }

.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 play to keep focus on the tray. */
.state-playing .how-to-play,
.state-playing .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.75rem; }
    .instruction { font-size: 0.95rem; }
    .histogram { height: 100px; gap: 0.4rem; }
    .hist-glyph { font-size: 1rem; }
    .cand-glyph { font-size: 2.2rem; }
    .candidate { min-height: 68px; padding: 0.9rem 0.4rem; }
    .readout.clock { font-size: 1.2rem; }
}

@media (max-width: 360px) {
    .candidates { gap: 0.6rem; }
    .cand-glyph { font-size: 2rem; }
}
