/* Embedding Maze — FunSlop.com
   Navigate a grid of word-rooms; doors open only between related concepts.
   Neon-on-near-black, self-contained, mobile-first. */

: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);
    --cell-bg: #11141f;
    --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);
    background-image:
        radial-gradient(circle at 18% 16%, rgba(189, 0, 255, 0.14), transparent 46%),
        radial-gradient(circle at 82% 84%, rgba(5, 217, 232, 0.12), transparent 48%);
}

/* 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.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(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 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: 0.75rem;
    background: linear-gradient(45deg, var(--cyan), var(--neon-purple));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* HUD: level + goal */
.hud {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    max-width: 420px;
    margin: 0 auto 0.6rem;
    flex-wrap: wrap;
}

.hud-level {
    font-family: var(--font-display);
    font-weight: 700;
    color: var(--neon-purple);
    text-shadow: 0 0 12px rgba(189, 0, 255, 0.5);
    font-size: 1rem;
}

.hud-goal {
    font-size: 1rem;
    color: var(--text-muted);
}

.hud-goal strong {
    color: var(--gold);
    text-shadow: 0 0 12px rgba(255, 213, 74, 0.45);
    font-family: var(--font-display);
}

/* Carry indicator — the heart of the loop */
.carry-row {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    background: rgba(57, 255, 20, 0.06);
    border: 1px solid rgba(57, 255, 20, 0.3);
    border-radius: 999px;
    padding: 0.4rem 1rem;
    margin-bottom: 1rem;
}

.carry-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.carry-word {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.15rem;
    color: var(--neon-green);
    text-shadow: 0 0 12px rgba(57, 255, 20, 0.55);
}

/* The board */
.board-wrap {
    width: 100%;
    display: flex;
    justify-content: center;
    margin-bottom: 0.75rem;
}

.board {
    --cols: 3;
    --rows: 2;
    display: grid;
    grid-template-columns: repeat(var(--cols), 1fr);
    gap: 0.5rem;
    width: 100%;
    max-width: min(92vw, 460px);
}

.cell {
    position: relative;
    font-family: var(--font-body);
    aspect-ratio: 1;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 0.3rem;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    background: var(--cell-bg);
    color: var(--text-muted);
    cursor: pointer;
    transition: transform 0.12s, box-shadow 0.18s, border-color 0.18s, background 0.18s, color 0.18s;
    overflow: hidden;
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
}

.cell-word {
    font-weight: 500;
    font-size: clamp(0.62rem, 2.6vw, 0.95rem);
    line-height: 1.05;
    word-break: break-word;
}

.cell-badge {
    position: absolute;
    top: 3px;
    right: 4px;
    font-size: 0.5rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--gold);
    background: rgba(255, 213, 74, 0.12);
    border: 1px solid rgba(255, 213, 74, 0.35);
    border-radius: 6px;
    padding: 0 0.25rem;
    line-height: 1.25;
}

/* Rooms reachable from the current token (related to carried word) */
.cell.is-open {
    border-color: rgba(5, 217, 232, 0.55);
    color: var(--cyan);
    box-shadow: 0 0 16px rgba(5, 217, 232, 0.25), inset 0 0 12px rgba(5, 217, 232, 0.08);
    cursor: pointer;
}

.cell.is-open:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 22px rgba(5, 217, 232, 0.45);
}

/* The goal room */
.cell.is-goal {
    border-color: rgba(255, 213, 74, 0.6);
    color: var(--gold);
    box-shadow: inset 0 0 14px rgba(255, 213, 74, 0.14);
}

.cell.is-goal.is-open {
    box-shadow: 0 0 22px rgba(255, 213, 74, 0.5);
    animation: goal-pulse 1.1s ease-in-out infinite;
}

@keyframes goal-pulse {
    0%, 100% { box-shadow: 0 0 18px rgba(255, 213, 74, 0.4); }
    50% { box-shadow: 0 0 30px rgba(255, 213, 74, 0.7); }
}

/* The token's current room */
.cell.is-token {
    border-color: var(--neon-green);
    background: rgba(57, 255, 20, 0.12);
    color: var(--neon-green);
    font-weight: 700;
    text-shadow: 0 0 10px rgba(57, 255, 20, 0.5);
    box-shadow: 0 0 22px rgba(57, 255, 20, 0.45), inset 0 0 14px rgba(57, 255, 20, 0.15);
    cursor: default;
}

.cell.is-token.is-station-active {
    border-color: var(--gold);
    box-shadow: 0 0 24px rgba(255, 213, 74, 0.55), inset 0 0 14px rgba(57, 255, 20, 0.15);
    cursor: pointer;
    animation: station-pulse 1.2s ease-in-out infinite;
}

@keyframes station-pulse {
    0%, 100% { box-shadow: 0 0 20px rgba(255, 213, 74, 0.45), inset 0 0 14px rgba(57, 255, 20, 0.15); }
    50% { box-shadow: 0 0 30px rgba(255, 213, 74, 0.8), inset 0 0 14px rgba(57, 255, 20, 0.15); }
}

/* Rejected move shake */
.cell.shake {
    animation: cell-shake 0.3s ease-in-out;
    border-color: var(--pink) !important;
    box-shadow: 0 0 16px rgba(255, 42, 109, 0.45) !important;
}

@keyframes cell-shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-5px); }
    40% { transform: translateX(5px); }
    60% { transform: translateX(-4px); }
    80% { transform: translateX(4px); }
}

/* Idle demo cells are not interactive */
.cell.demo {
    cursor: default;
}

/* Feedback / status lines */
.feedback {
    min-height: 2.6em;
    font-size: 0.95rem;
    color: var(--text-muted);
    line-height: 1.4;
    margin: 0.25rem auto 0;
    max-width: 460px;
}

.verdict {
    min-height: 1.2em;
    font-family: var(--font-display);
    font-weight: 700;
    color: var(--neon-green);
    text-shadow: 0 0 12px rgba(57, 255, 20, 0.4);
    margin: 0.35rem 0 0;
    font-size: 1.05rem;
}

.campaign-complete .verdict {
    color: var(--gold);
    text-shadow: 0 0 14px rgba(255, 213, 74, 0.55);
}

.steps {
    font-size: 0.9rem;
    color: var(--cyan);
    margin-top: 0.35rem;
    min-height: 1.2em;
}

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

/* Start / advance button */
.start-btn {
    margin-top: 1rem;
    font-family: var(--font-display);
    background: linear-gradient(135deg, var(--cyan), var(--neon-purple));
    color: #04130a;
    border: none;
    padding: 0.9rem 2.4rem;
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: 0.4px;
    border-radius: 999px;
    cursor: pointer;
    box-shadow: 0 0 22px rgba(5, 217, 232, 0.35);
    transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
}

.start-btn:hover {
    transform: scale(1.04);
    filter: brightness(1.06);
    box-shadow: 0 0 32px rgba(189, 0, 255, 0.55);
}

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

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

/* Hide the start button mid-maze (game.js also toggles inline display) */
.state-playing .start-btn {
    display: none;
}

/* Control hints */
.controls-inline {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 1.1rem;
}

.control-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: 999px;
    padding: 0.3rem 0.7rem;
}

.control-pill .key {
    font-weight: 700;
    color: var(--cyan);
    font-size: 0.75rem;
}

.control-pill.special .key {
    color: var(--gold);
}

/* Hide control hints + verdict noise mid-flow appropriately */
.state-playing .controls-inline {
    display: none;
}

/* 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.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 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: 560px;
    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(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 blocks during active play to keep focus on the maze */
.state-playing .how-to-play,
.state-playing .related-games,
.state-won .how-to-play,
.state-won .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(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.7rem; }
    .hud-level, .hud-goal { font-size: 0.9rem; }
    .carry-word { font-size: 1.05rem; }
    .start-btn {
        padding: 0.8rem 1.9rem;
        font-size: 1.05rem;
    }
    .board { gap: 0.4rem; }
}

@media (max-width: 380px) {
    .cell { border-radius: 9px; }
    .board { gap: 0.32rem; }
}
