/* Latent Space — FunSlop.com
   Navigate a 2D word-embedding toward a hidden target using "warmth."
   Neon-on-near-black, self-contained, no parent 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);
    --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);
    background-image:
        radial-gradient(circle at 14% 16%, rgba(189, 0, 255, 0.14), transparent 42%),
        radial-gradient(circle at 86% 84%, rgba(5, 217, 232, 0.12), transparent 46%);
}

/* Ambient drifting 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: 1.75rem 1rem 6rem;
    max-width: 560px;
    width: 100%;
    margin: 0 auto;
}

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

/* --- Warmth readout (the heart of the game) --- */
.warmth-readout {
    margin: 0 auto 0.85rem;
    max-width: 420px;
}

.warmth-line {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 0.6rem;
    min-height: 2.6rem;
}

.warmth-value {
    font-family: var(--font-display);
    font-size: 2.4rem;
    font-weight: 700;
    color: var(--cyan);
    line-height: 1;
    transition: color 0.18s, text-shadow 0.18s;
    font-variant-numeric: tabular-nums;
}

.warmth-tag {
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--text-muted);
    text-transform: uppercase;
}

.warmth-bar {
    margin-top: 0.45rem;
    height: 10px;
    width: 100%;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--glass-border);
    overflow: hidden;
}

.warmth-bar-fill {
    height: 100%;
    width: 0%;
    border-radius: 999px;
    background: var(--cyan);
    transition: width 0.12s ease-out, background 0.18s;
}

/* Warmth-band reactive accents on the whole game */
.warmth-burning .warmth-tag { color: var(--gold); text-shadow: 0 0 14px var(--gold); }
.warmth-hot .warmth-tag { color: var(--pink); text-shadow: 0 0 12px var(--pink); }
.warmth-warm .warmth-tag { color: var(--pink); }
.warmth-cool .warmth-tag { color: var(--cyan); }
.warmth-cold .warmth-tag { color: var(--text-muted); }

.warmth-burning .canvas-wrapper {
    box-shadow:
        0 0 34px rgba(255, 213, 74, 0.45),
        inset 0 0 22px rgba(255, 213, 74, 0.16);
    border-color: rgba(255, 213, 74, 0.5);
    animation: burn-pulse 0.6s ease-in-out infinite;
}

.warmth-hot .canvas-wrapper {
    box-shadow:
        0 0 30px rgba(255, 42, 109, 0.4),
        inset 0 0 18px rgba(255, 42, 109, 0.12);
    border-color: rgba(255, 42, 109, 0.45);
}

@keyframes burn-pulse {
    0%, 100% { box-shadow: 0 0 28px rgba(255, 213, 74, 0.35), inset 0 0 18px rgba(255, 213, 74, 0.12); }
    50% { box-shadow: 0 0 42px rgba(255, 213, 74, 0.6), inset 0 0 26px rgba(255, 213, 74, 0.22); }
}

/* --- Map canvas --- */
.canvas-wrapper {
    width: min(92vw, 440px);
    aspect-ratio: 1;
    margin: 0 auto;
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid rgba(5, 217, 232, 0.28);
    box-shadow:
        0 0 26px rgba(189, 0, 255, 0.25),
        inset 0 0 18px rgba(5, 217, 232, 0.1);
    transition: box-shadow 0.2s, border-color 0.2s;
}

#canvas {
    display: block;
    width: 100%;
    height: 100%;
    background: var(--bg-dark);
    cursor: crosshair;
    touch-action: none;
}

.state-idle #canvas,
.state-gameover #canvas {
    cursor: default;
}

/* --- Stats row --- */
.stats {
    display: flex;
    justify-content: center;
    gap: 1.1rem;
    flex-wrap: wrap;
    margin-top: 0.85rem;
    font-size: 0.95rem;
    color: var(--text-muted);
    font-weight: 500;
}

#stat-score { color: var(--neon-green); }

.feedback {
    font-size: 1.02rem;
    color: var(--text-primary);
    margin-top: 0.75rem;
    min-height: 2.6em;
    line-height: 1.4;
}

.result {
    font-family: var(--font-display);
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--neon-green);
    margin-top: 0.4rem;
    min-height: 1.4em;
    line-height: 1.35;
    text-shadow: 0 0 12px rgba(57, 255, 20, 0.35);
}

.best-score {
    font-size: 0.92rem;
    color: var(--cyan);
    margin-top: 0.5rem;
    min-height: 1.2em;
}

/* --- Buttons --- */
.buttons {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 1rem;
}

.game-btn {
    font-family: var(--font-body);
    padding: 0.85rem 1.6rem;
    font-size: 1.05rem;
    font-weight: 700;
    border: 1px solid var(--glass-border);
    border-radius: 14px;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.15s, filter 0.15s, border-color 0.15s;
    min-width: 120px;
}

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

.btn-lock,
.btn-action {
    background: linear-gradient(135deg, var(--neon-green), var(--cyan));
    color: #04130a;
    box-shadow: 0 0 18px rgba(57, 255, 20, 0.32);
}
.btn-lock:hover,
.btn-action:hover {
    filter: brightness(1.08);
    box-shadow: 0 0 28px rgba(57, 255, 20, 0.5);
}

.btn-mode {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}
.btn-mode:hover {
    border-color: var(--cyan);
    color: var(--cyan);
}

.btn-daily {
    border-color: rgba(189, 0, 255, 0.35);
}
.btn-daily:hover {
    border-color: var(--neon-purple);
    color: var(--neon-purple);
}

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

/* --- State-driven visibility --- */
/* During play: show the lock button + action(lock) row hidden, mode buttons hidden */
.play-buttons { display: none; }
.mode-buttons { display: none; }

.state-playing .play-buttons { display: flex; }

.state-idle .mode-buttons,
.state-gameover .mode-buttons { display: flex; }

/* The "action" button is only meaningful as a duplicate lock during play on
   mobile; in idle/gameover it acts as New Target. Hide it during play (the
   big Lock In Guess button covers that) to keep the layout clean. */
.state-playing #action-btn { display: none; }

/* Result line only meaningful after a round */
.state-idle .result,
.state-playing .result { display: none; }

/* Hint only during idle/playing */
.state-gameover .hint { display: none; }

/* Hide SEO content during active play to keep the map focused */
.state-playing .how-to-play,
.state-playing .related-games {
    display: none;
}

/* New best celebration */
.state-gameover.new-best .result {
    color: var(--gold);
    text-shadow: 0 0 16px rgba(255, 213, 74, 0.55);
    animation: score-pop 0.4s 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.5rem 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.05rem;
    margin: 1.2rem 0 0.45rem;
    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 em { color: var(--gold); font-style: normal; }

.how-to-play ol {
    margin: 0.5rem 0 0.75rem 1.2rem;
    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: 1.75rem auto 0;
    max-width: 520px;
    text-align: center;
}

.related-games h3 {
    font-family: var(--font-display);
    font-size: 1.05rem;
    margin-bottom: 0.7rem;
    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.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(9, 11, 16, 0.78);
    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; }
    .warmth-value { font-size: 2rem; }
    .feedback { font-size: 0.95rem; }
    .result { font-size: 1.02rem; }
    .stats { font-size: 0.85rem; gap: 0.8rem; }
    .game-btn {
        padding: 0.75rem 1.2rem;
        font-size: 0.98rem;
        min-width: 100px;
    }
}

@media (max-width: 360px) {
    .game-btn { min-width: 88px; padding: 0.7rem 0.9rem; }
    .stats { gap: 0.6rem; }
}
