/* Mars III · 沙暴塔防 */
:root {
	--bg: #1a1410;
	--panel: #2c231a;
	--panel2: #372b20;
	--line: #4a3a28;
	--text: #e8d8c0;
	--dim: #9a8770;
	--accent: #f0a048;
	--bad: #e86050;
	--good: #7ee8a0;
}
* { box-sizing: border-box; }
html, body {
	margin: 0; padding: 0; height: 100%;
	background: var(--bg); color: var(--text);
	font-family: -apple-system, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
	overflow: hidden;
}
button {
	font: inherit; color: var(--text);
	background: var(--panel2); border: 1px solid var(--line);
	border-radius: 6px; padding: 4px 9px; cursor: pointer;
}
button:hover { border-color: var(--accent); }
button:disabled { opacity: .45; cursor: not-allowed; }
.hidden { display: none !important; }

#wrap { display: flex; flex-direction: column; height: 100vh; }

/* ── 顶栏 ── */
#hud {
	display: flex; align-items: center; gap: 14px;
	padding: 7px 14px; background: var(--panel);
	border-bottom: 1px solid var(--line); flex: 0 0 auto;
	font-size: 14px;
}
.hud-item { color: var(--dim); }
.hud-item b { color: var(--accent); font-size: 16px; margin-left: 3px; }
.hud-item b.bad { color: var(--bad); }
#btn-next { background: #6a4020; border-color: var(--accent); }
.spacer { flex: 1; }
.spd { min-width: 42px; font-size: 13px; }
.spd.on { background: var(--accent); color: #22160c; border-color: var(--accent); }

/* ── 主体 ── */
#stage { display: flex; flex: 1; min-height: 0; }
#main-col {
	flex: 1; display: flex; flex-direction: column;
	min-width: 0; min-height: 0;
}
#canvas-wrap {
	flex: 1; display: flex; align-items: center; justify-content: center;
	position: relative; padding: 8px; min-width: 0;
}
#cv {
	background: #2b211a; border: 1px solid var(--line);
	max-width: 100%; max-height: 100%;
	aspect-ratio: 1 / 1; height: 100%; width: auto;
	cursor: crosshair;
}

/* ── 侧栏 ── */
#side {
	width: 268px; flex: 0 0 268px; background: var(--panel);
	border-left: 1px solid var(--line);
	display: flex; flex-direction: column; gap: 8px;
	padding: 8px; overflow-y: auto;
}
#nextwave {
	background: var(--panel2); border: 1px solid var(--line);
	border-radius: 6px; padding: 7px 9px; font-size: 12.5px;
}
#nextwave b { color: var(--accent); }
.nw-row { display: flex; align-items: center; gap: 6px; margin-top: 3px; color: var(--dim); }
.nw-row i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

#palette { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; }
.pal-item {
	display: flex; flex-direction: column; align-items: center; gap: 1px;
	padding: 4px 2px; border-radius: 6px; border: 1px solid var(--line);
	border-left: 3px solid var(--bc, var(--accent));
	background: var(--panel2); cursor: pointer;
}
.pal-item:hover { border-color: var(--accent); }
.pal-icon { width: 22px; height: 22px; display: block; }
.pal-icon svg { width: 100%; height: 100%; }
.pal-name { font-size: 10px; line-height: 1.1; color: var(--text); text-align: center; }
.pal-cost { font-size: 10px; color: var(--accent); }
.pal-cap { font-size: 9px; color: var(--dim); }
.pal-item.armed { background: #4a3418; box-shadow: 0 0 0 1px var(--accent) inset; }
.pal-item.poor { opacity: .5; }
.pal-item.capped { opacity: .35; }

/* 画布下方：选中建筑详情条 */
#info {
	background: var(--panel2); border: 1px solid var(--line); border-top: none;
	padding: 6px 10px; font-size: 12.5px;
	display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
}
#info.hidden { display: none; }
.info-name { color: var(--accent); font-weight: 600; white-space: nowrap; }
.info-dmg { color: var(--dim); font-size: 11.5px; white-space: nowrap; }
.info-dmg b { color: var(--text); }
.info-lvtable { display: flex; gap: 6px; flex-wrap: wrap; flex: 1; min-width: 0; }
.info-lvrow {
	padding: 3px 8px; border: 1px solid var(--line); border-radius: 4px;
	font-size: 11px; color: var(--dim); white-space: nowrap;
}
.info-lvrow.cur { border-color: var(--accent); color: var(--text); background: rgba(240,160,72,0.08); }
.info-lvrow.next { border-style: dashed; }
.info-lvrow .lvtag { color: var(--accent); font-weight: 600; margin-right: 5px; }
.info-lvrow .lvcost { margin-left: 6px; color: var(--dim); }
.info-btns { display: flex; flex-wrap: wrap; gap: 5px; margin-left: auto; }
.info-btns button { font-size: 11.5px; padding: 3px 7px; }
.info-btns .danger { border-color: var(--bad); color: var(--bad); }

#help { font-size: 11.5px; color: var(--dim); line-height: 1.5; }
#help p { margin: 0; }
#help b { color: var(--text); }

#sel-desc {
	background: rgba(240,160,72,0.06);
	border-left: 3px solid var(--accent);
	border-radius: 4px; padding: 7px 9px;
	font-size: 12px; line-height: 1.55; color: var(--dim);
}
#sel-desc b { color: var(--text); }
.sd-ex { color: #c8a0e8; }
.sd-cap { color: var(--accent); }

/* ── 提示 ── */
#toasts {
	position: fixed; left: 50%; top: 64px; transform: translateX(-50%);
	display: flex; flex-direction: column; gap: 6px; align-items: center;
	pointer-events: none; z-index: 50;
}
.toast {
	background: rgba(44,35,26,0.95); border: 1px solid var(--line);
	border-left: 3px solid var(--accent);
	padding: 6px 13px; border-radius: 5px; font-size: 13px;
	animation: toastIn .18s ease-out;
}
.toast.bad { border-left-color: var(--bad); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-6px); } }

/* ── 结算 ── */
#overlay {
	position: fixed; inset: 0; background: rgba(12,8,5,0.82);
	display: flex; align-items: center; justify-content: center; z-index: 100;
}
.modal {
	background: var(--panel); border: 1px solid var(--line);
	border-radius: 10px; padding: 26px 34px; text-align: center;
	min-width: 300px;
}
.modal h1 { margin: 0 0 10px; font-size: 24px; color: var(--accent); }
.modal p { margin: 5px 0; color: var(--dim); font-size: 13.5px; }
.modal button { margin-top: 16px; padding: 8px 22px; background: var(--accent); color: #22160c; border: none; font-weight: 600; }

/* ── 窄屏 ── */
@media (max-width: 900px) {
	#stage { flex-direction: column; }
	#side { width: auto; flex: 0 0 auto; border-left: none; border-top: 1px solid var(--line); max-height: 46vh; }
	#main-col { flex: 1; }
	#info { border-top: 1px solid var(--line); }
	#cv { height: auto; width: 100%; }
}
