/* Overfit — FunSlop.com
   The bias-variance tradeoff as a canvas drawing game. Self-contained,
   neon-on-near-black, mobile-first. */

:root {
    --bg-dark: #090b10;
    --bg-canvas: #0c0f17;
    --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', var(--font-body);
    --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);
    background-image:
        radial-gradient(circle at 14% 16%, rgba(189, 0, 255, 0.16), transparent 44%),
        radial-gradient(circle at 86% 84%, rgba(5, 217, 232, 0.13), transparent 46%),
        radial-gradient(circle at 50% 50%, rgba(57, 255, 20, 0.04), transparent 60%);
    color: var(--text-primary);
}

.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: 1.75rem 1rem 6rem;
    max-width: 560px;
    width: 100%;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
}

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

.header-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 400px;
    margin-bottom: 0.75rem;
    gap: 1rem;
    min-height: 1.4rem;
}

.round-display {
    font-family: var(--font-display);
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--neon-purple);
    text-shadow: 0 0 12px rgba(189, 0, 255, 0.55);
    white-space: nowrap;
}

.best-display {
    font-size: 0.95rem;
    color: var(--gold);
    text-shadow: 0 0 10px rgba(255, 213, 74, 0.4);
    white-space: nowrap;
}

/* The canvas — the heart of the game */
.canvas-wrapper {
    position: relative;
    width: min(92vw, 400px);
    aspect-ratio: 1;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid rgba(189, 0, 255, 0.28);
    box-shadow:
        0 0 28px rgba(189, 0, 255, 0.25),
        inset 0 0 18px rgba(5, 217, 232, 0.1);
}

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

.state-classified #canvas,
.state-gameover #canvas {
    cursor: default;
}

.overlay-msg {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: var(--font-display);
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--cyan);
    text-shadow: 0 0 14px rgba(5, 217, 232, 0.7), 0 0 4px #000;
    pointer-events: none;
    text-align: center;
    padding: 0 1rem;
}

.overlay-msg:not(:empty) {
    animation: pulse-msg 0.8s ease-in-out infinite;
}

@keyframes pulse-msg {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.status-line {
    font-size: 1rem;
    color: var(--text-primary);
    margin: 0.9rem auto 0;
    max-width: 420px;
    min-height: 2.6em;
    line-height: 1.35;
}

.stats {
    display: flex;
    justify-content: center;
    gap: 1.75rem;
    margin-top: 0.5rem;
    font-family: var(--font-display);
    font-size: 1.2rem;
    font-weight: 700;
    min-height: 1.5em;
}

.stat-train {
    color: var(--cyan);
    text-shadow: 0 0 10px rgba(5, 217, 232, 0.45);
}

.stat-test {
    color: var(--text-muted);
    transition: color 0.2s, text-shadow 0.2s;
}

.stat-test.revealed {
    color: var(--neon-green);
    text-shadow: 0 0 12px rgba(57, 255, 20, 0.55);
}

/* When we flagged the run as overfit, paint the test number as a warning */
.overfit-flag .stat-test.revealed {
    color: var(--pink);
    text-shadow: 0 0 14px rgba(255, 42, 109, 0.6);
    animation: shake 0.3s ease-in-out;
}

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

.verdict {
    font-size: 1rem;
    color: var(--text-muted);
    margin: 0.6rem auto 0;
    max-width: 440px;
    min-height: 2.6em;
    line-height: 1.4;
}

.state-classified .verdict,
.state-gameover .verdict {
    color: var(--text-primary);
}

.overfit-flag .verdict {
    color: var(--pink);
}

.new-best .verdict {
    color: var(--gold);
    text-shadow: 0 0 10px rgba(255, 213, 74, 0.35);
}

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

.game-btn {
    font-family: var(--font-display);
    padding: 0.85rem 1.8rem;
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: 0.3px;
    border: none;
    border-radius: 999px;
    cursor: pointer;
    transition: transform 0.12s, box-shadow 0.15s, filter 0.15s, opacity 0.15s;
    color: #04130a;
}

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

.game-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(5, 217, 232, 0.6);
}

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

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

.btn-primary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    filter: grayscale(0.5);
    box-shadow: none;
}

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

.btn-secondary:hover {
    border-color: var(--neon-purple);
    color: var(--neon-purple);
}

/* Show / hide the secondary button by state */
.state-idle .btn-secondary {
    display: none;
}

/* SEO / how-to content */
.how-to-play {
    text-align: left;
    margin: 2.5rem auto 0;
    max-width: 520px;
    width: 100%;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 1.6rem;
}

.how-to-play h2 {
    font-family: var(--font-display);
    font-size: 1.35rem;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
}

.how-to-play h3 {
    font-family: var(--font-display);
    font-size: 1.05rem;
    margin: 1.2rem 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; }
.how-to-play .blue-text { color: var(--cyan); }
.how-to-play .red-text { color: var(--pink); }

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

.related-games {
    margin: 2rem auto 0;
    max-width: 520px;
    width: 100%;
    text-align: center;
}

.related-games h3 {
    font-family: var(--font-display);
    font-size: 1.05rem;
    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(5, 217, 232, 0.07);
    border: 1px solid rgba(5, 217, 232, 0.22);
    border-radius: 999px;
    padding: 0.45rem 1rem;
    font-size: 0.9rem;
    transition: border-color 0.2s, color 0.2s, box-shadow 0.2s;
}

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

/* Hide SEO content during active play to keep focus on the canvas */
.state-drawing .how-to-play,
.state-drawing .related-games,
.state-classified .how-to-play,
.state-classified .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(17, 20, 31, 0.8);
    border: 1px solid var(--glass-border);
    border-radius: 999px;
    backdrop-filter: blur(8px);
    transition: border-color 0.2s, color 0.2s, box-shadow 0.2s;
    z-index: 10;
}

.home-link:hover {
    border-color: var(--neon-purple);
    color: var(--neon-purple);
    box-shadow: 0 0 18px rgba(189, 0, 255, 0.3);
}

.home-link:active {
    transform: translateX(-50%) scale(0.95);
}

.home-link:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(5, 217, 232, 0.6);
}

/* Responsive */
@media (max-width: 600px) {
    .title { font-size: 1.8rem; }
    .status-line { font-size: 0.95rem; }
    .stats { font-size: 1.05rem; gap: 1.4rem; }
    .verdict { font-size: 0.92rem; }
    .game-btn { padding: 0.75rem 1.4rem; font-size: 0.98rem; }
    .round-display { font-size: 1rem; }
}

@media (max-width: 360px) {
    .game-btn { padding: 0.7rem 1.1rem; font-size: 0.9rem; }
    .buttons { gap: 0.6rem; }
}
