/* Mixture of Experts — FunSlop.com
   MoE routing under load. Route typed requests to the right expert lane
   before the buffers overflow. Neon-on-near-black, mobile-first, self-contained. */

:root {
    --bg-dark: #090b10;
    --bg-panel: #0e111a;
    --neon-green: #39ff14;
    --cyan: #05d9e8;
    --neon-purple: #bd00ff;
    --pink: #ff2a6d;
    --gold: #ffd54a;
    --orange: #ff9f1c;
    --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 drifting glow */
.glow-bg {
    position: fixed;
    top: -90px;
    left: -90px;
    width: 380px;
    height: 380px;
    background: radial-gradient(circle, var(--neon-purple) 0%, transparent 70%);
    opacity: 0.13;
    z-index: -1;
    filter: blur(60px);
    pointer-events: none;
    animation: float 14s infinite alternate;
}

@keyframes float {
    0% { transform: translate(0, 0); }
    100% { transform: translate(140px, 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;
}

.game-container.shaking { animation: shake 0.24s ease-in-out; }

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-7px); }
    60% { transform: translateX(7px); }
}

.content {
    text-align: center;
    padding: 1.75rem 1rem 6rem;
    max-width: 680px;
    width: 100%;
    margin: 0 auto;
}

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

/* Control hints */
.controls-inline {
    display: flex;
    gap: 0.55rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.control-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.82rem;
    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); }

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

.hud-item {
    flex: 1 1 0;
    max-width: 150px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 0.45rem 0.4rem 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.05rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.hud-label {
    font-size: 0.66rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.hud-value {
    font-family: var(--font-display);
    font-size: 1.45rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.05;
}

#hud-served { color: var(--neon-green); }
#hud-combo { color: var(--cyan); transition: color 0.15s, transform 0.15s; }
#hud-combo.combo-hot {
    color: var(--gold);
    text-shadow: 0 0 12px rgba(255, 213, 74, 0.6);
    transform: scale(1.06);
}

.hud-drops .hud-value { color: var(--text-muted); }
.hud-item.warn { border-color: rgba(255, 159, 28, 0.5); }
.hud-item.warn .hud-value { color: var(--orange); }
.hud-item.danger {
    border-color: rgba(255, 42, 109, 0.6);
    box-shadow: 0 0 16px rgba(255, 42, 109, 0.25);
    animation: pulseDanger 0.8s ease-in-out infinite;
}
.hud-item.danger .hud-value { color: var(--pink); }

@keyframes pulseDanger {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* ---- Board ---- */
.board {
    position: relative;
    background: var(--bg-panel);
    border: 1px solid var(--glass-border);
    border-radius: 18px;
    padding: 0.9rem 0.85rem 1rem;
    box-shadow:
        0 0 30px rgba(189, 0, 255, 0.14),
        inset 0 0 22px rgba(5, 217, 232, 0.05);
    overflow: hidden;
}

/* Incoming queue rail */
.queue-rail {
    margin-bottom: 0.85rem;
}

.rail-label {
    display: block;
    text-align: left;
    font-size: 0.7rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin: 0 0.1rem 0.4rem;
}

.queue {
    display: flex;
    gap: 0.5rem;
    align-items: stretch;
    min-height: 78px;
    padding: 0.35rem 0.3rem;
    border-radius: 12px;
    background:
        repeating-linear-gradient(
            90deg,
            rgba(255, 255, 255, 0.02) 0 2px,
            transparent 2px 14px);
    border: 1px dashed rgba(255, 255, 255, 0.07);
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.queue::-webkit-scrollbar { display: none; }

/* A queued request card */
.request {
    position: relative;
    flex: 0 0 auto;
    width: 72px;
    min-height: 68px;
    border: 1px solid color-mix(in srgb, var(--req) 55%, transparent);
    border-radius: 12px;
    background:
        linear-gradient(180deg,
            color-mix(in srgb, var(--req) 16%, var(--bg-panel)),
            color-mix(in srgb, var(--req) 6%, var(--bg-panel)));
    color: var(--req);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.18rem;
    padding: 0.45rem 0.2rem 0.55rem;
    cursor: pointer;
    font-family: var(--font-body);
    transition: transform 0.12s, box-shadow 0.18s, border-color 0.18s, opacity 0.2s;
}

.request:active { transform: scale(0.94); }
.request:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }

.request .req-icon { font-size: 1.4rem; line-height: 1; }
.request .req-type {
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: var(--text-primary);
}

/* TTL bar under each request */
.req-life {
    position: absolute;
    left: 8px;
    right: 8px;
    bottom: 6px;
    height: 4px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.1);
    overflow: hidden;
}
.req-life-fill {
    display: block;
    height: 100%;
    width: 100%;
    transform-origin: left center;
    background: var(--req);
    border-radius: 3px;
    transition: transform 0.1s linear;
}
.request.urgent .req-life-fill { background: var(--pink); }
.request.urgent { animation: reqBlink 0.6s ease-in-out infinite; }

@keyframes reqBlink {
    0%, 100% { border-color: color-mix(in srgb, var(--req) 55%, transparent); }
    50% { border-color: var(--pink); box-shadow: 0 0 14px rgba(255, 42, 109, 0.5); }
}

/* Head-of-queue gets a ring so the "tap a lane" path is obvious */
.request.head {
    box-shadow: 0 0 0 2px var(--req), 0 0 16px color-mix(in srgb, var(--req) 60%, transparent);
}
.request.selected {
    box-shadow: 0 0 0 3px var(--cyan), 0 0 20px rgba(5, 217, 232, 0.6);
    transform: translateY(-4px) scale(1.04);
}

/* Spawn / leave animations */
.request.spawn { animation: reqIn 0.24s ease-out; }
@keyframes reqIn {
    from { opacity: 0; transform: translateY(-16px) scale(0.8); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.request.leaving { pointer-events: none; }
.request.leave-serve { animation: reqServe 0.22s ease-in forwards; }
.request.leave-misroute { animation: reqReject 0.22s ease-in forwards; }
.request.leave-drop { animation: reqDrop 0.22s ease-in forwards; }

@keyframes reqServe {
    to { opacity: 0; transform: translateY(36px) scale(0.6); }
}
@keyframes reqReject {
    0% { transform: translateX(0); }
    50% { transform: translateX(8px); }
    100% { opacity: 0; transform: translateX(-12px) scale(0.7); }
}
@keyframes reqDrop {
    to { opacity: 0; transform: translateY(-26px) scale(0.5) rotate(-12deg); }
}

/* ---- Expert lanes ---- */
.experts {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.55rem;
}

.expert {
    position: relative;
    border: 1px solid color-mix(in srgb, var(--lane) 45%, transparent);
    border-radius: 14px;
    background:
        linear-gradient(180deg,
            color-mix(in srgb, var(--lane) 12%, var(--bg-panel)),
            color-mix(in srgb, var(--lane) 4%, var(--bg-panel)));
    color: var(--lane);
    min-height: 92px;
    padding: 0.55rem 0.5rem 0.5rem;
    cursor: pointer;
    overflow: hidden;
    font-family: var(--font-body);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.2rem;
    transition: transform 0.1s, box-shadow 0.18s, border-color 0.18s, filter 0.2s;
}

.expert:hover { box-shadow: 0 0 18px color-mix(in srgb, var(--lane) 40%, transparent); }
.expert:active { transform: scale(0.96); }
.expert:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }

.expert-icon { font-size: 1.6rem; line-height: 1; z-index: 2; }
.expert-label {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-primary);
    z-index: 2;
}

/* vertical load meter fills from the bottom */
.load-track {
    position: absolute;
    inset: 0;
    z-index: 1;
    pointer-events: none;
}
.load-fill {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 100%;
    transform-origin: bottom center;
    transform: scaleY(0);
    background: linear-gradient(180deg,
        color-mix(in srgb, var(--lane) 38%, transparent),
        color-mix(in srgb, var(--lane) 14%, transparent));
    transition: transform 0.12s linear;
}

.expert-status {
    position: absolute;
    top: 5px;
    right: 7px;
    z-index: 3;
    font-size: 0.55rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}

/* Hot lane (near capacity) */
.expert.hot {
    border-color: var(--pink);
    box-shadow: 0 0 20px rgba(255, 42, 109, 0.4), inset 0 0 14px rgba(255, 42, 109, 0.25);
    animation: hotPulse 0.6s ease-in-out infinite;
}
.expert.hot .expert-status { color: var(--pink); }
.expert.hot .load-fill {
    background: linear-gradient(180deg, rgba(255, 42, 109, 0.55), rgba(255, 42, 109, 0.2));
}

@keyframes hotPulse {
    0%, 100% { box-shadow: 0 0 20px rgba(255, 42, 109, 0.35), inset 0 0 14px rgba(255, 42, 109, 0.2); }
    50% { box-shadow: 0 0 28px rgba(255, 42, 109, 0.6), inset 0 0 20px rgba(255, 42, 109, 0.4); }
}

/* Offline lane */
.expert.offline {
    filter: grayscale(0.85) brightness(0.6);
    border-color: rgba(139, 155, 180, 0.4);
    cursor: not-allowed;
}
.expert.offline .expert-status { color: var(--pink); }
.expert.offline::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 2;
    background: repeating-linear-gradient(
        45deg,
        rgba(255, 42, 109, 0.12) 0 8px,
        transparent 8px 16px);
}

/* Lane feedback flashes */
.expert.fx-serve { animation: laneServe 0.34s ease-out; }
.expert.fx-reject { animation: laneReject 0.34s ease-in-out; }
.expert.fx-overload { animation: laneOverload 0.36s ease-in-out; }
.expert.fx-hint { animation: laneHint 0.36s ease-out; }
.expert.fx-empty { animation: laneEmpty 0.3s ease-out; }
.expert.fx-offline { animation: laneReject 0.34s ease-in-out; }
.expert.fx-online { animation: laneServe 0.34s ease-out; }

@keyframes laneServe {
    0% { transform: scale(1); }
    40% { transform: scale(1.06); box-shadow: 0 0 26px color-mix(in srgb, var(--lane) 70%, transparent); }
    100% { transform: scale(1); }
}
@keyframes laneReject {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-6px); border-color: var(--pink); }
    75% { transform: translateX(6px); border-color: var(--pink); }
}
@keyframes laneOverload {
    0%, 100% { transform: scale(1); }
    30% { transform: scale(1.04); box-shadow: 0 0 28px rgba(255, 42, 109, 0.7); }
    60% { transform: scale(0.98); }
}
@keyframes laneHint {
    0% { box-shadow: 0 0 0 color-mix(in srgb, var(--lane) 70%, transparent); }
    50% { box-shadow: 0 0 0 3px var(--lane), 0 0 22px color-mix(in srgb, var(--lane) 70%, transparent); }
    100% { box-shadow: none; }
}
@keyframes laneEmpty {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.45; }
}

/* ---- Toast ---- */
.toast {
    position: absolute;
    left: 50%;
    top: 46%;
    transform: translate(-50%, -50%) scale(0.8);
    padding: 0.4rem 0.9rem;
    border-radius: 999px;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.95rem;
    letter-spacing: 0.01em;
    background: rgba(9, 11, 16, 0.86);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    opacity: 0;
    pointer-events: none;
    z-index: 20;
    white-space: nowrap;
    transition: opacity 0.18s, transform 0.18s;
}
.toast.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.toast.good { color: var(--neon-green); border-color: rgba(57, 255, 20, 0.5); box-shadow: 0 0 18px rgba(57, 255, 20, 0.3); }
.toast.bad { color: var(--pink); border-color: rgba(255, 42, 109, 0.5); box-shadow: 0 0 18px rgba(255, 42, 109, 0.3); }

/* ---- Overlay (idle / gameover) ---- */
.overlay {
    position: absolute;
    inset: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(9, 11, 16, 0.84);
    backdrop-filter: blur(5px);
}
.state-playing .overlay { display: none; }

.overlay-card {
    max-width: 420px;
    text-align: center;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: 18px;
    padding: 1.5rem 1.4rem 1.6rem;
}

.overlay-title {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.6rem;
    color: var(--text-primary);
}
.state-gameover .overlay-title { color: var(--pink); }
.state-gameover.new-best .overlay-title {
    color: var(--gold);
    text-shadow: 0 0 16px rgba(255, 213, 74, 0.5);
    animation: popIn 0.4s ease-out;
}

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

.overlay-body {
    font-size: 0.98rem;
    line-height: 1.5;
    color: var(--text-muted);
    margin-bottom: 0.85rem;
}
.state-gameover .overlay-body { color: var(--text-primary); }

.best-line {
    font-size: 0.9rem;
    color: var(--cyan);
    min-height: 1.2em;
    margin-bottom: 1rem;
}

.game-btn {
    font-family: var(--font-display);
    padding: 0.85rem 2rem;
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    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.18s, filter 0.18s;
}
.game-btn:hover { filter: brightness(1.08); box-shadow: 0 0 32px rgba(57, 255, 20, 0.55); }
.game-btn:active { transform: scale(0.96); }
.game-btn:focus-visible { outline: 3px solid var(--cyan); outline-offset: 3px; }

/* ---- SEO / how-to ---- */
.how-to-play {
    text-align: left;
    margin: 2.75rem auto 0;
    max-width: 600px;
    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.7rem;
    color: var(--text-primary);
}
.how-to-play h3 {
    font-family: var(--font-display);
    font-size: 1.05rem;
    margin: 1.15rem 0 0.45rem;
    color: var(--cyan);
}
.how-to-play p {
    font-weight: 300;
    line-height: 1.6;
    color: var(--text-muted);
    margin-bottom: 0.7rem;
}
.how-to-play strong { color: var(--text-primary); font-weight: 500; }
.how-to-play ol {
    margin: 0.5rem 0 0.7rem 1.2rem;
    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: 600px;
    text-align: center;
}
.related-games h3 {
    font-family: var(--font-display);
    font-size: 1.05rem;
    margin-bottom: 0.7rem;
    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 + control hints while playing */
.state-playing .how-to-play,
.state-playing .related-games,
.state-playing .controls-inline { display: none; }

/* ---- Home link ---- */
.home-link {
    position: fixed;
    bottom: 1.1rem;
    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: 50;
}
.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.65rem; }
    .hud-value { font-size: 1.25rem; }
    .request { width: 64px; }
    .request .req-icon { font-size: 1.25rem; }
    .expert { min-height: 84px; }
    .expert-icon { font-size: 1.4rem; }
}

@media (max-width: 380px) {
    .content { padding: 1.25rem 0.7rem 6rem; }
    .board { padding: 0.7rem 0.6rem 0.8rem; }
    .experts { gap: 0.4rem; }
    .request { width: 58px; min-height: 62px; }
    .expert { min-height: 76px; padding: 0.4rem 0.3rem; }
    .expert-label { font-size: 0.7rem; }
}

/* Wider screens: give the six experts a single comfortable row */
@media (min-width: 720px) {
    .experts { grid-template-columns: repeat(6, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
    .glow-bg,
    .hud-item.danger,
    .expert.hot,
    .request.urgent { animation: none; }
    .request.spawn,
    .expert.fx-serve,
    .expert.fx-reject,
    .expert.fx-overload,
    .expert.fx-hint,
    .expert.fx-empty { animation-duration: 0.01ms; }
}
