/* Slop Factory — FunSlop.com
   Node-graph content-pipeline builder. Neon-on-near-black. Self-contained. */

:root {
    --bg-dark: #090b10;
    --bg-panel: #0e111a;
    --bg-floor: #0b0e16;
    --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, BlinkMacSystemFont, 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);
    background-image:
        radial-gradient(circle at 14% 12%, rgba(189, 0, 255, 0.14), transparent 42%),
        radial-gradient(circle at 86% 88%, rgba(5, 217, 232, 0.12), transparent 46%);
}

.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 {
    width: 100%;
    max-width: 680px;
    margin: 0 auto;
    padding: 1.1rem 0.9rem 5.5rem;
}

/* Top bar */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 0.5rem;
}

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

.hud {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.hud-pill {
    font-family: var(--font-display);
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--cyan);
    background: rgba(5, 217, 232, 0.08);
    border: 1px solid rgba(5, 217, 232, 0.3);
    border-radius: 999px;
    padding: 0.3rem 0.8rem;
    white-space: nowrap;
}

.hud-pill.best {
    color: var(--gold);
    background: rgba(255, 213, 74, 0.08);
    border-color: rgba(255, 213, 74, 0.3);
}

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

.briefing {
    font-size: 0.92rem;
    line-height: 1.5;
    color: var(--text-muted);
    margin-bottom: 0.85rem;
}

/* Meters */
.meters {
    display: flex;
    gap: 0.7rem;
    margin-bottom: 0.7rem;
}

.meter {
    flex: 1;
    background: var(--bg-panel);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: 0.6rem 0.85rem;
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.meter-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    width: 100%;
}

.meter-value {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--neon-green);
    text-shadow: 0 0 12px rgba(57, 255, 20, 0.4);
    transition: color 0.2s;
}

.meter-value.hit {
    color: var(--gold);
    text-shadow: 0 0 14px rgba(255, 213, 74, 0.55);
}

.meter-value.risk {
    color: var(--pink);
    text-shadow: 0 0 12px rgba(255, 42, 109, 0.45);
}

.meter-target {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Canvas / factory floor */
.canvas-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 5 / 4;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid rgba(189, 0, 255, 0.25);
    box-shadow:
        0 0 26px rgba(189, 0, 255, 0.22),
        inset 0 0 18px rgba(5, 217, 232, 0.08);
    background: var(--bg-floor);
}

#canvas {
    display: block;
    width: 100%;
    height: 100%;
    touch-action: none;
    cursor: grab;
}

#canvas:active { cursor: grabbing; }

.trash-zone {
    position: absolute;
    bottom: 0.55rem;
    right: 0.55rem;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    color: var(--pink);
    background: rgba(255, 42, 109, 0.08);
    border: 1px dashed rgba(255, 42, 109, 0.45);
    border-radius: 10px;
    padding: 0.35rem 0.6rem;
    opacity: 0;
    transition: opacity 0.18s, transform 0.18s, background 0.18s;
    pointer-events: none;
}

.trash-zone.show { opacity: 0.85; }
.trash-zone.armed {
    opacity: 1;
    transform: scale(1.12);
    background: rgba(255, 42, 109, 0.28);
}

/* Palette tray */
.palette {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin: 0.7rem 0;
}

.palette-item {
    font-family: var(--font-body);
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    padding: 0.45rem 0.7rem;
    cursor: pointer;
    transition: transform 0.1s, border-color 0.15s, box-shadow 0.15s, opacity 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    position: relative;
}

.palette-item::before {
    content: '';
    width: 0.6rem;
    height: 0.6rem;
    border-radius: 3px;
    background: var(--node-color, var(--cyan));
    box-shadow: 0 0 8px var(--node-color, var(--cyan));
    flex: none;
}

.palette-item:hover {
    transform: translateY(-2px);
    border-color: var(--node-color, var(--cyan));
    box-shadow: 0 0 14px var(--node-glow, rgba(5, 217, 232, 0.3));
}

.palette-item:active { transform: scale(0.96); }

.palette-item.locked {
    opacity: 0.35;
    cursor: not-allowed;
    pointer-events: none;
}

.palette-item .lock-tag {
    font-size: 0.65rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* Action bar */
.actionbar {
    display: flex;
    gap: 0.6rem;
    justify-content: center;
    flex-wrap: wrap;
    margin: 0.5rem 0 0.4rem;
}

.game-btn {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.05rem;
    border: none;
    border-radius: 999px;
    padding: 0.8rem 1.8rem;
    cursor: pointer;
    color: #04130a;
    transition: transform 0.12s, box-shadow 0.15s, filter 0.15s;
}

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

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

.next-btn {
    background: linear-gradient(135deg, var(--gold), var(--pink));
    box-shadow: 0 0 20px rgba(255, 213, 74, 0.3);
    display: none;
}
.next-btn:hover { filter: brightness(1.08); }

.start-btn {
    background: linear-gradient(135deg, var(--neon-purple), var(--cyan));
    color: #fff;
    box-shadow: 0 0 22px rgba(189, 0, 255, 0.35);
}
.start-btn:hover { filter: brightness(1.1); box-shadow: 0 0 30px rgba(189, 0, 255, 0.55); }

/* State-driven button + UI visibility */
.state-idle .run-btn,
.state-idle .next-btn,
.state-idle .palette,
.state-idle .meters,
.state-idle .trash-zone { display: none; }

.state-playing .start-btn,
.state-playing .next-btn { display: none; }

.state-cleared .start-btn { display: none; }
.state-cleared .run-btn { display: none; }
.state-cleared .next-btn { display: inline-block; }

.state-gameover .start-btn { display: inline-block; }
.state-gameover .run-btn,
.state-gameover .next-btn { display: none; }

/* Verdict line */
.verdict {
    text-align: center;
    font-family: var(--font-display);
    font-size: 1.05rem;
    font-weight: 700;
    min-height: 1.4em;
    margin: 0.35rem 0;
    color: var(--text-primary);
}
.verdict.good { color: var(--neon-green); text-shadow: 0 0 12px rgba(57, 255, 20, 0.45); }
.verdict.bad { color: var(--pink); text-shadow: 0 0 12px rgba(255, 42, 109, 0.45); }
.verdict.banned { color: var(--pink); }

.state-cleared .verdict { animation: pop 0.4s ease-out; }
@keyframes pop {
    0% { transform: scale(0.8); opacity: 0; }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); opacity: 1; }
}

.hint {
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-muted);
    min-height: 1.2em;
    margin: 0.2rem 0 0.4rem;
    line-height: 1.45;
}

.state-playing .briefing,
.state-cleared .briefing,
.state-gameover .briefing { display: none; }

/* SEO / how-to content */
.how-to-play {
    text-align: left;
    margin: 2.25rem auto 0;
    max-width: 600px;
    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;
}

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

.how-to-play strong { color: var(--text-primary); font-weight: 500; }

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

.fun-fact {
    margin-top: 1.15rem;
    padding: 0.95rem 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: 600px;
    text-align: center;
}

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

.related-games-list {
    display: flex;
    gap: 0.55rem;
    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.42rem 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 during active play / results for focus */
.state-playing .how-to-play,
.state-playing .related-games,
.state-cleared .how-to-play,
.state-cleared .related-games,
.state-gameover .how-to-play,
.state-gameover .related-games { display: none; }

/* Home link */
.home-link {
    position: fixed;
    bottom: 1rem;
    bottom: calc(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: 50;
}
.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.5rem; }
    .meter-value { font-size: 1.25rem; }
    .game-btn { padding: 0.7rem 1.4rem; font-size: 0.95rem; }
    .palette-item { font-size: 0.78rem; padding: 0.42rem 0.6rem; }
    .briefing { font-size: 0.85rem; }
}
