:root {
	color-scheme: dark;
	--bg: #030712;
	--panel: rgba(16, 23, 41, 0.72);
	--text: #f2f5ff;
	--muted: #94a3b8;
	font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, sans-serif;
}

* {
	box-sizing: border-box;
}

[x-cloak] {
	display: none !important;
}

html,
body {
	height: 100%;
	margin: 0;
	background: var(--bg);
	color: var(--text);
	overflow: hidden;
}

body::before {
	content: "";
	position: fixed;
	inset: 0;
	pointer-events: none;
	background-image: url("./menubg.png");
	background-repeat: repeat;
	background-position: center;
	background-size: 50%;
	image-rendering: pixelated;
	opacity: 0.9;
}

.ui-icons {
	position: absolute;
	width: 0;
	height: 0;
	overflow: hidden;
	pointer-events: none;
}

#root {
	position: relative;
	width: 100%;
	height: 100%;
}

#game {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	display: block;
}


:is(#hud, #display-mode-cta) {
	position: absolute;
	top: 12px;
	min-height: 34px;
	padding: 8px 10px;
	border-radius: 4px;
	backdrop-filter: blur(10px);
	color: var(--text);
	font-size: 12px;
	line-height: 1;
	white-space: nowrap;
	z-index: 4;
}

#hud {
	position: absolute;
	left: 12px;
	min-width: 120px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 8px 10px;
	border: 1px solid rgba(108, 240, 255, 0.16);
	border-radius: 4px;
	background: rgba(3, 7, 18, 0.46);
	backdrop-filter: blur(10px);
	box-shadow: 0 10px 24px rgba(2, 6, 23, 0.14);
	text-align: center;
}

#hud:empty {
	display: none;
}

#display-mode-cta {
	position: absolute;
	right: 12px;
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 8px 10px;
	border: 1px solid rgba(148, 163, 184, 0.18);
	border-radius: 4px;
	background: rgba(15, 23, 42, 0.5);
	backdrop-filter: blur(10px);
	box-shadow: 0 10px 24px rgba(2, 6, 23, 0.16);
	font: inherit;
	font-weight: 700;
	text-align: left;
	cursor: pointer;
	user-select: none;
}

#display-mode-cta:focus-visible {
	outline: 2px solid rgba(125, 211, 252, 0.95);
	outline-offset: 2px;
}

#display-mode-cta-icon {
	flex: 0 0 auto;
	width: 16px;
	height: 16px;
	display: grid;
	place-items: center;
	color: var(--text);
	font-size: 16px;
	line-height: 1;
}

#loading-screen {
	position: absolute;
	inset: 0;
	display: grid;
	place-items: center;
	padding: 12px;
	background-image: url("./menubg.png");
	background-repeat: repeat;
	background-position: center;
	background-size: 50%;
	image-rendering: pixelated;
	z-index: 3;
}

#loading-panel {
	width: 620px;
	flex: none;
	padding: 26px;
	border-radius: 4px;
	background: linear-gradient(180deg, rgba(6, 12, 28, 0.92), rgba(8, 15, 32, 0.84));
	border: 1px solid rgba(148, 163, 184, 0.18);
	box-shadow: 0 36px 90px rgba(2, 6, 23, 0.6);
	backdrop-filter: blur(14px);
	display: flex;
	flex-direction: column;
	gap: 16px;
	transform-origin: top left;
}

#loading-panel-frame {
	display: flex;
	align-items: flex-start;
	justify-content: flex-start;
	max-width: 100%;
	max-height: 100%;
	overflow: visible;
}

#loading-title {
	font-size: 28px;
	font-weight: 800;
	letter-spacing: 0.02em;
	margin-bottom: 0;
}

#loading-bar {
	height: 12px;
	border-radius: 2px;
	background: rgba(148, 163, 184, 0.14);
	overflow: hidden;
	margin-bottom: 0;
}

#loading-bar > span {
	display: block;
	height: 100%;
	width: 0%;
	background: linear-gradient(90deg, #f59e0b, #f97316);
	transition: width 180ms ease;
}

#loading-status {
	font-size: 15px;
	color: #cbd5e1;
	margin-bottom: 0;
}

#control-grid {
	display: grid;
	grid-template-columns: 1fr;
	gap: 12px;
	margin-bottom: 0;
	user-select: none;
}

.control-card {
	border: 1px solid rgba(148, 163, 184, 0.16);
	border-radius: 4px;
	background: rgba(15, 23, 42, 0.62);
	overflow: hidden;
	transition: border-color 140ms ease, background 140ms ease;
	min-width: 0;
	cursor: pointer;
}

.control-card.selected {
	border-color: rgba(249, 115, 22, 0.7);
	background: rgba(24, 33, 56, 0.88);
}

.control-card:focus-visible {
	outline: 2px solid rgba(125, 211, 252, 0.95);
	outline-offset: 2px;
}

.control-card-toggle {
	width: 100%;
	display: flex;
	align-items: flex-start;
	gap: 16px;
	padding: 16px;
	border: 0;
	background: transparent;
	color: inherit;
	font: inherit;
	text-align: left;
}

.control-card-head {
	display: flex;
	align-items: center;
	gap: 14px;
	min-width: 0;
}

.control-icon {
	width: 48px;
	height: 48px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	border-radius: 4px;
	background: rgba(249, 115, 22, 0.12);
	color: #fdba74;
	flex: 0 0 auto;
}

.control-icon svg,
.option-toggle-ui svg {
	width: 24px;
	height: 24px;
	fill: currentColor;
}

.control-name {
	font-size: 18px;
	font-weight: 700;
	margin-bottom: 2px;
}

.control-summary {
	font-size: 13px;
	line-height: 1.35;
	color: var(--muted);
}

.control-card-body {
	display: grid;
	gap: 8px;
	min-height: 0;
	max-height: 0;
	overflow: hidden;
	padding: 0 16px 0;
	border-top: 1px solid rgba(148, 163, 184, 0);
	opacity: 0;
	transition: max-height 160ms ease, padding-bottom 160ms ease, border-top-color 120ms ease, opacity 100ms ease;
}

.control-card-body.expanded {
	max-height: 280px;
	padding-bottom: 16px;
	border-top-color: rgba(148, 163, 184, 0.12);
	opacity: 1;
}

.binding-row {
	display: grid;
	grid-template-columns: 84px minmax(0, 1fr);
	gap: 10px;
	align-items: center;
	padding-top: 10px;
}

.binding-label {
	font-size: 11px;
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: #94a3b8;
}

.binding-value {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 6px;
	min-width: 0;
}

.binding-chord {
	display: inline-flex;
	flex-wrap: nowrap;
	gap: 6px;
	white-space: nowrap;
}

.binding-sep {
	font-size: 12px;
	color: #64748b;
	text-transform: uppercase;
	letter-spacing: 0.08em;
}

.keycap {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 34px;
	height: 30px;
	padding: 0 10px;
	border-radius: 4px;
	background: rgba(30, 41, 59, 0.95);
	border: 1px solid rgba(148, 163, 184, 0.18);
	box-shadow: inset 0 -2px 0 rgba(15, 23, 42, 0.7);
	font-size: 13px;
	font-weight: 700;
	color: #f8fafc;
}

.keycap.wide {
	min-width: 76px;
}

#session-options {
	display: flex;
	align-items: center;
	gap: 10px;
	flex-wrap: wrap;
	padding-top: 4px;
	user-select: none;
}

@media (orientation: landscape) {
	#loading-panel {
		width: 1120px;
	}

	#control-grid {
		grid-template-columns: repeat(3, minmax(0, 1fr));
		align-items: stretch;
	}

	#session-options {
		justify-content: space-between;
	}
}

.option-toggle {
	position: relative;
	display: inline-flex;
	align-items: center;
	gap: 10px;
	padding: 11px 14px;
	border-radius: 4px;
	border: 1px solid rgba(148, 163, 184, 0.18);
	background: rgba(15, 23, 42, 0.62);
	font-size: 14px;
	font-weight: 600;
	color: var(--text);
	cursor: pointer;
}

.option-toggle input {
	position: absolute;
	opacity: 0;
	pointer-events: none;
}

.option-toggle-ui {
	width: 22px;
	height: 22px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	border-radius: 4px;
	border: 1px solid rgba(148, 163, 184, 0.3);
	background: rgba(15, 23, 42, 0.9);
	color: transparent;
	transition: background 140ms ease, border-color 140ms ease, color 140ms ease;
}

.option-toggle input:checked + .option-toggle-ui {
	background: rgba(249, 115, 22, 0.18);
	border-color: rgba(249, 115, 22, 0.7);
	color: #fdba74;
}

#play-button {
	appearance: none;
	margin-left: auto;
	padding: 13px 24px;
	border: 0;
	border-radius: 4px;
	background: linear-gradient(135deg, #f59e0b, #ea580c);
	color: #fff7ed;
	font: inherit;
	font-size: 16px;
	font-weight: 800;
	letter-spacing: 0.02em;
	box-shadow: 0 20px 35px rgba(234, 88, 12, 0.28);
	cursor: pointer;
	transition: transform 140ms ease, opacity 140ms ease;
}

#play-button:disabled {
	opacity: 0.45;
	cursor: wait;
}

#touch-controls {
	position: absolute;
	inset: 0;
	pointer-events: none;
	user-select: none;
	opacity: 0;
	transition: opacity 160ms ease;
}

#touch-controls.enabled {
	opacity: 0.75;
	pointer-events: auto;
}

#touch-controls .pad,
#touch-controls .cluster {
	position: absolute;
	display: grid;
	gap: 10px;
}

#touch-controls button {
	appearance: none;
	border: 1px solid rgba(148, 163, 184, 0.45);
	background: rgba(15, 23, 42, 0.7);
	color: var(--text);
	border-radius: 4px;
	width: 64px;
	height: 64px;
	font-weight: 600;
	font-size: 13px;
	letter-spacing: 0.4px;
	backdrop-filter: blur(8px);
	box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06), 0 10px 24px rgba(2, 6, 23, 0.35);
	touch-action: none;
}

#touch-controls button.active {
	background: rgba(56, 189, 248, 0.7);
	border-color: rgba(56, 189, 248, 0.9);
	color: #0b1120;
}

#touch-controls .pad {
	left: 18px;
	bottom: 18px;
	width: 220px;
	height: 220px;
	display: block;
}

#touch-controls .pad .dir {
	position: absolute;
	width: 80px;
	height: 80px;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 18px;
	font-weight: 700;
	color: var(--text);
	border: 1px solid rgba(148, 163, 184, 0.45);
	border-radius: 4px;
	background: rgba(15, 23, 42, 0.7);
	pointer-events: none;
	backdrop-filter: blur(8px);
	box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06), 0 10px 24px rgba(2, 6, 23, 0.35);
}

#touch-controls .pad .dir .dir-glyph {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	height: 100%;
	line-height: 1;
	transform: rotate(-45deg);
}

#touch-controls .pad .dir.active {
	background: rgba(56, 189, 248, 0.7);
	border-color: rgba(56, 189, 248, 0.9);
	color: #0b1120;
}

#touch-controls .pad .dir.up {
	left: 50%;
	top: 8px;
	transform: translateX(-50%) rotate(45deg);
}

#touch-controls .pad .dir.down {
	left: 50%;
	bottom: 8px;
	transform: translateX(-50%) rotate(45deg);
}

#touch-controls .pad .dir.left {
	left: 8px;
	top: 50%;
	transform: translateY(-50%) rotate(45deg);
}

#touch-controls .pad .dir.right {
	right: 8px;
	top: 50%;
	transform: translateY(-50%) rotate(45deg);
}

#touch-controls .cluster {
	right: 24px;
	bottom: 24px;
	grid-template-columns: repeat(2, 64px);
	grid-auto-rows: 64px;
	align-items: center;
}

#touch-controls .cluster button[data-btn="start"],
#touch-controls .cluster button[data-btn="select"] {
	grid-column: 1 / span 2;
	justify-self: center;
	width: 120px;
	height: 56px;
	border-radius: 4px;
	font-size: 12px;
}
