/* Tokenizer — FunSlop.com
   BPE-as-a-speed-puzzle. Tap the gaps between characters to chop text into
   the tokens the model secretly uses. Neon-on-near-black, self-contained. */

: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, BlinkMacSystemFont, 'Segoe UI', Roboto, 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, FunSlop house style */
.glow-bg {
    position: fixed;
    top: -90px;
    right: -90px;
    width: 380px;
    height: 380px;
    background: radial-gradient(circle, var(--cyan) 0%, transparent 70%);
    opacity: 0.13;
    z-index: -1;
    filter: blur(60px);
    pointer-events: none;
    animation: float 13s infinite alternate;
}

@keyframes float {
    0% { transform: translate(0, 0); }
    100% { transform: translate(-120px, 80px); }
}

.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 1rem 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 hints */
.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(--cyan); }
.control-pill.special .key { color: var(--neon-green); }

/* HUD: timer / score / streak */
.hud {
    display: flex;
    justify-content: center;
    align-items: baseline;
    gap: 1.4rem;
    flex-wrap: wrap;
    margin-bottom: 0.75rem;
    font-family: var(--font-display);
}

.hud-timer {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--cyan);
    min-width: 3.4ch;
}

.hud-timer.urgent {
    color: var(--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; }
}

.hud-score {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--neon-green);
}

.hud-streak {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-muted);
    transition: color 0.2s, text-shadow 0.2s;
}

.hud-streak.hot {
    color: var(--gold);
    text-shadow: 0 0 12px rgba(255, 213, 74, 0.6);
}

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

/* ===== The chop board — the heart of the game ===== */
.chop-area {
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    justify-content: center;
    gap: 0;
    margin: 0.5rem auto 0.5rem;
    padding: 1rem 0.5rem;
    min-height: 6rem;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--glass-border);
    transition: box-shadow 0.2s, border-color 0.2s;
}

/* Each character tile */
.char {
    font-family: var(--font-display);
    font-size: 2.5rem;
    font-weight: 700;
    line-height: 1;
    padding: 0.55rem 0.05rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0.7em;
    text-shadow: 0 0 1px rgba(9, 11, 16, 0.9), 0 0 10px rgba(5, 217, 232, 0.25);
}

.char.is-space {
    color: var(--text-muted);
}

/* The tappable gap between two characters */
.gap {
    position: relative;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    width: 1.5rem;          /* generous touch target */
    align-self: stretch;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
}

.gap:focus-visible {
    outline: 2px solid var(--cyan);
    outline-offset: -2px;
    border-radius: 6px;
}

/* The hairline shown in the gap */
.gap-line {
    width: 3px;
    height: 60%;
    border-radius: 3px;
    background: rgba(139, 155, 180, 0.18);
    transition: background 0.12s, box-shadow 0.12s, height 0.12s, width 0.12s;
}

.gap:hover .gap-line {
    background: rgba(5, 217, 232, 0.5);
}

/* A committed cut — bright neon scissor line */
.gap.cut .gap-line {
    width: 4px;
    height: 92%;
    background: var(--neon-green);
    box-shadow: 0 0 12px rgba(57, 255, 20, 0.85);
}

/* Where the model would actually cut (shown after submit, as a teaching cue) */
.gap.truth .gap-line {
    width: 4px;
    height: 92%;
    background: var(--gold);
    box-shadow: 0 0 12px rgba(255, 213, 74, 0.85);
}

.gap.cut.truth .gap-line {
    background: var(--neon-green); /* you got it right — keep it green */
}

/* Board feedback flashes on submit */
.chop-area.flash-good {
    border-color: var(--neon-green);
    box-shadow: 0 0 28px rgba(57, 255, 20, 0.35);
    animation: pop 0.3s ease-out;
}

.chop-area.flash-mid {
    border-color: var(--gold);
    box-shadow: 0 0 24px rgba(255, 213, 74, 0.3);
}

.chop-area.flash-bad {
    border-color: var(--pink);
    box-shadow: 0 0 24px rgba(255, 42, 109, 0.3);
    animation: shake 0.25s ease-in-out;
}

@keyframes pop {
    0% { transform: scale(1); }
    45% { transform: scale(1.03); }
    100% { transform: scale(1); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-8px); }
    75% { transform: translateX(8px); }
}

/* In the idle demo, dim the gaps so it reads as a preview, not interactive */
.chop-area.demo .gap { cursor: default; }
.chop-area.demo .gap.cut .gap-line {
    background: var(--cyan);
    box-shadow: 0 0 12px rgba(5, 217, 232, 0.7);
}

/* Live token readout / verdict line */
.readout {
    font-family: var(--font-display);
    font-size: 1.05rem;
    color: var(--cyan);
    margin: 0.5rem auto 0.75rem;
    min-height: 2.6em;
    line-height: 1.35;
    max-width: 620px;
    word-break: break-word;
}

/* Buttons */
.buttons {
    display: none;
    gap: 0.85rem;
    justify-content: center;
    margin-top: 0.5rem;
    flex-wrap: wrap;
}

.state-playing .buttons {
    display: flex;
}

.game-btn {
    font-family: var(--font-body);
    padding: 0.85rem 1.7rem;
    font-size: 1.1rem;
    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;
    color: var(--bg-dark);
}

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

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

.btn-submit {
    background: var(--neon-green);
    box-shadow: 0 0 18px rgba(57, 255, 20, 0.35);
    min-width: 150px;
}

.btn-submit:hover {
    filter: brightness(1.1);
    box-shadow: 0 0 26px rgba(57, 255, 20, 0.55);
}

.btn-clear {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
    border: 1px solid var(--glass-border);
}

.btn-clear:hover {
    border-color: var(--pink);
    color: var(--pink);
}

/* Start / replay button — shown only in idle + gameover */
.btn-start {
    display: none;
    margin: 0.75rem auto 0;
    background: linear-gradient(135deg, var(--cyan), var(--neon-green));
    box-shadow: 0 0 22px rgba(5, 217, 232, 0.35);
    padding: 0.95rem 2.6rem;
    font-size: 1.2rem;
    font-family: var(--font-display);
    letter-spacing: 0.5px;
    border-radius: 999px;
}

.btn-start:hover {
    filter: brightness(1.08);
    box-shadow: 0 0 32px rgba(5, 217, 232, 0.55);
}

.state-idle .btn-start,
.state-gameover .btn-start {
    display: inline-block;
}

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

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

/* Hide control hints + readout chrome once a run starts or ends */
.state-playing .controls-inline,
.state-gameover .controls-inline {
    display: none;
}

.state-idle,
.state-gameover {
    cursor: pointer;
}

/* New best celebration */
.state-gameover.new-best .hud-score,
.state-gameover.new-best .readout {
    color: var(--gold);
    text-shadow: 0 0 14px rgba(255, 213, 74, 0.5);
}

.state-gameover.new-best .instruction {
    color: var(--gold);
    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 em { color: var(--neon-green); font-style: normal; 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); }
.fun-fact em { color: var(--cyan); font-style: normal; }

.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 to keep focus on the board */
.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; }
    .instruction { font-size: 0.98rem; }
    .char { font-size: 1.9rem; padding: 0.5rem 0.02rem; }
    .gap { width: 1.25rem; }
    .hud-timer { font-size: 1.3rem; }
    .hud-score { font-size: 1.15rem; }
    .readout { font-size: 0.95rem; }
    .game-btn { padding: 0.75rem 1.4rem; font-size: 1rem; }
    .btn-start { padding: 0.85rem 2rem; font-size: 1.1rem; }
}

/* Very narrow phones (down to 320px): shrink tiles so long words still fit */
@media (max-width: 380px) {
    .char { font-size: 1.55rem; }
    .gap { width: 1rem; }
    .hud { gap: 1rem; }
}
