@import url("https://fonts.googleapis.com/css2?family=Barlow+Condensed:wght@500;600;700&family=IBM+Plex+Mono:wght@400;500;600&family=Inter:wght@400;500;600;700&display=swap");

:root {
	color-scheme: dark;
	--ink: #edf0e6;
	--muted: #9aa18f;
	--faint: #8f9885;
	--paper: #151a14;
	--panel: #1c221b;
	--panel-raised: #232a21;
	--line: #343c31;
	--line-bright: #4a5545;
	--olive: #aab67b;
	--olive-bright: #cad69a;
	--blue: #5e9bc4;
	--blue-dark: #275673;
	--red: #c66d67;
	--red-dark: #783d3a;
	--amber: #d7ad62;
	--danger: #df7b70;
	--shadow: 0 22px 60px rgb(0 0 0 / 28%);
}

* { box-sizing: border-box; }

.visually-hidden {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

html { min-width: 320px; background: #0e120d; }

body {
	margin: 0;
	min-height: 100vh;
	color: var(--ink);
	font-family: "Inter", sans-serif;
	background:
		radial-gradient(circle at 18% -10%, rgb(122 137 87 / 14%), transparent 34rem),
		linear-gradient(180deg, #11160f 0%, #0d110c 100%);
}

button, a { font: inherit; }
button { color: inherit; }
button:focus-visible, a:focus-visible { outline: 2px solid var(--olive-bright); outline-offset: 2px; }

.app-shell {
	width: min(1460px, 100%);
	margin: 0 auto;
	padding: 18px;
}

.topbar {
	display: grid;
	grid-template-columns: 1fr auto 1fr;
	align-items: center;
	gap: 20px;
	min-height: 76px;
	padding: 12px 18px;
	border: 1px solid var(--line);
	border-radius: 7px 7px 2px 2px;
	background: linear-gradient(135deg, rgb(34 42 32 / 98%), rgb(23 29 22 / 98%));
	box-shadow: var(--shadow);
}

.brand-block, .scenario-title, .side-identity, .unit-title, .report-heading, .ready-row {
	display: flex;
	align-items: center;
}

.brand-block { gap: 12px; }

.brand-mark {
	display: grid;
	gap: 3px;
	width: 34px;
	padding: 8px 5px;
	border: 1px solid #667052;
	background: #30382b;
	transform: skewX(-8deg);
}

.brand-mark span { display: block; height: 2px; background: var(--olive-bright); }
.brand-mark span:nth-child(2) { width: 75%; }
.brand-mark span:nth-child(3) { width: 48%; }

.eyebrow, .section-label {
	margin: 0;
	color: var(--olive);
	font: 600 10px/1.2 "IBM Plex Mono", monospace;
	letter-spacing: .15em;
	text-transform: uppercase;
}

h1, h2 { margin: 0; font-family: "Barlow Condensed", sans-serif; text-transform: uppercase; }
h1 { font-size: 25px; letter-spacing: .06em; }
h2 { margin-top: 3px; font-size: 18px; letter-spacing: .04em; }

.turn-block { display: grid; justify-items: center; gap: 2px; }
.turn-block strong { font-family: "IBM Plex Mono", monospace; font-size: 14px; }
.time-label { color: var(--faint); font-size: 10px; }

.phase-chip {
	padding: 3px 9px;
	border: 1px solid #6d7658;
	border-radius: 2px;
	color: var(--olive-bright);
	background: #30372b;
	font: 600 9px "IBM Plex Mono", monospace;
	letter-spacing: .12em;
	text-transform: uppercase;
}

.scoreboard { display: flex; align-items: center; justify-content: flex-end; gap: 13px; }
.score { display: grid; grid-template-columns: auto auto; align-items: baseline; gap: 0 8px; min-width: 90px; }
.score span { font: 600 12px "IBM Plex Mono", monospace; text-transform: uppercase; }
.score strong { grid-row: 1 / 3; grid-column: 2; font: 700 31px/1 "Barlow Condensed", sans-serif; }
.score small { color: var(--muted); font-size: 9px; }
.score-blue strong, .score-blue span { color: #8dc2e2; }
.score-red strong, .score-red span { color: #e19a94; }
.score-divider { color: var(--faint); font: 600 10px "IBM Plex Mono", monospace; }

.command-layout {
	display: grid;
	grid-template-columns: minmax(0, 1fr) 318px;
	gap: 10px;
	margin-top: 10px;
}

.map-card, .command-rail, .report-card {
	border: 1px solid var(--line);
	background: var(--panel);
	box-shadow: 0 12px 32px rgb(0 0 0 / 18%);
}

.map-card { min-width: 0; border-radius: 3px; overflow: hidden; }

.map-toolbar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 15px;
	min-height: 56px;
	padding: 8px 13px;
	border-bottom: 1px solid var(--line);
	background: #20271e;
}

.scenario-title { gap: 9px; min-width: 150px; }
.scenario-title div { display: grid; }
.scenario-title strong { font: 600 17px "Barlow Condensed", sans-serif; letter-spacing: .05em; text-transform: uppercase; }
.scenario-title small { color: var(--muted); font: 9px "IBM Plex Mono", monospace; }

.map-pulse {
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: var(--olive-bright);
	box-shadow: 0 0 0 4px rgb(202 214 154 / 9%);
}

.map-modes { display: flex; gap: 3px; padding: 3px; background: #151a14; border: 1px solid #30372e; border-radius: 3px; }
.mode-button {
	border: 0;
	padding: 6px 10px;
	color: var(--muted);
	background: transparent;
	font-size: 10px;
	text-transform: uppercase;
	cursor: pointer;
}
.mode-button.active { color: var(--ink); background: #343c31; }
.mode-button:disabled { opacity: .34; cursor: not-allowed; }

.audio-controls { display: flex; align-items: flex-start; gap: 5px; }
.audio-channel { display: grid; gap: 3px; }
.sound-toggle {
	display: flex;
	align-items: center;
	gap: 6px;
	padding: 6px 8px;
	border: 1px solid var(--line);
	border-radius: 2px;
	color: var(--ink);
	background: #171c16;
	cursor: pointer;
}
.audio-channel .sound-toggle { justify-content: center; min-height: 31px; }
.volume-control { display: flex; align-items: center; gap: 4px; padding: 0 3px; }
.volume-control input { width: 72px; height: 28px; margin: 0; accent-color: var(--olive-bright); cursor: pointer; }
.volume-control output { min-width: 28px; color: var(--muted); font: 8px "IBM Plex Mono", monospace; text-align: right; }
.sound-toggle:hover { border-color: var(--line-bright); background: #242b21; }
.sound-toggle svg { width: 17px; height: 17px; fill: currentColor; }
.music-toggle svg { fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.sound-toggle svg .sound-wave { fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }
.sound-toggle span { color: var(--faint); font: 8px "IBM Plex Mono", monospace; text-transform: uppercase; }
.sound-toggle strong { color: var(--olive-bright); }
.sound-toggle[aria-pressed="false"] { color: var(--faint); }
.sound-toggle[aria-pressed="false"] .sound-wave { display: none; }
.sound-toggle[aria-pressed="false"] strong { color: var(--danger); }
.sound-toggle kbd { margin-left: 1px; }

.opponent-chip {
	display: grid;
	grid-template-columns: auto auto;
	align-items: center;
	gap: 1px 7px;
	padding: 6px 9px;
	border: 1px solid var(--line);
	border-radius: 2px;
	background: #171c16;
}
.opponent-chip span { color: var(--faint); font: 8px "IBM Plex Mono", monospace; text-transform: uppercase; }
.opponent-chip strong { color: #e19a94; font: 600 11px "IBM Plex Mono", monospace; text-transform: uppercase; }
.opponent-chip small { grid-column: 1 / -1; color: var(--muted); font-size: 8px; text-align: right; }

.map-viewport {
	position: relative;
	overflow: auto;
	min-height: 560px;
	background:
		linear-gradient(rgb(12 15 11 / 15%), rgb(12 15 11 / 15%)),
		repeating-linear-gradient(0deg, transparent 0 3px, rgb(255 255 255 / 1.4%) 3px 4px),
		#11160f;
	scrollbar-color: #46513f #171c16;
}

#map { display: block; width: 812px; height: 728px; margin: 0 auto; touch-action: manipulation; cursor: default; }
#map:focus-visible { outline: 3px solid var(--olive-bright); outline-offset: -3px; }
#map.tool-move, #map.tool-attack, #map.tool-bombard, #map.tool-support-attack, #map.tool-interdict { cursor: crosshair; }

.map-message {
	position: absolute;
	left: 50%;
	top: 16px;
	max-width: calc(100% - 28px);
	transform: translateX(-50%);
	padding: 7px 11px;
	border: 1px solid rgb(79 91 72 / 85%);
	border-radius: 2px;
	color: #d7dbc9;
	background: rgb(18 23 17 / 90%);
	box-shadow: 0 8px 18px rgb(0 0 0 / 22%);
	font: 500 10px "IBM Plex Mono", monospace;
	pointer-events: none;
	transition: opacity .2s;
}
.map-message:empty { opacity: 0; }
.map-message.error { color: #ffd2ce; border-color: var(--red-dark); }

.resolution-playback {
	position: absolute;
	left: 16px;
	bottom: 16px;
	width: min(420px, calc(100% - 32px));
	padding: 11px 12px 9px;
	border: 1px solid #77825f;
	border-left: 3px solid var(--olive-bright);
	background: rgb(18 23 17 / 94%);
	box-shadow: 0 14px 34px rgb(0 0 0 / 38%);
	backdrop-filter: blur(5px);
}
.resolution-playback[hidden] { display: none; }
.resolution-meta { display: flex; justify-content: space-between; align-items: center; color: var(--olive); font: 600 8px "IBM Plex Mono", monospace; letter-spacing: .12em; text-transform: uppercase; }
.resolution-meta strong { color: var(--ink); letter-spacing: 0; }
.resolution-playback p { min-height: 17px; margin: 7px 0 8px; color: #eef1e7; font: 500 11px/1.45 "IBM Plex Mono", monospace; }
.resolution-progress { height: 2px; overflow: hidden; background: #343c31; }
.resolution-progress span { display: block; width: 0; height: 100%; background: var(--olive-bright); transition: width .18s linear; }
.resolution-playback button { display: flex; align-items: center; gap: 5px; margin: 7px 0 0 auto; padding: 2px 0; border: 0; color: var(--faint); background: transparent; font-size: 8px; cursor: pointer; }
.resolution-playback button:hover { color: var(--ink); }

.map-legend {
	display: flex;
	align-items: center;
	gap: 13px;
	min-height: 35px;
	padding: 6px 12px;
	border-top: 1px solid var(--line);
	color: var(--muted);
	background: #181e17;
	font-size: 9px;
}
.map-legend span { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.map-legend i { width: 9px; height: 9px; border: 1px solid rgb(255 255 255 / 15%); }
.terrain-open { background: #777859; }
.terrain-forest { background: #344a32; }
.terrain-hills { background: #79684f; }
.terrain-urban { background: #555a59; }
.map-legend .river-line { width: 16px; height: 2px; border: 0; background: #568ba0; }
.legend-note { margin-left: auto; color: var(--faint); }

.command-rail { align-self: start; border-radius: 3px; overflow: hidden; }
.rail-section { padding: 15px; border-bottom: 1px solid var(--line); }
.rail-section:last-child { border-bottom: 0; }
.identity-section { background: linear-gradient(110deg, rgb(48 66 77 / 48%), transparent); }
body[data-side="red"] .identity-section { background: linear-gradient(110deg, rgb(92 52 49 / 48%), transparent); }
.side-identity { gap: 10px; margin-top: 9px; }
.side-identity div { display: grid; }
.side-identity strong { font-family: "Barlow Condensed", sans-serif; font-size: 19px; text-transform: uppercase; }
.side-identity small { color: var(--muted); font-size: 10px; }
.side-roundel {
	display: grid;
	place-items: center;
	width: 34px;
	height: 34px;
	border: 2px solid #b9d8e9;
	border-radius: 50%;
	color: white;
	background: var(--blue-dark);
	font: 700 14px "IBM Plex Mono", monospace;
}
body[data-side="red"] .side-roundel { border-color: #edbbb6; background: var(--red-dark); }

.section-heading, .movement-line { display: flex; align-items: center; justify-content: space-between; }
.section-heading > span { color: var(--faint); font: 10px "IBM Plex Mono", monospace; }
.empty-state, .empty-report { margin: 13px 0 0; color: var(--faint); font-size: 11px; line-height: 1.55; }
.unit-details { margin-top: 13px; }
.unit-title { gap: 9px; }
.unit-title div { display: grid; }
.unit-title strong { font-size: 12px; }
.unit-title small { color: var(--muted); font-size: 10px; }
.unit-badge { display: grid; place-items: center; width: 38px; height: 34px; padding: 4px; border: 1px solid #7893a2; color: #cbe7f6; background: #294453; }
.unit-badge svg { width: 28px; height: 28px; }
body[data-side="red"] .unit-badge { border-color: #9f6863; color: #f4c5c1; background: #563533; }

.status-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; margin-top: 12px; background: var(--line); border: 1px solid var(--line); }
.status-grid div { display: grid; gap: 2px; padding: 8px; background: #171c16; }
.status-grid span, .movement-line span { color: var(--faint); font-size: 9px; text-transform: uppercase; }
.status-grid strong { font: 600 11px "IBM Plex Mono", monospace; }
.movement-line { margin-top: 8px; padding: 8px; border: 1px solid var(--line); }
.movement-line strong { color: var(--olive-bright); font: 600 11px "IBM Plex Mono", monospace; }
.hex-inspector { margin-top: 15px; padding-top: 13px; border-top: 1px solid var(--line); }
.hex-details { display: grid; gap: 8px; margin-top: 10px; }
.hex-terrain { display: grid; grid-template-columns: 18px 1fr; align-items: center; gap: 8px; }
.hex-terrain > i { width: 18px; height: 18px; border: 1px solid rgb(255 255 255 / 25%); border-radius: 2px; }
.hex-terrain > div { display: grid; gap: 2px; }
.hex-terrain strong { font-size: 11px; }
.hex-terrain small { color: var(--muted); font: 9px/1.4 "IBM Plex Mono", monospace; }
.hex-symbol-list { display: grid; gap: 5px; }
.hex-symbol-item { display: grid; grid-template-columns: 27px 1fr; align-items: center; gap: 7px; padding: 6px; border: 1px solid #30382d; background: #151a14; }
.hex-symbol-mark { color: var(--olive-bright); font: 700 9px "IBM Plex Mono", monospace; text-align: center; }
.hex-symbol-copy { display: grid; gap: 1px; }
.hex-symbol-copy strong { font-size: 10px; }
.hex-symbol-copy small { color: var(--muted); font: 9px/1.4 "IBM Plex Mono", monospace; }

.order-buttons { display: grid; gap: 6px; margin-top: 10px; }
.artillery-controls { margin-top: 13px; padding-top: 12px; border-top: 1px solid var(--line); }
.artillery-controls[hidden] { display: none; }
.artillery-buttons { grid-template-columns: 1fr 1fr; }
.artillery-buttons .order-button { grid-template-columns: 28px 1fr auto; min-width: 0; padding: 7px 6px; }
.artillery-buttons .order-icon { width: 26px; height: 25px; }
.artillery-buttons .order-button small { line-height: 1.3; }
.order-button {
	display: grid;
	grid-template-columns: 32px 1fr auto;
	align-items: center;
	gap: 8px;
	width: 100%;
	padding: 8px;
	border: 1px solid var(--line);
	border-radius: 2px;
	text-align: left;
	background: #171c16;
	cursor: pointer;
	transition: border-color .12s, background .12s, transform .12s;
}
.order-button:hover:not(:disabled) { border-color: var(--line-bright); background: #242b21; transform: translateX(2px); }
.order-button.active { border-color: var(--olive); background: #30372a; }
.order-button.shortcut-hit, .ready-button.shortcut-hit, .sound-toggle.shortcut-hit { border-color: #d3df9a; box-shadow: 0 0 0 2px rgb(190 207 126 / 20%); }
.order-button:disabled { opacity: .38; cursor: not-allowed; }
.order-button > span:last-child { display: grid; gap: 1px; }
.order-button strong { font-size: 11px; text-transform: uppercase; }
.order-button small { color: var(--muted); font-size: 9px; }
.order-icon { display: grid; place-items: center; width: 30px; height: 27px; border: 1px solid #4a5545; color: var(--olive-bright); background: #2b3228; font: 600 16px "IBM Plex Mono", monospace; }
.route-readout { margin-top: 9px; min-height: 30px; padding: 7px 8px; color: var(--muted); background: #151a14; border-left: 2px solid #515d49; font: 9px/1.5 "IBM Plex Mono", monospace; }
.shortcut-strip { display: flex; justify-content: space-between; gap: 8px; margin-top: 7px; color: var(--faint); font: 8px "IBM Plex Mono", monospace; text-transform: uppercase; }
kbd { min-width: 17px; padding: 2px 4px; border: 1px solid #56614f; border-bottom-color: #77836d; border-radius: 2px; color: #d8dfca; background: #252c22; box-shadow: inset 0 -1px rgb(0 0 0 / 35%); font: 600 8px "IBM Plex Mono", monospace; text-align: center; text-transform: uppercase; }
.order-button > kbd { justify-self: end; }

.commit-section { background: #171c16; }
.ready-row { justify-content: space-between; margin-bottom: 9px; color: var(--muted); font-size: 10px; }
.ready-row strong { color: var(--amber); font: 600 10px "IBM Plex Mono", monospace; text-transform: uppercase; }
.ready-row strong.locked { color: var(--olive-bright); }
.ready-button {
	position: relative;
	display: grid;
	gap: 2px;
	width: 100%;
	padding: 11px 14px;
	border: 1px solid #77825f;
	border-radius: 2px;
	color: #f4f6ed;
	background: linear-gradient(180deg, #4b5640, #384132);
	box-shadow: inset 0 1px rgb(255 255 255 / 8%);
	cursor: pointer;
	text-align: center;
}
.ready-button:hover:not(:disabled) { background: linear-gradient(180deg, #5a664c, #414b39); }
.ready-button:disabled { opacity: .5; cursor: not-allowed; }
.ready-button span { font: 700 13px "Barlow Condensed", sans-serif; letter-spacing: .08em; text-transform: uppercase; }
.ready-button small { color: #c0c6b4; font-size: 9px; }
.ready-button kbd { position: absolute; top: 50%; right: 9px; transform: translateY(-50%); color: #e5eadb; background: rgb(28 34 25 / 55%); }
.commit-warning { margin: 7px 0 0; color: var(--faint); font-size: 9px; text-align: center; }

.report-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.report-card { min-height: 174px; border-radius: 3px; padding: 14px; }
.report-heading { justify-content: space-between; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.report-heading > span { padding: 3px 6px; border: 1px solid var(--line); color: var(--muted); font: 9px "IBM Plex Mono", monospace; text-transform: uppercase; }
.report-list { display: grid; gap: 6px; margin-top: 9px; }
.report-item { display: grid; grid-template-columns: 35px 1fr auto; align-items: center; gap: 9px; min-height: 38px; padding: 6px 8px; background: #171c16; border: 1px solid #2d342b; }
.report-item .report-symbol { display: grid; place-items: center; width: 28px; height: 25px; color: var(--olive-bright); border: 1px solid #485141; font: 600 12px "IBM Plex Mono", monospace; }
.report-item div { display: grid; gap: 2px; }
.report-item strong { font-size: 10px; }
.report-item small { color: var(--muted); font: 9px "IBM Plex Mono", monospace; }
.report-item button { border: 0; color: var(--faint); background: transparent; cursor: pointer; }
.report-item button:hover { color: var(--danger); }
.event-item { grid-template-columns: 25px 1fr; }
.event-item .report-symbol { width: 22px; height: 22px; border-radius: 50%; }

footer { display: flex; justify-content: space-between; align-items: center; padding: 13px 2px 2px; color: var(--faint); font: 9px "IBM Plex Mono", monospace; }
footer button { border: 0; padding: 4px; color: var(--faint); background: transparent; cursor: pointer; text-decoration: underline; }
footer button:hover { color: var(--ink); }

@media (max-width: 1050px) {
	.topbar { grid-template-columns: 1fr 1fr; }
	.turn-block { order: 3; grid-column: 1 / -1; display: flex; justify-content: center; gap: 10px; padding-top: 7px; border-top: 1px solid var(--line); }
	.scoreboard { justify-self: end; }
	.command-layout { grid-template-columns: minmax(0, 1fr); }
	.command-rail { display: grid; grid-template-columns: 1fr 1.2fr 1.3fr 1fr; }
	.rail-section { border-right: 1px solid var(--line); border-bottom: 0; }
	.rail-section:last-child { border-right: 0; }
	.map-viewport { min-height: 470px; max-height: 70vh; }
}

@media (max-width: 900px) {
	.command-rail { grid-template-columns: 1fr 1fr; }
	.rail-section { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
	.rail-section:nth-child(even) { border-right: 0; }
}

@media (max-width: 760px) {
	.app-shell { padding: 8px; }
	.topbar { gap: 10px; padding: 10px; }
	.brand-mark { display: none; }
	h1 { font-size: 21px; }
	.score { min-width: auto; }
	.score span, .score-divider { display: none; }
	.score small { grid-column: 1 / 3; }
	.scoreboard { gap: 9px; }
	.map-toolbar { align-items: flex-start; flex-wrap: wrap; }
	.map-modes { order: 3; width: 100%; }
	.map-modes .mode-button { flex: 1; }
	.opponent-chip span, .opponent-chip small { display: none; }
	#map { margin: 0; }
	.map-legend { overflow-x: auto; }
	.legend-note { display: none !important; }
	.command-rail { grid-template-columns: 1fr; }
	.artillery-buttons { grid-template-columns: 1fr 1fr; }
	.rail-section { border-right: 0; border-bottom: 1px solid var(--line); }
	.report-grid { grid-template-columns: 1fr; }
	footer { align-items: flex-start; gap: 10px; }
}

@media (max-width: 390px) {
	.artillery-buttons { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
	*, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
