:root {
	--night: #0f131e;
	--panel: #1b2236;
	--panel-deep: #141a2a;
	--ink: #080b13;
	--line: #34406a;
	--gold: #f4b847;
	--gold-deep: #b9761f;
	--cream: #f7ecd2;
	--muted: #a3add0;
	--soul: #7ff3ff;
	--hood: #8f62d6;
	--pixel: 4px;
	color-scheme: dark;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 72px; }

body {
	margin: 0;
	background: var(--night);
	color: var(--cream);
	font: 400 1.0625rem/1.6 Nunito, system-ui, sans-serif;
	overflow-x: hidden;
}

img, video, canvas { display: block; max-width: 100%; }

canvas, .stage img, .gallery img, .card img { image-rendering: pixelated; }

/* Pixelify Sans draws its "fi" ligature as one glyph that reads as "A". */
h1, h2, h3 { font-family: "Pixelify Sans", system-ui, sans-serif; font-variant-ligatures: none; line-height: 1.1; margin: 0; }

a { color: var(--gold); }

:focus-visible { outline: 3px solid var(--soul); outline-offset: 3px; }

/* ------------------------------------------------------------ Bar */

.bar {
	position: fixed;
	inset: 0 0 auto;
	z-index: 10;
	display: flex;
	align-items: center;
	gap: 24px;
	padding: 10px clamp(16px, 4vw, 40px);
	background: linear-gradient(var(--night), rgb(15 19 30 / 0.7) 70%, transparent);
	backdrop-filter: blur(6px);
}

.brand {
	display: flex;
	align-items: center;
	gap: 10px;
	color: var(--cream);
	text-decoration: none;
	font: 1rem Silkscreen, monospace;
	letter-spacing: 0.04em;
}

.brand img { image-rendering: pixelated; }

.bar nav { display: flex; gap: 22px; margin-left: auto; }

.bar nav a {
	color: var(--muted);
	text-decoration: none;
	font: 0.8rem Silkscreen, monospace;
}

.bar nav a:hover { color: var(--cream); }

/* ------------------------------------------------------------ Buttons and panels */

.button {
	--depth: 5px;
	display: inline-block;
	padding: 12px 22px 10px;
	border: 0;
	background: var(--gold);
	color: #2a1806;
	font: 0.9rem Silkscreen, monospace;
	text-decoration: none;
	cursor: pointer;
	box-shadow:
		0 0 0 3px var(--ink),
		inset 0 -4px 0 var(--gold-deep),
		inset 0 3px 0 #ffe39b,
		0 var(--depth) 0 3px var(--ink);
	transform: translateY(0);
	transition: transform 0.08s, box-shadow 0.08s;
}

.button:hover { transform: translateY(-2px); --depth: 7px; }
.button:active { transform: translateY(3px); --depth: 2px; }

.button.ghost {
	background: var(--panel);
	color: var(--cream);
	box-shadow:
		0 0 0 3px var(--ink),
		inset 0 0 0 2px var(--line),
		0 var(--depth) 0 3px var(--ink);
}

.button.small { padding: 8px 14px 6px; font-size: 0.75rem; }

.panel {
	background: var(--panel);
	box-shadow: 0 0 0 3px var(--ink), inset 0 0 0 3px var(--line), 0 18px 40px rgb(0 0 0 / 0.35);
}

.tab {
	display: inline-block;
	margin: 0 0 14px;
	padding: 5px 12px 3px;
	background: var(--gold);
	color: #2a1806;
	font: 0.8rem Silkscreen, monospace;
	box-shadow: 0 0 0 3px var(--ink), inset 0 -3px 0 var(--gold-deep);
}

/* ------------------------------------------------------------ Hero stage */

.stage {
	position: relative;
	aspect-ratio: 418 / 240;
	max-height: 92vh;
	width: 100%;
	overflow: hidden;
	background: #2a2440;
}

/* The world is 426 low-res pixels wide; 4 px each side stay hidden for the pointer parallax. */
.world {
	position: absolute;
	top: 0;
	bottom: 0;
	left: calc(-4 / 418 * 100%);
	width: calc(426 / 418 * 100%);
}

.world > * {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
}

.stage::after {
	content: "";
	position: absolute;
	inset: 0;
	pointer-events: none;
	background:
		linear-gradient(rgb(15 19 30 / 0.78), rgb(15 19 30 / 0.15) 34%, transparent 50%),
		linear-gradient(transparent 82%, var(--night));
}

.fallback { display: none; position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.no-webgl .fallback { display: block; }
.no-webgl .world { display: none; }

.hero { position: relative; }

.hero-copy {
	position: absolute;
	z-index: 2;
	top: clamp(64px, 9vw, 120px);
	left: 0;
	right: 0;
	text-align: center;
	padding: 0 16px;
}

.hero-copy h1 img {
	width: min(560px, 62vw);
	height: auto;
	margin: 0 auto;
	image-rendering: auto;
	filter: drop-shadow(0 6px 0 rgb(8 11 19 / 0.6));
	animation: rise 0.9s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}

.tagline {
	margin: 0.4em 0 0;
	font: 700 clamp(1rem, 2.4vw, 1.7rem) "Pixelify Sans", sans-serif;
	text-shadow: 0 3px 0 var(--ink);
	animation: rise 0.9s 0.15s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}

.callout {
	position: absolute;
	z-index: 2;
	left: calc((122 - 4) / 418 * 100%);
	top: calc(96 / 240 * 100%);
	transform: translate(-50%, 0) scale(0.6);
	opacity: 0;
	font: 700 clamp(1rem, 3vw, 2.6rem) "Pixelify Sans", sans-serif;
	color: var(--gold);
	text-align: center;
	text-shadow: 0 3px 0 var(--ink), 3px 0 0 var(--ink), -3px 0 0 var(--ink), 0 -3px 0 var(--ink);
	transition: opacity 0.2s, transform 0.3s cubic-bezier(0.2, 1.6, 0.4, 1);
	pointer-events: none;
}

.callout small {
	display: block;
	font: clamp(0.55rem, 1.1vw, 0.9rem) Silkscreen, monospace;
	color: var(--cream);
}

.callout.show { opacity: 1; transform: translate(-50%, 0) scale(1); }

.hero-band {
	position: relative;
	z-index: 3;
	max-width: 880px;
	margin: clamp(-90px, -6vw, -24px) auto 0;
	padding: 0 16px;
	text-align: center;
}

.hero-band p { font-size: 1.15rem; color: var(--cream); margin: 0 0 26px; }
.hero-band strong { color: var(--gold); }

.actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 18px; }

@keyframes rise {
	from { opacity: 0; transform: translateY(24px) scale(0.92); }
}

/* ------------------------------------------------------------ Stats */

.stats {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 12px 40px;
	max-width: 1100px;
	margin: 72px auto 0;
	padding: 0 16px;
	list-style: none;
	color: var(--muted);
	font: 0.8rem Silkscreen, monospace;
	text-align: center;
}

.stats b {
	display: block;
	font: 700 2.4rem "Pixelify Sans", sans-serif;
	color: var(--cream);
	text-shadow: 0 4px 0 var(--ink);
}

/* ------------------------------------------------------------ Sections */

.section { max-width: 1200px; margin: 0 auto; padding: 110px 16px 0; }

.section-head { max-width: 720px; margin: 0 auto 44px; text-align: center; }

.kicker { font: 0.8rem Silkscreen, monospace; color: var(--soul); letter-spacing: 0.06em; }

.section-head h2 {
	margin: 8px 0 12px;
	font-size: clamp(2rem, 4.6vw, 3.2rem);
	text-shadow: 0 4px 0 var(--ink);
}

.section-head p { margin: 0; color: var(--muted); }

/* ------------------------------------------------------------ Fusion Lab */

.lab {
	display: grid;
	grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr) minmax(0, 1fr);
	gap: 28px;
	padding: 28px;
}

.picker { min-width: 0; }

.chips { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }

.chip {
	display: grid;
	justify-items: center;
	gap: 2px;
	padding: 6px 6px 5px;
	border: 0;
	background: var(--panel-deep);
	color: var(--muted);
	font: 0.72rem Silkscreen, monospace;
	cursor: pointer;
	box-shadow: inset 0 0 0 2px var(--line);
	transition: transform 0.1s, background 0.1s;
}

.chip canvas { width: 60px; height: 60px; }
.chip span { max-width: 100%; letter-spacing: -0.03em; }
.chip:hover { transform: translateY(-2px); color: var(--cream); background: #222b45; }

.chip[aria-pressed="true"] {
	background: #2d2a4a;
	color: var(--cream);
	box-shadow: inset 0 0 0 2px var(--gold), 0 0 0 2px var(--ink);
}

.altar { display: grid; justify-items: center; align-content: start; text-align: center; min-width: 0; }

.equation { display: flex; align-items: center; gap: 14px; }

.equation figure, .view-fused { margin: 0; }

.equation .frame { width: 140px; height: 140px; }

.op { font: 700 2rem "Pixelify Sans", sans-serif; color: var(--gold); }

.frame {
	display: grid;
	place-items: center;
	background: var(--panel-deep);
	box-shadow: inset 0 0 0 2px var(--line);
	padding: 4px;
}

.view-fused { width: 100%; margin-top: 18px; }
.frame.big { background: linear-gradient(var(--panel-deep), #221f40); }
.frame.big canvas { cursor: grab; touch-action: pan-y; }
.frame.big canvas:active { cursor: grabbing; }

.tag { margin-top: 6px; font: 0.72rem Silkscreen, monospace; color: var(--muted); }

.fusion-name {
	margin: 18px 0 6px;
	font-size: clamp(1.8rem, 3.6vw, 2.6rem);
	color: var(--gold);
	text-shadow: 0 4px 0 var(--ink);
}

.fusion-body, .fusion-power { margin: 4px 0; color: var(--muted); max-width: 46ch; }
.fusion-body b, .fusion-power b { color: var(--cream); }
.fusion-power i { color: var(--soul); font-style: normal; font-weight: 800; }
.fusion-body i { color: var(--cream); font-style: normal; font-weight: 800; }

.altar .actions { margin-top: 20px; }

.hint { margin: 18px 0 0; font-size: 0.85rem; color: #bea2f2; }

.lab-fallback { display: none; grid-column: 1 / -1; text-align: center; }
.no-webgl .lab > :not(.lab-fallback) { display: none; }
.no-webgl .lab-fallback { display: block; }
html:not(.lab-ready):not(.no-webgl) .lab { opacity: 0.4; pointer-events: none; }
.lab { transition: opacity 0.4s; }

/* ------------------------------------------------------------ Feature cards */

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 26px; perspective: 900px; }

.card {
	padding: 10px 10px 22px;
	transition: transform 0.25s cubic-bezier(0.2, 1.2, 0.4, 1), box-shadow 0.25s;
	transform-style: preserve-3d;
}

.card:hover {
	transform: rotateX(4deg) rotateY(-5deg) translateY(-6px);
	box-shadow: 0 0 0 3px var(--ink), inset 0 0 0 3px var(--gold), 0 30px 50px rgb(0 0 0 / 0.45);
}

.card img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; box-shadow: 0 0 0 2px var(--ink); }
.card h3 { margin: 18px 12px 8px; font-size: 1.5rem; }
.card p { margin: 0 12px; color: var(--muted); font-size: 0.98rem; }

.riddles { margin-top: 40px; padding: 26px 28px 20px; }

.riddle-list {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
	gap: 14px 28px;
	margin: 0;
	padding: 0;
	list-style: none;
}

.riddle-list li { display: flex; align-items: center; gap: 14px; color: var(--cream); font-style: italic; }

.mystery {
	flex: none;
	display: grid;
	place-items: center;
	width: 36px;
	height: 36px;
	background: #2a1f4a;
	color: var(--hood);
	font: 700 1.3rem "Pixelify Sans", sans-serif;
	font-style: normal;
	box-shadow: inset 0 0 0 2px var(--hood);
}

/* ------------------------------------------------------------ Gallery, video, footer */

.gallery { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 22px; }
.gallery figure { margin: 0; }
.gallery img { width: 100%; aspect-ratio: 426 / 240; object-fit: cover; box-shadow: 0 0 0 3px var(--ink), 0 14px 30px rgb(0 0 0 / 0.35); }
.gallery figcaption { margin-top: 10px; font: 0.75rem Silkscreen, monospace; color: var(--muted); }

.video { padding: 10px; max-width: 960px; margin: 0 auto; }
.video video { width: 100%; aspect-ratio: 16 / 9; background: var(--ink); }

.footer {
	max-width: 760px;
	margin: 120px auto 0;
	padding: 0 16px 60px;
	text-align: center;
	color: var(--muted);
}

.footer img { margin: 0 auto 14px; }
.footer strong { color: var(--cream); }

/* ------------------------------------------------------------ Small screens and motion */

@media (max-width: 900px) {
	.lab { grid-template-columns: 1fr 1fr; padding: 20px; }
	.altar { grid-column: 1 / -1; order: -1; }
}

@media (max-width: 560px) {
	.bar nav { display: none; }
	.bar .button { margin-left: auto; }
	.lab { grid-template-columns: 1fr; }
	.hero-copy { position: static; padding-top: 76px; padding-bottom: 8px; }
	.stage { aspect-ratio: 300 / 240; }
	.stage::after { background: linear-gradient(var(--night), transparent 18%, transparent 80%, var(--night)); }
	/* Keeps the party (x 80) and the foes (x 370) of the 426 px world in a 300 px window. */
	.world { left: calc(-75 / 300 * 100%); width: calc(426 / 300 * 100%); }
	.callout { left: calc((122 - 75) / 300 * 100%); }
	.hero-band p { font-size: 1rem; }
}

@media (prefers-reduced-motion: reduce) {
	html { scroll-behavior: auto; }
	*, *::before, *::after { animation: none !important; transition: none !important; }
}
