/* Paste-to-Play — FunSlop.com
   Bring-your-own-content side-scrolling runner. Paste text -> level -> casualty.
   Self-contained neon-on-near-black aesthetic. */

: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;
    --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 neon glow, FunSlop house style */
.glow-bg {
    position: fixed;
    top: -80px;
    left: -80px;
    width: 360px;
    height: 360px;
    background: radial-gradient(circle, var(--cyan) 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(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: 2.25rem 1.25rem 6rem;
    max-width: 720px;
    width: 100%;
    margin: 0 auto;
}

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

/* ---------------- Paste panel (idle) ---------------- */
.paste-panel {
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: 0.9rem;
    margin-bottom: 1rem;
}

.state-idle .paste-panel {
    display: flex;
}

.paste-blurb {
    font-size: 1rem;
    line-height: 1.55;
    color: var(--text-muted);
    font-weight: 300;
    text-align: center;
}

.source-text {
    width: 100%;
    resize: vertical;
    min-height: 7rem;
    font-family: var(--font-body);
    font-size: 1rem;
    line-height: 1.5;
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: 0.9rem 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.source-text::placeholder {
    color: var(--text-muted);
    opacity: 0.7;
}

.source-text:focus {
    outline: none;
    border-color: var(--cyan);
    box-shadow: 0 0 0 3px rgba(5, 217, 232, 0.2);
}

.paste-stats {
    font-size: 0.85rem;
    color: var(--text-muted);
    min-height: 1.2em;
    text-align: center;
}

.paste-stats .ok { color: var(--neon-green); }
.paste-stats .warn { color: var(--gold); }

/* ---------------- Buttons ---------------- */
.game-btn {
    font-family: var(--font-display);
    padding: 0.95rem 2rem;
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: 0.3px;
    border: none;
    border-radius: 999px;
    cursor: pointer;
    transition: transform 0.12s, box-shadow 0.18s, filter 0.18s;
    color: #04130a;
}

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

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

.generate-btn {
    align-self: center;
    background: linear-gradient(135deg, var(--neon-green), var(--cyan));
    box-shadow: 0 0 22px rgba(57, 255, 20, 0.35);
}

.generate-btn:hover {
    filter: brightness(1.08);
    box-shadow: 0 0 32px rgba(57, 255, 20, 0.55);
}

.action-btn {
    display: none;
    margin: 1rem auto 0;
    background: linear-gradient(135deg, var(--neon-purple), var(--pink));
    color: var(--text-primary);
    box-shadow: 0 0 22px rgba(189, 0, 255, 0.35);
}

.action-btn:hover {
    filter: brightness(1.1);
    box-shadow: 0 0 32px rgba(189, 0, 255, 0.55);
}

.state-gameover .action-btn {
    display: block;
    animation: fadeIn 0.4s ease-out;
}

/* ---------------- HUD ---------------- */
.hud {
    display: none;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 560px;
    margin: 0 auto 0.6rem;
    font-family: var(--font-display);
    font-weight: 700;
    gap: 0.75rem;
}

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

.hud-item { white-space: nowrap; }

.hud-dist {
    font-size: 1.5rem;
    color: var(--cyan);
    text-shadow: 0 0 12px rgba(5, 217, 232, 0.5);
}

.hud-progress {
    font-size: 1.1rem;
    color: var(--text-muted);
}

.hud-shield {
    font-size: 1rem;
    color: var(--gold);
    min-width: 4rem;
    text-align: right;
    text-shadow: 0 0 10px rgba(255, 213, 74, 0.5);
}

/* ---------------- Canvas ---------------- */
.canvas-wrapper {
    display: none;
    position: relative;
    width: 100%;
    max-width: 560px;
    aspect-ratio: 16 / 9;
    margin: 0 auto;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid rgba(5, 217, 232, 0.25);
    box-shadow:
        0 0 28px rgba(189, 0, 255, 0.22),
        inset 0 0 18px rgba(5, 217, 232, 0.1);
}

.state-playing .canvas-wrapper,
.state-gameover .canvas-wrapper {
    display: block;
}

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

.touch-hint {
    position: absolute;
    bottom: 0.6rem;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.85rem;
    color: var(--text-muted);
    background: rgba(9, 11, 16, 0.7);
    padding: 0.3rem 0.8rem;
    border-radius: 999px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
}

.state-playing .touch-hint.show {
    opacity: 1;
}

/* ---------------- Result lines ---------------- */
.result-line {
    display: none;
    font-family: var(--font-display);
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--pink);
    text-shadow: 0 0 14px rgba(255, 42, 109, 0.5);
    margin-top: 1rem;
    min-height: 1.4em;
    padding: 0 0.5rem;
}

.best-line {
    display: none;
    font-size: 0.95rem;
    color: var(--text-muted);
    margin-top: 0.4rem;
    min-height: 1.2em;
}

.state-gameover .result-line,
.state-gameover .best-line {
    display: block;
    animation: fadeIn 0.4s ease-out;
}

.state-gameover.new-best .result-line {
    color: var(--gold);
    text-shadow: 0 0 16px rgba(255, 213, 74, 0.6);
}

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

/* ---------------- SEO / how-to ---------------- */
.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; }

.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 while actively running */
.state-playing .how-to-play,
.state-playing .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.75rem; }
    .paste-blurb { font-size: 0.9rem; }
    .game-btn { padding: 0.8rem 1.5rem; font-size: 1rem; }
    .hud-dist { font-size: 1.25rem; }
    .hud-progress { font-size: 0.95rem; }
    .result-line { font-size: 1.1rem; }
    .how-to-play { padding: 1.25rem; }
}
