/* ===== Zombie Arcade — global theme tokens ===== */
:root {
    --bg-0: #0a0d0a;
    --bg-1: #131713;
    --bg-2: #1c221c;
    --toxic: #7aff5a;
    --toxic-dim: #3fa632;
    --blood: #c0392b;
    --rust: #8c3b1e;
    --bone: #e8e6d9;
    --muted: #6b726b;
}

html, body {
    margin: 0;
    background: var(--bg-0);
    color: var(--bone);
    font-family: 'Share Tech Mono', 'Courier New', Courier, monospace;
    font-size: 16px;
}

* { box-sizing: border-box; }

a {
    color: var(--toxic);
    text-decoration: none;
}
a:hover { color: var(--toxic-dim); text-decoration: underline; }

h1, h2, h3, h4, h5, h6 {
    color: var(--toxic);
    font-family: 'Silkscreen', 'Courier New', monospace;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.btn-link,
button.btn-link {
    color: var(--toxic);
    text-decoration: none;
    padding: 0;
}

/* ===== Game Detail ===== */
.game-detail,
.leaderboard-preview { padding: 1rem; }
.game-detail-desc { color: var(--muted); max-width: 60ch; }

.arcade-btn {
    background: var(--bg-2);
    color: var(--toxic);
    border: 2px solid var(--toxic);
    padding: 0.8rem 2rem;
    font-family: 'Silkscreen', 'Courier New', monospace;
    font-size: 1.05rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.15s;
}
.arcade-btn:hover {
    background: var(--toxic);
    color: var(--bg-0);
    box-shadow: 0 0 15px var(--toxic);
}

/* ===== Leaderboard ===== */
.leaderboard-list,
.leaderboard-table {
    list-style: none;
    padding: 0;
    width: 100%;
    border-collapse: collapse;
}
.leaderboard-list li {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem;
    border-bottom: 1px solid var(--bg-2);
}
.leaderboard-table th,
.leaderboard-table td {
    padding: 0.5rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--bg-2);
}
.leaderboard-table th {
    color: var(--toxic);
    text-transform: uppercase;
}
.leaderboard-controls {
    display: flex;
    gap: 1rem;
    padding: 1rem;
    flex-wrap: wrap;
}
.leaderboard-controls select {
    background: var(--bg-2);
    color: var(--bone);
    border: 1px solid var(--toxic-dim);
    padding: 0.3rem;
    font-family: inherit;
}

/* ===== Profile ===== */
.profile-details {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 0.5rem 2rem;
    padding: 1rem;
    max-width: 600px;
}
.profile-details dt { color: var(--muted); }

/* ===== Misc ===== */
.arcade-error {
    color: var(--blood);
    padding: 1rem;
    border: 1px solid var(--blood);
}

h1:focus { outline: none; }
.validation-message { color: var(--blood); }
.valid.modified:not([type=checkbox]) { outline: 1px solid var(--toxic-dim); }
.invalid { outline: 1px solid var(--blood); }

.blazor-error-boundary {
    background: var(--blood);
    color: white;
    padding: 1rem;
}
.blazor-error-boundary::after { content: "An error has occurred." }

/* ── Fullscreen scaling: canvas-based games ─────────────────────────────── */

#game-stage:fullscreen,
#game-stage:-webkit-full-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
}

/* Zero out container padding so the canvas can fill the full viewport height */
#game-stage:fullscreen .zombio-stage,
#game-stage:fullscreen .zs-stage,
#game-stage:fullscreen .zman-container,
#game-stage:-webkit-full-screen .zombio-stage,
#game-stage:-webkit-full-screen .zs-stage,
#game-stage:-webkit-full-screen .zman-container {
    padding: 0;
    gap: 0;
}

/* Zombio 512×264 (landscape ~1.94:1) */
#game-stage:fullscreen .zombio-stage canvas,
#game-stage:-webkit-full-screen .zombio-stage canvas {
    width: min(100vw, calc(100vh * (512 / 264)));
    width: min(100dvw, calc(100dvh * (512 / 264)));
    height: auto;
    max-width: unset;
}

/* ZSurvive 640×376 (landscape ~1.70:1) */
#game-stage:fullscreen .zs-stage canvas,
#game-stage:-webkit-full-screen .zs-stage canvas {
    width: min(100vw, calc(100vh * (640 / 376)));
    width: min(100dvw, calc(100dvh * (640 / 376)));
    height: auto;
    max-width: unset;
}

/* ZMan 448×496 (portrait ~0.90:1) */
#game-stage:fullscreen .zman-container canvas,
#game-stage:-webkit-full-screen .zman-container canvas {
    width: min(100vw, calc(100vh * (448 / 496)));
    width: min(100dvw, calc(100dvh * (448 / 496)));
    height: auto;
    max-width: unset;
}

/* Hide control hints in fullscreen */
#game-stage:fullscreen .zombio-hint,
#game-stage:fullscreen .zs-hint,
#game-stage:fullscreen .zman-hint,
#game-stage:-webkit-full-screen .zombio-hint,
#game-stage:-webkit-full-screen .zs-hint,
#game-stage:-webkit-full-screen .zman-hint {
    display: none;
}

/* ── RoD normal layout: cap side-panel height at canvas height ────────────
   Without a max-height the panel grows with story-feed content, breaking
   overflow-y: auto on the feed. Canvas height = stage-width × (600/800):
     stage-width = min(90vw, (100vh - 14rem) × (800/600))
     → canvas height = min(67.5vw, 100vh - 14rem) */
.realm-game-layout .realm-side-panel {
    max-height: min(67.5vw, calc(100vh - 14rem));
}

/* Stacked layout (<820px): override with a fixed panel height.
   Uses ID selector to win specificity over the later-loaded scoped
   CSS rule (GameSidePanel.razor.css) that sets height: auto.
   Restrict to non-fullscreen so the fullscreen sizing rules below can apply. */
@media (max-width: 820px) {
    #realm-game-layout:not(:fullscreen) .realm-side-panel {
        height: 200px;
        max-height: 200px;
    }
}

/* ── RoD fullscreen: side-panel height matches canvas height ─────────────
   .realm-side-panel lives in GameSidePanel (child component, different scope
   attribute) so this rule must be global — scoped CSS in the parent can't
   reach it without ::deep.
   Horizontal overhead = 320px panel + 0.75rem gap + 2×1rem padding. */
.realm-game-layout:fullscreen .realm-side-panel,
.realm-game-layout:-webkit-full-screen .realm-side-panel {
    height: min(100vh, max(0px, calc((100vw - 320px - 2rem - 0.75rem) * (600 / 800))));
    height: min(100dvh, max(0px, calc((100dvw - 320px - 2rem - 0.75rem) * (600 / 800))));
    max-height: 100dvh;
    width: 320px;
}

/* RoD fullscreen on narrow viewports: hide the side panel and give the
   canvas the full screen width so the game remains playable. */
@media (max-width: 720px) {
    .realm-game-layout:fullscreen .realm-side-panel,
    .realm-game-layout:-webkit-full-screen .realm-side-panel {
        display: none;
    }
    .realm-game-layout:fullscreen .realm-stage,
    .realm-game-layout:-webkit-full-screen .realm-stage {
        width: min(100vw, calc(100vh * (800 / 600)));
        width: min(100dvw, calc(100dvh * (800 / 600)));
    }
}
