/* Steering — FunSlop.com
   Indirect control of an emergent boid swarm. You get four sliders and a
   prayer. Self-contained dark-neon styling, no shared theme required. */

:root {
    --color-bg: #090b10;
    --color-bg-secondary: #0c0f18;
    --color-panel: #11141f;
    --color-green: #39ff14;
    --color-purple: #bd00ff;
    --color-cyan: #05d9e8;
    --color-pink: #ff2a6d;
    --color-gold: #ffd54a;
    --color-text: #f0f4f8;
    --color-muted: #8b9bb4;
    --glass-border: rgba(255, 255, 255, 0.08);

    --font-body: 'Outfit', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-head: 'Space Grotesk', var(--font-body);

    --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);
    color: var(--color-text);
    background: var(--color-bg);
    background-image:
        radial-gradient(circle at 14% 16%, rgba(189, 0, 255, 0.16), transparent 44%),
        radial-gradient(circle at 86% 84%, rgba(5, 217, 232, 0.13), transparent 46%),
        radial-gradient(circle at 50% 40%, rgba(57, 255, 20, 0.05), transparent 62%);
    background-attachment: fixed;
}

.game-container {
    position: relative;
    width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    user-select: none;
    -webkit-user-select: none;
}

.content {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 520px;
    padding: 1.4rem 1rem calc(5rem + env(safe-area-inset-bottom, 0px));
}

.header-info {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    width: 100%;
    gap: 1rem;
    margin-bottom: 0.45rem;
}

.title {
    margin: 0;
    font-family: var(--font-head);
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    background: linear-gradient(45deg, var(--color-purple), var(--color-cyan), var(--color-green));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.level-display {
    font-family: var(--font-head);
    font-size: 1.15rem;
    font-weight: 500;
    color: var(--color-purple);
    text-shadow: 0 0 12px rgba(189, 0, 255, 0.55);
    white-space: nowrap;
}

.objective {
    width: 100%;
    text-align: center;
    font-size: 0.98rem;
    line-height: 1.4;
    color: var(--color-cyan);
    min-height: 2.6em;
    margin-bottom: 0.7rem;
    text-shadow: 0 0 10px rgba(5, 217, 232, 0.35);
}

/* --- Arena --- */
.canvas-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 1;
    max-width: 460px;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid rgba(189, 0, 255, 0.25);
    box-shadow:
        0 0 30px rgba(189, 0, 255, 0.25),
        inset 0 0 18px rgba(5, 217, 232, 0.1);
}

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

/* Overlay shown on idle / between runs */
.overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    text-align: center;
    padding: 1.5rem;
    background: rgba(9, 11, 16, 0.78);
    backdrop-filter: blur(3px);
    transition: opacity 0.25s ease;
}

.overlay-line {
    font-family: var(--font-head);
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--color-text);
    text-shadow: 0 0 16px rgba(189, 0, 255, 0.5);
}

.overlay-sub {
    font-size: 0.95rem;
    color: var(--color-muted);
    max-width: 22rem;
    line-height: 1.45;
    margin-bottom: 0.6rem;
}

/* Hide overlay while a run is live */
.state-playing .overlay {
    opacity: 0;
    pointer-events: none;
}

/* --- Stats row --- */
.stats {
    display: flex;
    justify-content: space-between;
    width: 100%;
    max-width: 460px;
    gap: 1rem;
    margin-top: 0.85rem;
    font-size: 1.05rem;
    font-weight: 700;
    font-family: var(--font-head);
}

.stat-saved {
    color: var(--color-green);
    text-shadow: 0 0 10px rgba(57, 255, 20, 0.45);
}

.stat-timer {
    color: var(--color-muted);
    transition: color 0.2s;
}

.stat-timer.urgent {
    color: var(--color-pink);
    text-shadow: 0 0 12px rgba(255, 42, 109, 0.7);
    animation: pulse 0.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* --- Sliders --- */
.sliders {
    width: 100%;
    max-width: 460px;
    margin-top: 1rem;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.6rem 1.1rem;
}

.slider-row {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 0.55rem 0.7rem 0.65rem;
}

.slider-label {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-size: 0.85rem;
}

.slider-name {
    font-family: var(--font-head);
    font-weight: 700;
    letter-spacing: 0.2px;
}

.slider-val {
    font-family: var(--font-head);
    font-weight: 500;
    color: var(--color-text);
    font-variant-numeric: tabular-nums;
}

/* Range input — cross-browser neon styling */
.weight-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
    outline: none;
    cursor: pointer;
}

.weight-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--color-text);
    border: 2px solid var(--color-cyan);
    box-shadow: 0 0 10px rgba(5, 217, 232, 0.7);
    cursor: pointer;
    transition: transform 0.1s;
}

.weight-slider::-webkit-slider-thumb:active {
    transform: scale(1.2);
}

.weight-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--color-text);
    border: 2px solid var(--color-cyan);
    box-shadow: 0 0 10px rgba(5, 217, 232, 0.7);
    cursor: pointer;
}

.weight-slider:focus-visible {
    box-shadow: 0 0 0 3px rgba(5, 217, 232, 0.5);
}

.hint {
    width: 100%;
    max-width: 460px;
    text-align: center;
    font-size: 0.85rem;
    color: var(--color-muted);
    margin-top: 0.8rem;
    min-height: 1.2em;
    line-height: 1.35;
}

/* Action row (Next / Retry) */
.action-row {
    display: none;
    justify-content: center;
    width: 100%;
    margin-top: 0.9rem;
}

.state-won .action-row,
.state-gameover .action-row {
    display: flex;
}

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

.start-btn:hover {
    transform: scale(1.04);
    filter: brightness(1.07);
    box-shadow: 0 0 32px rgba(57, 255, 20, 0.55);
}

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

.start-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(5, 217, 232, 0.6);
}

/* --- Home link --- */
.home-link {
    position: fixed;
    bottom: 1rem;
    bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
    left: 50%;
    transform: translateX(-50%);
    color: var(--color-text);
    text-decoration: none;
    font-size: 0.9rem;
    padding: 0.5rem 1.1rem;
    border-radius: 999px;
    background: rgba(17, 20, 31, 0.85);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(6px);
    transition: color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
    z-index: 200;
}

.home-link:hover {
    color: var(--color-purple);
    border-color: rgba(189, 0, 255, 0.5);
    box-shadow: 0 0 18px rgba(189, 0, 255, 0.3);
}

.home-link:active {
    transform: translateX(-50%) scale(0.96);
}

.home-link:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(5, 217, 232, 0.6);
}

/* --- SEO / how-to content --- */
.how-to-play {
    text-align: left;
    width: 100%;
    margin-top: 2.5rem;
    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-head);
    font-size: 1.35rem;
    margin-bottom: 0.7rem;
    color: var(--color-text);
}

.how-to-play h3 {
    font-family: var(--font-head);
    font-size: 1.05rem;
    margin: 1.2rem 0 0.4rem;
    color: var(--color-cyan);
}

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

.how-to-play strong { color: var(--color-text); font-weight: 500; }
.how-to-play em { color: var(--color-green); font-style: normal; }

.how-to-play ol {
    margin: 0.4rem 0 0.7rem 1.2rem;
    color: var(--color-muted);
    line-height: 1.65;
}

.fun-fact {
    margin-top: 1.2rem;
    padding: 1rem;
    border-left: 3px solid var(--color-purple);
    background: rgba(189, 0, 255, 0.06);
    border-radius: 0 10px 10px 0;
}

.fun-fact p { margin: 0; }
.fun-fact strong { color: var(--color-purple); }

.related-games {
    width: 100%;
    margin-top: 2rem;
    text-align: center;
}

.related-games h3 {
    font-family: var(--font-head);
    font-size: 1.05rem;
    margin-bottom: 0.7rem;
    color: var(--color-muted);
}

.related-games-list {
    display: flex;
    gap: 0.6rem;
    justify-content: center;
    flex-wrap: wrap;
}

.related-game-link {
    text-decoration: none;
    color: var(--color-text);
    background: rgba(5, 217, 232, 0.07);
    border: 1px solid rgba(5, 217, 232, 0.22);
    border-radius: 999px;
    padding: 0.45rem 1rem;
    font-size: 0.9rem;
    transition: border-color 0.2s, box-shadow 0.2s, color 0.2s;
}

.related-game-link:hover {
    border-color: rgba(5, 217, 232, 0.6);
    box-shadow: 0 0 16px rgba(5, 217, 232, 0.3);
    color: var(--color-cyan);
}

/* Hide SEO content + sliders during gameover/won so the verdict reads clean */
.state-gameover .how-to-play,
.state-gameover .related-games,
.state-won .how-to-play,
.state-won .related-games {
    display: none;
}

/* Outcome flavor on the objective line */
.state-won .objective {
    color: var(--color-green);
    text-shadow: 0 0 12px rgba(57, 255, 20, 0.5);
}

.state-gameover .objective {
    color: var(--color-pink);
    text-shadow: 0 0 12px rgba(255, 42, 109, 0.5);
}

/* New best celebration */
.new-best .stat-saved {
    color: var(--color-gold);
    text-shadow: 0 0 14px rgba(255, 213, 74, 0.6);
    animation: score-pop 0.4s ease-out;
}

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

/* --- Responsive --- */
@media (max-width: 600px) {
    .title { font-size: 1.65rem; }
    .level-display { font-size: 1rem; }
    .objective { font-size: 0.9rem; }
    .stats { font-size: 0.95rem; }
    .start-btn { padding: 0.8rem 2rem; font-size: 1.05rem; }
    .overlay-line { font-size: 1.15rem; }
}

@media (max-width: 360px) {
    .sliders { gap: 0.5rem 0.6rem; }
    .slider-row { padding: 0.45rem 0.55rem 0.55rem; }
    .slider-label { font-size: 0.78rem; }
}
