/* Same palette as the desktop app (src/app/ui.h) */
:root {
  --bg: #0c1018;
  --panel: #121722;
  --panel-hi: #1c2332;
  --border: #303c52;
  --text: #dae2f0;
  --dim: #808ea6;
  --accent: #ffc448;
  --good: #6edc8c;
  --bad: #f06060;
  --t0: #48b054;
  --t1: #e8c858;
  --t2: #e84048;
  --panel-w: 420px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 13px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; overflow: hidden; }
button, select, .button {
  font: inherit; color: var(--text); background: var(--panel-hi); border: 1px solid var(--border);
  border-radius: 4px; padding: 5px 10px; cursor: pointer; text-decoration: none; display: inline-block;
}
button:hover, select:hover, .button:hover { border-color: #5a6e96; }
button.active { color: var(--accent); border-color: var(--accent); background: #463c1e; }
button:disabled { opacity: .45; cursor: default; }
.dim { color: var(--dim); }
kbd { font: 11px ui-monospace, monospace; border: 1px solid var(--border); border-radius: 3px; padding: 0 3px; }

#topbar {
  height: 38px; display: flex; align-items: center; gap: 6px; padding: 0 10px;
  background: var(--panel); border-bottom: 1px solid var(--border); white-space: nowrap; overflow: hidden;
}
.brand { color: var(--dim); margin-right: 6px; }
.brand b { color: var(--accent); font-weight: 600; }
.chip { padding: 2px 8px; border-radius: 10px; background: var(--panel-hi); font-variant-numeric: tabular-nums; }
.chip.tier i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; vertical-align: -1px; }
.t0 i { background: var(--t0); } .t1 i { background: var(--t1); } .t2 i { background: var(--t2); }
.chip.climate { border: 1px solid transparent; }
.grow { flex: 1; }
button.icon { padding: 2px 9px; }

main { position: absolute; top: 38px; left: 0; right: 0; bottom: 0; display: flex; }
#stage { position: relative; flex: 1; min-width: 0; }
#view { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; }
#view.dragging { cursor: grabbing; }
#legend {
  position: absolute; left: 10px; bottom: 34px; background: rgba(18, 23, 34, .88); border: 1px solid var(--border);
  border-radius: 5px; padding: 6px 9px; min-width: 190px; pointer-events: none;
}
#legend .title { font-weight: 600; margin-bottom: 4px; }
#legend .bar { height: 9px; border-radius: 2px; }
#legend .ends { display: flex; justify-content: space-between; color: var(--dim); font-size: 11px; }
#legend .keys { display: flex; gap: 10px; margin-top: 5px; color: var(--dim); font-size: 11px; flex-wrap: wrap; }
#legend .keys svg { vertical-align: -1px; margin-right: 3px; }
#legend .keys .pip { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 4px; vertical-align: 0; }
#legend .keys .ring { display: inline-block; width: 8px; height: 8px; border-radius: 50%; border: 1.5px solid rgba(255,255,255,.7); margin-right: 4px; vertical-align: -1px; }
#legend .keys i { display: inline-block; width: 9px; height: 9px; margin-right: 4px; vertical-align: -1px; border-radius: 2px; }
#hint { position: absolute; left: 10px; bottom: 8px; color: var(--dim); font-size: 11px; pointer-events: none; }
#banner {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%); background: #3a2020; color: #ffd0c8;
  border: 1px solid var(--bad); border-radius: 5px; padding: 6px 14px;
}
#banner.info { background: #1c2c20; color: #d0ffd8; border-color: var(--good); }

#panel {
  width: var(--panel-w); flex: none; background: var(--panel); border-left: 1px solid var(--border);
  overflow-y: auto; padding: 4px 12px 16px;
}
#panel.hidden { display: none; }
section { border-bottom: 1px solid var(--border); padding: 8px 0 10px; }
section:last-child { border-bottom: 0; }
h2 { font-size: 12px; font-weight: 600; color: var(--accent); margin: 8px 0 6px; text-transform: uppercase; letter-spacing: .04em;
  display: flex; justify-content: space-between; align-items: baseline; }
h2 small { color: var(--dim); text-transform: none; letter-spacing: 0; font-weight: 400; }
.link { cursor: pointer; color: var(--dim); }
.link:hover { color: var(--text); }
.seg { display: flex; flex-wrap: wrap; gap: 4px; }
.seg button { padding: 3px 8px; font-size: 12px; }
.check { display: block; margin-top: 6px; color: var(--dim); }
.row { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.chart { width: 100%; height: 130px; display: block; background: #0e131d; border-radius: 4px; }
.chart.small { height: 80px; }
.legend-row { display: flex; gap: 12px; margin-top: 6px; color: var(--dim); font-size: 11px; flex-wrap: wrap; }
.legend-row i { display: inline-block; width: 10px; height: 3px; margin-right: 4px; vertical-align: 3px; }
.events { margin: 0; padding: 0; list-style: none; max-height: 220px; overflow-y: auto; font-size: 12px; }
.events.long { max-height: 420px; }
.events li { padding: 2px 0; border-bottom: 1px dashed #222a3a; color: var(--dim); }
.events li[data-ev] { cursor: pointer; }
.events li[data-ev]:hover { background: var(--panel-hi); }
.events li b { color: var(--text); font-weight: 500; }
.events li.ev-climate { color: #d8b878; } .events li.ev-extinct { color: #f09090; } .events li.ev-dominant { color: #a8c8f0; }
.events li.ev-crash { color: #c89090; } .events li.ev-boom { color: #98c8a0; } .events li.ev-floor { color: #6a7690; }
dl { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; margin: 0; font-size: 12px; }
dt { color: var(--dim); }
dd { margin: 0; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.cells { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.cells span { font-size: 11px; padding: 1px 6px; border-radius: 8px; background: var(--panel-hi); }
.cells i { display: inline-block; width: 8px; height: 8px; margin-right: 4px; border-radius: 2px; }

/* Tabs (like the app's panel) */
.tabs { position: sticky; top: 0; z-index: 5; display: flex; gap: 3px; background: var(--panel); padding: 6px 0 6px; border-bottom: 1px solid var(--border); margin: 0 -2px 6px; }
.tabs button { flex: 1; padding: 4px 2px; font-size: 12px; min-width: 0; }
.tab > h2:first-child { margin-top: 4px; }
.chart { height: 118px; margin-bottom: 6px; cursor: crosshair; touch-action: pan-y; }
.chart.mini { height: 110px; }
.chart.overview { height: 150px; }
.chart.timeline { height: 280px; }
.chart.spark { height: 90px; margin-top: 6px; }
.range-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 2px 0 8px; }
.range-bar .seg button { padding: 2px 7px; font-size: 11px; }
.range-label { color: var(--dim); font-size: 11px; }
.climate-line { font-size: 12px; margin: 2px 0 8px; }
.small { font-size: 11px; }
.grow { flex: 1; }
.table { width: 100%; border-collapse: collapse; font-size: 12px; font-variant-numeric: tabular-nums; }
.table th { text-align: left; color: var(--dim); font-weight: 400; padding: 2px 4px; }
.table td { padding: 2px 4px; border-top: 1px solid #1c2332; }
.table tr[data-sp], .table tr[data-bk] { cursor: pointer; }
.table tr[data-sp]:hover, .table tr[data-bk]:hover, .table tr.sel { background: var(--panel-hi); }
.table td i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; vertical-align: -1px; }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 4px; }
.dot.t0, .tierpill.t0 { background: var(--t0); } .dot.t1, .tierpill.t1 { background: var(--t1); } .dot.t2, .tierpill.t2 { background: var(--t2); }
.tierpill { color: #0a0c12; border-radius: 8px; padding: 0 7px; font-size: 11px; font-weight: 600; margin-left: 8px; }
.star { color: var(--accent); }
.link.sp { text-decoration: underline dotted; }
#lineage { background: #0e131d; border: 1px solid var(--border); border-radius: 5px; padding: 8px 10px; margin: 8px 0; font-size: 12px; }
.lin-head, .ins-head { display: flex; align-items: center; gap: 6px; font-size: 14px; }
.lin-head i, .ins-head i { width: 12px; height: 12px; border-radius: 2px; display: inline-block; }
.lin-row { margin-top: 5px; line-height: 1.55; }
.summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 4px 0 6px; }
.summary div { background: #0e131d; border: 1px solid #1f2838; border-radius: 5px; padding: 5px 7px; }
.summary b { display: block; font-size: 15px; font-variant-numeric: tabular-nums; }
.summary span { color: var(--dim); font-size: 10.5px; line-height: 1.2; display: block; }
#ev-search { width: 100%; margin: 6px 0; font: inherit; color: var(--text); background: #0e131d; border: 1px solid var(--border); border-radius: 4px; padding: 5px 8px; }
#ev-kinds button { padding: 2px 7px; font-size: 11px; }
/* inspector */
#ins-body .name { font-size: 16px; font-weight: 600; }
.kv-bar { display: grid; grid-template-columns: 78px 1fr auto; gap: 8px; align-items: center; font-size: 12px; margin: 3px 0; }
.kv-bar .bar, .kv-bar .sbar { position: relative; height: 8px; background: #232b3c; border-radius: 3px; overflow: hidden; }
.kv-bar .bar > div { height: 100%; }
.kv-bar .bar > b { position: absolute; top: 0; bottom: 0; width: 2px; background: #fff; }
.kv-bar .sbar > div { position: absolute; top: 0; bottom: 0; background: var(--info, #60b4ff); }
.kv-bar .sbar::after { content: ''; position: absolute; left: 50%; top: 0; bottom: 0; width: 1px; background: #4a5670; }
.kv-bar > span:last-child { min-width: 70px; text-align: right; }
.budget { margin: 8px 0 4px; font-size: 12px; }
.budget .good { color: var(--good); } .budget .bad { color: var(--bad); }
.budget .stack { display: flex; height: 9px; margin: 3px 0; }
.budget .stack i { display: block; height: 100%; margin-right: 1px; }
.now { margin: 6px 0; }
.ins-body2 { display: grid; grid-template-columns: 130px 1fr; gap: 10px; margin: 6px 0; }
.ins-body2 canvas { width: 130px; height: 130px; border-radius: 4px; }
.hidden-row { display: grid; grid-template-columns: repeat(16, 1fr); gap: 2px; margin-bottom: 6px; }
.hidden-row i { height: 12px; border-radius: 2px; display: block; }
#zoom { position: fixed; inset: 0; z-index: 40; background: rgba(4, 6, 10, .72); display: flex; align-items: center; justify-content: center; }
#zoom[hidden] { display: none; }
.zoom-box { width: min(1100px, 94vw); background: var(--panel); border: 1px solid var(--border); border-radius: 6px; padding: 10px; }
.zoom-box canvas { width: 100%; height: min(520px, 70vh); display: block; cursor: crosshair; }
#tip { position: fixed; z-index: 60; pointer-events: none; background: rgba(12, 16, 24, .95); border: 1px solid var(--border); border-radius: 4px;
  padding: 4px 8px; font-size: 11.5px; line-height: 1.45; max-width: 280px; }
#tip[hidden] { display: none; }

/* Phone: the panel becomes a sheet over the map */
@media (max-width: 760px) {
  :root { --panel-w: 100%; }
  #panel { position: absolute; left: 0; right: 0; bottom: 0; height: 55%; border-left: 0; border-top: 1px solid var(--border); padding: 4px 16px 16px; }
  #topbar { gap: 4px; padding: 0 8px; }
  .brand, #tb-sun, #tb-species, #tb-speed { display: none; }
  .summary { grid-template-columns: repeat(2, 1fr); }
  #hint { display: none; }
  #legend { bottom: 10px; }
}
#perf { position: fixed; left: 8px; bottom: 36px; z-index: 50; margin: 0; padding: 6px 8px; font: 11px/1.35 ui-monospace, monospace;
        background: rgba(8, 10, 16, 0.85); color: #cfd8e8; border: 1px solid #2a3346; border-radius: 4px; pointer-events: none; }
