:root {
  --bg: #14161c; --panel: #1e2129; --panel2: #262a35; --border: #343946;
  --text: #e8e6df; --muted: #9aa0ad; --accent: #d4a94a; --accent2: #7bb5ff;
  --danger: #e05a5a; --ok: #5ec27a;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 14px/1.45 system-ui, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; }
button { font: inherit; cursor: pointer; background: var(--panel2); color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: 6px 12px; }
button:hover:not(:disabled) { border-color: var(--accent); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary { background: var(--accent); color: #1a1408; border-color: transparent; font-weight: 600; }
button.ghost { background: transparent; }
button.small { padding: 2px 8px; font-size: 12px; }
input, select { font: inherit; background: #0f1116; color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: 6px 8px; }
label { display: block; margin: 10px 0; color: var(--muted); }
label input, label select { display: block; width: 100%; margin-top: 4px; color: var(--text); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.screen { height: 100%; }
#lobby, #room { display: flex; align-items: center; justify-content: center; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 28px 32px; width: min(440px, 92vw); box-shadow: 0 20px 60px rgba(0,0,0,.4); }
.card h1 { margin: 0 0 4px; font-size: 28px; }
.card h2 { margin: 0 0 4px; }
.sub { color: var(--muted); margin: 0 0 16px; }
.row { display: flex; gap: 8px; margin: 8px 0; }
.row input { flex: 1; }
.row button { white-space: nowrap; }
.divider { text-align: center; color: var(--muted); margin: 8px 0; }
.msg { min-height: 1.4em; color: var(--accent2); }
.code { font-family: ui-monospace, Consolas, monospace; letter-spacing: 3px; color: var(--accent); }
.plist { list-style: none; padding: 0; margin: 12px 0; }
.plist li { padding: 6px 10px; border: 1px solid var(--border); border-radius: 6px; margin-bottom: 6px; display: flex; justify-content: space-between; }

#game { display: flex; flex-direction: column; }
#topbar { display: flex; align-items: center; gap: 18px; padding: 8px 14px; background: var(--panel); border-bottom: 1px solid var(--border); }
#dayInfo { font-weight: 600; }
#resInfo { display: flex; gap: 14px; }
#resInfo span { white-space: nowrap; }
#timer { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--muted); }
#timer.urgent { color: var(--danger); font-weight: 700; }
#main { flex: 1; display: flex; min-height: 0; }
#mapWrap { flex: 1; position: relative; overflow: auto; background: #0b0d12; }
#map { display: block; image-rendering: pixelated; }
#hoverInfo { position: sticky; left: 8px; bottom: 8px; display: inline-block; background: rgba(20,22,28,.9); border: 1px solid var(--border); padding: 4px 10px; border-radius: 6px; font-size: 12px; pointer-events: none; min-height: 1.6em; }
#side { width: 340px; background: var(--panel); border-left: 1px solid var(--border); display: flex; flex-direction: column; overflow-y: auto; }
#side section { padding: 10px 12px; border-bottom: 1px solid var(--border); }
#side h3 { margin: 0 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: 1px; color: var(--accent); }
#logSec { flex: 1; display: flex; flex-direction: column; min-height: 200px; }
#log { flex: 1; overflow-y: auto; font-size: 12px; min-height: 120px; max-height: 320px; }
#log div { padding: 3px 0; border-bottom: 1px dashed #2a2e39; }
#log .battle { cursor: pointer; color: var(--accent2); }
#log .chat { color: #c9d6b6; }
#log .day { color: var(--accent); }
#chatForm { display: flex; gap: 6px; margin-top: 8px; }
#chatForm input { flex: 1; }

.item { display: flex; align-items: center; gap: 8px; padding: 4px 6px; border-radius: 6px; }
.item.clickable { cursor: pointer; }
.item.clickable:hover { background: var(--panel2); }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.stack { display: flex; justify-content: space-between; padding: 2px 6px; background: var(--panel2); border-radius: 4px; margin: 2px 0; }
.buildRow { display: flex; justify-content: space-between; align-items: center; gap: 6px; padding: 4px 0; border-bottom: 1px dashed #2a2e39; }
.buildRow .n { font-weight: 600; }
.buildRow .c { color: var(--muted); font-size: 12px; }
.recruitRow { display: flex; align-items: center; gap: 6px; padding: 4px 0; }
.recruitRow input { width: 56px; padding: 3px 6px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; margin: 6px 0; }
.kv span:nth-child(odd) { color: var(--muted); }
.tag { display: inline-block; padding: 0 6px; border-radius: 4px; font-size: 11px; background: var(--panel2); margin-right: 4px; }
.tag.ok { background: #1f3a2a; color: var(--ok); }

#modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; z-index: 20; }
.modalBox { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 20px 24px; width: min(560px, 92vw); max-height: 85vh; overflow: auto; }
.modalBox h2 { margin: 0 0 8px; }
.vs { display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; align-items: start; }
.vs h4 { margin: 0 0 6px; }
.lost { color: var(--danger); }
#toasts { position: fixed; top: 56px; right: 360px; display: flex; flex-direction: column; gap: 6px; z-index: 30; pointer-events: none; }
.toast { background: rgba(30,33,41,.95); border: 1px solid var(--accent); border-radius: 8px; padding: 8px 14px; max-width: 360px; animation: fade 4s forwards; }
.toast.err { border-color: var(--danger); }
@keyframes fade { 0% { opacity: 0; transform: translateY(-6px);} 8% { opacity: 1; transform: none;} 85% { opacity: 1;} 100% { opacity: 0;} }

@media (max-width: 900px) {
  #main { flex-direction: column; }
  #side { width: auto; border-left: 0; border-top: 1px solid var(--border); max-height: 45vh; }
  #toasts { right: 12px; }
}
