:root {
	--bg: #0a0d07;
	--surface: #fffdf8;
	--surface-2: #f8f5ee;
	--line: #b8cc72;
	--text: #27241f;
	--muted: #5f6648;
	--green: #a7ff16;
	--blue: #285f7a;
	--amber: #8f6e22;
	--red: #9d3434;
	--shadow: 0 10px 28px rgba(0, 0, 0, 0.22);
}

* {
	box-sizing: border-box;
}

body {
	margin: 0;
	overflow-x: hidden;
	background:
		radial-gradient(circle at 18% 0%, rgba(167, 255, 22, 0.14), transparent 30%),
		var(--bg);
	color: var(--text);
	font-family: Arial, Helvetica, sans-serif;
	font-size: 14px;
	line-height: 1.35;
}

.topbar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	padding: 14px 18px;
	border-top: 3px solid #a7ff16;
	border-bottom: 1px solid rgba(167, 255, 22, 0.36);
	background:
		linear-gradient(90deg, rgba(167, 255, 22, 0.16), transparent 42%),
		#101409;
	color: #f4f7e8;
}

.topbar-title {
	display: flex;
	align-items: center;
	gap: 14px;
	min-width: 0;
}

.brand-mini {
	display: inline-grid;
	grid-template-columns: 42px auto;
	align-items: center;
	gap: 10px;
	color: #f4f7e8;
	font-weight: 800;
	text-decoration: none;
}

.brand-mini span {
	display: grid;
	place-items: center;
	width: 42px;
	height: 42px;
	border: 1px solid #ddff72;
	border-radius: 8px;
	background: linear-gradient(135deg, #a7ff16, #d7ff66);
	color: #081003;
	box-shadow: 0 0 28px rgba(167, 255, 22, 0.34);
}

.brand-mini strong {
	display: none;
}

h1,
h2,
p {
	margin: 0;
}

h1 {
	font-size: 20px;
	font-weight: 700;
}

h2 {
	font-size: 15px;
	font-weight: 700;
}

.topbar p {
	margin-top: 2px;
	color: #b8c09c;
}

.topbar .brand-line {
	margin: 0 0 5px;
	color: #a7ff16;
	font-size: 12px;
	font-weight: 800;
	text-transform: uppercase;
}

.status {
	min-width: 220px;
	text-align: right;
	color: #a7ff16;
	font-weight: 700;
}

.layout {
	display: grid;
	grid-template-columns: minmax(340px, 0.78fr) minmax(440px, 1.22fr);
	gap: 10px;
	max-width: 1440px;
	margin: 0 auto;
	padding: 16px;
}

.panel {
	background: var(--surface);
	border: 1px solid var(--line);
	border-radius: 8px;
	box-shadow: var(--shadow);
	padding: 14px;
	min-width: 0;
}

.input-panel,
.results-panel {
	grid-column: span 2;
}

.section-head {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	justify-content: space-between;
	gap: 12px;
	margin-bottom: 8px;
}

.actions {
	display: flex;
	align-items: center;
	gap: 6px;
	flex-wrap: wrap;
}

.language-select {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	color: #b8c09c;
	font-size: 12px;
	font-weight: 800;
}

.language-select select {
	width: auto;
	height: 28px;
	border-color: #6f614b;
	background: var(--surface-2);
	color: #201a12;
	font-weight: 700;
}

.btn {
	height: 28px;
	border: 1px solid #6f614b;
	background: #d8c49a;
	color: #201a12;
	padding: 0 10px;
	border-radius: 3px;
	font-weight: 700;
	cursor: pointer;
}

.btn:hover {
	filter: brightness(0.98);
}

.btn.primary {
	background: var(--green);
	border-color: #5ba800;
	color: #071003;
}

.btn.ghost {
	background: var(--surface-2);
}

textarea {
	display: block;
	width: 100%;
	min-height: 190px;
	padding: 8px;
	border: 1px solid var(--line);
	background: #fff;
	color: var(--text);
	border-radius: 3px;
	resize: vertical;
	font-family: Consolas, "Courier New", monospace;
	font-size: 12px;
}

input,
select {
	width: 100%;
	height: 30px;
	padding: 4px 6px;
	border: 1px solid var(--line);
	background: #fff;
	color: var(--text);
	border-radius: 3px;
	font: inherit;
}

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

.field-note {
	color: var(--muted);
	font-size: 11px;
	font-weight: 400;
}

.nav-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	text-decoration: none;
}

.summary-row {
	display: flex;
	flex-wrap: wrap;
	gap: 14px;
	margin-top: 6px;
	color: var(--muted);
	font-weight: 700;
}

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

.server-sync-row {
	display: grid;
	grid-template-columns: minmax(180px, 260px) auto minmax(220px, 1fr);
	align-items: end;
	gap: 8px;
	margin-bottom: 10px;
}

.chips {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	min-height: 32px;
}

.chip {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	border: 1px solid var(--line);
	background: var(--surface-2);
	padding: 5px 8px;
	border-radius: 3px;
	color: var(--text);
	cursor: pointer;
	user-select: none;
}

.chip input {
	width: 14px;
	height: 14px;
	padding: 0;
	margin: 0;
}

.table-wrap {
	overflow: auto;
	border: 1px solid var(--line);
	border-radius: 6px;
	background: #fff;
	max-height: 520px;
	-webkit-overflow-scrolling: touch;
}

table {
	width: 100%;
	border-collapse: collapse;
	min-width: 980px;
}

th,
td {
	border-bottom: 1px solid #e6ded2;
	padding: 6px 7px;
	text-align: left;
	vertical-align: middle;
	white-space: nowrap;
}

th {
	position: sticky;
	top: 0;
	z-index: 1;
	background: #ece4d7;
	font-size: 12px;
	color: #4b4237;
}

tbody tr:nth-child(even) {
	background: #fbf8f1;
}

.tw-icons-cell {
	min-width: 76px;
}

.tw-icon-pair {
	display: inline-flex;
	align-items: center;
	gap: 1px;
	margin-right: 5px;
	vertical-align: middle;
}

.tw-icon-wrap {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 18px;
	height: 18px;
	border: 1px solid #b8aa92;
	border-radius: 2px;
	background: #efe6d2;
	overflow: hidden;
	font-size: 10px;
	font-weight: 700;
	line-height: 1;
	color: #fff;
}

.tw-icon-wrap img {
	display: block;
	width: 18px;
	height: 18px;
}

.tw-icon-wrap img ~ .tw-icon-fallback {
	display: none;
}

.tw-icon-fallback {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	height: 100%;
}

.tw-attack-small .tw-icon-fallback {
	background: #4f9a36;
}

.tw-attack-medium .tw-icon-fallback {
	background: #d47a1f;
}

.tw-attack-large .tw-icon-fallback {
	background: #a52e25;
}

.tw-noble-icon .tw-icon-fallback {
	background: #d9cfaa;
	color: #3d352a;
}

.tw-icon-text,
.tw-icon-more {
	font-size: 12px;
	color: var(--muted);
}

.muted {
	color: var(--muted);
}

.good {
	color: var(--green);
	font-weight: 700;
}

.warn {
	color: var(--amber);
	font-weight: 700;
}

.bad {
	color: var(--red);
	font-weight: 700;
}

.empty {
	padding: 16px;
	color: var(--muted);
}

.export-box {
	display: none;
	margin-top: 8px;
	min-height: 120px;
}

.export-box.visible {
	display: block;
}

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

	.input-panel,
	.results-panel {
		grid-column: auto;
	}

	.topbar {
		align-items: flex-start;
		flex-direction: column;
	}

	.topbar-title {
		align-items: flex-start;
	}

	.status {
		min-width: 0;
		text-align: left;
	}

	.unit-config-grid {
		grid-template-columns: repeat(2, minmax(120px, 1fr));
	}

	.server-sync-row {
		grid-template-columns: 1fr;
	}

	.language-select,
	.language-select select {
		width: 100%;
	}
}

@media (max-width: 640px) {
	.topbar {
		padding: 12px;
	}

	.topbar-title {
		gap: 10px;
	}

	h1 {
		font-size: 18px;
		line-height: 1.2;
	}

	.layout {
		gap: 10px;
		padding: 10px;
	}

	.panel {
		padding: 12px;
		border-radius: 7px;
	}

	.section-head {
		align-items: flex-start;
		flex-direction: column;
		gap: 8px;
	}

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

	.btn,
	.nav-btn {
		min-height: 34px;
		justify-content: center;
	}

	.status {
		width: 100%;
	}

	.summary-row {
		gap: 8px 12px;
	}

	.unit-config-grid {
		grid-template-columns: 1fr;
	}

	.chips {
		max-height: 180px;
		overflow: auto;
		padding-right: 2px;
	}

	.chip {
		width: 100%;
	}

	textarea {
		min-height: 220px;
		font-size: 12px;
	}

	.table-wrap {
		max-width: calc(100vw - 20px);
		max-height: 62vh;
	}

	table {
		min-width: 820px;
		font-size: 12px;
	}

	th,
	td {
		padding: 6px;
	}
}

@media (max-width: 440px) {
	.brand-mini {
		grid-template-columns: 36px auto;
	}

	.brand-mini span {
		width: 36px;
		height: 36px;
	}

	.topbar p {
		font-size: 12px;
	}
}
