/* Seeded Dungeon — FunSlop.com
   A daily micro-roguelike. 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);
    --font-body: 'Outfit', system-ui, -apple-system, BlinkMacSystemFont, 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 — FunSlop house style */
.glow-bg {
    position: fixed;
    top: -90px;
    left: -90px;
    width: 380px;
    height: 380px;
    background: radial-gradient(circle, var(--neon-purple) 0%, transparent 70%);
    opacity: 0.16;
    z-index: -1;
    filter: blur(64px);
    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;
    transition: box-shadow 0.12s ease;
}

/* Hit-flash feedback (inset glows triggered by the game) */
.game-container.fx-hit    { box-shadow: inset 0 0 0 4px rgba(57, 255, 20, 0.35); }
.game-container.fx-hurt   { box-shadow: inset 0 0 0 5px rgba(255, 42, 109, 0.5); animation: jolt 0.18s; }
.game-container.fx-wall   { box-shadow: inset 0 0 0 3px rgba(139, 155, 180, 0.25); }
.game-container.fx-descend{ box-shadow: inset 0 0 0 5px rgba(189, 0, 255, 0.45); }

@keyframes jolt {
    0%, 100% { transform: translateX(0); }
    30% { transform: translateX(-5px); }
    70% { transform: translateX(5px); }
}

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

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

.day-label {
    font-family: var(--font-display);
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--cyan);
    letter-spacing: 0.5px;
    margin-bottom: 0.85rem;
    text-shadow: 0 0 12px rgba(5, 217, 232, 0.35);
}

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

.hud-stat {
    font-family: var(--font-display);
    font-size: 0.95rem;
    font-weight: 700;
    padding: 0.3rem 0.7rem;
    border-radius: 999px;
    border: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.03);
}

.hud-stat.depth { color: var(--neon-purple); }
.hud-stat.gold  { color: var(--gold); }
.hud-stat.hp    { color: var(--neon-green); }

.hp-bar {
    width: 100%;
    max-width: 400px;
    height: 8px;
    margin: 0 auto 0.85rem;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--glass-border);
    border-radius: 999px;
    overflow: hidden;
}

.hp-fill {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, var(--neon-green), var(--cyan));
    border-radius: 999px;
    transition: width 0.18s ease, background 0.2s ease;
}

/* Dungeon board */
.board-wrapper {
    width: min(92vw, 400px);
    aspect-ratio: 1;
    margin: 0 auto;
    border-radius: 14px;
    overflow: hidden;
    border: 1px solid rgba(5, 217, 232, 0.22);
    box-shadow:
        0 0 30px rgba(189, 0, 255, 0.25),
        inset 0 0 18px rgba(5, 217, 232, 0.1);
}

#canvas {
    display: block;
    width: 100%;
    height: 100%;
    background: #070910;
    touch-action: none;
}

/* Live log */
.log {
    font-family: var(--font-body);
    font-size: 0.82rem;
    line-height: 1.35;
    color: var(--text-muted);
    margin: 0.7rem auto 0.2rem;
    min-height: 3.4em;
    max-width: 440px;
    white-space: pre-wrap;
    text-align: center;
}

/* Readout (idle hint + game-over result) */
.verdict {
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0.35rem 0 0.25rem;
    min-height: 1.3em;
    line-height: 1.3;
}

.score-line {
    font-size: 0.98rem;
    color: var(--text-muted);
    margin-bottom: 0.2rem;
    min-height: 1.2em;
    line-height: 1.35;
}

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

/* Buttons */
.action-row {
    display: flex;
    gap: 0.7rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 0.5rem;
}

.game-btn {
    font-family: var(--font-display);
    padding: 0.85rem 1.7rem;
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: 0.3px;
    border-radius: 999px;
    cursor: pointer;
    border: 1px solid var(--glass-border);
    transition: transform 0.12s, box-shadow 0.15s, filter 0.15s, border-color 0.2s, color 0.2s;
}

.game-btn:active { transform: scale(0.96); }
.game-btn:focus-visible { outline: 3px solid var(--cyan); outline-offset: 2px; }

.game-btn.primary {
    color: #04130a;
    border: none;
    background: linear-gradient(135deg, var(--neon-green), var(--cyan));
    box-shadow: 0 0 22px rgba(57, 255, 20, 0.32);
}

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

.game-btn.ghost {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.04);
}

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

/* The share button only matters once you've died */
#share-btn { display: none; }
.state-gameover #share-btn { display: inline-block; }

/* On-screen d-pad */
.dpad {
    display: none;
    position: relative;
    width: 168px;
    height: 168px;
    margin: 0.9rem auto 0;
}

.state-playing .dpad { display: block; }

.dpad-btn {
    position: absolute;
    width: 54px;
    height: 54px;
    font-size: 1.1rem;
    color: var(--cyan);
    background: rgba(5, 217, 232, 0.08);
    border: 1px solid rgba(5, 217, 232, 0.3);
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.08s, background 0.15s, box-shadow 0.15s;
}

.dpad-btn:active {
    transform: scale(0.9);
    background: rgba(5, 217, 232, 0.22);
    box-shadow: 0 0 16px rgba(5, 217, 232, 0.5);
}

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

.dpad-btn.up    { top: 0;    left: 57px; }
.dpad-btn.left  { top: 57px; left: 0; }
.dpad-btn.down  { top: 114px; left: 57px; }
.dpad-btn.right { top: 57px; left: 114px; }

/* New-best celebration on the result text */
.state-gameover.new-best .verdict {
    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 .score-line { color: var(--gold); }

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

/* During play, the idle/result copy stays quiet; the log carries the show. */
.state-playing .verdict,
.state-playing .score-line,
.state-playing .best-line {
    display: none;
}

/* Hide the start button while actively crawling. */
.state-playing #start-btn { display: none; }

/* SEO / how-to content */
.how-to-play {
    text-align: left;
    margin: 2.5rem auto 0;
    max-width: 480px;
    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.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.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: 1.9rem auto 0;
    max-width: 480px;
    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 blocks during active play to keep the board front-and-center. */
.state-playing .how-to-play,
.state-playing .related-games {
    display: none;
}

/* Home link */
.home-link {
    position: fixed;
    bottom: 1.1rem;
    bottom: calc(1.1rem + env(safe-area-inset-bottom, 0px));
    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.82);
    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; }
    .verdict { font-size: 1rem; }
    .hud-stat { font-size: 0.85rem; padding: 0.28rem 0.6rem; }
    .game-btn { padding: 0.75rem 1.4rem; font-size: 0.98rem; }
}

/* Short / landscape phones: tighten vertical rhythm. */
@media (max-height: 720px) {
    .content { padding-top: 1rem; }
    .how-to-play, .related-games { margin-top: 1.5rem; }
}
