:root {
	--bg-space: #030712;
	--hud-bg: rgba(7, 12, 24, 0.85);
	--hud-border: rgba(56, 189, 248, 0.25);
	--hud-border-glow: rgba(56, 189, 248, 0.4);
	--cyan: #06b6d4;
	--cyan-bright: #38bdf8;
	--emerald: #10b981;
	--emerald-glow: rgba(16, 185, 129, 0.4);
	--amber: #f59e0b;
	--rose: #f43f5e;
	--rose-glow: rgba(244, 63, 94, 0.5);
	--purple: #8b5cf6;
	--text-primary: #f8fafc;
	--text-muted: #94a3b8;
}

* {
	margin: 0;
	padding: 0;
	box-sizing: border-box;
	user-select: none;
	-webkit-user-select: none;
}

html,
body {
	width: 100%;
	height: 100%;
	overflow: hidden;
	background-color: var(--bg-space);
	font-family:
		'Space Grotesk',
		'Noto Sans SC',
		'Noto Sans JP',
		-apple-system,
		sans-serif;
	color: var(--text-primary);
}

#game-wrapper {
	position: relative;
	width: 100vw;
	height: 100vh;
	overflow: hidden;
	display: flex;
	flex-direction: column;
}

#gameCanvas {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	z-index: 1;
	display: block;
	background: #000;
}

/* Flight HUD Header */
#flight-hud {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	z-index: 10;
	background: linear-gradient(180deg, rgba(3, 7, 18, 0.94) 0%, rgba(3, 7, 18, 0.6) 80%, rgba(3, 7, 18, 0) 100%);
	backdrop-filter: blur(8px);
	padding: 0.8rem 1.5rem 1.5rem 1.5rem;
	display: flex;
	justify-content: space-between;
	align-items: flex-start;
	pointer-events: none;
}

.hud-brand {
	display: flex;
	flex-direction: column;
	gap: 2px;
	pointer-events: auto;
}

.hud-logo {
	font-family: 'Orbitron', sans-serif;
	font-size: 1.25rem;
	font-weight: 900;
	letter-spacing: 0.18em;
	color: #fff;
	text-shadow: 0 0 12px rgba(56, 189, 248, 0.6);
}

.hud-logo span {
	color: var(--cyan-bright);
}

.hud-mission {
	font-family: 'Share Tech Mono', monospace;
	font-size: 0.75rem;
	letter-spacing: 0.08em;
	color: var(--cyan);
	opacity: 0.9;
}

/* Telemetry Dashboard */
.telemetry-panel {
	display: flex;
	gap: 1.25rem;
	background: var(--hud-bg);
	border: 1px solid var(--hud-border);
	padding: 0.6rem 1.2rem;
	border-radius: 12px;
	box-shadow:
		0 8px 32px rgba(0, 0, 0, 0.5),
		inset 0 0 16px rgba(56, 189, 248, 0.05);
	backdrop-filter: blur(12px);
	pointer-events: auto;
}

.telemetry-item {
	display: flex;
	flex-direction: column;
	align-items: center;
	min-width: 85px;
}

.t-label {
	font-family: 'Orbitron', 'Space Grotesk', sans-serif;
	font-size: 0.62rem;
	font-weight: 600;
	letter-spacing: 0.08em;
	color: var(--text-muted);
	margin-bottom: 3px;
	white-space: nowrap;
}

.t-value {
	font-size: 1rem;
	font-weight: 700;
	color: #fff;
}

.t-value.mono {
	font-family: 'Share Tech Mono', monospace;
	font-size: 1.05rem;
	letter-spacing: 0.05em;
}

.t-value.safe {
	color: var(--emerald);
	text-shadow: 0 0 8px var(--emerald-glow);
}

.t-value.warning {
	color: var(--amber);
	text-shadow: 0 0 8px rgba(245, 158, 11, 0.6);
}

.t-value.danger {
	color: var(--rose);
	text-shadow: 0 0 10px var(--rose-glow);
	animation: pulseWarning 0.6s infinite alternate;
}

.t-value.highlight {
	color: var(--cyan-bright);
	text-shadow: 0 0 10px rgba(56, 189, 248, 0.6);
}

.t-sub {
	font-family: 'Share Tech Mono', monospace;
	font-size: 0.58rem;
	color: var(--text-muted);
	opacity: 0.7;
	margin-top: 1px;
	white-space: nowrap;
}

/* Fuel Bar */
.bar-container {
	width: 90px;
	height: 8px;
	background: rgba(255, 255, 255, 0.1);
	border-radius: 4px;
	overflow: hidden;
	margin: 3px 0;
	border: 1px solid rgba(255, 255, 255, 0.15);
}

.bar-fill {
	height: 100%;
	width: 100%;
	background: linear-gradient(90deg, #10b981, #06b6d4);
	border-radius: 4px;
	transition:
		width 0.1s linear,
		background-color 0.3s ease;
	box-shadow: 0 0 8px var(--cyan);
}

.bar-fill.low {
	background: linear-gradient(90deg, #f59e0b, #f43f5e);
	box-shadow: 0 0 8px var(--rose-glow);
}

/* HUD Controls */
.hud-controls {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	pointer-events: auto;
}

.hud-select {
	background: var(--hud-bg);
	border: 1px solid var(--hud-border);
	color: var(--cyan-bright);
	font-family: 'Share Tech Mono', monospace;
	font-size: 0.85rem;
	font-weight: 700;
	padding: 0.4rem 0.6rem;
	border-radius: 8px;
	cursor: pointer;
	outline: none;
	transition: all 0.2s ease;
}

.hud-select:hover,
.hud-select:focus {
	border-color: var(--cyan-bright);
	background: rgba(56, 189, 248, 0.15);
}

.hud-select option {
	background: #0f172a;
	color: #fff;
}

.hud-btn {
	background: var(--hud-bg);
	border: 1px solid var(--hud-border);
	color: var(--text-primary);
	font-size: 1rem;
	width: 38px;
	height: 38px;
	border-radius: 8px;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	transition: all 0.2s ease;
}

.hud-btn:hover {
	background: rgba(56, 189, 248, 0.2);
	border-color: var(--cyan-bright);
	transform: scale(1.05);
}

/* Radar Container */
#radar-container {
	position: absolute;
	bottom: 1.5rem;
	left: 1.5rem;
	z-index: 10;
	background: var(--hud-bg);
	border: 1px solid var(--hud-border);
	border-radius: 10px;
	padding: 6px;
	box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
	pointer-events: none;
}

.radar-header {
	font-family: 'Orbitron', 'Space Grotesk', sans-serif;
	font-size: 0.58rem;
	font-weight: 700;
	letter-spacing: 0.1em;
	color: var(--cyan-bright);
	text-align: center;
	margin-bottom: 4px;
	opacity: 0.85;
}

#radarCanvas {
	border-radius: 6px;
	background: rgba(2, 6, 23, 0.95);
	border: 1px solid rgba(56, 189, 248, 0.2);
	display: block;
}

/* Master Caution Banner */
.caution-alert {
	position: absolute;
	top: 90px;
	left: 50%;
	transform: translateX(-50%);
	z-index: 15;
	background: rgba(244, 63, 94, 0.25);
	border: 1px solid var(--rose);
	color: #ffe4e6;
	padding: 0.45rem 1.5rem;
	border-radius: 20px;
	font-family: 'Orbitron', 'Space Grotesk', sans-serif;
	font-size: 0.82rem;
	font-weight: 700;
	letter-spacing: 0.08em;
	box-shadow: 0 0 20px rgba(244, 63, 94, 0.4);
	backdrop-filter: blur(6px);
	pointer-events: none;
	transition:
		opacity 0.2s ease,
		transform 0.2s ease;
}

.caution-alert.hidden {
	opacity: 0;
	transform: translateX(-50%) translateY(-10px);
	pointer-events: none;
}

.blink {
	animation: blinkEffect 0.5s infinite alternate;
}

@keyframes blinkEffect {
	from {
		opacity: 1;
	}
	to {
		opacity: 0.35;
	}
}

@keyframes pulseWarning {
	from {
		transform: scale(1);
	}
	to {
		transform: scale(1.08);
	}
}

/* Overlay and Modals */
.overlay-screen {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	z-index: 50;
	background: rgba(2, 6, 23, 0.82);
	backdrop-filter: blur(10px);
	display: flex;
	align-items: center;
	justify-content: center;
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.3s ease;
}

.overlay-screen.active {
	opacity: 1;
	pointer-events: auto;
}

.modal-card {
	background: linear-gradient(135deg, rgba(15, 23, 42, 0.96) 0%, rgba(10, 15, 30, 0.98) 100%);
	border: 1px solid rgba(56, 189, 248, 0.35);
	border-radius: 20px;
	padding: 2.2rem;
	width: 90%;
	max-width: 560px;
	text-align: center;
	box-shadow:
		0 20px 60px rgba(0, 0, 0, 0.8),
		0 0 40px rgba(56, 189, 248, 0.15);
	animation: modalPop 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes modalPop {
	from {
		transform: scale(0.9) translateY(20px);
		opacity: 0;
	}
	to {
		transform: scale(1) translateY(0);
		opacity: 1;
	}
}

.modal-badge {
	display: inline-block;
	font-family: 'Orbitron', 'Space Grotesk', sans-serif;
	font-size: 0.72rem;
	font-weight: 700;
	letter-spacing: 0.15em;
	color: var(--cyan-bright);
	background: rgba(6, 182, 212, 0.12);
	border: 1px solid rgba(6, 182, 212, 0.3);
	padding: 0.3rem 0.9rem;
	border-radius: 9999px;
	margin-bottom: 1rem;
	text-transform: uppercase;
}

.modal-title {
	font-family: 'Orbitron', 'Space Grotesk', sans-serif;
	font-size: 1.8rem;
	font-weight: 900;
	letter-spacing: 0.05em;
	margin-bottom: 0.75rem;
	background: linear-gradient(135deg, #fff 30%, var(--cyan-bright) 100%);
	-webkit-background-clip: text;
	-webkit-text-fill-color: transparent;
}

.modal-desc {
	font-size: 0.95rem;
	color: var(--text-muted);
	line-height: 1.55;
	margin-bottom: 1.5rem;
}

.key-guide {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 0.75rem;
	background: rgba(3, 7, 18, 0.6);
	border: 1px solid rgba(255, 255, 255, 0.08);
	border-radius: 12px;
	padding: 1rem;
	margin-bottom: 1.5rem;
	text-align: left;
	font-size: 0.85rem;
}

.key-row {
	display: flex;
	align-items: center;
	gap: 0.5rem;
}

.key-badge {
	font-family: 'Share Tech Mono', monospace;
	background: rgba(255, 255, 255, 0.12);
	border: 1px solid rgba(255, 255, 255, 0.25);
	padding: 0.2rem 0.5rem;
	border-radius: 6px;
	font-weight: 700;
	color: #fff;
	font-size: 0.8rem;
	box-shadow: 0 2px 0 rgba(255, 255, 255, 0.1);
	white-space: nowrap;
}

.stats-grid {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: 0.75rem;
	margin-bottom: 1.5rem;
}

.stat-box {
	background: rgba(3, 7, 18, 0.6);
	border: 1px solid rgba(255, 255, 255, 0.08);
	border-radius: 10px;
	padding: 0.75rem 0.5rem;
}

.stat-box .s-label {
	font-family: 'Orbitron', 'Space Grotesk', sans-serif;
	font-size: 0.58rem;
	color: var(--text-muted);
	margin-bottom: 4px;
	white-space: nowrap;
}

.stat-box .s-val {
	font-family: 'Share Tech Mono', monospace;
	font-size: 1.1rem;
	font-weight: 700;
	color: #fff;
}

.stat-box.highlight .s-val {
	color: var(--emerald);
	text-shadow: 0 0 10px var(--emerald-glow);
}

.btn-primary {
	width: 100%;
	padding: 1rem;
	border-radius: 12px;
	background: linear-gradient(135deg, #06b6d4 0%, #3b82f6 100%);
	border: none;
	color: #fff;
	font-family: 'Orbitron', 'Space Grotesk', sans-serif;
	font-size: 1rem;
	font-weight: 700;
	letter-spacing: 0.08em;
	cursor: pointer;
	transition: all 0.25s ease;
	box-shadow: 0 6px 20px rgba(6, 182, 212, 0.35);
}

.btn-primary:hover {
	transform: translateY(-2px);
	box-shadow: 0 8px 28px rgba(6, 182, 212, 0.55);
}

.btn-primary:active {
	transform: translateY(1px);
}

/* Touch Controls (Mobile) */
#touch-controls {
	position: absolute;
	bottom: 1.5rem;
	left: 0;
	right: 0;
	padding: 0 1.5rem;
	display: none;
	justify-content: space-between;
	align-items: flex-end;
	z-index: 20;
	pointer-events: none;
}

.touch-group {
	display: flex;
	gap: 0.75rem;
	pointer-events: auto;
}

.touch-btn {
	background: rgba(15, 23, 42, 0.75);
	border: 1px solid rgba(56, 189, 248, 0.4);
	color: #fff;
	font-size: 1.3rem;
	width: 60px;
	height: 60px;
	border-radius: 16px;
	backdrop-filter: blur(10px);
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
	touch-action: manipulation;
}

.touch-btn:active,
.touch-btn.active {
	background: rgba(56, 189, 248, 0.35);
	border-color: var(--cyan-bright);
	transform: scale(0.95);
}

.touch-btn.thrust-btn {
	width: 140px;
	font-family: 'Orbitron', 'Space Grotesk', sans-serif;
	font-size: 0.85rem;
	font-weight: 700;
	letter-spacing: 0.05em;
	background: linear-gradient(135deg, rgba(6, 182, 212, 0.6) 0%, rgba(59, 130, 246, 0.6) 100%);
	border-color: var(--cyan-bright);
}

.touch-btn.thrust-btn:active,
.touch-btn.thrust-btn.active {
	background: linear-gradient(135deg, rgba(6, 182, 212, 0.9) 0%, rgba(59, 130, 246, 0.9) 100%);
}

/* Responsive Styles */
@media (max-width: 900px) {
	.telemetry-panel {
		gap: 0.75rem;
		padding: 0.4rem 0.8rem;
	}

	.telemetry-item {
		min-width: 65px;
	}

	.t-label {
		font-size: 0.55rem;
	}

	.t-value {
		font-size: 0.85rem;
	}

	.t-value.mono {
		font-size: 0.9rem;
	}

	.bar-container {
		width: 65px;
	}
}

@media (max-width: 768px) {
	#flight-hud {
		flex-direction: column;
		align-items: stretch;
		gap: 0.6rem;
		padding: 0.5rem 0.8rem;
	}

	.hud-brand {
		flex-direction: row;
		justify-content: space-between;
		align-items: center;
	}

	.telemetry-panel {
		overflow-x: auto;
		justify-content: space-between;
	}

	#radar-container {
		display: none;
	}

	#touch-controls {
		display: flex;
	}

	.key-guide {
		grid-template-columns: 1fr;
	}
}

@media (pointer: coarse) {
	#touch-controls {
		display: flex;
	}
}
