/* Few-Shot — FunSlop.com
   Teach a hidden concept to a tiny model with as few labeled examples as
   possible. Sample-efficiency puzzle, neon-on-near-black house style. */

: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;
    right: -80px;
    width: 380px;
    height: 380px;
    background: radial-gradient(circle, var(--cyan) 0%, transparent 70%);
    opacity: 0.12;
    z-index: -1;
    filter: blur(60px);
    pointer-events: none;
    animation: float 14s 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: 2.25rem 1.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-purple));
    -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(--cyan); }
.control-pill.special .key { color: var(--gold); }

.instruction {
    font-size: 1.1rem;
    line-height: 1.4;
    color: var(--text-primary);
    margin: 0 auto 0.85rem;
    min-height: 2.6em;
    max-width: 560px;
}

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

.hud-item {
    font-family: var(--font-display);
    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.25rem 0.7rem;
}

.hud-acc { color: var(--cyan); }

/* Accuracy / generalization bar */
.accuracy-bar {
    width: 100%;
    max-width: 480px;
    height: 14px;
    margin: 0 auto 1.1rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    overflow: hidden;
}

.accuracy-fill {
    height: 100%;
    width: 0%;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--pink), var(--cyan));
    box-shadow: 0 0 12px rgba(5, 217, 232, 0.5);
    transition: width 0.35s cubic-bezier(0.2, 0.8, 0.2, 1), background 0.3s;
}

.accuracy-fill.full {
    background: linear-gradient(90deg, var(--neon-green), var(--gold));
    box-shadow: 0 0 18px rgba(57, 255, 20, 0.7);
}

.accuracy-fill.flash-fail { animation: bar-shake 0.3s ease-in-out; }
.accuracy-fill.flash-warn { animation: bar-pulse 0.4s ease-out; }

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

@keyframes bar-pulse {
    0% { filter: brightness(1); }
    50% { filter: brightness(1.6); }
    100% { filter: brightness(1); }
}

/* The board of items */
.board {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.6rem;
    margin: 0 auto 1.25rem;
    max-width: 480px;
    width: 100%;
}

/* Hide the board entirely on idle / gameover (no stray empty cells) */
.state-idle .board,
.state-gameover .board {
    display: none;
}

.item {
    position: relative;
    aspect-ratio: 1 / 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.03);
    border: 1.5px solid var(--glass-border);
    border-radius: 14px;
    cursor: pointer;
    padding: 0;
    font-family: var(--font-body);
    transition: transform 0.12s, border-color 0.18s, box-shadow 0.18s, background 0.18s;
    overflow: hidden;
}

.item:hover {
    border-color: rgba(255, 255, 255, 0.25);
    transform: translateY(-2px);
}

.item:active { transform: scale(0.95); }

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

.glyphs {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.05em;
    line-height: 1;
    text-shadow: 0 0 6px var(--ink), 0 0 1px rgba(9, 11, 16, 0.9);
    padding: 0.25rem;
}

.glyphs.sz-small { font-size: 1.5rem; }
.glyphs.sz-big { font-size: 2.4rem; }

/* Dashed-border items get a visibly "unstable" ring around the glyph cluster */
.glyphs.bd-dashed {
    border: 2px dashed currentColor;
    border-radius: 10px;
    padding: 0.15rem 0.3rem;
    opacity: 0.95;
}
.glyphs.bd-solid {
    border: 2px solid transparent;
    padding: 0.15rem 0.3rem;
}

/* Label badge (the +/-) shown in the corner */
.label-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1rem;
    line-height: 1;
    opacity: 0;
    transform: scale(0.4);
    transition: opacity 0.15s, transform 0.15s;
}

.item.label-pos {
    border-color: var(--neon-green);
    background: rgba(57, 255, 20, 0.1);
    box-shadow: 0 0 14px rgba(57, 255, 20, 0.3);
}
.item.label-pos .label-badge {
    opacity: 1;
    transform: scale(1);
    background: var(--neon-green);
    color: var(--bg-dark);
}
.item.label-pos .label-badge::before { content: '+'; }

.item.label-neg {
    border-color: var(--pink);
    background: rgba(255, 42, 109, 0.1);
    box-shadow: 0 0 14px rgba(255, 42, 109, 0.3);
}
.item.label-neg .label-badge {
    opacity: 1;
    transform: scale(1);
    background: var(--pink);
    color: var(--bg-dark);
}
.item.label-neg .label-badge::before { content: '−'; }

/* Revealed truth on solve (dimmed, non-interactive) */
.item.revealed-pos {
    border-color: var(--neon-green);
    background: rgba(57, 255, 20, 0.14);
    cursor: default;
}
.item.revealed-pos .label-badge {
    opacity: 1; transform: scale(1);
    background: var(--neon-green); color: var(--bg-dark);
}
.item.revealed-pos .label-badge::before { content: '+'; }

.item.revealed-neg {
    border-color: rgba(255, 42, 109, 0.4);
    background: rgba(255, 255, 255, 0.02);
    cursor: default;
    opacity: 0.55;
}
.item.revealed-neg .label-badge {
    opacity: 1; transform: scale(1);
    background: rgba(255, 42, 109, 0.5); color: var(--bg-dark);
}
.item.revealed-neg .label-badge::before { content: '−'; }

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

.game-btn {
    font-family: var(--font-body);
    padding: 0.9rem 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-test {
    background: var(--cyan);
    box-shadow: 0 0 18px rgba(5, 217, 232, 0.35);
}
.btn-test:hover { filter: brightness(1.1); box-shadow: 0 0 26px rgba(5, 217, 232, 0.5); }

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

.btn-start {
    background: var(--neon-purple);
    color: var(--text-primary);
    box-shadow: 0 0 18px rgba(189, 0, 255, 0.4);
}
.btn-start:hover { filter: brightness(1.15); box-shadow: 0 0 26px rgba(189, 0, 255, 0.55); }

/* Button visibility per state */
.btn-test, .btn-next, .btn-start { display: none; }
.state-idle .btn-start,
.state-gameover .btn-start { display: inline-block; }
.state-playing .btn-test { display: inline-block; }
.state-solved .btn-next { display: inline-block; }

/* Hide control hints once finished */
.state-gameover .controls-inline { display: none; }

.hint {
    font-size: 0.95rem;
    color: var(--text-muted);
    margin-top: 1.25rem;
    min-height: 1.4em;
    line-height: 1.4;
    max-width: 540px;
    margin-left: auto;
    margin-right: auto;
}

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

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

.state-solved .instruction { color: var(--neon-green); }

/* 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.85rem; }
    .instruction { font-size: 1rem; }
    .board { gap: 0.45rem; max-width: 100%; }
    .glyphs.sz-small { font-size: 1.2rem; }
    .glyphs.sz-big { font-size: 1.9rem; }
    .item { border-radius: 11px; }
    .label-badge { width: 18px; height: 18px; font-size: 0.85rem; }
    .game-btn { padding: 0.8rem 1.3rem; font-size: 1rem; }
}

@media (max-width: 360px) {
    .glyphs.sz-small { font-size: 1rem; }
    .glyphs.sz-big { font-size: 1.5rem; }
    .board { gap: 0.35rem; }
}
