/* Prompt Jenga — FunSlop.com
   Pull words from a working prompt without toppling the output. */

: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;
    --mono: 'Space Grotesk', ui-monospace, 'SF Mono', Menlo, monospace;
}

* {
    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(--neon-purple) 0%, transparent 70%);
    opacity: 0.14;
    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, 60px); }
}

.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.25rem 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-green));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Control hints */
.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(--neon-green); }

.state-playing .controls-inline,
.state-collapsed .controls-inline,
.state-cleared .controls-inline,
.state-gameover .controls-inline { display: none; }

.instruction {
    font-size: 1.1rem;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
    min-height: 2.6em;
    line-height: 1.35;
    transition: color 0.2s;
}

/* HUD stats row */
.hud {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 0.85rem;
    min-height: 1.5em;
}

.stat {
    font-family: var(--font-display);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--glass-border);
    border-radius: 999px;
    padding: 0.25rem 0.75rem;
}

.stat:empty { display: none; }
.stat-removed { color: var(--cyan); }
.stat-best { color: var(--gold); }

/* Stability meter */
.stability {
    max-width: 440px;
    margin: 0 auto 1.1rem;
    text-align: left;
}

.state-idle .stability { display: none; }

.stability-label {
    font-family: var(--font-display);
    font-size: 0.78rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 0.35rem;
}

.stability-bar {
    height: 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--glass-border);
    overflow: hidden;
}

.stability-fill {
    height: 100%;
    width: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--pink), var(--gold) 45%, var(--neon-green));
    transition: width 0.35s ease;
}

/* The prompt: a stack of pullable word-blocks */
.prompt-stack {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    justify-content: center;
    align-items: center;
    min-height: 3rem;
    margin-bottom: 1.4rem;
}

.word-block {
    font-family: var(--font-body);
    font-size: 1.05rem;
    font-weight: 500;
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-bottom: 3px solid rgba(5, 217, 232, 0.35);
    border-radius: 9px;
    padding: 0.5rem 0.7rem;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.15s, background 0.15s, opacity 0.3s;
    line-height: 1;
}

.word-block:hover {
    background: rgba(5, 217, 232, 0.12);
    box-shadow: 0 0 14px rgba(5, 217, 232, 0.3);
    transform: translateY(-2px);
}

.word-block:active { transform: translateY(1px) scale(0.96); }

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

/* A safely-pulled block animates out and reserves no space */
.word-block.removed {
    display: none;
}

/* The fatal pull: the block flashes red then drops */
.word-block.load-pulled {
    background: rgba(255, 42, 109, 0.25);
    border-color: var(--pink);
    color: #fff;
    animation: drop-out 0.7s ease-in forwards;
    box-shadow: 0 0 22px rgba(255, 42, 109, 0.6);
    cursor: default;
}

/* Surviving load-bearing tokens are revealed at collapse */
.word-block.reveal-load {
    background: rgba(255, 42, 109, 0.14);
    border-bottom-color: var(--pink);
    color: var(--pink);
    cursor: default;
}

@keyframes drop-out {
    0% { transform: translateY(0) rotate(0); opacity: 1; }
    100% { transform: translateY(80px) rotate(14deg); opacity: 0; }
}

/* Whole tower shudders when integrity is low */
.game-container.shaky .prompt-stack {
    animation: jitter 0.5s ease-in-out infinite;
}

@keyframes jitter {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-2px) rotate(-0.3deg); }
    75% { transform: translateX(2px) rotate(0.3deg); }
}

/* The simulated model output preview */
.preview-wrap {
    max-width: 480px;
    margin: 0 auto 1.25rem;
    text-align: left;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    overflow: hidden;
}

.preview-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 0.85rem;
    background: rgba(255, 255, 255, 0.04);
    border-bottom: 1px solid var(--glass-border);
}

.preview-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--neon-green);
    box-shadow: 0 0 8px var(--neon-green);
    transition: background 0.2s, box-shadow 0.2s;
}

.preview-title {
    font-family: var(--font-display);
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.preview-body {
    font-family: var(--mono);
    font-size: 0.95rem;
    line-height: 1.5;
    padding: 0.95rem 0.95rem 1.05rem;
    white-space: pre-wrap;
    word-break: break-word;
    min-height: 4.5em;
    transition: color 0.2s;
}

.preview-body.preview-idle { color: var(--text-muted); }
.preview-body.preview-good { color: var(--neon-green); }
.preview-body.preview-broken {
    color: var(--pink);
    animation: glitch 0.25s steps(2) 2;
}

@keyframes glitch {
    0% { transform: translate(0, 0); }
    50% { transform: translate(2px, -1px); }
    100% { transform: translate(-1px, 1px); }
}

/* Recolor the status dot when output breaks */
.state-collapsed .preview-dot,
.state-gameover .preview-broken ~ .preview-dot {
    background: var(--pink);
    box-shadow: 0 0 8px var(--pink);
}

.preview-wrap:has(.preview-broken) .preview-dot {
    background: var(--pink);
    box-shadow: 0 0 8px var(--pink);
}

/* Action button */
.actions {
    display: none;
    justify-content: center;
    margin-bottom: 0.5rem;
}

.state-playing .actions,
.state-cleared .actions { display: flex; }

.game-btn {
    font-family: var(--font-body);
    padding: 0.85rem 1.7rem;
    font-size: 1.05rem;
    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);
}

.btn-next {
    background: var(--gold);
    box-shadow: 0 0 18px rgba(255, 213, 74, 0.3);
}

.btn-next:hover {
    filter: brightness(1.08);
    box-shadow: 0 0 26px rgba(255, 213, 74, 0.5);
}

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

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

.hint {
    font-size: 0.92rem;
    color: var(--text-muted);
    margin-top: 1rem;
    min-height: 1.2em;
}

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

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

.state-gameover.new-best .preview-body {
    color: var(--gold) !important;
}

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

/* 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.75rem; }
    .instruction { font-size: 1rem; }
    .word-block { font-size: 0.98rem; padding: 0.45rem 0.6rem; }
    .preview-body { font-size: 0.88rem; }
    .game-btn { padding: 0.75rem 1.3rem; font-size: 1rem; }
}

@media (max-width: 360px) {
    .word-block { font-size: 0.9rem; padding: 0.4rem 0.5rem; }
}
