@font-face {
	font-family: "Chunk Five";
	src:
		url("ChunkFive-Regular.woff2") format("woff2"),
		url("ChunkFive-Regular.woff") format("woff"),
		url("ChunkFive-Regular.eot");
	font-weight: normal;
	font-style: normal;
	font-display: swap;
}

:root {
	--mx: 0.5;
	--my: 0.5;
	--scroll: 0;
	--tilt-x: 0deg;
	--tilt-y: 0deg;
	--spin: 0deg;
	--warp: 0;
	--hue: 0deg;
	--invert: 0;
	--pulse: 0;
	--bg-rpt: url("/bgInit1Repeat.gif");
	--ink: #111;
	--paper: #f2efe8;
}

* {
	box-sizing: border-box;
	margin: 0;
	padding: 0;
}

html,
body {
	height: 100%;
	height: 100dvh;
	overflow: hidden;
	touch-action: none;
	overscroll-behavior: none;
	-webkit-text-size-adjust: 100%;
	text-size-adjust: 100%;
}

body {
	font-family: "Chunk Five", sans-serif;
	color: var(--ink);
	background: var(--paper);
	cursor: crosshair;
	-webkit-user-select: none;
	user-select: none;
	-webkit-tap-highlight-color: transparent;
}

#stage {
	position: fixed;
	inset: 0;
	z-index: 1;
	pointer-events: none;
	perspective: 900px;
	transform-style: preserve-3d;
	transform: rotateX(var(--tilt-x)) rotateY(var(--tilt-y)) rotateZ(var(--spin));
	contain: paint;
}

/* bottom — full page width, tiles repeat-y (like original body bg) */
.layer-repeat {
	position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	min-height: 100%;
	min-height: 100dvh;
	/* overscan so init tilt never reveals edges */
	height: 120%;
	z-index: 0;
	pointer-events: none;
	background-color: var(--paper);
	background-image: var(--bg-rpt);
	background-repeat: repeat-y;
	background-size: 100% auto;
	background-position: top left;
	transform: none;
	/* hue/invert here — not on body — so canvases aren't refiltered every frame */
	filter: hue-rotate(var(--hue)) invert(var(--invert));
	contain: paint;
}

#clouds {
	position: absolute;
	inset: 0;
	z-index: 1;
	width: 100%;
	height: 100%;
	image-rendering: pixelated;
	image-rendering: crisp-edges;
	mix-blend-mode: multiply;
	opacity: 0.92;
}

#wake {
	position: absolute;
	inset: 0;
	z-index: 2;
	width: 100%;
	height: 100%;
	opacity: 0.55;
	mix-blend-mode: multiply;
}

.brand {
	position: fixed;
	z-index: 5;
	top: max(clamp(1.2rem, 4vh, 2.5rem), env(safe-area-inset-top, 0px));
	left: max(clamp(1rem, 4vw, 2.5rem), env(safe-area-inset-left, 0px));
	pointer-events: auto;
	touch-action: manipulation;
	filter: hue-rotate(var(--hue)) invert(var(--invert));
	transform: translate3d(
			calc((var(--mx) - 0.5) * -28px),
			calc((var(--my) - 0.5) * 18px + var(--scroll) * -40px),
			0
		)
		rotate(calc((var(--mx) - 0.5) * -4deg));
	contain: layout style;
}

.brand-name {
	display: inline-block;
	font-size: clamp(2.4rem, 7vw, 5.2rem);
	font-weight: 800;
	letter-spacing: -0.04em;
	line-height: 0.95;
	color: #111;
	text-decoration: none;
	mix-blend-mode: soft-light;
	text-shadow: 0 0 0 transparent;
	transition: text-shadow 300ms ease, mix-blend-mode 200ms ease;
}

.brand-name:hover {
	mix-blend-mode: difference;
	text-shadow: 4px 4px 0 hotpink;
	background: none;
	color: #111;
}

.void {
	position: fixed;
	inset: 0;
	z-index: 1;
	pointer-events: none;
}

#echoes {
	position: fixed;
	inset: 0;
	z-index: 4;
	pointer-events: none;
	overflow: hidden;
	filter: hue-rotate(var(--hue)) invert(var(--invert));
	contain: paint;
}

.echo {
	position: absolute;
	font-family: "Chunk Five", sans-serif;
	font-weight: 700;
	letter-spacing: -0.03em;
	color: #111;
	mix-blend-mode: soft-light;
	opacity: 0.85;
	transform: translate(-50%, -50%);
	animation: echo-drift 2s ease-out forwards;
	white-space: nowrap;
	user-select: none;
}

.echo.pawn {
	font-size: 2.4rem;
	mix-blend-mode: difference;
	animation-duration: 2.4s;
}

.ripple {
	position: absolute;
	border: 1px solid rgba(20, 20, 20, 0.35);
	border-radius: 50%;
	transform: translate(-50%, -50%);
	animation: ripple-out 0.75s cubic-bezier(0.1, 0.7, 0.2, 1) forwards;
	mix-blend-mode: multiply;
}

.hole {
	position: absolute;
	width: 140px;
	height: 140px;
	border-radius: 50%;
	transform: translate(-50%, -50%);
	background-image: var(--bg-rpt);
	background-repeat: repeat-y;
	background-size: 100% auto;
	background-position: var(--hx, 0%) var(--hy, 0%);
	box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(0, 0, 0, 0.15);
	mix-blend-mode: normal;
	animation: hole-life 2s ease-in-out forwards;
	filter: contrast(1.3);
}

#cursor-twin {
	position: fixed;
	z-index: 10;
	width: 18px;
	height: 18px;
	margin: -9px 0 0 -9px;
	border: 2px solid rgba(17, 17, 17, 0.7);
	border-radius: 50%;
	pointer-events: none;
	opacity: 1;
	box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.6);
	transform: translate3d(-100px, -100px, 0);
	transition: width 120ms ease, height 120ms ease, margin 120ms ease, background 120ms ease;
}

#cursor-twin.hot {
	width: 42px;
	height: 42px;
	margin: -21px 0 0 -21px;
	background: hotpink;
	border-color: #111;
}

#orbit-trail {
	position: fixed;
	inset: 0;
	z-index: 6;
	width: 100%;
	height: 100%;
	pointer-events: none;
}

#orbit-fx {
	position: fixed;
	inset: 0;
	z-index: 6;
	width: 100%;
	height: 100%;
	pointer-events: none;
}

#rockets {
	position: fixed;
	inset: 0;
	z-index: 7;
	pointer-events: none;
	overflow: hidden;
}

.rocket {
	position: absolute;
	left: 0;
	top: 0;
	width: 10px;
	height: 22px;
	margin: -11px 0 0 -5px;
	background: linear-gradient(180deg, hotpink 0%, #111 55%, #111 100%);
	clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
	transform: translate(var(--rx, 0px), var(--ry, 0px)) rotate(var(--angle, 0deg));
	box-shadow: 0 0 8px rgba(255, 20, 147, 0.45);
}

.rocket.orbiting {
	box-shadow: 0 0 10px rgba(255, 20, 147, 0.65);
}

.rocket.orbit-locked {
	box-shadow:
		0 0 14px rgba(255, 20, 147, 0.9),
		0 0 28px rgba(255, 80, 160, 0.45);
}

.rocket.orbit-drone {
	cursor: pointer;
	animation: orbit-drone-pulse 1.1s ease-in-out infinite;
	box-shadow:
		0 0 16px rgba(255, 20, 147, 1),
		0 0 36px rgba(255, 60, 140, 0.7),
		0 0 56px rgba(180, 40, 255, 0.35);
}

@keyframes orbit-drone-pulse {
	0%,
	100% {
		filter: brightness(1);
	}
	50% {
		filter: brightness(1.4);
	}
}

.rocket::after {
	content: "";
	position: absolute;
	left: 50%;
	bottom: -10px;
	width: 4px;
	height: 12px;
	margin-left: -2px;
	background: linear-gradient(180deg, rgba(255, 120, 40, 0.9), transparent);
	border-radius: 50%;
	filter: blur(1px);
}

.explosion-canvas {
	position: fixed;
	inset: 0;
	z-index: 999;
	width: 100%;
	height: 100%;
	pointer-events: none;
	image-rendering: pixelated;
	image-rendering: crisp-edges;
	mix-blend-mode: multiply;
}

body.exploded {
	cursor: none;
}

body.exploded > *:not(.explosion-canvas):not(.rebuild-flash):not(#cursor-twin):not(#rockets) {
	animation: page-shred 0.65s steps(6, end) forwards;
}

body.exploded .layer-repeat {
	animation-delay: 0.02s;
}

body.exploded #stage {
	animation-delay: 0.05s;
}

.rebuild-flash {
	position: fixed;
	inset: 0;
	z-index: 998;
	background: var(--paper);
	opacity: 0;
	pointer-events: none;
	animation: rebuild-in 0.8s steps(4, end) forwards;
}

@keyframes page-shred {
	0% {
		transform: scale(1) rotate(0deg);
		filter: none;
		opacity: 1;
	}
	35% {
		transform: scale(1.06) rotate(calc(var(--shred-r, 1) * 4deg));
		filter: contrast(1.6) brightness(1.4);
	}
	100% {
		transform: scale(2.2) rotate(calc(var(--shred-r, 1) * 14deg));
		filter: contrast(2.2) brightness(2.8);
		opacity: 0;
	}
}

@keyframes rebuild-in {
	0% {
		opacity: 1;
	}
	100% {
		opacity: 0;
	}
}

.hint {
	position: fixed;
	z-index: 5;
	right: 1.4rem;
	bottom: 1.2rem;
	font-size: 0.75rem;
	letter-spacing: 0.18em;
	text-transform: uppercase;
	opacity: 0.45;
	mix-blend-mode: multiply;
	pointer-events: none;
	transform: translateY(calc(var(--scroll) * -20px));
}

@keyframes echo-drift {
	0% {
		opacity: 0;
		filter: blur(6px);
		transform: translate(-50%, -50%) scale(0.4) rotate(-8deg);
	}
	12% {
		opacity: 0.9;
		filter: blur(0);
	}
	100% {
		opacity: 0;
		filter: blur(2px);
		transform: translate(
				calc(-50% + (var(--ex, 1) * 80px)),
				calc(-50% + (var(--ey, -1) * 120px))
			)
			scale(1.35)
			rotate(12deg);
	}
}

@keyframes ripple-out {
	0% {
		width: 12px;
		height: 12px;
		opacity: 0.8;
	}
	100% {
		width: 420px;
		height: 420px;
		opacity: 0;
	}
}

@keyframes hole-life {
	0% {
		opacity: 0;
		transform: translate(-50%, -50%) scale(0.2) rotate(0deg);
	}
	15% {
		opacity: 1;
		transform: translate(-50%, -50%) scale(1) rotate(8deg);
	}
	85% {
		opacity: 0.85;
	}
	100% {
		opacity: 0;
		transform: translate(-50%, -50%) scale(1.4) rotate(-18deg);
	}
}

@media (max-width: 640px) {
	.brand-name {
		font-size: clamp(2rem, 12vw, 3rem);
	}

	#cursor-twin {
		width: 22px;
		height: 22px;
		margin: -11px 0 0 -11px;
	}

	#cursor-twin.hot {
		width: 48px;
		height: 48px;
		margin: -24px 0 0 -24px;
	}

	#arrakis-gate {
		width: 44px;
		height: 72px;
		margin-top: -36px;
	}

	.rocket.orbit-drone {
		width: 14px;
		height: 30px;
		margin: -15px 0 0 -7px;
	}
}

@media (pointer: coarse) {
	body {
		cursor: none;
	}

	#cursor-twin {
		/* twin is the only “cursor” on touch */
		opacity: 1;
	}
}

/*
 * Mobile FF/Chrome often composes filtered layers + multiply-blend canvases
 * to solid black. Flatten stacking and drop blend modes on touch/narrow viewports.
 */
@media (pointer: coarse), (max-width: 640px) {
	html.safe-composite #stage,
	html.safe-composite .layer-repeat,
	html.safe-composite #echoes {
		contain: none;
	}

	html.safe-composite #stage {
		perspective: none;
		transform-style: flat;
		transform: rotateZ(var(--spin));
	}

	html.safe-composite .brand {
		transform: translate3d(
				calc((var(--mx) - 0.5) * -18px),
				calc((var(--my) - 0.5) * 12px + var(--scroll) * -24px),
				0
			)
			rotate(calc((var(--mx) - 0.5) * -3deg));
	}

	html.safe-composite #clouds,
	html.safe-composite #wake,
	html.safe-composite .explosion-canvas,
	html.safe-composite .ripple,
	html.safe-composite .hint {
		mix-blend-mode: normal;
	}

	html.safe-composite #clouds {
		opacity: 0.48;
	}

	html.safe-composite #wake {
		opacity: 0.38;
	}

	html.safe-composite #echoes,
	html.safe-composite .brand {
		filter: none;
	}

	html.safe-composite .brand-name,
	html.safe-composite .echo {
		mix-blend-mode: normal;
		color: #111;
	}

	html.safe-composite .layer-repeat {
		filter: none;
	}
}

#arrakis-gate {
	position: fixed;
	left: 0;
	top: 50%;
	width: 28px;
	height: 56px;
	margin-top: -28px;
	padding: 0;
	border: 0;
	background: transparent;
	opacity: 0;
	cursor: default;
	z-index: 6;
	pointer-events: auto;
}

.dev-panel {
	position: fixed;
	right: max(0.65rem, env(safe-area-inset-right, 0px));
	bottom: max(0.55rem, env(safe-area-inset-bottom, 0px));
	z-index: 20;
	display: flex;
	flex-direction: column;
	width: min(15rem, calc(100vw - 1.2rem));
	max-height: min(62vh, 420px);
	padding: 0.55rem 0.55rem 0.5rem;
	font-family: ui-monospace, "Cascadia Code", "Consolas", monospace;
	font-size: 0.62rem;
	line-height: 1.4;
	color: rgba(242, 239, 232, 0.92);
	background: rgba(17, 17, 17, 0.88);
	border: 1px solid rgba(242, 239, 232, 0.14);
	box-shadow: 0 8px 28px rgba(0, 0, 0, 0.28);
	pointer-events: auto;
	touch-action: pan-y;
	user-select: none;
	-webkit-font-smoothing: antialiased;
	overscroll-behavior: contain;
}

.dev-panel--hidden {
	display: none;
}

.dev-panel--tone {
	right: auto;
	left: max(0.65rem, env(safe-area-inset-left, 0px));
}

.dev-panel-head {
	flex: 0 0 auto;
	margin-bottom: 0.35rem;
	padding-bottom: 0.3rem;
	border-bottom: 1px solid rgba(242, 239, 232, 0.12);
	font-size: 0.58rem;
	letter-spacing: 0.14em;
	text-transform: uppercase;
	opacity: 0.72;
}

.dev-panel-head kbd {
	display: inline-block;
	margin-left: 0.25rem;
	padding: 0.05rem 0.28rem;
	font-size: 0.55rem;
	letter-spacing: 0;
	text-transform: none;
	border: 1px solid rgba(242, 239, 232, 0.22);
	border-radius: 2px;
	opacity: 0.85;
}

.dev-panel-body {
	flex: 1 1 auto;
	min-height: 0;
	overflow-x: hidden;
	overflow-y: auto;
	scrollbar-width: thin;
	scrollbar-color: rgba(242, 239, 232, 0.28) transparent;
}

.dev-panel-body::-webkit-scrollbar {
	width: 5px;
}

.dev-panel-body::-webkit-scrollbar-thumb {
	background: rgba(242, 239, 232, 0.22);
	border-radius: 3px;
}

.dev-section {
	margin: 0 0 0.2rem;
	border-bottom: 1px solid rgba(242, 239, 232, 0.08);
}

.dev-section:last-child {
	border-bottom: 0;
	margin-bottom: 0;
}

.dev-section > summary {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 0.28rem 0.1rem;
	font-size: 0.58rem;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	color: rgba(255, 105, 180, 0.9);
	cursor: pointer;
	list-style: none;
}

.dev-section > summary::-webkit-details-marker {
	display: none;
}

.dev-section > summary::after {
	content: "+";
	font-size: 0.7rem;
	color: rgba(242, 239, 232, 0.45);
}

.dev-section[open] > summary::after {
	content: "−";
}

.dev-section-rows {
	padding: 0.1rem 0 0.35rem;
}

.dev-row {
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 0.6rem;
	padding: 0.06rem 0.1rem;
}

.dev-control {
	padding: 0.12rem 0.1rem;
}

.dev-control-check {
	cursor: pointer;
}

.dev-control-check input {
	accent-color: hotpink;
	cursor: pointer;
}

.dev-control input[type="range"] {
	flex: 1 1 auto;
	min-width: 0;
	height: 12px;
	margin: 0;
	accent-color: rgba(255, 105, 180, 0.9);
	cursor: pointer;
}

.dev-control-val {
	flex: 0 0 2.4rem;
	min-width: 2.4rem;
}

.dev-k {
	flex: 1 1 auto;
	color: rgba(242, 239, 232, 0.5);
}

.dev-v {
	flex: 0 0 auto;
	color: #f2efe8;
	text-align: right;
}

.dev-on {
	color: #7dffb2;
}

.dev-off {
	color: rgba(242, 239, 232, 0.35);
}
