:root {
	color-scheme: dark;
	--bg: #10131a;
	--panel: #171c24;
	--panel-2: #202633;
	--text: #edf2f8;
	--muted: #a9b5c4;
	--line: #333b49;
	--primary: #4f8cff;
	--primary-strong: #76a8ff;
	--accent: #6ee5a0;
	--warn: #f4b95f;
	--danger: #ff6b78;
	font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
	background: var(--bg);
	color: var(--text);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--bg); }
a { color: inherit; }

.site-header {
	position: sticky;
	top: 0;
	z-index: 10;
	display: grid;
	grid-template-columns: auto 1fr auto;
	align-items: center;
	gap: 1rem;
	padding: 0.85rem clamp(1rem, 4vw, 3rem);
	border-bottom: 1px solid var(--line);
	background: color-mix(in oklab, var(--bg) 88%, transparent);
	backdrop-filter: blur(12px);
}

.brand {
	font-weight: 800;
	font-size: 1.25rem;
	text-decoration: none;
}

nav {
	display: flex;
	gap: 0.8rem;
	flex-wrap: wrap;
}

nav a,
.text-link {
	color: var(--primary-strong);
	text-decoration: none;
	font-weight: 650;
}

.header-actions,
.actions {
	display: flex;
	align-items: center;
	gap: 0.65rem;
	flex-wrap: wrap;
}

.header-actions form { margin: 0; }

.primary-button,
.secondary-button,
.ghost-button,
button.primary-button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 2.35rem;
	border-radius: 0.45rem;
	padding: 0 0.9rem;
	border: 1px solid var(--line);
	text-decoration: none;
	font-weight: 750;
	cursor: pointer;
}

.primary-button,
button.primary-button {
	border-color: color-mix(in oklab, var(--primary) 70%, white);
	background: var(--primary);
	color: white;
}

.secondary-button,
.ghost-button {
	background: var(--panel-2);
	color: var(--text);
}

.ghost-button {
	min-height: 2rem;
	padding: 0 0.7rem;
}

.full { width: 100%; }

main {
	width: min(1180px, calc(100% - 2rem));
	margin: 0 auto;
}

.hero {
	min-height: calc(100svh - 5rem);
	display: grid;
	grid-template-columns: minmax(0, 0.95fr) minmax(320px, 1.05fr);
	align-items: center;
	gap: clamp(2rem, 6vw, 5rem);
	padding: clamp(3rem, 8vw, 5rem) 0 2rem;
}

.hero h1,
.page-title h1 {
	margin: 0;
	font-size: clamp(3rem, 10vw, 7rem);
	line-height: 0.9;
	letter-spacing: 0;
}

.hero p,
.page-title p {
	color: var(--muted);
	font-size: 1.05rem;
	line-height: 1.6;
	max-width: 56rem;
}

.eyebrow {
	color: var(--accent) !important;
	text-transform: uppercase;
	font-size: 0.78rem !important;
	font-weight: 800;
	letter-spacing: 0.08em;
	margin: 0 0 0.8rem;
}

.world-preview {
	aspect-ratio: 1.25;
	border: 1px solid var(--line);
	border-radius: 0.5rem;
	background:
		radial-gradient(circle at 30% 25%, color-mix(in oklab, var(--accent) 24%, transparent), transparent 30%),
		linear-gradient(145deg, #17202a, #0a0d12);
	overflow: hidden;
	position: relative;
}

.metric-strip,
.status-metrics {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: 0.75rem;
	margin: 1rem 0 3rem;
}

.metric-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.metric-strip div,
.status-metrics article,
.content-card,
.world-card,
.admin-card,
.table-panel,
.detail-aside {
	background: var(--panel);
	border: 1px solid var(--line);
	border-radius: 0.5rem;
}

.metric-strip div,
.status-metrics article {
	padding: 1rem;
}

.metric-strip strong,
.status-metrics strong {
	display: block;
	font-size: 2rem;
}

.metric-strip span,
.status-metrics span,
td span {
	color: var(--muted);
}

.section-grid,
.page {
	padding: clamp(2.5rem, 6vw, 4.5rem) 0;
}

.two-column,
.detail-layout,
.ops-layout {
	display: grid;
	grid-template-columns: minmax(220px, 0.75fr) minmax(0, 1.25fr);
	gap: clamp(1.5rem, 4vw, 3rem);
}

.section-heading h2,
.page-title h1 {
	font-size: clamp(2rem, 5vw, 4rem);
	line-height: 1;
}

.card-list,
.content-grid,
.world-directory,
.play-world-grid,
.timeline {
	display: grid;
	gap: 1rem;
}

.content-grid {
	grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.docs-landing-title .page-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 0.75rem;
	margin-top: 1.25rem;
}

.doc-spotlight {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: 1rem;
	margin: 2rem 0;
}

.doc-spotlight article,
.doc-flow {
	background: var(--panel);
	border: 1px solid var(--line);
	border-radius: 0.5rem;
	padding: 1rem;
}

.doc-spotlight h2,
.doc-flow h2 {
	margin: 0 0 0.6rem;
}

.doc-spotlight p,
.doc-flow span {
	color: var(--muted);
	line-height: 1.6;
}

.doc-flow {
	display: grid;
	grid-template-columns: minmax(220px, 0.45fr) minmax(0, 1fr);
	gap: clamp(1rem, 3vw, 2rem);
	margin: 0 0 1rem;
}

.doc-flow ol {
	display: grid;
	gap: 0.75rem;
	margin: 0;
	padding: 0;
	list-style: none;
	counter-reset: docs-flow;
}

.doc-flow li {
	counter-increment: docs-flow;
	display: grid;
	grid-template-columns: auto 1fr;
	gap: 0.2rem 0.75rem;
	align-items: start;
}

.doc-flow li::before {
	content: counter(docs-flow);
	display: grid;
	place-items: center;
	width: 1.8rem;
	height: 1.8rem;
	border-radius: 999px;
	background: color-mix(in oklab, var(--primary) 28%, var(--panel-2));
	color: var(--text);
	font-weight: 800;
}

.doc-flow strong,
.doc-flow span {
	grid-column: 2;
}

.play-world-grid {
	grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.card-list article,
.timeline article,
.content-card,
.world-card,
.admin-card {
	padding: 1rem;
}

.content-card {
	display: block;
	text-decoration: none;
}

.world-card {
	display: flex;
	flex-direction: column;
}

.content-card h2,
.world-card h2,
.admin-card h2 {
	margin: 0 0 0.5rem;
}

.content-card p,
.world-card p,
.detail-copy,
.admin-card p {
	color: var(--muted);
	line-height: 1.6;
}

.detail-copy {
	font-size: 1.05rem;
}

.detail-aside {
	padding: 1rem;
	align-self: start;
}

.world-card-header,
.world-stats,
.status-world-list article {
	display: flex;
	justify-content: space-between;
	gap: 1rem;
	align-items: flex-start;
}

.world-card-header > span {
	color: var(--accent);
	font-weight: 800;
}

.world-stats {
	color: var(--muted);
	margin: 1rem 0;
	flex-wrap: wrap;
}

.character-list {
	display: grid;
	gap: 0.55rem;
	margin: 0 0 1rem;
}

.character-list div {
	border: 1px solid var(--line);
	border-radius: 0.4rem;
	background: color-mix(in oklab, var(--panel-2) 72%, transparent);
	padding: 0.65rem;
}

.character-list strong,
.character-list span {
	display: block;
}

.character-list span,
.empty-note {
	color: var(--muted);
	font-size: 0.9rem;
}

.world-card > .primary-button {
	margin-top: auto;
}

.play-character-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
	gap: 0.6rem;
	margin-bottom: 1rem;
}

.character-pick {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 0.2rem;
	width: 100%;
	padding: 0.85rem 1rem;
	background: var(--panel);
	border: 1px solid var(--line);
	border-radius: 0.5rem;
	color: var(--text);
	font: inherit;
	font-size: 1.15rem;
	text-align: left;
	cursor: pointer;
	transition: border-color 0.15s;
}

.character-pick:hover {
	border-color: var(--primary);
}

.play-actions {
	display: flex;
	gap: 0.75rem;
	margin-top: 1rem;
}

.create-inline {
	margin-top: 0.75rem;
	padding-top: 0.75rem;
	border-top: 1px solid var(--line);
}

.play-game-page {
	width: 100%;
	max-width: none;
	/* The site header and footer are hidden in-world (see below), so the game
	   canvas owns the whole viewport. */
	height: 100svh;
	min-height: 620px;
	margin: 0;
	padding: 0;
	overflow: hidden;
	background: #05070b;
}

#play-app {
	height: 100%;
	min-height: 0;
}

/* On short viewports — notably phones in landscape — the 620px floor above is
   taller than the visible viewport, so `overflow: hidden` clips the bottom of
   the page and pushes the bottom-anchored HUD (joystick, action buttons,
   hotbar, chat) off the bottom edge. Drop the floor there so the game fills
   exactly the visible height (100svh) and the controls stay on screen. */
@media (max-height: 620px) {
	.play-game-page {
		min-height: 0;
	}
}

/* During gameplay (the in-world Play view) the site chrome must be neither
   visible nor interactable so it can't sit over or steal clicks from the game. */
body:has(.play-game-page) .site-header,
body:has(.play-game-page) .site-footer {
	display: none;
}

/* While the escape menu is open, bring the header back as a fixed overlay
   pinned to the top of the screen. It sits above the menu overlay/card
   (z-index 1000/1001) so its links stay clickable, while the centred menu card
   leaves the top strip clear so the two don't interfere. */
body.escape-menu-open:has(.play-game-page) .site-header {
	display: grid;
	position: fixed;
	inset: 0 0 auto 0;
	z-index: 1100;
}

.play-loading {
	display: grid;
	place-items: center;
	height: 100%;
	background: var(--color-base-100);
	color: var(--text);
	font-weight: 750;
}

.status-world-list {
	display: grid;
	gap: 0.75rem;
}

.status-world-list article {
	background: var(--panel);
	border: 1px solid var(--line);
	border-radius: 0.5rem;
	padding: 0.9rem;
}

.roadmap {
	color: var(--muted);
	line-height: 1.8;
}

.auth-page {
	min-height: calc(100svh - 7rem);
	display: grid;
	place-items: center;
}

.auth-card {
	width: min(100%, 420px);
	background: var(--panel);
	border: 1px solid var(--line);
	border-radius: 0.5rem;
	padding: 1.25rem;
}

.auth-card h1 {
	margin: 0 0 1rem;
}

label {
	display: block;
	margin: 0.8rem 0 0.3rem;
	color: var(--muted);
	font-size: 0.9rem;
	font-weight: 650;
}

input,
select,
textarea {
	width: 100%;
	border: 1px solid var(--line);
	border-radius: 0.4rem;
	background: #0c0f14;
	color: var(--text);
	padding: 0.65rem 0.7rem;
	font: inherit;
}

.validation {
	display: block;
	color: var(--danger);
	font-size: 0.85rem;
	margin-top: 0.25rem;
}

.form-note {
	color: var(--muted);
}

.toolbar {
	display: flex;
	gap: 0.75rem;
	margin-bottom: 1rem;
}

.toolbar input { max-width: 34rem; }

.satellite-toolbar {
	display: grid;
	grid-template-columns: minmax(220px, 1.4fr) minmax(120px, 0.6fr) minmax(120px, 0.6fr) auto auto;
	gap: 0.75rem;
	align-items: end;
	margin-bottom: 1rem;
}

.satellite-toolbar label {
	margin: 0;
}

.satellite-toolbar label span {
	display: block;
	margin-bottom: 0.3rem;
	color: var(--muted);
	font-size: 0.9rem;
	font-weight: 650;
}

.satellite-shell {
	display: grid;
	grid-template-columns: minmax(0, 1fr) 180px;
	gap: 1rem;
	align-items: start;
}

.satellite-map-wrap {
	min-height: min(72svh, 760px);
	display: grid;
	place-items: center;
	border: 1px solid var(--line);
	border-radius: 0.5rem;
	background: #05070b;
	overflow: hidden;
}

#satellite-map {
	width: min(100%, 760px);
	aspect-ratio: 1;
	height: auto;
	image-rendering: pixelated;
	image-rendering: crisp-edges;
	cursor: grab;
	touch-action: none;
	background: #05070b;
}

#satellite-map:active {
	cursor: grabbing;
}

.satellite-readout {
	display: grid;
	gap: 0.35rem;
	padding: 0.9rem;
	border: 1px solid var(--line);
	border-radius: 0.5rem;
	background: var(--panel);
}

.satellite-readout strong {
	font-size: 1.35rem;
}

.satellite-readout span {
	color: var(--muted);
}

table {
	width: 100%;
	border-collapse: collapse;
}

th,
td {
	text-align: left;
	border-bottom: 1px solid var(--line);
	padding: 0.75rem;
	vertical-align: top;
}

td span {
	display: block;
	font-size: 0.75rem;
	margin-top: 0.25rem;
	overflow-wrap: anywhere;
}

dl {
	display: grid;
	grid-template-columns: 7rem 1fr;
	gap: 0.5rem 1rem;
}

dt { color: var(--muted); }
dd { margin: 0; }

.stack-form {
	display: grid;
	gap: 0.65rem;
	margin-bottom: 1rem;
}

.check-row {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	margin: 0;
}

.check-row input {
	width: auto;
}

.notice {
	display: inline-block;
	color: var(--accent) !important;
	background: color-mix(in oklab, var(--accent) 12%, transparent);
	border: 1px solid color-mix(in oklab, var(--accent) 35%, transparent);
	border-radius: 0.4rem;
	padding: 0.55rem 0.7rem;
}

.site-footer {
	display: flex;
	gap: 1rem;
	flex-wrap: wrap;
	justify-content: center;
	padding: 2rem 1rem;
	color: var(--muted);
	border-top: 1px solid var(--line);
}

/* Editor styles */

.texture-preview-cell { width: 3rem; }
.texture-thumb {
	width: 32px;
	height: 32px;
	image-rendering: pixelated;
	border: 1px solid var(--line);
	border-radius: 0.2rem;
}
.color-swatch {
	display: inline-block;
	width: 32px;
	height: 32px;
	border: 1px solid var(--line);
	border-radius: 0.2rem;
}
.color-swatch.inline, .color-swatch.large { vertical-align: middle; }
.color-swatch.large { width: 64px; height: 64px; }

.texture-preview-large img {
	width: 128px;
	height: 128px;
	image-rendering: pixelated;
	border: 1px solid var(--line);
	border-radius: 0.3rem;
}

.face-grid {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: 1rem;
}
.face-tile {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 0.3rem;
}
.face-tile .texture-preview {
	width: 64px;
	height: 64px;
	image-rendering: pixelated;
	border: 1px solid var(--line);
	border-radius: 0.3rem;
}
.face-label { font-weight: 600; font-size: 0.85rem; }
.face-overlay-label { font-size: 0.75rem; color: var(--muted); }

.node-preview-3d {
	display: flex;
	justify-content: center;
	background: #181c24;
	border: 1px solid var(--line);
	border-radius: 0.4rem;
	padding: 0.5rem;
}
.node-preview-3d canvas { border-radius: 0.3rem; }

.json-editor-layout {
	display: grid;
	gap: 1rem;
}
.json-editor-layout textarea {
	width: 100%;
	min-height: 30rem;
	font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
	font-size: 0.85rem;
	line-height: 1.5;
	tab-size: 2;
	background: #0c0f14;
	color: var(--text);
	border: 1px solid var(--line);
	border-radius: 0.4rem;
	padding: 1rem;
	resize: vertical;
}
.json-editor-actions {
	display: flex;
	gap: 0.75rem;
}

.notice.error {
	color: var(--danger) !important;
	background: color-mix(in oklab, var(--danger) 12%, transparent);
	border-color: color-mix(in oklab, var(--danger) 35%, transparent);
}

.text-link.danger { color: var(--danger); }

@media (max-width: 760px) {
	.site-header,
	.hero,
	.two-column,
	.detail-layout,
	.ops-layout,
	.doc-flow {
		grid-template-columns: 1fr;
	}

	.site-header {
		position: static;
	}

	.header-actions,
	nav {
		justify-content: flex-start;
	}

	.metric-strip,
	.status-metrics,
	.doc-spotlight {
		grid-template-columns: 1fr;
	}

	.toolbar {
		flex-direction: column;
	}

	.satellite-toolbar,
	.satellite-shell {
		grid-template-columns: 1fr;
	}

	.satellite-map-wrap {
		min-height: auto;
	}

	.face-grid {
		grid-template-columns: repeat(2, 1fr);
	}
}
