/* Autocomplete Tennis — FunSlop.com
   Rally word-associations against a for-loop with a grudge. */

: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(--cyan) 0%, transparent 70%);
    opacity: 0.13;
    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, 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: 2rem 1.1rem 6rem;
    max-width: 640px;
    width: 100%;
    margin: 0 auto;
}

.title {
    font-family: var(--font-display);
    font-size: 2.2rem;
    font-weight: 700;
    letter-spacing: -1px;
    margin-bottom: 0.75rem;
    background: linear-gradient(45deg, var(--cyan), var(--neon-green), var(--gold));
    -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.78rem;
}

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

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

/* Secret target banner */
.target-line {
    font-size: 0.95rem;
    color: var(--text-muted);
    margin-bottom: 0.85rem;
    min-height: 1.2em;
    line-height: 1.4;
    transition: transform 0.2s;
}

.target-line .target-word {
    font-family: var(--font-display);
    font-weight: 700;
    color: var(--gold);
    text-shadow: 0 0 12px rgba(255, 213, 74, 0.45);
    letter-spacing: 0.5px;
}

.target-line .target-sub { color: var(--text-muted); font-size: 0.82rem; }

.target-line.target-hit {
    animation: target-pop 0.5s ease-out;
}

@keyframes target-pop {
    0% { transform: scale(1); }
    35% { transform: scale(1.12); }
    100% { transform: scale(1); }
}

/* Scoreboard */
.scoreboard { margin-bottom: 1rem; }

.score {
    font-size: 1.05rem;
    color: var(--text-primary);
    min-height: 1.2em;
}

.best-score {
    font-size: 0.9rem;
    color: var(--text-muted);
    min-height: 1.1em;
    margin-top: 0.15rem;
}

/* The court — the live play surface */
.court {
    background: rgba(255, 255, 255, 0.025);
    border: 1px solid var(--glass-border);
    border-radius: 18px;
    padding: 1.1rem 1rem 1.25rem;
    margin: 0 auto;
}

/* Rally history */
.rally-log {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    max-height: 132px;
    overflow: hidden;
    margin-bottom: 0.9rem;
    min-height: 1.2em;
}

.log-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
    padding: 0.32rem 0.7rem;
    border-radius: 9px;
    font-size: 0.9rem;
    animation: log-in 0.25s ease-out;
}

@keyframes log-in {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.log-who {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    font-weight: 700;
}

.log-word {
    font-family: var(--font-display);
    font-weight: 700;
    letter-spacing: 0.5px;
}

.log-serve  { background: rgba(189, 0, 255, 0.10); }
.log-serve  .log-word { color: var(--neon-purple); }
.log-you    { background: rgba(57, 255, 20, 0.09); }
.log-you    .log-word { color: var(--neon-green); }
.log-model  { background: rgba(5, 217, 232, 0.09); }
.log-model  .log-word { color: var(--cyan); }
.log-whiff  { background: rgba(255, 42, 109, 0.12); }
.log-whiff  .log-word { color: var(--pink); }

/* The current prompt word — the heart of the volley */
.prompt-block { margin: 0.4rem 0 0.6rem; }

.prompt-label {
    font-size: 0.92rem;
    color: var(--text-muted);
    min-height: 1.2em;
    margin-bottom: 0.35rem;
    line-height: 1.35;
}

.prompt-word {
    font-family: var(--font-display);
    font-size: 2.9rem;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--text-primary);
    min-height: 1.2em;
    line-height: 1.1;
    text-shadow: 0 0 1px rgba(9, 11, 16, 0.9), 0 0 22px rgba(5, 217, 232, 0.35);
    transition: transform 0.1s, color 0.2s;
}

.prompt-word.point {
    color: var(--neon-green);
    text-shadow: 0 0 24px rgba(57, 255, 20, 0.6);
    animation: pulse 0.4s ease-out;
}

.prompt-word.whiff {
    color: var(--pink);
    text-shadow: 0 0 24px rgba(255, 42, 109, 0.6);
    animation: shake 0.3s ease-in-out;
}

@keyframes pulse {
    0% { transform: scale(0.85); }
    50% { transform: scale(1.12); }
    100% { transform: scale(1); }
}

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

/* Volley timer bar */
.timerbar {
    height: 8px;
    width: 100%;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 999px;
    overflow: hidden;
    margin: 0.4rem 0 0.3rem;
}

.timerbar-fill {
    height: 100%;
    width: 100%;
    background: var(--cyan);
    border-radius: 999px;
    transition: background 0.2s;
    box-shadow: 0 0 10px currentColor;
}

.timer {
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 700;
    color: var(--cyan);
    min-height: 1.2em;
    margin-bottom: 0.6rem;
}

/* Association chips */
.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
    margin-bottom: 0.85rem;
    min-height: 0;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-family: var(--font-body);
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 0.55rem 0.85rem;
    cursor: pointer;
    transition: transform 0.1s, border-color 0.15s, box-shadow 0.15s, background 0.15s;
    text-transform: lowercase;
}

.chip:hover {
    border-color: var(--neon-green);
    color: var(--neon-green);
    box-shadow: 0 0 16px rgba(57, 255, 20, 0.25);
}

.chip:active { transform: scale(0.94); }

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

.chip-key {
    font-family: var(--font-display);
    font-size: 0.72rem;
    color: var(--bg-dark);
    background: var(--cyan);
    border-radius: 6px;
    padding: 0.05rem 0.4rem;
    font-weight: 700;
}

/* Typed-word input row */
.input-row {
    display: flex;
    gap: 0.55rem;
    justify-content: center;
    align-items: stretch;
}

#word-input {
    flex: 1 1 auto;
    max-width: 320px;
    font-family: var(--font-body);
    font-size: 1.05rem;
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 0.7rem 0.9rem;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

#word-input::placeholder { color: var(--text-muted); }

#word-input:focus {
    border-color: var(--cyan);
    box-shadow: 0 0 14px rgba(5, 217, 232, 0.25);
}

.game-btn {
    font-family: var(--font-body);
    padding: 0.7rem 1.3rem;
    font-size: 1.02rem;
    font-weight: 700;
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.15s, filter 0.15s;
    color: var(--bg-dark);
    background: var(--neon-green);
    box-shadow: 0 0 16px rgba(57, 255, 20, 0.3);
    white-space: nowrap;
}

.game-btn:hover {
    filter: brightness(1.1);
    box-shadow: 0 0 24px rgba(57, 255, 20, 0.5);
}

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

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

.hint {
    font-size: 0.95rem;
    color: var(--text-muted);
    margin-top: 1rem;
    min-height: 1.3em;
    line-height: 1.4;
}

/* ---- State-driven visibility ---- */

/* In idle / gameover: hide the live interactive bits, show "tap to play" cues */
.state-idle .timerbar,
.state-idle .input-row,
.state-gameover .timerbar,
.state-gameover .input-row {
    display: none;
}

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

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

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

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

.state-gameover.new-best .instruction { color: var(--gold); }

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

/* ---- SEO / how-to content ---- */
.how-to-play {
    text-align: left;
    margin: 2.5rem 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 code {
    font-family: 'Space Grotesk', monospace;
    background: rgba(5, 217, 232, 0.1);
    color: var(--cyan);
    padding: 0.05rem 0.35rem;
    border-radius: 5px;
    font-size: 0.9em;
}

.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(9, 11, 16, 0.7);
    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.7rem; }
    .instruction { font-size: 0.98rem; }
    .prompt-word { font-size: 2.3rem; }
    .chip { font-size: 0.95rem; padding: 0.5rem 0.7rem; }
    .score { font-size: 0.98rem; }
    #word-input { font-size: 1rem; }
    .game-btn { padding: 0.65rem 1rem; font-size: 0.95rem; }
    .court { padding: 0.9rem 0.7rem 1.1rem; }
}

@media (max-width: 360px) {
    .prompt-word { font-size: 1.9rem; }
    .control-pill { font-size: 0.78rem; }
}
