:root {
	--bg: #060805;
	--panel: #10160c;
	--panel-2: #17200f;
	--ink: #f5f8e9;
	--muted: #aeb993;
	--line: #39461d;
	--toxic: #a7ff16;
	--toxic-2: #67c900;
	--gold: #d8b45b;
	--red: #da4e3a;
	--blue: #5fd0ff;
	--gray: #93a28c;
	--shadow: 0 20px 55px rgba(0, 0, 0, .38);
}

* {
	box-sizing: border-box;
}

html,
body {
	max-width: 100%;
	overflow-x: hidden;
}

body {
	margin: 0;
	background:
		radial-gradient(circle at 20% 8%, rgba(167, 255, 22, .15), transparent 30%),
		linear-gradient(180deg, #050604, var(--bg));
	color: var(--ink);
	font-family: Arial, Helvetica, sans-serif;
}

a {
	color: inherit;
	text-decoration: none;
}

button,
input,
textarea {
	font: inherit;
}

.topbar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	padding: 16px clamp(14px, 3vw, 34px);
	border-bottom: 1px solid rgba(167, 255, 22, .24);
	background: rgba(8, 12, 6, .92);
}

.brand,
.topbar nav {
	display: flex;
	align-items: center;
	gap: 10px;
}

.brand-mark {
	display: grid;
	place-items: center;
	width: 42px;
	height: 42px;
	border-radius: 8px;
	background: linear-gradient(135deg, var(--toxic), #d7ff69);
	color: #081003;
	font-weight: 900;
	box-shadow: 0 0 24px rgba(167, 255, 22, .28);
}

.brand strong,
.brand small {
	display: block;
	line-height: 1.1;
}

.brand small {
	margin-top: 3px;
	color: var(--muted);
	font-size: 12px;
	font-weight: 700;
	text-transform: uppercase;
}

.btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 38px;
	padding: 0 14px;
	border: 1px solid rgba(215, 180, 86, .65);
	border-radius: 6px;
	background: #171d10;
	color: var(--ink);
	font-weight: 800;
	cursor: pointer;
}

.btn:hover {
	border-color: var(--toxic);
	color: var(--toxic);
}

.btn.primary {
	border-color: #dbff72;
	background: linear-gradient(135deg, var(--toxic), var(--toxic-2));
	color: #071003;
}

.layout {
	display: grid;
	grid-template-columns: minmax(0, 1fr) minmax(340px, 390px);
	gap: 14px;
	padding: 14px;
}

.panel,
.map-shell {
	border: 1px solid rgba(167, 255, 22, .22);
	border-radius: 8px;
	background: rgba(12, 16, 8, .9);
	box-shadow: var(--shadow);
}

.controls,
.map-shell {
	grid-column: 1;
	min-width: 0;
}

.side-grid {
	display: grid;
	grid-column: 2;
	grid-row: 1 / span 2;
	gap: 14px;
	align-content: start;
	min-width: 0;
	overflow: hidden;
}

.panel {
	padding: 14px;
	min-width: 0;
}

.panel-head,
.panel-line,
.actions,
.map-toolbar,
.legend {
	display: flex;
	align-items: center;
	gap: 10px;
}

.panel-head,
.map-toolbar {
	justify-content: space-between;
}

.panel-head {
	align-items: flex-start;
	gap: 18px;
}

.actions {
	flex: 0 0 auto;
	flex-wrap: wrap;
	justify-content: flex-end;
}

h1,
h2,
p {
	margin-top: 0;
}

h1 {
	margin-bottom: 5px;
	font-size: 24px;
	color: var(--toxic);
}

h2 {
	margin-bottom: 12px;
	font-size: 18px;
	color: #f7ffe8;
}

p,
#statusText,
#mapMeta,
.empty {
	color: var(--muted);
	line-height: 1.4;
}

.form-grid,
.relation-grid {
	display: grid;
	gap: 10px;
}

.form-grid {
	grid-template-columns:
		minmax(170px, 1fr)
		minmax(220px, 1.15fr)
		repeat(3, minmax(82px, .45fr))
		minmax(116px, .55fr);
	margin-top: 12px;
}

.relation-grid {
	grid-template-columns: repeat(3, minmax(150px, 1fr)) minmax(140px, auto);
	align-items: end;
	margin-top: 10px;
}

label {
	display: grid;
	gap: 5px;
	color: var(--muted);
	font-size: 12px;
	font-weight: 800;
}

input,
textarea {
	width: 100%;
	min-width: 0;
	border: 1px solid rgba(215, 180, 86, .42);
	border-radius: 5px;
	background: #070a06;
	color: var(--ink);
	padding: 9px 10px;
	font-weight: 700;
}

textarea {
	resize: vertical;
	min-height: 52px;
}

.relation-button {
	min-width: 140px;
	height: 52px;
}

.map-shell {
	overflow: hidden;
	min-width: 0;
}

.map-toolbar {
	padding: 10px 12px;
	border-bottom: 1px solid rgba(167, 255, 22, .18);
	background: rgba(23, 32, 15, .85);
	font-size: 12px;
	font-weight: 800;
	gap: 12px;
}

.legend {
	flex-wrap: wrap;
	color: var(--muted);
	min-width: 0;
}

.legend span {
	display: inline-flex;
	align-items: center;
	gap: 6px;
}

.dot {
	display: inline-block;
	width: 10px;
	height: 10px;
	border-radius: 50%;
}

.own { background: var(--toxic); }
.ally { background: var(--blue); }
.enemy { background: var(--red); }
.neutral { background: var(--gray); }

.ring,
.sync-mark,
.shield-ring {
	display: inline-block;
	width: 13px;
	height: 13px;
	border-radius: 50%;
}

.ring {
	border: 2px solid var(--gold);
}

.sync-mark {
	border: 2px solid #fff;
}

.shield-ring {
	border: 2px solid #b987ff;
	box-shadow: 0 0 10px rgba(185, 135, 255, .55);
}

#mapCanvas {
	display: block;
	width: 100%;
	height: min(68vh, 720px);
	min-height: 430px;
	background: #18220f;
	cursor: crosshair;
	touch-action: none;
	user-select: none;
}

.summary-grid {
	display: grid;
	grid-template-columns: repeat(2, minmax(110px, 1fr));
	gap: 8px;
}

.metric {
	min-width: 0;
	padding: 10px;
	border: 1px solid rgba(215, 180, 86, .26);
	border-radius: 6px;
	background: rgba(23, 32, 15, .72);
}

.metric strong {
	display: block;
	color: var(--toxic);
	font-size: 20px;
	line-height: 1;
}

.metric span {
	color: var(--muted);
	font-size: 12px;
	font-weight: 800;
}

.selected-list {
	display: grid;
	gap: 7px;
	color: #dbe4c9;
	font-size: 14px;
}

.selected-list b {
	color: var(--toxic);
}

.table-wrap {
	overflow: auto;
	max-height: 390px;
	max-width: 100%;
}

table {
	width: 100%;
	border-collapse: collapse;
	font-size: 11px;
}

th,
td {
	padding: 7px 6px;
	border-bottom: 1px solid rgba(215, 180, 86, .18);
	text-align: left;
	white-space: nowrap;
}

.front-panel th:nth-child(2),
.front-panel td:nth-child(2),
.front-panel th:nth-child(5),
.front-panel td:nth-child(5) {
	max-width: 112px;
	overflow: hidden;
	text-overflow: ellipsis;
}

th {
	position: sticky;
	top: 0;
	background: #243114;
	color: var(--toxic);
	z-index: 1;
}

tr:hover td {
	background: rgba(167, 255, 22, .08);
}

#frontCount {
	margin-left: auto;
	color: var(--muted);
	font-size: 12px;
	font-weight: 800;
}

@media (max-width: 1180px) {
	.layout {
		grid-template-columns: 1fr;
	}

	.controls,
	.map-shell,
	.side-grid {
		grid-column: 1;
	}

	.side-grid {
		grid-row: auto;
		grid-template-columns: repeat(2, minmax(0, 1fr));
		overflow: visible;
	}

	.front-panel {
		grid-column: 1 / -1;
	}
}

@media (max-width: 980px) {
	.form-grid {
		grid-template-columns: minmax(170px, 1fr) minmax(200px, 1fr) repeat(2, minmax(90px, .5fr));
	}

	.relation-grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}

	.relation-grid label:nth-child(3),
	.relation-button {
		grid-column: 1 / -1;
	}
}

@media (max-width: 760px) {
	.topbar,
	.panel-head,
	.map-toolbar,
	.actions {
		align-items: stretch;
		flex-direction: column;
	}

	.topbar nav,
	.actions,
	.actions .btn,
	.topbar nav .btn {
		width: 100%;
	}

	.topbar nav {
		display: grid;
		grid-template-columns: repeat(3, minmax(0, 1fr));
	}

	.form-grid,
	.relation-grid,
	.side-grid {
		grid-template-columns: 1fr;
	}

	.relation-grid label:nth-child(3),
	.relation-button {
		grid-column: auto;
	}

	.relation-button {
		width: 100%;
		height: 42px;
	}

	#mapCanvas {
		min-height: 360px;
	}
}

@media (max-width: 480px) {
	.layout {
		padding: 8px;
		gap: 8px;
	}

	.panel {
		padding: 10px;
	}

	.topbar {
		padding: 12px;
	}

	.topbar nav {
		grid-template-columns: 1fr;
	}

	.summary-grid {
		grid-template-columns: 1fr;
	}

	#mapCanvas {
		height: 64vh;
		min-height: 320px;
	}
}
