/* Vector Tug-of-War — FunSlop.com
   Word-analogy arithmetic puzzle. Drag word tiles into +/- slots, or pick from
   multiple choice, before the embedding budget runs out. Neon-on-near-black. */

: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;
}

* {
    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 */
.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 1rem 6rem;
    max-width: 640px;
    width: 100%;
    margin: 0 auto;
}

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

/* ---- HUD ---- */
.hud {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 0.6rem;
}

.hud-cell {
    font-family: var(--font-display);
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--glass-border);
    border-radius: 999px;
    padding: 0.35rem 0.85rem;
    white-space: nowrap;
}

#hud-score { color: var(--neon-green); }
#hud-streak { color: var(--gold); }
#hud-timer { color: var(--cyan); }
#hud-timer.urgent { color: var(--pink); animation: blink 0.5s ease-in-out infinite; }

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ---- Timer bar ---- */
.timer-bar {
    width: 100%;
    max-width: 420px;
    height: 6px;
    margin: 0 auto 1rem;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 999px;
    overflow: hidden;
}

.timer-bar-fill {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, var(--cyan), var(--neon-green));
    border-radius: 999px;
    transition: width 0.1s linear;
}

.timer-bar-fill.urgent {
    background: linear-gradient(90deg, var(--pink), var(--gold));
}

.instruction {
    font-size: 1.05rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
    min-height: 1.4em;
    padding: 0 0.5rem;
}

/* ---- Puzzle area ---- */
.puzzle {
    min-height: 9rem;
    margin-bottom: 0.75rem;
}

.idle-hint {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-top: 1.25rem;
}

/* analogy / equation line */
.analogy-line,
.eq-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.4rem 0.55rem;
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0.5rem 0 1.25rem;
}

.analogy-line .word,
.eq-row .word {
    color: var(--text-primary);
    text-shadow: 0 0 12px rgba(5, 217, 232, 0.25);
}

.analogy-line .word.target,
.eq-row .word.target {
    color: var(--neon-green);
    text-shadow: 0 0 14px rgba(57, 255, 20, 0.5);
}

.eq-row .word.base { color: var(--cyan); }

.op {
    font-weight: 700;
    color: var(--text-muted);
}

.op.plus { color: var(--neon-green); }
.op.minus { color: var(--pink); }
.op.eq { color: var(--text-muted); }
.op.rel, .op.as {
    font-family: var(--font-body);
    font-size: 0.85rem;
    font-weight: 300;
    font-style: italic;
    color: var(--text-muted);
}

/* ---- Multiple-choice grid ---- */
.choices {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.7rem;
    max-width: 440px;
    margin: 0 auto;
}

.choice {
    position: relative;
    font-family: var(--font-body);
    font-size: 1.15rem;
    font-weight: 500;
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--glass-border);
    border-radius: 14px;
    padding: 0.95rem 0.75rem;
    cursor: pointer;
    transition: transform 0.1s, border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.choice:hover {
    border-color: var(--cyan);
    box-shadow: 0 0 18px rgba(5, 217, 232, 0.25);
}

.choice:active { transform: scale(0.97); }

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

.choice-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.3rem;
    height: 1.3rem;
    margin-right: 0.4rem;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.06);
    border-radius: 6px;
    vertical-align: middle;
}

.choice.correct {
    border-color: var(--neon-green);
    background: rgba(57, 255, 20, 0.14);
    box-shadow: 0 0 22px rgba(57, 255, 20, 0.4);
    animation: pop 0.25s ease-out;
}

.choice.wrong {
    border-color: var(--pink);
    background: rgba(255, 42, 109, 0.14);
    animation: shake 0.25s ease-in-out;
}

.choice.reveal {
    border-color: var(--neon-green);
    box-shadow: 0 0 16px rgba(57, 255, 20, 0.3);
}

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

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

/* ---- Equation puzzle ---- */
.eq-target {
    font-size: 1.05rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.eq-target strong {
    color: var(--neon-green);
    font-family: var(--font-display);
    text-shadow: 0 0 12px rgba(57, 255, 20, 0.45);
}

.slot {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 5.2rem;
    min-height: 2.8rem;
    padding: 0.2rem;
    border: 2px dashed rgba(189, 0, 255, 0.5);
    border-radius: 12px;
    background: rgba(189, 0, 255, 0.06);
    transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
    vertical-align: middle;
}

.slot.over {
    border-color: var(--cyan);
    background: rgba(5, 217, 232, 0.12);
    box-shadow: 0 0 16px rgba(5, 217, 232, 0.3);
}

.slot.correct {
    border-style: solid;
    border-color: var(--neon-green);
    background: rgba(57, 255, 20, 0.12);
    box-shadow: 0 0 18px rgba(57, 255, 20, 0.4);
}

.slot.wrong {
    border-style: solid;
    border-color: var(--pink);
    background: rgba(255, 42, 109, 0.12);
    animation: shake 0.25s ease-in-out;
}

/* tile bank + tiles */
.tile-bank {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    justify-content: center;
    margin-top: 0.5rem;
    min-height: 3rem;
}

.tile {
    font-family: var(--font-body);
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--text-primary);
    background: linear-gradient(135deg, rgba(5, 217, 232, 0.16), rgba(189, 0, 255, 0.16));
    border: 1px solid rgba(5, 217, 232, 0.4);
    border-radius: 12px;
    padding: 0.7rem 1.1rem;
    cursor: grab;
    touch-action: manipulation;
    transition: transform 0.1s, box-shadow 0.15s, border-color 0.15s;
}

.tile:hover {
    border-color: var(--cyan);
    box-shadow: 0 0 16px rgba(5, 217, 232, 0.3);
}

.tile:active { cursor: grabbing; transform: scale(0.96); }

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

.tile.selected {
    border-color: var(--gold);
    box-shadow: 0 0 18px rgba(255, 213, 74, 0.5);
    transform: translateY(-2px);
}

.tile.dragging { opacity: 0.5; }

.tile.placed {
    margin: 0;
    padding: 0.45rem 0.7rem;
    font-size: 1rem;
    background: linear-gradient(135deg, rgba(57, 255, 20, 0.18), rgba(5, 217, 232, 0.18));
}

/* ---- Feedback line ---- */
.feedback {
    font-size: 1rem;
    min-height: 1.5em;
    margin: 0.4rem 0 0.8rem;
    color: var(--text-muted);
    padding: 0 0.5rem;
}

.feedback.good { color: var(--neon-green); }
.feedback.good strong { color: var(--gold); }
.feedback.bad { color: var(--pink); }
.feedback.warn { color: var(--gold); }

.reveal-ans {
    color: var(--text-muted);
    font-style: italic;
    font-size: 0.9rem;
}

/* ---- Action row + button ---- */
.action-row {
    display: flex;
    justify-content: center;
    margin-bottom: 0.6rem;
    min-height: 3.4rem;
}

.game-btn {
    font-family: var(--font-display);
    padding: 0.9rem 2.4rem;
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    border: none;
    border-radius: 999px;
    cursor: pointer;
    color: #04130a;
    background: linear-gradient(135deg, var(--neon-green), var(--cyan));
    box-shadow: 0 0 22px rgba(57, 255, 20, 0.35);
    transition: transform 0.12s, box-shadow 0.15s, opacity 0.15s;
}

.game-btn:hover {
    transform: scale(1.04);
    box-shadow: 0 0 32px rgba(57, 255, 20, 0.6);
}

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

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

/* During analogy rounds the primary button is irrelevant — keep layout but hide it */
.game-btn.hidden-soft {
    visibility: hidden;
}

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

/* ---- Game over summary ---- */
.gameover-summary {
    margin: 1rem auto 0;
    max-width: 420px;
}

.go-score {
    font-family: var(--font-display);
    font-size: 2.6rem;
    font-weight: 700;
    color: var(--gold);
    text-shadow: 0 0 18px rgba(255, 213, 74, 0.45);
}

.go-line {
    font-size: 1.05rem;
    color: var(--text-muted);
    margin: 0.4rem 0 0.7rem;
}

.go-line strong { color: var(--text-primary); }

.go-verdict {
    font-size: 1rem;
    color: var(--cyan);
    font-style: italic;
    padding: 0 0.5rem;
}

.state-gameover.new-best .go-score {
    animation: pop 0.45s ease-out;
}

/* ---- State visibility ---- */
.state-idle .timer-bar { opacity: 0.4; }

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

.how-to-play .hl-plus { color: var(--neon-green); font-weight: 700; }
.how-to-play .hl-minus { color: var(--pink); font-weight: 700; }

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

/* Hide SEO content during active gameplay to keep focus on the puzzle */
.state-playing .how-to-play,
.state-playing .related-games,
.state-feedback .how-to-play,
.state-feedback .related-games {
    display: none;
}

/* ---- Responsive ---- */
@media (max-width: 600px) {
    .title { font-size: 1.65rem; }
    .instruction { font-size: 0.95rem; }
    .analogy-line, .eq-row { font-size: 1.2rem; gap: 0.35rem 0.45rem; }
    .op.rel, .op.as { font-size: 0.78rem; }
    .choice { font-size: 1.02rem; padding: 0.85rem 0.6rem; }
    .tile { font-size: 1rem; padding: 0.6rem 0.9rem; }
    .slot { min-width: 4.4rem; min-height: 2.6rem; }
    .game-btn { padding: 0.8rem 1.9rem; font-size: 1.05rem; }
    .go-score { font-size: 2.1rem; }
}

@media (max-width: 360px) {
    .choices { gap: 0.5rem; }
    .choice { font-size: 0.95rem; padding: 0.75rem 0.5rem; }
    .analogy-line, .eq-row { font-size: 1.05rem; }
}
