/* ============================================================
   OT Cyber Quest - style.css
   ============================================================ */

*, *::before, *::after {
	box-sizing: border-box;
}

button {
	touch-action: manipulation;
}

body {
	margin: 0;
	padding: 1em;
	background-color: #0a0a14;
	color: #c8c8d0;
	font-family: monospace, monospace;
	font-size: 14px;
	display: flex;
	flex-direction: column;
	align-items: center;
}

/* ============================================================
   Header
   ============================================================ */

#game-wrap {
	display: flex;
	flex-direction: column;
	align-items: stretch;
}

#game-header {
	margin-bottom: 0.75em;
	text-align: center;
	position: relative;
	z-index: 10;
}

#game-header h1 {
	margin: 0;
	font-size: 1.5em;
	color: #4a9eff;
	letter-spacing: 0.08em;
}

#header-tagline {
	margin: 0.2em 0 0 0;
	font-size: 0.85em;
	color: #5a6a8a;
}

/* ============================================================
   Main layout
   ============================================================ */

#game-container {
	display: flex;
	gap: 1em;
	align-items: flex-start;
}

/* ============================================================
   Game column (canvas only)
   ============================================================ */

#game-column {
	display: flex;
	flex-direction: column;
	align-items: center;
	flex-shrink: 0;
	position: relative;
}

#game-canvas {
	display: block;
	border: 2px solid #1e2a3e;
	cursor: pointer;
	image-rendering: pixelated;
	touch-action: manipulation;
}

#canvas-toast {
	position: absolute;
	left: 50%;
	transform: translateX(-50%) translateY(-100%);
	background-color: rgba(8, 14, 30, 0.88);
	border: 1px solid #00cc44;
	color: #b8d4f0;
	font-family: monospace, monospace;
	font-size: 0.9em;
	padding: 0.35em 0.9em;
	border-radius: 4px;
	white-space: nowrap;
	pointer-events: none;
	opacity: 0;
	transition: opacity 0.4s ease;
	z-index: 10;
}

#canvas-toast.toast-show {
	opacity: 1;
}

/* Floating map button -- hidden on desktop, shown on phone via media query */
#btn-map {
	display: none;
	position: absolute;
	top: 0.5em;
	right: 0.5em;
	z-index: 20;
	background-color: rgba(8, 8, 20, 0.75);
	border: 1px solid #2e3a5a;
	color: #b8d4f0;
	font-family: monospace, monospace;
	font-size: 0.85em;
	padding: 0.35em 0.65em;
	border-radius: 4px;
	cursor: pointer;
}

#btn-map:hover {
	border-color: #4a9eff;
}

/* Close button inside mini-map-panel -- hidden on desktop */
#btn-map-close {
	display: none;
}

@keyframes tool-pickup-flash {
	0%   { box-shadow: 0 0 0 2px #4a9eff; }
	60%  { box-shadow: 0 0 0 2px #2a5a9a; }
	100% { box-shadow: none; }
}

.tool-entry.flash {
	animation: tool-pickup-flash 3.2s ease-out forwards;
}

/* ============================================================
   D-pad
   ============================================================ */

#dpad-wrap {
	position: relative;
	display: flex;
	justify-content: center;
	align-items: flex-start;
}

#dpad {
	display: grid;
	grid-template-columns: repeat(3, 44px);
	grid-template-rows: repeat(2, 44px);
	gap: 4px;
}

#dpad button {
	display: flex;
	align-items: center;
	justify-content: center;
	background-color: #1a1a2e;
	border: 1px solid #2e3a5a;
	color: #c8c8d0;
	font-size: 1.3em;
	cursor: pointer;
	border-radius: 6px;
	padding: 0;
	transition: background-color 0.1s, color 0.1s;
	-webkit-tap-highlight-color: transparent;
	user-select: none;
}

#dpad button:hover {
	background-color: #252540;
	border-color: #4a9eff;
}

#dpad button:active {
	background-color: #2a4a7a;
	color: #ffffff;
}

/* ============================================================
   Side panel
   ============================================================ */

#side-panel {
	display: flex;
	flex-direction: row;
	gap: 0.75em;
	align-items: flex-start;
	flex-shrink: 0;
}

#side-col-main {
	display: flex;
	flex-direction: column;
	gap: 0.75em;
	min-width: 200px;
	max-width: 280px;
}

#status-panel,
#inventory-panel {
	background-color: #0e0e1c;
	border: 1px solid #1e2a3e;
	border-radius: 4px;
	padding: 0.75em;
}

#status-panel h2,
#inventory-panel h2 {
	margin: 0;
	font-size: 0.95em;
	color: #4a9eff;
	letter-spacing: 0.05em;
}

#inventory-panel-header {
	display: flex;
	align-items: center;
	align-self: stretch;
	border-bottom: 1px solid #1e2a3e;
	padding-bottom: 0.3em;
	margin-bottom: 0.5em;
}

#inventory-panel-header h2 {
	flex: 1;
	text-align: center;
}

#btn-inventory-close {
	display: none;
}

#status-panel h2 {
	margin: 0 0 0.5em 0;
	border-bottom: 1px solid #1e2a3e;
	padding-bottom: 0.3em;
}

#status-panel p {
	margin: 0.3em 0;
	font-size: 0.9em;
}

#status-panel span {
	color: #e0e0e0;
}

/* ============================================================
   Inventory
   ============================================================ */

#tool-list {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 0.4em;
}

.tool-entry {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 0.3em 0.5em;
	border-radius: 3px;
	background-color: #111128;
	border: 1px solid #1e2a3e;
	transition: border-color 0.2s, background-color 0.2s;
}

.tool-entry.has-tool {
	border-color: #1e4a7e;
	background-color: #0a1428;
}

.tool-entry.fix-mode-available {
	border-color: #3a9a3a;
	background-color: #0e1e0e;
	cursor: pointer;
}

.tool-entry.fix-mode-available:hover {
	background-color: #102010;
	border-color: #60cc60;
}

.tool-name {
	font-size: 0.8em;
	color: #8090a0;
}

.tool-entry.has-tool .tool-name {
	color: #80aee0;
}

.tool-count {
	font-size: 0.85em;
	color: #404050;
	min-width: 2.5em;
	text-align: right;
}

.tool-entry.has-tool .tool-count {
	color: #5090d0;
}


.hidden {
	display: none !important;
}

li[title]:hover::after {
/*outline: 1px solid red;*/
/*	content: attr(title);*/
/*	display: inline-block;*/
/*	position: absolute;*/
/*	top: -100%;*/
/*	left: 0;*/
}

/* ============================================================
   Message area
   ============================================================ */

#message-area {
	margin-top: 0.75em;
	width: 100%;
	max-width: 1100px;
}

#message-box {
	background-color: #0e0e1c;
	border: 2px solid #2a3a5a;
	border-radius: 4px;
	padding: 0.6em 0.8em;
	margin: 0;
	font-size: 0.9em;
	line-height: 1.5;
	color: #a0b8d0;
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.35s ease;
	display: flex;
	align-items: flex-start;
	gap: 0.75em;
}

#message-box.visible {
	opacity: 1;
	pointer-events: auto;
	border-color: #4a7abf;
}

#message-box.visible-attack {
	opacity: 1;
	pointer-events: auto;
	border-color: #e07000;
}

#message-box.visible-pickup {
	opacity: 1;
	pointer-events: auto;
	border-color: #40c0a0;
}

#message-box.visible-fix {
	opacity: 1;
	pointer-events: auto;
	border-color: #3a9a3a;
}

#message-text {
	flex: 1;
	min-width: 0;
	overflow-wrap: break-word;
}

#btn-dismiss {
	flex-shrink: 0;
	align-self: center;
	padding: 0.25em 0.7em;
	background-color: #111128;
	border: 1px solid #3a4a6a;
	color: #6878a0;
	font-family: monospace, monospace;
	font-size: 0.8em;
	cursor: pointer;
	border-radius: 3px;
	white-space: nowrap;
	transition: border-color 0.1s, color 0.1s;
}

#btn-dismiss:hover {
	border-color: #6a8ab0;
	color: #b0c0d0;
}

#btn-use-stairs {
	flex-shrink: 0;
	align-self: center;
	padding: 0.25em 0.7em;
	background-color: #0e1a0e;
	border: 1px solid #3a7a3a;
	color: #5ab05a;
	font-family: monospace, monospace;
	font-size: 0.8em;
	cursor: pointer;
	border-radius: 3px;
	white-space: nowrap;
	transition: border-color 0.1s, color 0.1s;
}

#btn-use-stairs:hover {
	border-color: #66cc66;
	color: #88ee88;
}

#btn-use-stairs.hidden {
	display: none !important;
}

/* ============================================================
   End screen overlay
   ============================================================ */

/* ============================================================
   Configuration screen
   ============================================================ */

#config-screen {
	position: fixed;
	inset: 0;
	background-color: rgba(0, 0, 0, 0.92);
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 200;
}

#config-screen.hidden {
	display: none !important;
}

#config-box {
	background-color: #0e0e1c;
	border: 2px solid #2a3a5a;
	border-radius: 6px;
	padding: 2em 2.5em;
	min-width: 320px;
	text-align: center;
}

#config-title {
	margin: 0 0 0.2em 0;
	font-size: 1.4em;
	color: #4a9eff;
	letter-spacing: 0.08em;
}

#config-sub {
	margin: 0 0 1.5em 0;
	font-size: 0.85em;
	color: #5a6a8a;
}

.cfg-group {
	margin-bottom: 1.2em;
	text-align: left;
}

.cfg-label {
	font-size: 0.8em;
	color: #5a6a8a;
	letter-spacing: 0.05em;
	margin-bottom: 0.4em;
}

.cfg-options {
	display: flex;
	gap: 0.5em;
}

.cfg-btn {
	flex: 1;
	padding: 0.45em 0.2em;
	background-color: #111128;
	border: 1px solid #2e3a5a;
	color: #6878a0;
	font-family: monospace, monospace;
	font-size: 0.85em;
	cursor: pointer;
	border-radius: 4px;
	transition: background-color 0.1s, border-color 0.1s, color 0.1s;
}

.cfg-btn:hover:not(:disabled) {
	background-color: #1a1a38;
	border-color: #4a6a9a;
	color: #a0b0d0;
}

.cfg-btn.selected {
	background-color: #1a2a4a;
	border-color: #4a9eff;
	color: #4a9eff;
}

.cfg-btn:disabled {
	opacity: 0.3;
	cursor: default;
}

.cfg-slider-row {
	align-items: center;
}

.cfg-slider-bound {
	font-size: 0.8em;
	color: #5a6a8a;
	flex-shrink: 0;
}

.cfg-slider {
	flex: 1;
	-webkit-appearance: none;
	appearance: none;
	height: 4px;
	background: #1e2a3e;
	border-radius: 2px;
	outline: none;
	cursor: pointer;
	margin: 0;
	padding: 0;
	border: none;
}

.cfg-slider::-webkit-slider-thumb {
	-webkit-appearance: none;
	appearance: none;
	width: 16px;
	height: 16px;
	border-radius: 50%;
	background: #4a9eff;
	cursor: pointer;
	border: none;
}

.cfg-slider::-moz-range-thumb {
	width: 16px;
	height: 16px;
	border-radius: 50%;
	background: #4a9eff;
	cursor: pointer;
	border: none;
}

.cfg-slider:focus {
	outline: none;
}

.cfg-slider:focus-visible::-webkit-slider-thumb {
	box-shadow: 0 0 0 3px #0e0e1c, 0 0 0 5px #4a9eff;
}

.cfg-slider:focus-visible::-moz-range-thumb {
	box-shadow: 0 0 0 3px #0e0e1c, 0 0 0 5px #4a9eff;
}

.cfg-text-input {
	flex: 1;
	background-color: #111128;
	border: 1px solid #2e3a5a;
	color: #c8c8d0;
	font-family: monospace, monospace;
	font-size: 16px;	/* must be >=16px to prevent auto-zoom on mobile */
	padding: 0.45em 0.6em;
	border-radius: 4px;
	outline: none;
	transition: border-color 0.1s;
}

.cfg-text-input:focus {
	border-color: #4a9eff;
}

.cfg-text-input::placeholder {
	color: #3a4a6a;
}

#btn-load-game {
	margin-top: 0.5em;
	width: 100%;
	padding: 0.5em 0;
	background-color: #0e1a0e;
	border: 1px solid #3a7a3a;
	color: #5ab05a;
	font-family: monospace, monospace;
	font-size: 0.85em;
	cursor: pointer;
	border-radius: 4px;
	letter-spacing: 0.05em;
	transition: background-color 0.1s, border-color 0.1s, color 0.1s;
}

#btn-load-game:hover {
	background-color: #142514;
	border-color: #5ab05a;
	color: #80d880;
}

#btn-start-mission {
	margin-top: 0.5em;
	width: 100%;
	padding: 0.6em 0;
	background-color: #1a2a4a;
	border: 1px solid #4a9eff;
	color: #4a9eff;
	font-family: monospace, monospace;
	font-size: 0.95em;
	cursor: pointer;
	border-radius: 4px;
	letter-spacing: 0.05em;
	transition: background-color 0.1s;
}

#btn-start-mission:hover {
	background-color: #253a6a;
}

/* ============================================================
   End screen overlay
   ============================================================ */

#end-screen {
	position: fixed;
	inset: 0;
	background-color: rgba(0, 0, 0, 0.88);
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 100;
}

#end-screen.hidden {
	display: none !important;
}

#end-box {
	background-color: #0e0e1c;
	border: 2px solid #2a3a5a;
	border-radius: 6px;
	padding: 2em;
	min-width: 320px;
	max-width: 480px;
	text-align: center;
}

#end-title {
	font-size: 1.4em;
	margin: 0 0 0.4em 0;
	letter-spacing: 0.05em;
}

#end-msg {
	font-size: 0.9em;
	color: #a0b0c0;
	margin: 0 0 1em 0;
}

#end-summary {
	margin: 0 0 1.2em 0;
}

.end-table {
	width: 100%;
	border-collapse: collapse;
	font-size: 0.82em;
	text-align: left;
}

.end-table thead th {
	padding: 0.3em 0.5em;
	border-bottom: 1px solid #2a3a5a;
	font-size: 0.9em;
	letter-spacing: 0.03em;
}

.end-table tbody td {
	padding: 0.25em 0.5em;
	border-bottom: 1px solid #151525;
}

.end-table thead th:not(:first-child),
.end-table tbody td:not(:first-child) {
	text-align: center;
	width: 4em;
}

#btn-new-game {
	padding: 0.5em 1.5em;
	background-color: #1a2a4a;
	border: 1px solid #4a9eff;
	color: #4a9eff;
	font-family: monospace, monospace;
	font-size: 0.9em;
	cursor: pointer;
	border-radius: 4px;
	transition: background-color 0.1s;
}

#btn-new-game:hover {
	background-color: #253a6a;
}

/* ============================================================
   End screen outcome classes
   ============================================================ */

.outcome-fixed {
	color: #44cc44;
}

.outcome-broken {
	color: #cc8844;
}

.outcome-compromised {
	color: #cc4444;
}

.outcome-stat {
	color: #7080a0;
	margin-top: 0.5em;
}

/* Mini-map */

#mini-map-panel {
	background-color: #0e0e1c;
	border: 1px solid #1e2a3e;
	border-radius: 4px;
	padding: 0.75em;
	display: flex;
	flex-direction: column;
	align-items: center;
	flex-shrink: 0;
	position: relative;
}

#mini-map-header {
	display: flex;
	align-items: center;
	align-self: stretch;
	border-bottom: 1px solid #1e2a3e;
	padding-bottom: 0.3em;
	margin-bottom: 0.5em;
}

#mini-map-header h2 {
	flex: 1;
	margin: 0;
	font-size: 1.5em;
	color: #4a9eff;
	letter-spacing: 0.05em;
	text-align: center;
}

#mini-map {
	display: block;
	image-rendering: pixelated;
}

#mini-map.map-locked,
#mini-map.map-locked + #map-legend {
	visibility: hidden;
}

/* Legend below the mini-map canvas */
#map-legend {
	display: flex;
	align-items: center;
	gap: 0.4em;
	margin-top: 0.5em;
	font-size: 0.75em;
	color: #8899bb;
}

.map-legend-swatch {
	display: inline-block;
	width: 0.9em;
	height: 0.9em;
	border-radius: 2px;
	flex-shrink: 0;
}

.map-legend-compromised {
	background-color: #cc2222;
}

/* ============================================================
   Debug panel
   ============================================================ */

#debug-panel {
	margin-top: 1em;
	width: 100%;
	max-width: 1100px;
	background-color: #080e08;
	border: 1px solid #1a3a1a;
	border-radius: 4px;
	padding: 0.75em 1em;
	font-size: 0.8em;
}

#debug-panel h2 {
	margin: 0 0 0.5em 0;
	font-size: 0.95em;
	color: #44cc44;
	letter-spacing: 0.08em;
	border-bottom: 1px solid #1a3a1a;
	padding-bottom: 0.3em;
}

.dbg-stat {
	color: #5a7a5a;
	margin-bottom: 0.4em;
	font-size: 0.95em;
}

.dbg-stat strong {
	color: #88ee88;
	font-size: 1.1em;
	letter-spacing: 0.05em;
}

.dbg-hint {
	color: #3a5a3a;
	margin-left: 1em;
	font-size: 0.9em;
}

.dbg-hint code {
	color: #5a8a5a;
}

#dbg-layout {
	display: flex;
	gap: 2em;
	margin-top: 0.5em;
	align-items: flex-start;
}

#dbg-map,
#dbg-legend,
#dbg-rooms {
	font-family: monospace, monospace;
	font-size: 1em;
	line-height: 1.35;
	background: none;
	border: none;
	padding: 0;
	margin: 0;
	white-space: pre;
}

#dbg-map {
	color: #5a9a5a;
	flex-shrink: 0;
}

#dbg-legend {
	color: #4a7a4a;
	flex-shrink: 0;
	border-left: 1px solid #1a3a1a;
	border-right: 1px solid #1a3a1a;
	padding: 0 1em;
}

#dbg-rooms {
	color: #3a6a3a;
}

/* ============================================================
   Help buttons
   ============================================================ */

#header-game-btns {
	position: absolute;
	top: 50%;
	left: 0;
	transform: translateY(-50%);
	display: flex;
	gap: 0.4em;
}

#header-game-btns button,
#btn-help-header {
	padding: 0.15em 0.5em;
	background-color: #0e0e20;
	border: 1px solid #252540;
	color: #b8d4f0;
	font-family: monospace, monospace;
	font-size: 0.75em;
	cursor: pointer;
	border-radius: 3px;
	transition: border-color 0.1s, color 0.1s;
}

#btn-help-header {
	position: absolute;
	top: 50%;
	right: 0;
	transform: translateY(-50%);
}

#header-game-btns button:hover,
#btn-help-header:hover {
	border-color: #4a9eff;
	color: #4a9eff;
}

#btn-help-dpad {
	position: absolute;
	top: 0;
	right: 0;
	width: 33px;
	height: 33px;
	display: flex;
	align-items: center;
	justify-content: center;
	background-color: #0e0e22;
	border: 1px solid #222242;
	color: #405060;
	font-size: 1.0em;
	cursor: pointer;
	border-radius: 4px;
	padding: 0;
	transition: border-color 0.1s, color 0.1s;
	-webkit-tap-highlight-color: transparent;
	user-select: none;
}

#btn-help-dpad:hover {
	border-color: #3a6aaa;
	color: #4a9eff;
	background-color: #111130;
}

#btn-help-dpad:active {
	background-color: #1a2a4a;
	color: #4a9eff;
}

/* ============================================================
   Help screen overlay
   ============================================================ */

#help-screen {
	position: fixed;
	inset: 0;
	background-color: rgba(0, 0, 0, 0.88);
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 150;
}

#help-screen.hidden {
	display: none !important;
}

#help-box {
	background-color: #0e0e1c;
	border: 2px solid #2a3a5a;
	border-radius: 6px;
	width: min(600px, 90vw);
	height: 80vh;
	display: flex;
	flex-direction: column;
	overflow: hidden;
}

#help-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 0.8em 1.2em;
	border-bottom: 1px solid #2a3a5a;
	flex-shrink: 0;
}

/* Tab buttons replacing the old h2 title */
#help-tabs {
	display: flex;
	gap: 0.4em;
}

.help-tab {
	padding: 0.2em 0.9em;
	background-color: #111128;
	border: 1px solid #3a4a6a;
	color: #6878a0;
	font-family: monospace, monospace;
	font-size: 0.9em;
	cursor: pointer;
	border-radius: 3px;
	transition: border-color 0.1s, color 0.1s;
}

.help-tab:hover {
	border-color: #6a8ab0;
	color: #b0c0d0;
}

.help-tab.selected {
	border-color: #4a9eff;
	color: #4a9eff;
	background-color: #0a1830;
}

/* Glossary definition list */
.glossary-list {
	margin: 0;
	padding: 0;
}

.glossary-list dt {
	color: #4a9eff;
	font-size: 0.9em;
	font-weight: bold;
	margin-top: 0.9em;
}

.glossary-list dt:first-child {
	margin-top: 0;
}

.glossary-list dd {
	margin: 0.2em 0 0 0.8em;
	color: #a0b8d0;
	font-size: 0.85em;
	line-height: 1.45;
}

#btn-help-close {
	padding: 0.25em 0.7em;
	background-color: #111128;
	border: 1px solid #3a4a6a;
	color: #6878a0;
	font-family: monospace, monospace;
	font-size: 0.8em;
	cursor: pointer;
	border-radius: 3px;
	transition: border-color 0.1s, color 0.1s;
}

#btn-help-close:hover {
	border-color: #6a8ab0;
	color: #b0c0d0;
}

#help-body {
	overflow-y: auto;
	padding: 0.75em 1.4em 1.1em;
}

.help-section {
	margin-bottom: 1.1em;
}

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

.help-section h3 {
	margin: 0 0 0.35em 0;
	font-size: 0.9em;
	color: #4a9eff;
	letter-spacing: 0.04em;
	border-bottom: 1px solid #1e2a3e;
	padding-bottom: 0.2em;
}

.help-section p {
	margin: 0.3em 0;
	font-size: 0.85em;
	color: #a0b0c0;
	line-height: 1.45;
}

.help-list {
	margin: 0.25em 0;
	padding-left: 1.4em;
	font-size: 0.85em;
	color: #a0b0c0;
/*	line-height: 1.55;*/
	line-height: 1.33;
}
.help-list li {
/*	margin-bottom: 2px;*/
}

.help-table {
	width: 100%;
	border-collapse: collapse;
	font-size: 0.82em;
	margin-top: 0.25em;
}

.help-table thead th {
	padding: 0.2em 0.5em;
	border-bottom: 1px solid #2a3a5a;
	color: #6878a0;
	text-align: left;
	font-size: 0.9em;
	letter-spacing: 0.03em;
}

.help-table tbody td {
	padding: 0.2em 0.5em;
	border-bottom: 1px solid #151525;
	color: #a0b0c0;
}

.help-table tbody tr:last-child td {
	border-bottom: none;
}

/* ============================================================
   Tablet responsive layout (viewport narrower than 1050px)
   ============================================================ */

@media (max-width: 1050px) {
	#game-container {
		flex-direction: column;
		align-items: center;
	}

	#game-canvas {
		max-width: calc(100vw - 2em);
		height: auto !important;
	}

	#side-panel {
		width: 100%;
		max-width: 800px;
	}

	#side-col-main {
		display: grid;
		grid-template-columns: 1fr 1fr;
		grid-template-areas:
			"status    inventory"
			"dpad      inventory";
		gap: 0.75em;
		flex: 1;
		min-width: 0;
		max-width: none;
	}

	#status-panel    { grid-area: status; }
	#inventory-panel { grid-area: inventory; }
	#dpad-wrap       { grid-area: dpad; align-self: start; }
}

@media (max-width: 600px) {
	#side-panel {
		flex-direction: column;
	}

	#side-col-main {
		display: flex;
		flex-direction: column;
		min-width: 0;
		max-width: none;
	}
}

/* ============================================================
   Title / landing screen
   ============================================================ */

#title-screen {
	position: fixed;
	inset: 0;
	z-index: 50;
	background: #080812;
	overflow-y: auto;
	display: flex;
	flex-direction: column;
	align-items: center;
}

#title-box {
	width: 100%;
	max-width: 640px;
	padding: 2em 1.5em 3em;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 1.1em;
}

#title-game-name {
	margin: 0;
	font-size: 2em;
	color: #4a9eff;
	letter-spacing: 0.08em;
	text-align: center;
}

#title-game-sub {
	margin: -0.5em 0 0;
	font-size: 0.85em;
	color: #5a6a8a;
	text-align: center;
}

#title-svg {
	display: block;
	width: 100%;
	height: auto;
	max-height: 30vh;
	border-radius: 3px;
}

#title-story {
	margin: 0;
	color: #b8b8d0;
	line-height: 1.65;
	font-size: 0.95em;
}

#btn-title-start {
	width: 220px;
	padding: 0.7em 2em;
	font-size: 1.05em;
	font-family: inherit;
	background: #1e4a80;
	color: #d8e8ff;
	border: 1px solid #3a6aaa;
	border-radius: 3px;
	cursor: pointer;
	letter-spacing: 0.05em;
}

#btn-title-start:hover {
	background: #2a5a90;
	border-color: #5a8acc;
}

#btn-title-howtoplay {
	width: 220px;
	padding: 0.55em 2em;
	font-size: 0.9em;
	font-family: inherit;
	background: #14142a;
	color: #7a8aaa;
	border: 1px solid #282848;
	border-radius: 3px;
	cursor: pointer;
}

#btn-title-howtoplay:hover {
	background: #1e1e38;
	color: #9aabcc;
}

#title-howtoplay-text {
	width: 100%;
	background: #0e0e22;
	border: 1px solid #252545;
	border-radius: 3px;
	padding: 1em 1.2em;
}

#title-howtoplay-text p {
	margin: 0;
	color: #a0a8c0;
	line-height: 1.65;
	font-size: 0.9em;
}

/* SVG building window animation classes */
.win-dark { fill: #0a0a1a; }
.win-red  { fill: #050000; animation: win-red-pulse 2.8s ease-in-out infinite; }
.ant-blink {
	fill: #050000;
	animation: win-red-pulse 1.3s ease-in-out infinite;
	filter: drop-shadow(0 0 5px rgba(110, 10, 0, 0.9));
}

@keyframes win-red-pulse {
	0%, 100% { fill: #050000; }
	50%       { fill: #6e0500; }
}

/* ============================================================
   Compact layout for height-constrained viewports (iPad landscape)
   ============================================================ */

/* ============================================================
   Hamburger menu (shown only on phone)
   ============================================================ */

#hamburger-wrap {
	position: absolute;
	top: 50%;
	left: 0;
	transform: translateY(-50%);
	display: none;
}

#btn-inventory {
	position: absolute;
	top: 50%;
	right: 0;
	transform: translateY(-50%);
	display: none;
	padding: 0.15em 0.5em;
	background-color: #0e0e20;
	border: 1px solid #252540;
	color: #b8d4f0;
	font-family: monospace, monospace;
	font-size: 0.85em;
	cursor: pointer;
	border-radius: 3px;
	transition: border-color 0.1s, color 0.1s;
	line-height: 1;
}

#btn-inventory:hover {
	border-color: #4a9eff;
	color: #b8d4f0;
}

#btn-hamburger {
	padding: 0.15em 0.5em;
	background-color: #0e0e20;
	border: 1px solid #252540;
	color: #b8d4f0;
	font-family: monospace, monospace;
	font-size: 1.1em;
	cursor: pointer;
	border-radius: 3px;
	transition: border-color 0.1s, color 0.1s;
	line-height: 1;
}

#btn-hamburger:hover,
#btn-hamburger.open {
	border-color: #4a9eff;
	color: #4a9eff;
}

#hamburger-menu {
	display: none;
	position: absolute;
	top: calc(100% + 4px);
	left: 0;
	flex-direction: column;
	background-color: #0e0e20;
	border: 1px solid #252540;
	border-radius: 3px;
	z-index: 400;
	min-width: 110px;
	overflow: hidden;
}

#hamburger-menu.open {
	display: flex;
}

.hmenu-btn {
	padding: 0.5em 0.8em;
	background: none;
	border: none;
	border-bottom: 1px solid #1a1a30;
	color: #B8D4F0;
	font-family: monospace, monospace;
	font-size: 0.85em;
	cursor: pointer;
	text-align: left;
	transition: background-color 0.1s, color 0.1s;
}

.hmenu-btn:last-child {
	border-bottom: none;
}

.hmenu-btn:hover {
	background-color: #1a1a30;
	color: #4a9eff;
}

/* ============================================================
   D-pad canvas overlay (phone portrait)
   Active when JS moves #dpad-wrap into #game-column
   ============================================================ */

#game-column > #dpad-wrap {
	position: absolute;
	bottom: 0.5em;
	left: 0.5em;
	z-index: 20;
	justify-content: flex-start;
	align-items: flex-start;
}

#game-column > #dpad-wrap #dpad {
	grid-template-columns: repeat(3, 36px);
	grid-template-rows: repeat(2, 36px);
	gap: 3px;
}

#game-column > #dpad-wrap #dpad button {
	font-size: 0.85em;
	background-color: rgba(26, 26, 46, 0.75);
	border-color: rgba(46, 58, 90, 0.75);
}

#game-column > #dpad-wrap #btn-help-dpad {
	display: none;
}

/* Backdrops behind overlays -- catch outside taps to dismiss */
#map-backdrop,
#inventory-backdrop {
	display: none;
	position: fixed;
	inset: 0;
	z-index: 99;
}

#map-backdrop.open,
#inventory-backdrop.open {
	display: block;
}

/* ============================================================
   Phone portrait layout (max-width: 480px)
   ============================================================ */

@media (max-width: 480px) {
	body {
		padding: 0.3em;
	}

	#header-tagline {
		display: none;
	}

	#header-game-btns,
	#btn-help-header {
		display: none;
	}

	#hamburger-wrap {
		display: block;
	}

	#game-container {
		gap: 0.4em;
	}

	#side-panel {
		flex-direction: column;
		width: 100%;
		gap: 0.4em;
	}

	#side-col-main {
		display: flex;
		flex-direction: column;
		gap: 0.4em;
		min-width: 0;
		max-width: none;
	}

	#mini-map-panel {
		display: none;
	}

	#status-panel {
		padding: 0.35em 0.6em;
	}

	#status-panel h2 {
		display: none;
	}

	#status-panel p {
		display: inline;
		margin: 0 0.75em 0 0;
		font-size: 0.82em;
	}

	#dpad {
		grid-template-columns: repeat(3, 54px);
		grid-template-rows: repeat(2, 54px);
	}

	#btn-help-dpad {
		display: none;
	}

	/* Show the floating Map button on phone */
	#btn-map {
		display: block;
	}

	/* Show Inventory button in header on phone */
	#btn-inventory {
		display: block;
	}

	#tool-list {
		gap: 0.2em;
	}

	.tool-entry {
		padding: 0.15em 0.4em;
	}

	/* Hide inventory from sidebar on phone (accessed via popup instead) */
	#side-col-main #inventory-panel:not(.inventory-popup-open) {
		display: none;
	}

	/* Inventory as overlay -- positioned over canvas by JS */
	#inventory-panel.inventory-popup-open {
		display: flex;
		position: fixed;
		z-index: 100;
		padding: 0.4em;
		flex-direction: column;
		overflow: hidden;
	}

	#inventory-panel.inventory-popup-open #inventory-panel-header {
		align-self: stretch;
	}

	#inventory-panel.inventory-popup-open #btn-inventory-close {
		display: block;
		background: none;
		border: none;
		color: #4a9eff;
		font-size: 1.1em;
		cursor: pointer;
		padding: 0.2em 0.4em;
		line-height: 1;
		flex-shrink: 0;
	}

	#inventory-panel.inventory-popup-open #btn-inventory-close:hover {
		color: #b8d4f0;
	}

	/* Mini-map as overlay -- positioned over canvas by JS */
	#mini-map-panel.map-overlay-open {
		display: flex;
		position: fixed;
		z-index: 100;
		padding: 0.4em;
		flex-direction: column;
		align-items: center;
		overflow: hidden;
	}

	#mini-map-panel.map-overlay-open #btn-map-close {
		display: block;
		background: none;
		border: none;
		color: #4a9eff;
		font-size: 1.1em;
		cursor: pointer;
		padding: 0.2em 0.4em;
		line-height: 1;
		flex-shrink: 0;
	}

	#mini-map-panel.map-overlay-open #btn-map-close:hover {
		color: #b8d4f0;
	}
}

/* ============================================================
   Compact layout for height-constrained viewports (iPad landscape)
   ============================================================ */

@media (min-width: 900px) and (max-height: 900px) {
	body {
		padding: 0.4em;
	}
	#game-header {
		margin-bottom: 0.4em;
	}
	#side-panel {
		font-size: 0.85em;
	}
	#side-col-main {
		min-width: 200px;
	}
	#status-panel,
	#inventory-panel {
		padding: 0.5em;
	}
	#tool-list {
		gap: 0.25em;
	}
	.tool-entry {
		padding: 0.2em 0.4em;
	}
}
