/* Temperature — FunSlop.com
   A physics puzzle controlled by one slider: the sampling temperature.
   Self-contained dark-neon styling, mobile-first. */

: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;
    --radius-md: 14px;
}

* {
    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 drifting glow. Hue shifts with temperature via the .state classes. */
.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;
    transition: background 0.4s ease;
}

@keyframes float {
    0% { transform: translate(0, 0); }
    100% { transform: translate(140px, 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: 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.85rem;
    background: linear-gradient(45deg, var(--cyan), var(--pink));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* HUD: level / samples / best */
.hud {
    display: flex;
    justify-content: center;
    gap: 0.55rem;
    flex-wrap: wrap;
    margin-bottom: 0.75rem;
}

.hud-item {
    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;
    white-space: nowrap;
}

.level-display {
    font-family: var(--font-display);
    color: var(--neon-purple);
}

.samples-display {
    font-family: var(--font-display);
    color: var(--gold);
}

.best-display {
    color: var(--cyan);
}

.best-display:empty {
    display: none;
}

.status {
    font-size: 1rem;
    color: var(--text-primary);
    margin-bottom: 0.9rem;
    min-height: 1.4em;
    line-height: 1.35;
    transition: color 0.2s;
}

.status.good { color: var(--neon-green); }
.status.bad { color: var(--pink); }
.status.warn { color: var(--gold); }

/* Canvas / play area */
.canvas-wrapper {
    position: relative;
    width: min(92vw, 460px);
    aspect-ratio: 1;
    margin: 0 auto;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid rgba(5, 217, 232, 0.28);
    box-shadow:
        0 0 30px rgba(189, 0, 255, 0.22),
        inset 0 0 18px rgba(5, 217, 232, 0.1);
}

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

/* Overlay for idle / win states sits on top of the canvas */
.overlay {
    position: absolute;
    inset: 0;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 1.5rem;
    background: rgba(9, 11, 16, 0.86);
    backdrop-filter: blur(4px);
    text-align: center;
}

.state-idle .overlay,
.state-won .overlay,
.state-complete .overlay {
    display: flex;
    animation: fadeIn 0.35s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.overlay-title {
    font-family: var(--font-display);
    font-size: 1.55rem;
    font-weight: 700;
    color: var(--neon-green);
    text-shadow: 0 0 16px rgba(57, 255, 20, 0.5);
}

.state-won .overlay-title { color: var(--gold); text-shadow: 0 0 16px rgba(255, 213, 74, 0.55); }
.state-complete .overlay-title { color: var(--cyan); text-shadow: 0 0 16px rgba(5, 217, 232, 0.55); }

.overlay-text {
    font-size: 0.98rem;
    font-weight: 300;
    color: var(--text-muted);
    line-height: 1.5;
    max-width: 30ch;
}

/* Temperature control — the star of the show */
.temp-control {
    margin: 1.1rem auto 0.5rem;
    max-width: 460px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: 0.9rem 1.1rem 1rem;
}

.temp-readout {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 0.55rem;
}

.temp-label {
    font-family: var(--font-display);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--text-muted);
}

.temp-value {
    font-family: var(--font-display);
    font-size: 1.9rem;
    font-weight: 700;
    line-height: 1;
    color: var(--cyan);
    text-shadow: 0 0 14px rgba(5, 217, 232, 0.4);
    transition: color 0.2s, text-shadow 0.2s;
    font-variant-numeric: tabular-nums;
}

/* Range slider — styled for both webkit and firefox */
.temp-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 12px;
    border-radius: 999px;
    background: linear-gradient(90deg,
        var(--cyan) 0%,
        var(--neon-green) 35%,
        var(--gold) 65%,
        var(--pink) 100%);
    outline: none;
    cursor: pointer;
    box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.6);
}

.temp-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--text-primary);
    border: 3px solid var(--bg-dark);
    box-shadow: 0 0 14px rgba(255, 255, 255, 0.6), 0 0 4px rgba(0,0,0,0.8);
    cursor: grab;
    transition: transform 0.1s;
}

.temp-slider::-webkit-slider-thumb:active {
    transform: scale(1.15);
    cursor: grabbing;
}

.temp-slider::-moz-range-thumb {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--text-primary);
    border: 3px solid var(--bg-dark);
    box-shadow: 0 0 14px rgba(255, 255, 255, 0.6);
    cursor: grab;
}

.temp-slider:focus-visible {
    box-shadow: inset 0 0 6px rgba(0,0,0,0.6), 0 0 0 3px rgba(5, 217, 232, 0.6);
}

.temp-scale {
    display: flex;
    justify-content: space-between;
    margin-top: 0.5rem;
    font-size: 0.72rem;
    color: var(--text-muted);
    font-family: var(--font-display);
    letter-spacing: 0.3px;
}

/* Action buttons */
.action-row {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    margin-top: 0.85rem;
}

.game-btn {
    font-family: var(--font-display);
    padding: 0.85rem 1.6rem;
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: 0.4px;
    border: 1px solid var(--glass-border);
    border-radius: 999px;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.15s, filter 0.15s, opacity 0.15s;
    color: var(--bg-dark);
}

.game-btn:active { transform: scale(0.95); }

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

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

.btn-sample {
    background: linear-gradient(135deg, var(--neon-green), var(--cyan));
    box-shadow: 0 0 20px rgba(57, 255, 20, 0.32);
    flex: 1;
    max-width: 260px;
}

.btn-sample:not(:disabled):hover {
    filter: brightness(1.1);
    box-shadow: 0 0 28px rgba(57, 255, 20, 0.5);
}

.btn-reset {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-muted);
    border: 1px solid var(--glass-border);
}

.btn-reset:hover {
    color: var(--pink);
    border-color: var(--pink);
}

.btn-primary {
    background: linear-gradient(135deg, var(--neon-green), var(--cyan));
    box-shadow: 0 0 22px rgba(57, 255, 20, 0.35);
    padding: 0.9rem 2.4rem;
    font-size: 1.15rem;
}

.btn-primary:hover {
    filter: brightness(1.1);
    box-shadow: 0 0 30px rgba(57, 255, 20, 0.55);
}

/* Hide gameplay controls outside of play */
.state-idle .temp-control,
.state-idle .action-row,
.state-won .temp-control,
.state-won .action-row,
.state-complete .temp-control,
.state-complete .action-row {
    opacity: 0.35;
    pointer-events: none;
    filter: grayscale(0.6);
}

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

/* 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.65rem;
    color: var(--text-primary);
}

.how-to-play h3 {
    font-family: var(--font-display);
    font-size: 1.05rem;
    margin: 1.15rem 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 .kw-goal { color: var(--neon-green); font-weight: 700; }

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

.fun-fact {
    margin-top: 1.15rem;
    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.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(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.75rem; }
    .status { font-size: 0.92rem; }
    .temp-value { font-size: 1.6rem; }
    .game-btn { padding: 0.75rem 1.2rem; font-size: 0.98rem; }
    .btn-primary { padding: 0.8rem 1.9rem; font-size: 1.05rem; }
    .hud-item { font-size: 0.78rem; padding: 0.3rem 0.65rem; }
}

@media (max-width: 360px) {
    .temp-scale { font-size: 0.62rem; }
    .action-row { gap: 0.5rem; }
}
