:root {
  --bg: #0b1216; --panel: #101b20; --panel2: #15242b; --line: #22363f; --text: #dce8ea; --muted: #7f979d;
  --green: #67d9a8; --orange: #f0a35e; --red: #ef6a5b; --blue: #98c7ff; --violet: #c49bff;
  font-family: ui-rounded, "SF Pro Rounded", "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body { display: flex; flex-direction: column; overflow: hidden; }
button { font: inherit; color: inherit; background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 5px 10px; cursor: pointer; }
button:hover { border-color: #3a5864; }
button.ghost { background: transparent; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.hidden { display: none !important; }

header { display: flex; align-items: center; gap: 18px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: linear-gradient(#0f1a1f, #0b1216); flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 9px; font-size: 17px; letter-spacing: .2px; }
.logo { width: 22px; height: 22px; border-radius: 50%; background: radial-gradient(circle at 35% 40%, var(--green) 0 26%, transparent 27%), radial-gradient(circle at 68% 64%, var(--orange) 0 20%, transparent 21%), #133034; box-shadow: 0 0 12px #67d9a855; }
.clock { display: flex; gap: 8px; align-items: center; font-variant-numeric: tabular-nums; }
.pill { font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--panel2); border: 1px solid var(--line); }
.hstats { margin-left: auto; display: flex; gap: 14px; align-items: center; font-size: 14px; }
.hstats b { font-variant-numeric: tabular-nums; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; }
.dot.g { background: var(--green); }
.live { font-size: 12px; padding: 2px 8px; border-radius: 99px; background: #173a2c; color: var(--green); }
.live::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: currentColor; margin-right: 5px; animation: pulse 1.6s infinite; }
.live.off { background: #3a1d1d; color: var(--red); }
@keyframes pulse { 50% { opacity: .25; } }

main { flex: 1; display: flex; min-height: 0; }
#stage { flex: 1; position: relative; min-width: 0; }
#world { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: grab; display: block; }
#world.drag { cursor: grabbing; }
.zoomBtns { position: absolute; right: 12px; top: 12px; display: flex; flex-direction: column; gap: 6px; }
.zoomBtns button { width: 34px; height: 34px; padding: 0; font-size: 18px; background: #101b20dd; backdrop-filter: blur(6px); }
.banner { position: absolute; left: 50%; top: 12px; transform: translateX(-50%); background: #2a2140ee; border: 1px solid #4b3c74; padding: 6px 8px 6px 14px; border-radius: 10px; display: flex; gap: 10px; align-items: center; font-size: 14px; white-space: nowrap; }
.banner.hl { background: #13303aee; border-color: #2c5a69; top: 56px; }
.maptip { position: absolute; left: 12px; bottom: 12px; font-size: 12px; color: var(--muted); background: #0b1216cc; padding: 5px 9px; border-radius: 8px; pointer-events: none; }

.card { position: absolute; left: 12px; bottom: 12px; width: 330px; max-width: calc(100% - 24px); max-height: calc(100% - 24px); overflow: auto; background: #101b20f2; backdrop-filter: blur(8px); border: 1px solid var(--line); border-radius: 14px; padding: 14px; box-shadow: 0 10px 40px #0008; }
.card h4 { margin: 0 0 2px; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.card .sw { width: 14px; height: 14px; border-radius: 50%; flex: none; }
.card .sub { color: var(--muted); font-size: 12px; margin-bottom: 10px; }
.card .x { position: absolute; right: 10px; top: 10px; padding: 2px 8px; }
.card .row { display: grid; grid-template-columns: 78px 1fr 44px; gap: 8px; align-items: center; font-size: 13px; margin: 5px 0; }
.card .row span:last-child { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.bar { height: 7px; background: #0b1216; border-radius: 9px; overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 9px; }
.card .acts { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.card .acts button.on { background: #1d4a3a; border-color: #2f7a5e; }
.card canvas { width: 100%; height: 150px; display: block; margin-top: 8px; background: #0b1216; border-radius: 10px; }
.lineage { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; font-size: 12px; }
.lineage span { padding: 2px 7px; border-radius: 99px; background: var(--panel2); }

aside { width: 390px; flex: none; border-left: 1px solid var(--line); background: var(--panel); display: flex; flex-direction: column; min-height: 0; }
.tabs { display: flex; gap: 4px; padding: 10px; border-bottom: 1px solid var(--line); }
.tabs button { flex: 1; background: transparent; border-color: transparent; font-size: 14px; position: relative; }
.tabs button.on { background: var(--panel2); border-color: var(--line); }
.ndot { position: absolute; top: 4px; right: 6px; width: 7px; height: 7px; border-radius: 50%; background: var(--orange); }
.tab { display: none; padding: 4px 14px 20px; overflow: auto; flex: 1; }
.tab.on { display: block; }
h3 { font-size: 14px; margin: 18px 0 8px; font-weight: 600; }
h3 small { font-weight: 400; font-size: 11px; margin-left: 4px; }

.bigstats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 10px; }
.bigstats div { background: var(--panel2); border-radius: 10px; padding: 8px 6px; text-align: center; }
.bigstats b { display: block; font-size: 19px; font-variant-numeric: tabular-nums; }
.bigstats span { font-size: 11px; color: var(--muted); }
.meter { margin-top: 14px; font-size: 13px; }
.diet { height: 9px; border-radius: 9px; background: linear-gradient(90deg, var(--green), var(--orange), var(--red)); position: relative; margin: 6px 0 3px; }
.diet i { position: absolute; top: -4px; width: 4px; height: 17px; background: #fff; border-radius: 3px; transform: translateX(-2px); transition: left .6s; box-shadow: 0 0 6px #000; }
.meter small { display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; }

.splist { display: flex; flex-direction: column; gap: 3px; }
.sp { display: grid; grid-template-columns: 12px 1fr 90px 36px; gap: 8px; align-items: center; padding: 5px 7px; border-radius: 8px; cursor: pointer; font-size: 13px; }
.sp:hover, .sp.on { background: var(--panel2); }
.sp .sw { width: 11px; height: 11px; border-radius: 50%; }
.sp .nm small { color: var(--muted); margin-left: 5px; font-size: 11px; }
.sp .n { text-align: right; font-variant-numeric: tabular-nums; }
.records, .deaths { display: grid; gap: 4px; font-size: 13px; }
.records div, .deaths div { display: flex; justify-content: space-between; gap: 10px; padding: 6px 9px; background: var(--panel2); border-radius: 8px; }
.records div span:last-child, .deaths div span:last-child { color: var(--muted); text-align: right; }

.range { display: flex; gap: 4px; margin-top: 10px; }
.range button { flex: 1; font-size: 12px; }
.range button.on { background: #1d3a44; border-color: #2c5a69; }
.chartWrap { position: relative; height: 200px; }
.chartWrap.small { height: 120px; }
.chartWrap canvas { width: 100%; height: 100%; display: block; }
.ctip { position: absolute; pointer-events: none; background: #0b1216f2; border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; font-size: 12px; min-width: 140px; z-index: 2; }
.ctip div { display: flex; gap: 6px; align-items: center; }
.ctip i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.legend { display: flex; gap: 12px; font-size: 11px; color: var(--muted); margin-top: 4px; }
.legend i { display: inline-block; width: 10px; height: 3px; margin-right: 4px; vertical-align: middle; }
input[type=range] { width: 100%; accent-color: var(--violet); }

.treeWrap { position: relative; margin-top: 8px; }
#tree { width: 100%; display: block; }

.news { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.ev { display: grid; grid-template-columns: 26px 1fr; gap: 8px; padding: 8px 9px; background: var(--panel2); border-radius: 10px; font-size: 13px; line-height: 1.35; }
.ev .ic { font-size: 16px; text-align: center; }
.ev small { display: block; color: var(--muted); font-size: 11px; margin-top: 2px; }
.ev.new { outline: 1px solid #f0a35e66; }

.modal { position: fixed; inset: 0; background: #000a; display: grid; place-items: center; z-index: 10; padding: 16px; }
.modal .box { max-width: 480px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 20px 22px; line-height: 1.5; font-size: 15px; }
.modal h2 { margin-top: 0; }
.modal .g { color: var(--green); } .modal .o { color: var(--orange); }
.modal ul { padding-left: 18px; }

@media (max-width: 860px) {
  body { overflow: auto; }
  main { flex-direction: column; }
  #stage { flex: none; height: 62vh; }
  aside { width: auto; border-left: 0; border-top: 1px solid var(--line); }
  .tab { overflow: visible; }
  header { gap: 8px 12px; padding: 8px 12px; }
  .hstats { margin-left: 0; gap: 10px; font-size: 13px; }
  #hRun { display: none; }
  .card { width: auto; right: 12px; max-height: 70%; }
}
