/* Reward Hacking — FunSlop.com
   Specification gaming, made playable. A literal objective, a hidden loophole,
   and a reward meter with no judgment. Self-contained neon-on-near-black. */

:root {
    --bg-dark: #090b10;
    --bg-panel: #11141f;
    --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, matching FunSlop's house style */
.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: 2rem 1.25rem 6rem;
    max-width: 620px;
    width: 100%;
    margin: 0 auto;
}

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

/* ------- HUD: level + objective + meter ------- */
.hud {
    display: none;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.state-playing .hud,
.state-revealed .hud {
    display: flex;
}

.hud-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.85rem;
}

.level-tag {
    font-family: var(--font-display);
    font-weight: 700;
    color: var(--cyan);
    letter-spacing: 0.5px;
    text-shadow: 0 0 10px rgba(5, 217, 232, 0.4);
}

.par-tag {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.objective-box {
    background: rgba(255, 213, 74, 0.06);
    border: 1px solid rgba(255, 213, 74, 0.28);
    border-radius: 12px;
    padding: 0.85rem 1rem;
    text-align: left;
    line-height: 1.45;
}

.objective-label {
    font-family: var(--font-display);
    font-weight: 700;
    color: var(--gold);
    margin-right: 0.4rem;
    text-shadow: 0 0 10px rgba(255, 213, 74, 0.4);
}

.objective-text {
    color: var(--text-primary);
    font-size: 1.05rem;
}

/* Reward meter */
.meter-wrap {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.meter-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    min-width: 4.5rem;
    text-align: left;
    white-space: nowrap;
}

.meter-track {
    flex: 1;
    height: 14px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 999px;
    overflow: hidden;
}

.meter-fill {
    height: 100%;
    width: 0%;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--pink), var(--gold));
    box-shadow: 0 0 12px rgba(255, 213, 74, 0.45);
    transition: width 0.25s ease, background 0.25s ease;
}

.meter-wrap.maxed .meter-fill {
    background: linear-gradient(90deg, var(--neon-green), var(--cyan));
    box-shadow: 0 0 18px rgba(57, 255, 20, 0.6);
}

.meter-value {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text-primary);
    min-width: 3rem;
    text-align: right;
}

.meter-wrap.maxed .meter-value {
    color: var(--neon-green);
    text-shadow: 0 0 10px rgba(57, 255, 20, 0.5);
}

/* ------- The interactive scene ------- */
.scene {
    display: none;
    position: relative;
    margin: 0.5rem auto 0;
    min-height: 200px;
    width: 100%;
    background: var(--bg-panel);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 1.25rem;
    overflow: hidden;
}

.state-playing .scene,
.state-revealed .scene {
    display: block;
}

.state-revealed .scene {
    opacity: 0.55;
    filter: saturate(0.6);
    pointer-events: none;
}

/* Generic scene helpers */
.scene-stage {
    position: relative;
    width: 100%;
    min-height: 170px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.scene-note {
    color: var(--text-muted);
    font-size: 0.82rem;
    margin-top: 0.85rem;
    line-height: 1.4;
}

/* Scene buttons / levers */
.lever {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.15rem;
    border: 1px solid var(--glass-border);
    border-radius: 14px;
    padding: 1rem 1.4rem;
    cursor: pointer;
    color: var(--bg-dark);
    transition: transform 0.08s, box-shadow 0.15s, filter 0.15s;
    min-width: 96px;
}

.lever:active { transform: scale(0.94); }

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

.lever.green { background: var(--neon-green); box-shadow: 0 0 16px rgba(57, 255, 20, 0.35); }
.lever.cyan  { background: var(--cyan);      box-shadow: 0 0 16px rgba(5, 217, 232, 0.35); }
.lever.purple{ background: var(--neon-purple); color: #fff; box-shadow: 0 0 16px rgba(189, 0, 255, 0.4); }
.lever.pink  { background: var(--pink);      color: #fff; box-shadow: 0 0 16px rgba(255, 42, 109, 0.4); }
.lever.gold  { background: var(--gold);      box-shadow: 0 0 16px rgba(255, 213, 74, 0.35); }
.lever.ghost { background: rgba(255,255,255,0.04); color: var(--text-muted); }
.lever:hover { filter: brightness(1.1); }

.lever.small {
    font-size: 0.9rem;
    padding: 0.6rem 0.9rem;
    min-width: 0;
}

/* The big readout used by counter levels */
.big-readout {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 3rem;
    color: var(--gold);
    text-shadow: 0 0 18px rgba(255, 213, 74, 0.4);
    width: 100%;
    margin-bottom: 0.5rem;
    word-break: break-all;
    line-height: 1.1;
}

/* Tile grid (red-tile level) */
.viewport {
    position: relative;
    width: 100%;
    max-width: 320px;
    margin: 0 auto;
    aspect-ratio: 4 / 3;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--glass-border);
    background: #05060a;
    transition: filter 0.35s, opacity 0.35s, transform 0.35s;
}

.viewport.lights-off { filter: brightness(0.04); }

.tile-grid {
    position: absolute;
    inset: 0;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 6px;
    padding: 8px;
    transition: transform 0.45s ease;
}

.tile {
    border-radius: 6px;
    cursor: pointer;
    transition: transform 0.12s, opacity 0.2s, background 0.2s;
}
.tile:active { transform: scale(0.9); }
.tile.red   { background: var(--pink);   box-shadow: 0 0 10px rgba(255,42,109,0.5); }
.tile.blue  { background: var(--cyan);   box-shadow: 0 0 8px rgba(5,217,232,0.4); }
.tile.gone  { opacity: 0; pointer-events: none; }

/* A cover-plate overlay you can drag down over the viewport */
.viewport-cover {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 100%;
    height: 100%;
    background: repeating-linear-gradient(45deg, #1a1d28, #1a1d28 10px, #11141f 10px, #11141f 20px);
    border-bottom: 3px solid var(--gold);
    cursor: grab;
    transition: bottom 0.05s linear;
    z-index: 4;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 0.4rem;
    color: var(--text-muted);
    font-size: 0.75rem;
}
.viewport-cover:active { cursor: grabbing; }

/* Package-delivery level */
.field {
    position: relative;
    width: 100%;
    height: 200px;
    border-radius: 12px;
    background:
        linear-gradient(rgba(5,217,232,0.05), rgba(5,217,232,0.05)),
        repeating-linear-gradient(0deg, transparent, transparent 24px, rgba(255,255,255,0.03) 24px, rgba(255,255,255,0.03) 25px),
        repeating-linear-gradient(90deg, transparent, transparent 24px, rgba(255,255,255,0.03) 24px, rgba(255,255,255,0.03) 25px);
    border: 1px solid var(--glass-border);
    overflow: hidden;
    touch-action: none;
}

.draggable {
    position: absolute;
    width: 48px;
    height: 48px;
    margin: -24px 0 0 -24px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    cursor: grab;
    touch-action: none;
    transition: box-shadow 0.15s;
    z-index: 2;
}
.draggable:active { cursor: grabbing; }
.draggable.dragging { z-index: 5; }

.package {
    background: var(--gold);
    color: var(--bg-dark);
    box-shadow: 0 0 14px rgba(255, 213, 74, 0.45);
}
.goal {
    background: transparent;
    border: 3px dashed var(--neon-green);
    color: var(--neon-green);
    box-shadow: 0 0 14px rgba(57, 255, 20, 0.3);
}
.sensor {
    background: var(--bg-panel);
    border: 1px solid var(--glass-border);
    color: var(--cyan);
    font-size: 1rem;
    z-index: 3;
}
.sensor .trash-hint {
    position: absolute;
    bottom: -16px;
    font-size: 0.55rem;
    color: var(--text-muted);
    white-space: nowrap;
}

/* a drag-to-delete bin */
.trash-bin {
    position: absolute;
    right: 6px;
    bottom: 6px;
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: rgba(255,42,109,0.08);
    border: 1px dashed rgba(255,42,109,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--pink);
    font-size: 1.1rem;
    z-index: 1;
    transition: transform 0.12s, background 0.15s;
}
.trash-bin.hot { background: rgba(255,42,109,0.25); transform: scale(1.12); }

/* Happiness / user level */
.user-rig {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.9rem;
    width: 100%;
}
.face {
    font-size: 3.5rem;
    line-height: 1;
    transition: transform 0.2s, filter 0.3s;
}
.face.muted { filter: grayscale(1) brightness(0.5); }
.user-controls {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
    justify-content: center;
}
.complaint {
    font-size: 0.85rem;
    color: var(--pink);
    min-height: 1.3em;
    font-style: italic;
}
.complaint.muted { color: var(--text-muted); text-decoration: line-through; }

/* Toggle switches (used by a couple levels) */
.toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 0.9rem;
}
.toggle .switch {
    width: 46px;
    height: 26px;
    border-radius: 999px;
    background: rgba(255,255,255,0.08);
    border: 1px solid var(--glass-border);
    position: relative;
    transition: background 0.2s;
    flex-shrink: 0;
}
.toggle .switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: transform 0.2s, background 0.2s;
}
.toggle.on .switch { background: rgba(57,255,20,0.3); }
.toggle.on .switch::after { transform: translateX(20px); background: var(--neon-green); }

/* Slider (sensor-tampering levels) */
.slider-row {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    width: 100%;
    max-width: 320px;
    margin: 0 auto;
    text-align: left;
}
.slider-row label { font-size: 0.85rem; color: var(--text-muted); }
input[type="range"].rh-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 8px;
    border-radius: 999px;
    background: rgba(255,255,255,0.08);
    outline: none;
}
input[type="range"].rh-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--cyan);
    box-shadow: 0 0 12px rgba(5,217,232,0.6);
    cursor: pointer;
}
input[type="range"].rh-slider::-moz-range-thumb {
    width: 22px;
    height: 22px;
    border: none;
    border-radius: 50%;
    background: var(--cyan);
    box-shadow: 0 0 12px rgba(5,217,232,0.6);
    cursor: pointer;
}

/* Generic chip / label inside a scene */
.chip {
    display: inline-block;
    padding: 0.3rem 0.7rem;
    border-radius: 999px;
    font-size: 0.8rem;
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-muted);
}

/* ------- Live feedback line ------- */
.feedback {
    font-size: 0.95rem;
    color: var(--text-muted);
    margin-top: 1rem;
    min-height: 1.4em;
    line-height: 1.4;
}

.state-revealed .feedback { display: none; }

/* ------- Reveal panel ------- */
.reveal {
    display: none;
    margin-top: 1.25rem;
    background: rgba(57, 255, 20, 0.05);
    border: 1px solid rgba(57, 255, 20, 0.3);
    border-radius: 16px;
    padding: 1.5rem;
    text-align: left;
    animation: reveal-in 0.35s ease-out;
}

.state-revealed .reveal { display: block; }

@keyframes reveal-in {
    from { opacity: 0; transform: translateY(12px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.reveal-title {
    font-family: var(--font-display);
    font-size: 1.3rem;
    color: var(--neon-green);
    margin-bottom: 0.5rem;
    text-shadow: 0 0 12px rgba(57, 255, 20, 0.4);
}

.reveal-body {
    font-weight: 300;
    line-height: 1.6;
    color: var(--text-primary);
    margin-bottom: 1.1rem;
}
.reveal-body strong { color: var(--gold); font-weight: 500; }

/* ------- Shared buttons ------- */
.game-btn {
    font-family: var(--font-display);
    font-weight: 700;
    border: none;
    border-radius: 999px;
    cursor: pointer;
    transition: transform 0.12s, box-shadow 0.15s, filter 0.15s;
    color: #04130a;
    letter-spacing: 0.3px;
}
.game-btn:active { transform: scale(0.97); }
.game-btn:focus-visible {
    outline: 3px solid var(--cyan);
    outline-offset: 2px;
}

.btn-next {
    background: linear-gradient(135deg, var(--neon-green), var(--cyan));
    padding: 0.85rem 2rem;
    font-size: 1.05rem;
    box-shadow: 0 0 20px rgba(57, 255, 20, 0.35);
}
.btn-next:hover { transform: scale(1.04); box-shadow: 0 0 30px rgba(57, 255, 20, 0.55); }

.btn-start, .btn-restart {
    background: linear-gradient(135deg, var(--pink), var(--gold));
    color: #160206;
    padding: 0.95rem 2.4rem;
    font-size: 1.15rem;
    box-shadow: 0 0 22px rgba(255, 42, 109, 0.35);
}
.btn-start:hover, .btn-restart:hover {
    transform: scale(1.04);
    box-shadow: 0 0 32px rgba(255, 42, 109, 0.55);
}

/* ------- Start panel ------- */
.start-panel {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 1.1rem;
    margin-top: 1rem;
}
.state-idle .start-panel { display: flex; }

.start-blurb {
    font-size: 1.1rem;
    line-height: 1.6;
    color: var(--text-muted);
    max-width: 440px;
}
.start-blurb strong { color: var(--gold); font-weight: 700; }

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

/* ------- Game over panel ------- */
.gameover-panel {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    margin-top: 1rem;
    animation: reveal-in 0.4s ease-out;
}
.state-gameover .gameover-panel { display: flex; }

.verdict-title {
    font-family: var(--font-display);
    font-size: 1.9rem;
    background: linear-gradient(45deg, var(--neon-green), var(--gold));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.verdict-body {
    font-size: 1.05rem;
    line-height: 1.6;
    color: var(--text-muted);
    max-width: 460px;
}

.run-stats {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
    justify-content: center;
    margin: 0.25rem 0 0.5rem;
}
.run-stat {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}
.run-stat .num {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.6rem;
    color: var(--cyan);
}
.run-stat .lbl {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}
.state-gameover.new-best .run-stat .num { color: var(--gold); text-shadow: 0 0 12px rgba(255,213,74,0.5); }

/* ------- Hint line ------- */
.hint {
    font-size: 0.88rem;
    color: var(--text-muted);
    margin-top: 1.25rem;
    min-height: 1.2em;
}

/* Hide HUD / scene / reveal / gameover panels when not relevant */
.state-idle .hud,
.state-idle .scene,
.state-idle .reveal,
.state-idle .gameover-panel,
.state-gameover .hud,
.state-gameover .scene,
.state-gameover .reveal,
.state-playing .start-panel,
.state-playing .gameover-panel,
.state-playing .reveal,
.state-revealed .start-panel,
.state-revealed .gameover-panel {
    display: none;
}

/* ------- SEO / how-to content ------- */
.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; }
.fun-fact strong { color: var(--neon-purple); }

.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 / reveal */
.state-playing .how-to-play,
.state-playing .related-games,
.state-revealed .how-to-play,
.state-revealed .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.8rem; }
    .objective-text { font-size: 0.98rem; }
    .big-readout { font-size: 2.3rem; }
    .face { font-size: 3rem; }
    .lever { font-size: 1rem; padding: 0.85rem 1.1rem; }
    .verdict-title { font-size: 1.55rem; }
    .start-blurb { font-size: 1rem; }
    .scene { padding: 1rem; }
}
