/* Copilot — FunSlop.com
   Accept or reject the AI's autocomplete to type the target fastest.
   Neon-on-near-black; trust calibration disguised as a typing test. */

:root {
    --bg-dark: #090b10;
    --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;
    --font-mono: 'Space Grotesk', ui-monospace, 'SF Mono', Menlo, monospace;
}

* {
    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 — house style. Cyan to match the "code editor" vibe. */
.glow-bg {
    position: fixed;
    top: -80px;
    left: -80px;
    width: 360px;
    height: 360px;
    background: radial-gradient(circle, var(--cyan) 0%, transparent 70%);
    opacity: 0.12;
    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: 2.25rem 1.25rem 6rem;
    max-width: 680px;
    width: 100%;
    margin: 0 auto;
}

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

/* Control hint pills */
.controls-inline {
    display: flex;
    gap: 0.6rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.control-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    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;
}

.control-pill .key {
    font-weight: 700;
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.06);
    border-radius: 6px;
    padding: 0.1rem 0.45rem;
    font-size: 0.8rem;
}

.control-pill.action .key { color: var(--neon-green); }
.control-pill.special .key { color: var(--pink); }
.control-pill.type .key { color: var(--cyan); }

/* HUD: timer / progress / accuracy */
.hud {
    display: flex;
    gap: 1.25rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 0.4rem;
    min-height: 1.6em;
}

.hud-item {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.05rem;
}

.timer { color: var(--cyan); }
.timer.low { color: var(--pink); animation: blink 0.8s infinite alternate; }
.score { color: var(--neon-green); }
.accuracy { color: var(--gold); }

@keyframes blink { from { opacity: 1; } to { opacity: 0.45; } }

.best-score {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 0.9rem;
    min-height: 1.2em;
    line-height: 1.4;
}

.instruction {
    font-size: 1.05rem;
    color: var(--text-primary);
    margin-bottom: 1rem;
    min-height: 1.4em;
    line-height: 1.4;
}

/* The editor — ghost target behind, your text in front */
.editor {
    position: relative;
    text-align: left;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--glass-border);
    border-radius: 14px;
    padding: 1.1rem 1.2rem;
    min-height: 8.5rem;
    margin: 0 auto 1rem;
    max-width: 600px;
    cursor: text;
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
}

.state-playing .editor {
    border-color: rgba(5, 217, 232, 0.4);
    box-shadow: 0 0 22px rgba(5, 217, 232, 0.12);
}

.editor.flash-good { animation: flash-good 0.3s ease-out; }
.editor.flash-wrong { animation: flash-wrong 0.3s ease-out; }

@keyframes flash-good {
    0% { box-shadow: 0 0 0 0 rgba(57, 255, 20, 0.55); }
    100% { box-shadow: 0 0 22px rgba(5, 217, 232, 0.12); }
}
@keyframes flash-wrong {
    0% { box-shadow: 0 0 0 0 rgba(255, 42, 109, 0.6); transform: translateX(0); }
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
    100% { box-shadow: 0 0 22px rgba(5, 217, 232, 0.12); transform: translateX(0); }
}

.doc {
    font-family: var(--font-mono);
    font-size: 1.15rem;
    line-height: 1.75;
    letter-spacing: 0.2px;
    word-break: break-word;
    white-space: pre-wrap;
}

.typed { color: var(--text-primary); }
.typed .err {
    color: var(--pink);
    background: rgba(255, 42, 109, 0.18);
    border-radius: 3px;
    text-decoration: underline wavy var(--pink);
}

.caret {
    display: inline-block;
    width: 2px;
    height: 1.2em;
    background: var(--neon-green);
    vertical-align: text-bottom;
    margin: 0 -1px;
    animation: caret-blink 1s steps(1) infinite;
}
.state-idle .caret,
.state-gameover .caret { display: none; }

@keyframes caret-blink { 50% { opacity: 0; } }

.ghost { color: var(--text-muted); opacity: 0.5; }

/* Suggestion chip row */
.suggestion-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    flex-wrap: wrap;
    min-height: 2.6rem;
    margin-bottom: 0.5rem;
    opacity: 0;
    transition: opacity 0.15s;
}
.suggestion-row.visible { opacity: 1; }

.suggestion-label {
    font-size: 0.82rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.suggestion-chip {
    font-family: var(--font-mono);
    font-size: 1.05rem;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.04);
    border: 1px dashed var(--glass-border);
    border-radius: 10px;
    padding: 0.35rem 0.8rem;
    min-height: 1.6em;
    transition: all 0.15s;
}

/* Active suggestion — styled neutrally on purpose; revealing slop would
   defeat the entire game. The player must judge the TEXT, not the color. */
.suggestion-chip.active {
    color: var(--cyan);
    border: 1px solid rgba(5, 217, 232, 0.5);
    background: rgba(5, 217, 232, 0.08);
    box-shadow: 0 0 14px rgba(5, 217, 232, 0.18);
    animation: chip-in 0.18s ease-out;
}

.suggestion-chip.muted {
    color: var(--text-muted);
    font-style: italic;
    border-style: dashed;
}

@keyframes chip-in {
    from { transform: translateY(4px) scale(0.96); opacity: 0; }
    to { transform: translateY(0) scale(1); opacity: 1; }
}

/* Action buttons */
.buttons {
    display: none;
    gap: 1rem;
    justify-content: center;
    margin-top: 0.5rem;
}
.state-playing .buttons { display: flex; }

.game-btn {
    font-family: var(--font-body);
    padding: 0.9rem 1.6rem;
    font-size: 1.05rem;
    font-weight: 700;
    border: 1px solid var(--glass-border);
    border-radius: 14px;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.15s, filter 0.15s;
    min-width: 130px;
    color: var(--bg-dark);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.game-btn:active { transform: scale(0.95); }
.game-btn:focus-visible { outline: 3px solid var(--cyan); outline-offset: 2px; }

.game-btn .kbd {
    font-size: 0.72rem;
    font-weight: 700;
    background: rgba(0, 0, 0, 0.22);
    border-radius: 5px;
    padding: 0.05rem 0.35rem;
    margin-left: 0.45rem;
}

.btn-accept {
    background: var(--neon-green);
    box-shadow: 0 0 18px rgba(57, 255, 20, 0.35);
}
.btn-accept:hover { filter: brightness(1.1); box-shadow: 0 0 26px rgba(57, 255, 20, 0.5); }

.btn-reject {
    background: var(--pink);
    box-shadow: 0 0 18px rgba(255, 42, 109, 0.35);
}
.btn-reject:hover { filter: brightness(1.1); box-shadow: 0 0 26px rgba(255, 42, 109, 0.5); }

.hint {
    font-size: 0.95rem;
    color: var(--text-muted);
    margin-top: 1.25rem;
    min-height: 1.2em;
}

/* Hidden input to summon the mobile soft keyboard. Kept off-screen but
   focusable; opacity 0 so it never shows. */
.ghost-input {
    position: absolute;
    left: -9999px;
    top: 0;
    width: 1px;
    height: 1px;
    opacity: 0;
    border: 0;
    padding: 0;
    pointer-events: none;
}

/* Hide control hints once a run is underway or finished */
.state-playing .controls-inline,
.state-gameover .controls-inline { display: none; }

.state-idle, .state-gameover { cursor: pointer; }
.state-idle .buttons, .state-gameover .buttons { display: none; }
.state-idle .suggestion-row, .state-gameover .suggestion-row { opacity: 0; }

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

@keyframes score-pop {
    0% { transform: scale(0.85); opacity: 0; }
    50% { transform: scale(1.08); }
    100% { transform: scale(1); opacity: 1; }
}

/* 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; }

.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); }

/* 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; }
    .instruction { font-size: 0.98rem; }
    .doc { font-size: 1.02rem; line-height: 1.65; }
    .editor { min-height: 9rem; padding: 1rem; }
    .hud { gap: 0.9rem; }
    .hud-item { font-size: 0.95rem; }
    .suggestion-chip { font-size: 0.98rem; }
    .game-btn { padding: 0.85rem 1.2rem; font-size: 0.98rem; min-width: 120px; }
}

@media (max-width: 360px) {
    .game-btn { min-width: 110px; padding: 0.8rem 0.9rem; }
    .controls-inline { gap: 0.4rem; }
    .control-pill { font-size: 0.78rem; padding: 0.3rem 0.6rem; }
}
