:root {
	color-scheme: dark;
	--bg: #14161a;
	--panel: #1d2026;
	--line: #2c313a;
	--text: #e6e8eb;
	--muted: #8b93a1;
	--accent: #4fb37a;
	--busy: #d9a441;
	--mine: #4aa3ff;
	--enemy: #ff5a4f;
}
* {
	box-sizing: border-box;
}
body {
	margin: 0;
	background: var(--bg);
	color: var(--text);
	font:
		14px / 1.4 system-ui,
		sans-serif;
}
header {
	display: flex;
	align-items: center;
	gap: 24px;
	padding: 10px 16px;
	border-bottom: 1px solid var(--line);
}
h1 {
	font-size: 18px;
	margin: 0;
}
h2 {
	font-size: 15px;
	margin: 20px 0 8px;
}
.muted {
	color: var(--muted);
}
#hud {
	display: flex;
	gap: 18px;
	align-items: center;
	color: var(--muted);
	flex-wrap: wrap;
}
#hud b {
	color: var(--text);
	font-weight: 600;
}
.score {
	display: inline-flex;
	align-items: center;
	gap: 6px;
}
.score .bar {
	display: inline-block;
	width: 90px;
	height: 8px;
	background: var(--line);
	border-radius: 4px;
	overflow: hidden;
}
.score .bar > span {
	display: block;
	height: 100%;
	width: 0;
	background: var(--mine);
	transition: width 0.3s;
}
.score .bar.enemy > span {
	background: var(--enemy);
}
main {
	padding: 16px;
}
.row {
	display: flex;
	gap: 8px;
	margin: 6px 0;
}
.row.wrap {
	flex-wrap: wrap;
}
input,
textarea,
select {
	background: var(--panel);
	color: var(--text);
	border: 1px solid var(--line);
	border-radius: 6px;
	padding: 6px 8px;
	font: inherit;
}
button {
	background: var(--accent);
	color: #0b1a11;
	border: 0;
	border-radius: 6px;
	padding: 6px 12px;
	font: inherit;
	font-weight: 600;
	cursor: pointer;
}
button.secondary {
	background: var(--line);
	color: var(--text);
}
button.link {
	background: none;
	color: var(--muted);
	padding: 0 4px;
	font-weight: 400;
	text-decoration: underline;
}
button:disabled {
	background: var(--line);
	color: var(--muted);
	cursor: not-allowed;
}
#games {
	list-style: none;
	padding: 0;
	margin: 0;
}
#games li {
	display: flex;
	gap: 12px;
	align-items: center;
	padding: 6px 0;
	border-bottom: 1px solid var(--line);
}
#game[hidden] {
	display: none;
}
#game {
	display: flex;
	gap: 16px;
	align-items: flex-start;
}
#game .left {
	flex: 1;
	min-width: 0;
}
#board canvas {
	border: 1px solid var(--line);
	border-radius: 6px;
	display: block;
	width: 100%;
	max-width: 984px;
	height: auto;
	image-rendering: pixelated;
}
#cursor {
	font-size: 12px;
	margin: 4px 0 8px;
	font-variant-numeric: tabular-nums;
}
.below {
	display: flex;
	gap: 12px;
	align-items: flex-start;
}
#minimap {
	border: 1px solid var(--line);
	border-radius: 4px;
	image-rendering: pixelated;
	flex: none;
}
#production {
	list-style: none;
	margin: 0;
	padding: 0;
	flex: none;
	min-width: 150px;
	max-height: 170px;
	overflow-y: auto;
	font-size: 12px;
	background: var(--panel);
	border: 1px solid var(--line);
	border-radius: 6px;
}
#production:empty {
	display: none;
}
#production li {
	padding: 3px 8px;
	border-bottom: 1px solid var(--line);
	font-variant-numeric: tabular-nums;
}
#production .repeat {
	display: block;
	color: var(--muted);
}
#feed {
	list-style: none;
	margin: 0;
	padding: 0;
	flex: 1;
	max-height: 170px;
	overflow-y: auto;
	font-size: 13px;
	background: var(--panel);
	border: 1px solid var(--line);
	border-radius: 6px;
}
#feed li {
	padding: 3px 8px;
	border-bottom: 1px solid var(--line);
}
#feed .ev-time {
	color: var(--muted);
	font-variant-numeric: tabular-nums;
	margin-right: 6px;
}
#feed .ev-icon {
	margin-right: 6px;
}
#feed .ev-unit_lost,
#feed .ev-building_lost,
#feed .ev-under_attack,
#feed .ev-outpost_lost {
	color: #ffb3ad;
}
#feed .ev-outpost_captured,
#feed .ev-building_complete {
	color: #b7f0c9;
}
#generals {
	display: flex;
	flex-direction: column;
	gap: 10px;
	width: 380px;
	flex: none;
}
.general {
	background: var(--panel);
	border: 1px solid var(--line);
	border-radius: 8px;
	padding: 10px;
}
.general.busy {
	border-color: var(--busy);
}
.general .top {
	display: flex;
	gap: 6px;
	align-items: center;
}
.general .role {
	color: var(--muted);
	font-size: 12px;
	flex: 1;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}
.general .profile[hidden] {
	display: none;
}
.general .profile {
	display: flex;
	flex-direction: column;
	gap: 6px;
	margin: 8px 0;
}
.pill {
	font-size: 12px;
	padding: 1px 8px;
	border-radius: 999px;
	background: var(--line);
	color: var(--muted);
}
.pill.busy {
	background: var(--busy);
	color: #241a05;
}
.budget {
	height: 4px;
	background: var(--line);
	border-radius: 2px;
	margin: 6px 0;
	overflow: hidden;
}
.budget > div {
	height: 100%;
	background: var(--accent);
}
.meta {
	color: var(--muted);
	font-size: 12px;
}
.report {
	white-space: pre-wrap;
	margin: 6px 0;
	font-size: 13px;
}
.general form {
	display: flex;
	gap: 6px;
}
.general textarea.order {
	flex: 1;
	resize: vertical;
	min-height: 34px;
	height: 34px;
}
#end {
	position: fixed;
	inset: 0;
	background: rgba(5, 6, 8, 0.72);
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 10;
}
#end[hidden] {
	display: none;
}
.end-card {
	background: var(--panel);
	border: 1px solid var(--line);
	border-radius: 10px;
	padding: 20px 24px;
	min-width: 560px;
	max-width: min(960px, 94vw);
	max-height: 92vh;
	overflow-y: auto;
}
.end-mvp {
	font-size: 15px;
	font-weight: 600;
	color: #f2c96b;
	margin: 10px 0 0;
}
.debrief-general {
	border-top: 1px solid var(--line);
	padding: 6px 0;
}
.debrief-general summary {
	cursor: pointer;
	font-variant-numeric: tabular-nums;
}
.debrief-order {
	margin: 8px 0 8px 14px;
	padding-left: 10px;
	border-left: 2px solid var(--line);
}
.debrief-head {
	display: flex;
	gap: 8px;
	align-items: center;
	font-size: 12px;
}
.debrief-time {
	color: var(--muted);
	font-variant-numeric: tabular-nums;
}
.debrief-outcome {
	padding: 0 6px;
	border-radius: 8px;
	background: var(--line);
}
.outcome-done {
	color: #7fe0a3;
}
.outcome-timeout,
.outcome-budget,
.outcome-failed {
	color: var(--enemy);
}
.debrief-text {
	white-space: pre-wrap;
	margin: 2px 0;
}
.debrief-chips {
	display: flex;
	flex-wrap: wrap;
	gap: 4px;
	margin: 4px 0;
}
.debrief-chips .chip {
	font-family: ui-monospace, monospace;
	font-size: 11px;
	padding: 1px 6px;
	border: 1px solid var(--line);
	border-radius: 6px;
}
.debrief-chips .chip.bad {
	color: var(--enemy);
	border-color: var(--enemy);
}
.debrief-report {
	color: var(--muted);
	font-style: italic;
	white-space: pre-wrap;
}
.end-card h2 {
	font-size: 28px;
	margin: 0 0 4px;
}
.end-you {
	color: #7fe0a3;
}
.end-enemy {
	color: var(--enemy);
}
.end-card table {
	border-collapse: collapse;
	width: 100%;
	font-variant-numeric: tabular-nums;
}
.end-card th,
.end-card td {
	text-align: left;
	padding: 4px 8px;
	border-bottom: 1px solid var(--line);
}
.end-card th {
	color: var(--muted);
	font-weight: 500;
}
.row.wrap {
	flex-wrap: wrap;
}
.hint {
	color: var(--muted);
	margin: 0 0 8px;
	max-width: 760px;
}
.general details {
	margin: 4px 0;
	font-size: 12px;
}
.general summary {
	color: var(--muted);
	cursor: pointer;
}
.steps {
	max-height: 260px;
	overflow: auto;
	margin-top: 4px;
}
.step {
	white-space: pre-wrap;
	word-break: break-word;
	font-family: ui-monospace, monospace;
	padding: 3px 6px;
	border-left: 2px solid var(--line);
	margin: 2px 0;
}
.step.code {
	border-color: var(--mine);
}
.step.text,
.step.order {
	border-color: var(--accent);
	font-family: inherit;
}
.step.error {
	border-color: var(--enemy);
}
#help {
	margin-left: auto;
	flex: none;
}
.intro {
	max-width: 760px;
	font-size: 15px;
	margin: 0 0 4px;
}
.grow {
	flex: 1;
}
.sprite {
	display: inline-block;
	width: 32px;
	height: 32px;
	background-image: url("assets/tiny-battle.png");
	background-size: 576px auto;
	image-rendering: pixelated;
}
#tutorial {
	background: var(--panel);
	color: var(--text);
	border: 1px solid var(--line);
	border-radius: 10px;
	padding: 0;
	width: min(520px, 92vw);
}
.tut-inner {
	padding: 20px 24px;
}
#tutorial::backdrop {
	background: rgba(5, 6, 8, 0.72);
}
#tutorial h2 {
	font-size: 20px;
	margin: 8px 0;
}
.tut-art {
	display: flex;
	gap: 6px;
	min-height: 40px;
	padding: 4px;
	background: #2a4a24;
	border-radius: 6px;
	justify-content: center;
}
.tut-body {
	line-height: 1.5;
}
.tut-example {
	white-space: pre-wrap;
	background: var(--bg);
	border-left: 3px solid var(--accent);
	padding: 8px 10px;
	font-size: 13px;
}
.tut-dots {
	display: flex;
	gap: 6px;
	justify-content: center;
	margin: 10px 0 4px;
}
#tutorial .tut-dots span {
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: var(--line);
}
#tutorial .tut-dots span.on {
	background: var(--accent);
}
.suggest {
	display: flex;
	flex-direction: column;
	gap: 4px;
	margin: 6px 0;
}
.suggest[hidden] {
	display: none;
}
.suggest .label {
	color: var(--muted);
	font-size: 11px;
	padding: 0;
	border: 0;
	text-align: left;
	text-decoration: none;
}
.suggest button:not(.label) {
	background: var(--bg);
	color: var(--text);
	border: 1px dashed var(--line);
	text-align: left;
	font-weight: 400;
	font-size: 12px;
	padding: 4px 8px;
}
.suggest button:not(.label):hover {
	border-color: var(--accent);
}
.suggest button.opening {
	border-style: solid;
	border-color: var(--accent);
}
.lock {
	color: var(--busy);
	font-size: 12px;
	margin: 4px 0;
}
.lock:empty {
	display: none;
}
#feed .ev-general_done {
	color: #b7f0c9;
}
#feed .ev-general_budget,
#feed .ev-general_timeout {
	color: var(--busy);
}
.suggest.collapsed button:not(.label) {
	display: none;
}

/* ---- login (Nori dark tokens; the game is dark-only) ---------------------------------------- */
#login {
	--n-canvas: #161616;
	--n-sheet: #1c1c1c;
	--n-nested: #262626;
	--n-hair: #262626;
	--n-strong: #393939;
	--n-muted: #525252;
	--n-comment: #8a8f98;
	--n-text: #dde1e6;
	--n-fg: #f2f4f8;
	--n-green: #42be65;
	--n-green-bright: #6fdc8c;
	--n-red: #f47067;
	--n-red-bright: #ff9cac;
	--n-yellow: #f2cc60;
	--n-yellow-bright: #fddc69;
	--n-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
	min-height: calc(100vh - 60px);
	display: grid;
	place-items: center;
	padding: 32px 16px;
	background: var(--n-canvas);
	color: var(--n-text);
	font-size: 15px;
	line-height: 1.5;
}
.login-card {
	width: min(440px, 100%);
	display: flex;
	flex-direction: column;
	gap: 16px;
	padding: clamp(24px, 5vw, 40px);
	background: var(--n-sheet);
	border: 1px solid var(--n-hair);
	border-radius: 8px;
}
#login h2 {
	margin: 0;
	color: var(--n-fg);
	font-size: 24px;
	font-weight: 600;
	letter-spacing: -0.01em;
}
.login-card p {
	margin: 0;
}
.login-card .hint {
	color: var(--n-comment);
	font-size: 13px;
}
.login-card .reserved {
	min-height: 1.5em;
}
.login-brand {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
}
.login-brand .wordmark {
	font-family: var(--n-mono);
	font-weight: 600;
	font-size: 18px;
	color: var(--n-fg);
}
.login-brand .caret {
	color: var(--n-green);
}
#login .label {
	font-family: var(--n-mono);
	font-size: 12px;
	font-weight: 500;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	color: var(--n-comment);
}
.login-form {
	display: flex;
	flex-direction: column;
	gap: 12px;
}
.login-form label {
	display: flex;
	flex-direction: column;
	gap: 6px;
}
#login .field {
	min-height: 42px;
	padding: 8px 12px;
	background: var(--n-sheet);
	color: var(--n-fg);
	border: 1px solid var(--n-strong);
	border-radius: 6px;
	font-size: 15px;
	transition: border-color 120ms linear;
}
#login .field:focus {
	outline: none;
	border-color: var(--n-green);
	box-shadow: 0 0 0 2px rgba(66, 190, 101, 0.35);
}
#login button {
	min-height: 42px;
	border-radius: 6px;
	font-size: 15px;
	transition: background-color 120ms linear;
}
#login .btn-primary {
	background: var(--n-green);
	color: var(--n-canvas);
	font-weight: 600;
}
#login .btn-primary:hover {
	background: var(--n-green-bright);
}
#login .btn-secondary {
	background: var(--n-nested);
	color: var(--n-text);
	font-weight: 500;
}
#login .btn-secondary:hover {
	background: var(--n-strong);
}
#login .btn-google {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
	width: 100%;
	background: var(--n-sheet);
	color: var(--n-fg);
	border: 1px solid var(--n-strong);
	font-weight: 500;
}
#login .btn-google svg {
	background: #fff;
	border-radius: 4px;
	padding: 3px;
	box-sizing: content-box;
}
#login .btn-google:hover {
	background: var(--n-nested);
}
#login .link {
	min-height: 0;
	padding: 0;
	background: none;
	border: 0;
	color: var(--n-green);
	font-size: 13px;
	font-weight: 400;
	text-decoration: none;
	cursor: pointer;
}
#login .link:hover {
	color: var(--n-green-bright);
	text-decoration: underline;
}
.login-extras {
	display: flex;
	justify-content: space-between;
	gap: 12px;
}
.login-divider {
	display: flex;
	align-items: center;
	gap: 12px;
	font-family: var(--n-mono);
	font-size: 12px;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	color: var(--n-comment);
}
.login-divider::before,
.login-divider::after {
	content: "";
	flex: 1;
	border-top: 1px solid var(--n-hair);
}
#login .callout-error,
#login .callout-warn {
	padding: 10px 12px;
	border-radius: 6px;
	font-size: 13px;
}
#login .callout-error {
	background: rgba(244, 112, 103, 0.09);
	border: 1px solid var(--n-red);
	color: var(--n-red-bright);
}
#login .callout-warn {
	background: rgba(242, 204, 96, 0.09);
	border: 1px solid var(--n-yellow);
	color: var(--n-yellow-bright);
}
#account {
	display: flex;
	align-items: center;
	gap: 10px;
}
#login[hidden],
#account[hidden] {
	display: none;
}
