:root {
	--ink: #f4f1ea;
	--muted: rgba(244, 241, 234, 0.6);
	--panel: rgba(18, 16, 28, 0.72);
	--panel-strong: rgba(18, 16, 28, 0.9);
	--accent: #ffb347;
	--accent-ink: #2a1a05;
	--line: rgba(255, 255, 255, 0.12);
	--radius: 18px;
	--font: "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, sans-serif;
}

* {
	box-sizing: border-box;
}

html, body {
	margin: 0;
	height: 100%;
	overflow: hidden;
	background: #1a1730;
	color: var(--ink);
	font-family: var(--font);
	font-size: 16px;
}

canvas.world {
	position: fixed;
	inset: 0;
	width: 100vw;
	height: 100vh;
	display: block;
}

.page {
	position: fixed;
	inset: 0;
	pointer-events: none;
}

.page > * {
	pointer-events: auto;
}

.hidden {
	display: none !important;
}

.screen {
	position: absolute;
	inset: 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	padding: 32px;
	animation: rise 320ms cubic-bezier(0.2, 0.9, 0.3, 1.2);
}

@keyframes rise {
	from {
		opacity: 0;
		transform: translateY(18px) scale(0.98);
	}
	to {
		opacity: 1;
		transform: none;
	}
}

button {
	font: inherit;
	color: var(--ink);
	background: var(--panel);
	border: 1px solid var(--line);
	border-radius: 999px;
	padding: 10px 22px;
	cursor: pointer;
	backdrop-filter: blur(10px);
	transition: transform 120ms ease, background 120ms ease, box-shadow 120ms ease;
}

button:hover {
	transform: translateY(-2px) scale(1.03);
	background: var(--panel-strong);
	box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

button:active {
	transform: scale(0.97);
}

button.primary {
	background: var(--accent);
	color: var(--accent-ink);
	border-color: transparent;
	font-weight: 700;
}

button.big {
	font-size: 22px;
	padding: 14px 40px;
}

button.link {
	background: none;
	border: none;
	color: var(--muted);
	padding: 6px 10px;
	backdrop-filter: none;
}

button.link:hover {
	color: var(--ink);
	box-shadow: none;
}

.menu .logo {
	font-size: clamp(56px, 10vw, 128px);
	font-weight: 900;
	letter-spacing: -0.04em;
	margin: -12vh 0 32px;
	text-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
	animation: breathe 2.4s ease-in-out infinite;
}

@keyframes breathe {
	0%, 100% {
		transform: scale(1) rotate(-1.5deg);
	}
	50% {
		transform: scale(1.03) rotate(1.5deg);
	}
}

.menu-buttons {
	display: flex;
	flex-wrap: wrap;
	gap: 14px;
	justify-content: center;
	margin-bottom: 24px;
}

.menu-status, .menu-online {
	margin: 4px 0;
	color: var(--muted);
	text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
}


.screen-heading {
	width: min(1100px, 100%);
	display: flex;
	align-items: center;
	justify-content: space-between;
}

.screen-heading h1 {
	margin: 0;
	font-size: 36px;
	text-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.columns {
	width: min(1100px, 100%);
	height: min(70vh, 640px);
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 20px;
}

.level-list, .leaderboard {
	background: var(--panel);
	backdrop-filter: blur(14px);
	border: 1px solid var(--line);
	border-radius: var(--radius);
	padding: 16px;
	overflow-y: auto;
}

.level-card {
	padding: 14px 16px;
	border-radius: 12px;
	cursor: pointer;
	transition: background 120ms ease, transform 120ms ease;
}

.level-card:hover {
	background: rgba(255, 255, 255, 0.06);
	transform: translateX(4px);
}

.level-card.selected {
	background: rgba(255, 179, 71, 0.18);
	box-shadow: inset 4px 0 0 var(--accent);
}

.level-name {
	font-size: 20px;
	font-weight: 700;
}

.level-author, .level-best, .muted, .level-description {
	color: var(--muted);
	font-size: 14px;
}

.level-description {
	white-space: pre-line;
}

.leaderboard h2 {
	margin: 0 0 6px;
	font-size: 28px;
}

.tabs {
	display: flex;
	gap: 6px;
	margin: 16px 0 10px;
}

.tab {
	padding: 6px 14px;
	font-size: 14px;
}

.tab.active {
	background: var(--accent);
	color: var(--accent-ink);
	border-color: transparent;
}

.board-row {
	display: grid;
	grid-template-columns: 40px 1fr auto;
	align-items: baseline;
	padding: 8px 10px;
	border-radius: 10px;
	font-variant-numeric: tabular-nums;
}

.board-row.top1 .board-rank {
	color: #ffd54a;
	font-weight: 800;
}

.board-row.top2 .board-rank {
	color: #d8dde6;
	font-weight: 800;
}

.board-row.top3 .board-rank {
	color: #d29a5a;
	font-weight: 800;
}

.board-gap {
	margin-left: 8px;
	font-size: 12px;
	font-weight: 400;
	color: var(--muted);
}

.board-gap-row {
	text-align: center;
	color: var(--muted);
}

.hud-board {
	position: absolute;
	top: 20px;
	right: 20px;
	width: 280px;
	padding: 8px;
	background: var(--panel);
	backdrop-filter: blur(10px);
	border: 1px solid var(--line);
	border-radius: 14px;
	font-size: 14px;
}

.hud-board .board-row {
	padding: 4px 8px;
	grid-template-columns: 28px 1fr auto;
}

.result-board {
	max-height: 40vh;
	overflow-y: auto;
	margin-top: 16px;
	text-align: left;
}

.buttons.left {
	justify-content: flex-start;
	margin: 10px 0;
}

.build-notice {
	position: absolute;
	bottom: 24px;
	left: 50%;
	transform: translateX(-50%);
	display: flex;
	gap: 14px;
	align-items: center;
	padding: 10px 12px 10px 20px;
	background: var(--panel-strong);
	border: 1px solid var(--accent);
	border-radius: 999px;
	animation: rise 260ms ease;
}

.toast {
	position: absolute;
	top: 24px;
	left: 50%;
	transform: translateX(-50%);
	background: var(--accent);
	color: var(--accent-ink);
	padding: 10px 20px;
	border-radius: 999px;
	font-weight: 700;
	animation: rise 260ms ease;
}

.board-row:nth-child(odd) {
	background: rgba(255, 255, 255, 0.04);
}

.board-row.mine {
	background: rgba(255, 179, 71, 0.18);
}

.board-rank {
	color: var(--muted);
}

.board-time {
	font-weight: 700;
}

.hud {
	position: absolute;
	inset: 0;
	pointer-events: none;
}

.hud-timer {
	position: absolute;
	top: 20px;
	left: 50%;
	transform: translateX(-50%);
	font-size: 44px;
	font-weight: 800;
	font-variant-numeric: tabular-nums;
	text-shadow: 0 4px 16px rgba(0, 0, 0, 0.6);
}

.hud-countdown {
	position: absolute;
	top: 30%;
	left: 50%;
	transform: translate(-50%, -50%);
	font-size: 160px;
	font-weight: 900;
	color: var(--accent);
	text-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
}

.hud-countdown.pop {
	animation: pop 500ms cubic-bezier(0.2, 0.9, 0.3, 1.3);
}

@keyframes pop {
	from {
		transform: translate(-50%, -50%) scale(2.2);
		opacity: 0;
	}
	to {
		transform: translate(-50%, -50%) scale(1);
		opacity: 1;
	}
}

.hud-ghosts {
	position: absolute;
	top: 80px;
	left: 50%;
	transform: translateX(-50%);
	color: var(--muted);
	text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
}


.result-box {
	background: var(--panel-strong);
	backdrop-filter: blur(14px);
	border: 1px solid var(--line);
	border-radius: var(--radius);
	padding: 32px 48px;
	text-align: center;
	min-width: 360px;
}

.result-box h1 {
	margin: 0;
	font-size: 28px;
	color: var(--muted);
}

.result-time {
	font-size: 72px;
	font-weight: 900;
	font-variant-numeric: tabular-nums;
	color: var(--accent);
	margin: 6px 0 12px;
}

.result-status, .result-detail {
	color: var(--muted);
	margin: 6px 0;
}

.buttons {
	display: flex;
	gap: 12px;
	justify-content: center;
	margin-top: 20px;
}

.chat {
	position: absolute;
	right: 20px;
	bottom: 20px;
	width: min(380px, calc(100vw - 40px));
	height: 420px;
	display: flex;
	flex-direction: column;
	background: var(--panel-strong);
	backdrop-filter: blur(14px);
	border: 1px solid var(--line);
	border-radius: var(--radius);
	overflow: hidden;
	transition: height 260ms cubic-bezier(0.2, 0.9, 0.3, 1.1);
}

.chat.closed {
	height: 52px;
	width: 52px;
	border-radius: 50%;
	border-color: transparent;
	background: none;
	backdrop-filter: none;
	overflow: visible;
}

.chat.closed .chat-heading {
	visibility: hidden;
}

.chat-icon {
	display: none;
	position: absolute;
	right: 0;
	bottom: 0;
	width: 52px;
	height: 52px;
	padding: 0;
	font-size: 24px;
	line-height: 52px;
	border-radius: 50%;
	background: var(--panel-strong);
}

.chat.closed .chat-icon {
	display: block;
}

.chat-icon.unread {
	box-shadow: 0 0 0 3px var(--line), 0 0 18px rgba(255, 255, 255, 0.25);
}

.chat-icon.mentioned {
	background: var(--accent);
	box-shadow: 0 0 0 3px rgba(255, 179, 71, 0.4), 0 0 24px rgba(255, 179, 71, 0.6);
	animation: breathe 1.2s ease-in-out infinite;
}

.chat-heading {
	padding: 12px 16px;
	font-weight: 700;
	cursor: pointer;
	border-bottom: 1px solid var(--line);
	user-select: none;
}

.chat-lines {
	flex: 1;
	overflow-y: auto;
	padding: 10px 14px;
	font-size: 14px;
}

.chat-line {
	margin: 3px 0;
	overflow-wrap: anywhere;
}

.chat-name {
	font-weight: 700;
	color: var(--accent);
	margin-right: 6px;
}

.chat-line.system .chat-name {
	color: #8fd3ff;
}

.chat-form {
	display: flex;
	gap: 6px;
	padding: 10px;
	border-top: 1px solid var(--line);
}

.chat-input, .field input {
	flex: 1;
	font: inherit;
	color: var(--ink);
	background: rgba(255, 255, 255, 0.08);
	border: 1px solid var(--line);
	border-radius: 10px;
	padding: 8px 12px;
	outline: none;
}

.chat-input:focus, .field input:focus {
	border-color: var(--accent);
}

.chat-send {
	padding: 8px 16px;
}

.dialog-backdrop {
	position: absolute;
	inset: 0;
	background: rgba(0, 0, 0, 0.5);
	display: flex;
	align-items: center;
	justify-content: center;
}

.dialog {
	display: flex;
	flex-direction: column;
	gap: 12px;
	width: 340px;
	background: var(--panel-strong);
	border: 1px solid var(--line);
	border-radius: var(--radius);
	padding: 28px;
	animation: rise 260ms ease;
}

.dialog h2 {
	margin: 0;
}

.field {
	display: flex;
	flex-direction: column;
	gap: 4px;
	font-size: 14px;
	color: var(--muted);
}

.dialog-message {
	margin: 0;
	min-height: 1.2em;
	color: #ff8a8a;
	font-size: 14px;
}

@media (max-width: 800px) {
	.columns {
		grid-template-columns: 1fr;
		height: 80vh;
	}
}

.chat.closed .chat-lines, .chat.closed .chat-form {
	visibility: hidden;
}

.menu-status, .menu-online {
	background: rgba(10, 8, 20, 0.55);
	padding: 4px 14px;
	border-radius: 999px;
	color: var(--ink);
}

.field select {
	font: inherit;
	color: var(--ink);
	background: rgba(255, 255, 255, 0.08);
	border: 1px solid var(--line);
	border-radius: 10px;
	padding: 8px 12px;
}

.field select option {
	color: #222;
}
