:root {
    --bg: #0b0d10;
    --panel: rgba(16, 19, 24, 0.92);
    --line: rgba(255, 255, 255, 0.09);
    --text: #e8eaed;
    --muted: #8b939e;
    --accent: #4ade80;
    --accent-dim: #22c55e;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    scroll-behavior: smooth;
    background: var(--bg);
    color: var(--text);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
}

#game { position: absolute; inset: 0; }

#viewport { display: block; width: 100%; height: 100%; }

#hud {
    position: absolute;
    inset: 0;
    pointer-events: none;
    image-rendering: pixelated;
    z-index: 5;
}

#gui {
    position: absolute;
    inset: 0;
    display: none;
    pointer-events: none;
    image-rendering: pixelated;
    z-index: 6;
    cursor: default;
}

.screen {
    position: absolute;
    inset: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(120% 100% at 50% 0%, #141922 0%, #08090c 70%);
}

.screen.dim {
    background: rgba(6, 8, 11, 0.78);
    backdrop-filter: blur(6px);
}

.screen.hidden { display: none; }

.death-screen {
    z-index: 25;
    display: block;
    background: transparent;
}

#deathCanvas {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    image-rendering: pixelated;
}

.panel {
    width: min(420px, calc(100vw - 48px));
    padding: 32px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--panel);
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55);
    text-align: left;
}

.controls-panel {
    width: min(760px, calc(100vw - 32px));
    max-height: calc(100vh - 32px);
    padding: 24px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--panel);
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55);
}

.controls-topline {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.controls-topline h2 { margin-bottom: 0; }

.controls-options {
    display: grid;
    gap: 6px;
}

.controls-option {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-size: 13px;
}

.controls-option input[type="range"] { width: 120px; }

.controls-list {
    max-height: min(62vh, 520px);
    margin-top: 18px;
    overflow-y: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.12);
}

.control-category {
    padding: 9px 14px 5px;
    border-bottom: 1px solid var(--line);
    color: var(--accent);
    font-size: 12px;
    font-weight: 650;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.control-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 150px 64px;
    align-items: center;
    gap: 8px;
    min-height: 42px;
    padding: 5px 10px 5px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.045);
    color: var(--text);
    font-size: 13px;
}

.control-row:last-child { border-bottom: 0; }

.control-row button {
    width: auto;
    margin: 0;
    padding: 7px 8px;
    border-radius: 6px;
    font-size: 12px;
}

.control-key.active {
    border-color: var(--accent);
    background: rgba(74, 222, 128, 0.16);
    color: var(--accent);
}

.control-key.conflict {
    border-color: #f87171;
    color: #fca5a5;
}

.control-reset:disabled { opacity: 0.35; cursor: default; }

.controls-footer {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 16px;
}

.controls-footer button { margin: 0; }

h1 {
    margin: 0 0 4px;
    font-size: 34px;
    letter-spacing: -0.02em;
    font-weight: 700;
}

h2 {
    margin: 0 0 18px;
    font-size: 22px;
    font-weight: 600;
}

.tag {
    margin: 0 0 26px;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.5;
}

.muted { color: var(--muted); font-size: 12px; margin: 10px 0 0; }

.row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 12px;
    font-size: 13px;
    color: var(--muted);
}

.row label { flex: 0 0 auto; }

select, input[type="range"] {
    flex: 1 1 auto;
    min-width: 0;
}

select {
    appearance: none;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: #14181f;
    color: var(--text);
    font-size: 13px;
    outline: none;
}

input[type="range"] {
    accent-color: var(--accent);
    background: transparent;
}

input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
}

.pack-preview {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 4px 0 14px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.02);
}

.pack-preview img {
    width: 40px;
    height: 40px;
    border-radius: 6px;
    image-rendering: pixelated;
    flex: 0 0 auto;
}

.pack-preview .muted {
    margin: 0;
    font-size: 12px;
    line-height: 1.4;
}

button {
    display: block;
    width: 100%;
    margin-top: 10px;
    padding: 12px 16px;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: #171c24;
    color: var(--text);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 120ms ease, border-color 120ms ease, transform 60ms ease;
}

button:hover { background: #1e242e; border-color: rgba(255, 255, 255, 0.16); }
button:active { transform: translateY(1px); }

button.primary {
    background: var(--accent-dim);
    border-color: transparent;
    color: #052e14;
    font-weight: 650;
}

button.primary:hover { background: var(--accent); }

.bar {
    height: 4px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.07);
    overflow: hidden;
    margin-top: 20px;
}

#loadBar {
    height: 100%;
    width: 0%;
    background: var(--accent);
    transition: width 180ms ease;
}

.hint {
    margin-top: 22px;
    padding-top: 18px;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 11.5px;
    line-height: 1.9;
}

#debug {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 10;
    padding: 8px 10px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.55);
    color: #d5f5e0;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 11px;
    line-height: 1.6;
    white-space: pre;
    pointer-events: none;
}

#debug.hidden { display: none; }

#fps {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 10;
    padding: 4px 8px;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.4);
    color: #9be7b4;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 11px;
    pointer-events: none;
}

#fps.hidden { display: none; }


/* ---------- landing page ---------- */

body {
    background: var(--bg);
}

.landing {
    min-height: 100svh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 80px 24px;
    background:
        radial-gradient(120% 90% at 50% -10%, rgba(74, 222, 128, 0.10) 0%, transparent 60%),
        radial-gradient(100% 80% at 50% 110%, rgba(56, 120, 255, 0.08) 0%, transparent 60%),
        var(--bg);
    border-bottom: 1px solid var(--line);
}

.landing-inner {
    width: min(760px, 100%);
    text-align: center;
}

.eyebrow {
    font-size: 12px;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 22px;
}

.hero-title {
    margin: 0;
    font-size: clamp(56px, 13vw, 132px);
    line-height: 0.92;
    letter-spacing: -0.04em;
    font-weight: 800;
    background: linear-gradient(180deg, #ffffff 20%, #7f8a99 120%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.hero-sub {
    margin: 22px auto 0;
    max-width: 560px;
    color: var(--muted);
    font-size: 15px;
    line-height: 1.65;
}

.hero-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 34px;
    flex-wrap: wrap;
}

.cta {
    display: inline-block;
    padding: 13px 30px;
    border-radius: 10px;
    background: var(--accent-dim);
    color: #052e14;
    font-size: 14px;
    font-weight: 650;
    text-decoration: none;
    border: 1px solid transparent;
    transition: background 120ms ease, transform 60ms ease;
}

.cta:hover { background: var(--accent); }
.cta:active { transform: translateY(1px); }

.cta.ghost {
    background: transparent;
    border-color: var(--line);
    color: var(--text);
}

.cta.ghost:hover { background: #171c24; border-color: rgba(255, 255, 255, 0.18); }

.stats {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 52px;
}

.stat {
    min-width: 116px;
    padding: 14px 18px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.02);
}

.stat b {
    display: block;
    font-size: 20px;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
}

.stat span {
    display: block;
    margin-top: 4px;
    font-size: 11px;
    color: var(--muted);
    letter-spacing: 0.04em;
}

.scroll-hint {
    margin-top: 44px;
    font-size: 11px;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: #5c6673;
}

.strip {
    padding: 72px 24px;
    border-bottom: 1px solid var(--line);
}

.strip-inner {
    width: min(1040px, 100%);
    margin: 0 auto;
    display: grid;
    gap: 28px;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.strip article h3 {
    margin: 0 0 10px;
    font-size: 15px;
    font-weight: 620;
}

.strip article p {
    margin: 0;
    color: var(--muted);
    font-size: 13.5px;
    line-height: 1.75;
}

.strip code {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12.5px;
    color: #a9d9bb;
}

.play-section {
    padding: 0;
    background: #000;
}

/* The game and every overlay it owns are positioned against this box. */
#app {
    position: relative;
    width: 100%;
    height: 100svh;
    overflow: hidden;
    background: #000;
}



/* ---------- multiplayer lobby ---------- */

input[type="text"] {
    flex: 1 1 auto;
    min-width: 0;
    padding: 9px 11px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: #14181f;
    color: var(--text);
    font-size: 13px;
    outline: none;
    font-family: inherit;
}

input[type="text"]:focus { border-color: var(--accent-dim); }

#mpCode {
    text-transform: uppercase;
    letter-spacing: 0.24em;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 18px 0 14px;
    color: #5c6673;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.16em;
}

.divider::before,
.divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--line);
}

.code-display {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin: 4px 0 20px;
    padding: 14px 16px;
    border: 1px dashed rgba(74, 222, 128, 0.35);
    border-radius: 10px;
    background: rgba(74, 222, 128, 0.06);
}

#lobbyCode {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 28px;
    font-weight: 700;
    letter-spacing: 0.22em;
    color: var(--accent);
}

.inline-btn {
    width: auto;
    margin: 0;
    padding: 7px 14px;
    font-size: 12px;
}

.lobby-row { color: var(--muted); }
.lobby-name { color: var(--text); font-size: 13px; }
.lobby-name.pending { color: #5c6673; font-style: italic; }

.error-text {
    min-height: 16px;
    margin: 12px 0 0;
    color: #ff6b6b;
    font-size: 12px;
}

button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

button:disabled:hover { background: #171c24; border-color: var(--line); }
button.primary:disabled:hover { background: var(--accent-dim); }

#netPing {
    position: absolute;
    top: 28px;
    right: 8px;
    z-index: 10;
    padding: 4px 8px;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.4);
    color: #9be7b4;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 11px;
    pointer-events: none;
}

#netPing.hidden { display: none; }
