:root {
	--night: #15183a;
	--night-soft: #242856;
	--panel: #fbf7ea;
	--ink: #343052;
	--muted: #78728e;
	--lavender: #9c8ee8;
	--blue: #65b9e8;
	--rose: #ed7f9b;
	--mint: #70c99c;
	--gold: #f6c85f;
	--violet: #b583df;
	--shadow: 0 18px 48px rgba(5, 7, 29, 0.34);
	font-family: "Trebuchet MS", "Arial Rounded MT Bold", Arial, sans-serif;
	color: #fff;
	background: var(--night);
}

* {
	box-sizing: border-box;
}

html,
body {
	width: 100%;
	min-width: 0;
	min-height: 100%;
	margin: 0;
	overflow: hidden;
	background:
		radial-gradient(circle at 18% 8%, rgba(156, 142, 232, 0.26), transparent 28%),
		radial-gradient(circle at 86% 22%, rgba(101, 185, 232, 0.2), transparent 25%),
		linear-gradient(160deg, #171a40, #0d102d);
}

button {
	font: inherit;
}

button:focus-visible,
canvas:focus-visible {
	outline: 4px solid rgba(246, 200, 95, 0.7);
	outline-offset: 3px;
}

.game-shell {
	display: grid;
	grid-template-rows: auto auto minmax(0, 1fr);
	gap: clamp(8px, 1.5vh, 14px);
	width: 100%;
	height: 100vh;
	height: 100dvh;
	max-width: 1120px;
	margin: 0 auto;
	padding: max(9px, env(safe-area-inset-top)) max(9px, env(safe-area-inset-right)) max(9px, env(safe-area-inset-bottom)) max(9px, env(safe-area-inset-left));
}

.topbar,
.brand,
.station__heading,
.station__actions,
.tipbar {
	display: flex;
	align-items: center;
}

.topbar {
	justify-content: space-between;
	gap: 12px;
}

.brand {
	gap: 11px;
	min-width: 0;
}

.brand strong,
.brand small {
	display: block;
}

.brand strong {
	font-size: clamp(1rem, 2.5vw, 1.3rem);
	line-height: 1;
}

.brand small {
	margin-top: 4px;
	color: #b9b8d4;
	font-size: 0.72rem;
}

.brand-mark {
	position: relative;
	display: grid;
	width: 40px;
	height: 40px;
	flex: 0 0 auto;
	place-items: center;
	border: 2px solid rgba(255, 255, 255, 0.2);
	border-radius: 14px;
	background: linear-gradient(145deg, var(--lavender), #6f63c8);
	box-shadow: 0 6px 18px rgba(3, 4, 24, 0.24);
}

.brand-mark::before,
.brand-mark::after,
.brand-mark i {
	position: absolute;
	width: 5px;
	height: 5px;
	border-radius: 50%;
	background: #fff4b8;
	box-shadow: 0 0 8px #fff4b8;
	content: "";
}

.brand-mark::before {
	top: 8px;
	left: 9px;
}

.brand-mark::after {
	right: 8px;
	bottom: 9px;
}

.brand-mark i {
	top: 17px;
	left: 18px;
	width: 7px;
	height: 7px;
}

.connection-pill {
	max-width: 160px;
	padding: 7px 12px;
	overflow: hidden;
	border: 1px solid rgba(255, 255, 255, 0.12);
	border-radius: 999px;
	background: rgba(255, 255, 255, 0.08);
	color: #c9c8de;
	font-size: 0.7rem;
	font-weight: 800;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.connection-pill.is-connected {
	border-color: rgba(112, 201, 156, 0.35);
	background: rgba(112, 201, 156, 0.16);
	color: #bcebd2;
}

.hud {
	display: grid;
	grid-template-columns: repeat(4, 1fr);
	gap: clamp(6px, 1.2vw, 10px);
}

.hud-card {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	min-width: 0;
	padding: clamp(8px, 1.5vw, 12px) clamp(9px, 2vw, 15px);
	border: 1px solid rgba(255, 255, 255, 0.1);
	border-radius: 16px;
	background: rgba(255, 255, 255, 0.075);
	backdrop-filter: blur(8px);
}

.hud-card span {
	color: #b9b8d4;
	font-size: clamp(0.58rem, 1.8vw, 0.7rem);
	font-weight: 900;
	text-transform: uppercase;
	letter-spacing: 0.08em;
}

.hud-card strong {
	font-size: clamp(0.9rem, 2.8vw, 1.18rem);
	white-space: nowrap;
}

.hud-card b {
	font: inherit;
}

.station {
	display: grid;
	grid-template-rows: auto minmax(0, 1fr) auto;
	min-height: 0;
	overflow: hidden;
	border: 2px solid rgba(255, 255, 255, 0.1);
	border-radius: clamp(22px, 4vw, 32px);
	background: rgba(20, 22, 54, 0.76);
	box-shadow: var(--shadow);
}

.station__heading {
	justify-content: space-between;
	gap: 12px;
	padding: clamp(10px, 2vw, 16px) clamp(12px, 2.5vw, 20px);
	border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.station__heading h1,
.station__heading p {
	margin: 0;
}

.station__heading h1 {
	margin-top: 2px;
	font-size: clamp(1rem, 3vw, 1.35rem);
}

.eyebrow {
	color: #d6cbff;
	font-size: 0.64rem;
	font-weight: 900;
	text-transform: uppercase;
	letter-spacing: 0.12em;
}

.station__actions {
	gap: 7px;
}

.small-button,
.sound-button {
	border: 1px solid rgba(255, 255, 255, 0.12);
	background: rgba(255, 255, 255, 0.08);
	color: #fff;
	font-weight: 800;
	cursor: pointer;
}

.small-button {
	padding: 8px 11px;
	border-radius: 11px;
	font-size: 0.7rem;
}

.small-button:disabled {
	opacity: 0.42;
	cursor: default;
}

.sound-button {
	position: relative;
	display: grid;
	width: 35px;
	height: 35px;
	padding: 0;
	place-items: center;
	border-radius: 11px;
}

.sound-button span {
	width: 12px;
	height: 15px;
	background: #fff;
	clip-path: polygon(0 34%, 38% 34%, 100% 0, 100% 100%, 38% 66%, 0 66%);
}

.sound-button span::after {
	position: absolute;
	top: 10px;
	right: 5px;
	width: 9px;
	height: 14px;
	border: 2px solid #fff;
	border-left: 0;
	border-radius: 0 12px 12px 0;
	content: "";
}

.sound-button[aria-pressed="false"] span::after {
	top: 16px;
	right: 5px;
	width: 13px;
	height: 2px;
	border: 0;
	border-radius: 2px;
	background: #fff;
	transform: rotate(-45deg);
}

.board-wrap {
	position: relative;
	min-height: 0;
	overflow: hidden;
	background:
		radial-gradient(circle at 25% 20%, rgba(101, 185, 232, 0.12), transparent 28%),
		radial-gradient(circle at 75% 70%, rgba(181, 131, 223, 0.13), transparent 31%),
		#10132f;
	touch-action: none;
}

canvas {
	display: block;
	width: 100%;
	height: 100%;
	touch-action: none;
}

.board-message {
	position: absolute;
	z-index: 3;
	top: 14px;
	left: 50%;
	padding: 8px 13px;
	border: 1px solid rgba(255, 255, 255, 0.2);
	border-radius: 999px;
	background: rgba(31, 34, 75, 0.92);
	font-size: 0.72rem;
	font-weight: 900;
	opacity: 0;
	pointer-events: none;
	transform: translate(-50%, -12px);
	transition: 180ms ease;
}

.board-message.is-visible {
	opacity: 1;
	transform: translate(-50%, 0);
}

.overlay {
	position: absolute;
	z-index: 5;
	inset: 0;
	display: grid;
	padding: clamp(12px, 3vw, 25px);
	overflow: auto;
	place-items: center;
	background: rgba(10, 12, 38, 0.52);
	backdrop-filter: blur(8px);
	opacity: 0;
	visibility: hidden;
	transition: opacity 220ms ease, visibility 220ms ease;
}

.overlay.is-visible {
	opacity: 1;
	visibility: visible;
}

.panel {
	width: min(100%, 520px);
	padding: clamp(18px, 4vw, 34px);
	border: 4px solid rgba(255, 255, 255, 0.86);
	border-radius: clamp(23px, 5vw, 36px);
	background:
		radial-gradient(circle at 88% 4%, rgba(246, 200, 95, 0.28), transparent 22%),
		var(--panel);
	color: var(--ink);
	text-align: center;
	box-shadow: 0 24px 70px rgba(3, 5, 24, 0.48);
}

.panel--compact {
	max-width: 430px;
}

.panel h2,
.panel p {
	margin-top: 0;
}

.panel h2 {
	margin-bottom: 9px;
	font-size: clamp(1.42rem, 5vw, 2.05rem);
	line-height: 1.05;
}

.panel p:not(.eyebrow) {
	margin-bottom: 16px;
	color: var(--muted);
	font-size: clamp(0.8rem, 2.4vw, 0.94rem);
	line-height: 1.45;
}

.panel .eyebrow {
	margin-bottom: 6px;
	color: #7666c4;
}

.panel > small {
	display: block;
	margin-top: 11px;
	color: var(--muted);
	font-size: 0.66rem;
}

.conductor {
	position: relative;
	width: 74px;
	height: 74px;
	margin: 2px auto 17px;
	border: 5px solid #fff;
	border-radius: 50%;
	background: var(--gold);
	box-shadow: 0 8px 22px rgba(52, 48, 82, 0.18);
}

.conductor > i,
.final-star > i {
	position: absolute;
	top: 28px;
	width: 6px;
	height: 8px;
	border-radius: 50%;
	background: var(--ink);
}

.conductor > i:first-of-type,
.final-star > i:first-of-type {
	left: 20px;
}

.conductor > i:nth-of-type(2),
.final-star > i:nth-of-type(2) {
	right: 20px;
}

.conductor > b,
.final-star > b {
	position: absolute;
	top: 40px;
	left: 50%;
	width: 16px;
	height: 8px;
	border-bottom: 3px solid var(--ink);
	border-radius: 50%;
	transform: translateX(-50%);
}

.conductor__ray {
	position: absolute;
	z-index: -1;
	top: 50%;
	left: 50%;
	width: 98px;
	height: 4px;
	border-radius: 4px;
	background: #f2c75e;
	transform: translate(-50%, -50%);
}

.conductor__ray--two {
	transform: translate(-50%, -50%) rotate(60deg);
}

.conductor__ray--three {
	transform: translate(-50%, -50%) rotate(120deg);
}

.instructions {
	display: grid;
	gap: 7px;
	margin: 0 0 18px;
	text-align: left;
}

.instructions span {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 8px 11px;
	border-radius: 12px;
	background: rgba(255, 255, 255, 0.75);
	font-size: clamp(0.72rem, 2.2vw, 0.84rem);
	font-weight: 800;
}

.instructions i {
	position: relative;
	width: 28px;
	height: 22px;
	flex: 0 0 auto;
}

.instruction-drag::before {
	position: absolute;
	top: 7px;
	left: 1px;
	width: 24px;
	height: 6px;
	border-radius: 6px;
	background: linear-gradient(90deg, var(--rose), var(--gold));
	content: "";
}

.instruction-drag::after {
	position: absolute;
	top: 2px;
	right: 0;
	width: 13px;
	height: 13px;
	border: 3px solid #fff;
	border-radius: 50%;
	background: var(--gold);
	content: "";
}

.instruction-route::before {
	position: absolute;
	inset: 1px 4px;
	border: 4px solid var(--blue);
	border-top-color: transparent;
	border-radius: 50%;
	content: "";
}

.instruction-route::after {
	position: absolute;
	top: 0;
	right: 3px;
	border-top: 5px solid transparent;
	border-bottom: 5px solid transparent;
	border-left: 8px solid var(--blue);
	content: "";
}

.instruction-hint::before {
	position: absolute;
	top: 0;
	left: 7px;
	width: 14px;
	height: 14px;
	border-radius: 50%;
	background: var(--gold);
	box-shadow: 0 0 10px rgba(246, 200, 95, 0.7);
	content: "";
}

.instruction-hint::after {
	position: absolute;
	bottom: 0;
	left: 11px;
	width: 6px;
	height: 7px;
	border-radius: 2px;
	background: #b68b35;
	content: "";
}

.primary-button {
	min-width: 180px;
	padding: 12px 22px;
	border: 0;
	border-bottom: 5px solid #554aa0;
	border-radius: 15px;
	background: linear-gradient(180deg, #a597ef, #7568ca);
	color: #fff;
	font-weight: 900;
	box-shadow: 0 8px 19px rgba(83, 72, 165, 0.27);
	cursor: pointer;
}

.primary-button:active {
	border-bottom-width: 2px;
	transform: translateY(3px);
}

.completion-orbit {
	position: relative;
	width: 72px;
	height: 72px;
	margin: 2px auto 16px;
	border: 3px solid var(--blue);
	border-radius: 50%;
	transform: rotate(-18deg);
}

.completion-orbit::before,
.completion-orbit::after {
	position: absolute;
	border-radius: 50%;
	content: "";
}

.completion-orbit::before {
	inset: 13px;
	background: var(--lavender);
	box-shadow: inset 0 0 0 5px #fff;
}

.completion-orbit::after {
	top: -7px;
	left: 28px;
	width: 14px;
	height: 14px;
	background: var(--gold);
	box-shadow: 0 0 10px rgba(246, 200, 95, 0.7);
}

.completion-orbit i {
	position: absolute;
	right: -5px;
	bottom: 6px;
	width: 11px;
	height: 11px;
	border-radius: 50%;
	background: var(--rose);
}

.final-star {
	position: relative;
	width: 80px;
	height: 80px;
	margin: 0 auto 15px;
	background: var(--gold);
	clip-path: polygon(50% 0, 62% 33%, 98% 35%, 69% 57%, 79% 94%, 50% 73%, 21% 94%, 31% 57%, 2% 35%, 38% 33%);
}

.final-star > i {
	top: 34px;
}

.final-star > i:first-of-type {
	left: 25px;
}

.final-star > i:nth-of-type(2) {
	right: 25px;
}

.final-star > b {
	top: 46px;
}

.level-stats {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: 7px;
	margin: 15px 0;
}

.level-stats span {
	padding: 10px 5px;
	border-radius: 13px;
	background: #fff;
}

.level-stats small,
.level-stats strong {
	display: block;
}

.level-stats small {
	margin-bottom: 3px;
	color: var(--muted);
	font-size: 0.58rem;
	font-weight: 900;
	text-transform: uppercase;
}

.level-stats strong {
	font-size: clamp(0.78rem, 2.8vw, 1rem);
}

.reward-receipt {
	margin: 0 0 14px;
	padding: 10px 12px;
	border: 1px solid #b7dfc7;
	border-radius: 13px;
	background: #e8f7ed;
	color: #2d785b;
	font-size: 0.73rem;
}

.reward-receipt strong,
.reward-receipt span {
	display: block;
}

.reward-receipt span {
	margin-top: 3px;
}

.tipbar {
	gap: 9px;
	min-height: 44px;
	padding: 8px 14px;
	border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.tipbar p {
	flex: 1;
	margin: 0;
	color: #b9b8d4;
	font-size: clamp(0.65rem, 2vw, 0.76rem);
}

.tipbar__cursor {
	width: 18px;
	height: 18px;
	border: 3px solid var(--gold);
	border-radius: 50%;
	box-shadow: 0 0 9px rgba(246, 200, 95, 0.55);
}

.progress-dots {
	display: flex;
	gap: 5px;
}

.progress-dots i {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.2);
}

.progress-dots i.is-current {
	background: var(--gold);
	box-shadow: 0 0 8px rgba(246, 200, 95, 0.7);
}

.progress-dots i.is-complete {
	background: var(--mint);
}

.achievement-toast {
	position: absolute;
	z-index: 20;
	top: max(12px, env(safe-area-inset-top));
	left: 50%;
	display: flex;
	align-items: center;
	gap: 11px;
	width: min(calc(100% - 28px), 370px);
	padding: 11px 15px;
	border: 2px solid rgba(255, 255, 255, 0.8);
	border-radius: 17px;
	background: #fff7ce;
	color: var(--ink);
	box-shadow: 0 15px 40px rgba(3, 5, 24, 0.4);
	transform: translate(-50%, -140%);
	transition: transform 250ms ease;
}

.achievement-toast.is-visible {
	transform: translate(-50%, 0);
}

.achievement-toast > span {
	width: 37px;
	height: 37px;
	border: 6px solid var(--gold);
	border-radius: 50%;
	background: var(--lavender);
	box-shadow: inset 0 0 0 4px #fff;
}

.achievement-toast small,
.achievement-toast strong {
	display: block;
}

.achievement-toast small {
	color: #7666c4;
	font-size: 0.6rem;
	font-weight: 900;
	text-transform: uppercase;
	letter-spacing: 0.08em;
}

.achievement-toast strong {
	margin-top: 2px;
	font-size: 0.86rem;
}

@media (max-width: 620px) {
	.game-shell {
		gap: 7px;
		padding: max(6px, env(safe-area-inset-top)) max(6px, env(safe-area-inset-right)) max(6px, env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-left));
	}

	.brand small,
	.connection-pill,
	.hud-card span {
		display: none;
	}

	.hud-card {
		justify-content: center;
		padding: 8px 5px;
	}

	.station__heading {
		padding: 8px 10px;
	}

	.small-button {
		padding: 7px 8px;
		font-size: 0.64rem;
	}

	.station__heading h1 {
		font-size: 0.96rem;
	}

	.tipbar {
		padding: 7px 10px;
	}

	.progress-dots {
		display: none;
	}

	.panel {
		padding: 18px 15px;
	}
}

@media (max-height: 600px) {
	.game-shell {
		grid-template-rows: 37px 42px minmax(0, 1fr);
		gap: 5px;
	}

	.brand small,
	.connection-pill,
	.hud-card span {
		display: none;
	}

	.station__heading {
		padding-top: 6px;
		padding-bottom: 6px;
	}

	.tipbar {
		min-height: 35px;
		padding-top: 5px;
		padding-bottom: 5px;
	}

	.conductor {
		display: none;
	}

	.instructions {
		grid-template-columns: repeat(3, 1fr);
		gap: 5px;
	}

	.instructions span {
		display: block;
		padding: 7px;
		text-align: center;
	}

	.instructions i {
		display: block;
		margin: 0 auto 4px;
	}

	.panel {
		padding: 14px 18px;
	}

	.panel p:not(.eyebrow) {
		margin-bottom: 10px;
	}
}

@media (prefers-reduced-motion: reduce) {
	* {
		animation-duration: 0.01ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.01ms !important;
	}
}
