/* The page is a map of the game's screen.

   Project Zomboid puts equipped items down the left edge, moodles down the
   right edge, and the body in a panel between them. This grid is that, at the
   same handedness, so a viewer never has to translate between the stream and
   this page. Everything the game keeps in separate panels -- needs, skills,
   clothing, lifetime stats -- sits below the map as reference. */
:root {
  color-scheme: dark;
  --text: #efeff1; --muted: #adadb8; --dim: #7c7c85;
  --ok: #6fcf6f; --warn: #e0b750; --crit: #e06c6c;
  --cold: #6aa6e0;
  --card: #17171a; --line: rgba(255,255,255,.09); --edge: #26262c;
}
* { box-sizing: border-box; }
body {
  margin: 0; padding: 22px 20px 40px;
  background: #0e0e10; color: var(--text);
  font-family: "Inter", system-ui, sans-serif; font-size: 14px; line-height: 1.5;
}
header, main, footer, .reference { max-width: 1240px; margin: 0 auto; }

.screen {
  display: grid;
  grid-template-columns: 205px minmax(0, 1fr) 210px;
  gap: 22px;
  align-items: start;
}

/* NOT .bar -- content.js uses that class for progress bars, and its rule
   (height .5em, background) was winning and flattening the header. */
.topbar { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
h1 { font-size: 1.1rem; margin: 0; font-weight: 650; }
h2 {
  font-size: .72rem; font-weight: 600; color: var(--dim);
  text-transform: uppercase; letter-spacing: .07em; margin: 0 0 .7em;
}
h2 .hint { text-transform: none; letter-spacing: 0; color: #5f5f68; font-weight: 400; }

#state { display: flex; align-items: center; gap: 7px; font-size: .84rem; color: var(--muted); }
#state .dot { width: 8px; height: 8px; border-radius: 50%; background: #555; }
#state.live .dot { background: var(--ok); box-shadow: 0 0 7px var(--ok); }
#state.paused .dot { background: var(--warn); }
#state.offline { color: var(--dim); }
.age { color: #5f5f68; font-size: .8rem; }

/* The answer, before any evidence. */
.verdict {
  margin: 16px 0 22px; padding: 14px 16px;
  border-radius: 8px; border-left: 4px solid var(--muted);
  background: var(--card); font-size: 1.05rem; font-weight: 600;
}
.verdict.ok { border-left-color: var(--ok); color: var(--ok); }
.verdict.warn { border-left-color: var(--warn); color: var(--warn); }
.verdict.crit { border-left-color: var(--crit); color: var(--crit); }

.empty {
  max-width: 720px; margin: 40px auto; padding: 28px;
  background: var(--card); border: 1px solid var(--edge); border-radius: 8px;
  text-align: center; color: var(--muted);
}
.empty strong { display: block; color: var(--text); font-size: 1.05rem; margin-bottom: .4em; }
.empty span { display: block; max-width: 46ch; margin: 0 auto; font-size: .88rem; }

/* --- left rail: the game's equipped-item sidebar ------------------------- */
.rail-left { position: sticky; top: 22px; }
.slot {
  background: var(--card); border: 1px solid var(--edge); border-radius: 8px;
  padding: 10px 12px 11px; margin-bottom: 8px;
}
.slot-tag {
  display: block; font-size: .66rem; text-transform: uppercase;
  letter-spacing: .07em; color: var(--dim); margin-bottom: 5px;
}
.hp-line { display: flex; align-items: baseline; }
.hp-pct { font-size: 1.5rem; font-weight: 650; font-variant-numeric: tabular-nums; line-height: 1.1; }
.hp-pct.ok { color: var(--ok); } .hp-pct.warn { color: var(--warn); } .hp-pct.crit { color: var(--crit); }
.item-name { font-weight: 600; font-size: .9rem; }
.slot-note { color: var(--muted); font-size: .78rem; margin: 3px 0 0; }
.slot-note.bad { color: var(--crit); }
.slot-bad { color: var(--crit); font-size: .78rem; font-weight: 600; margin-top: 3px; }
.slot-empty { color: var(--dim); font-size: .84rem; margin: 0; font-style: italic; }

/* --- centre: the body panel ---------------------------------------------- */
.body-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.modes { display: flex; gap: 4px; margin-bottom: .7em; }
.modes button {
  font: inherit; font-size: .74rem; padding: 3px 9px; cursor: pointer;
  background: transparent; color: var(--dim);
  border: 1px solid var(--edge); border-radius: 999px;
}
.modes button:hover { color: var(--muted); }
.modes button.on { background: #202026; color: var(--text); border-color: #3a3a44; }

.body-wrap {
  display: grid; grid-template-columns: 195px minmax(0, 1fr); gap: 16px;
  background: var(--card); border: 1px solid var(--edge); border-radius: 8px;
  padding: 14px; align-items: start;
}
.figure-host { display: flex; justify-content: center; }
.figure { width: 100%; max-width: 185px; height: auto; }
.part {
  stroke: transparent; stroke-width: 2.5;
  transition: fill .25s linear;
  cursor: pointer;
}
.part:hover { stroke: var(--muted); }
/* Injury outlines stay on in every view mode -- checking limb temperature
   should not hide the fact that the same limb is broken. */
.part.s-crit { stroke: var(--crit); }
.part.s-warn { stroke: var(--warn); }
.part.s-ok   { stroke: var(--ok); }
.part.picked { stroke: #fff; stroke-width: 3; }

.mode-note { color: var(--dim); font-size: .78rem; margin: 7px 2px 22px; }

.part-list { min-width: 0; }
.part-row {
  display: block; width: 100%; text-align: left; font: inherit; cursor: pointer;
  background: #1c1c21; border: 1px solid transparent; border-left: 3px solid #4a4a52;
  border-radius: 6px; padding: 7px 10px; margin-bottom: 5px; color: inherit;
}
.part-row:hover { border-color: #3a3a44; border-left-color: currentColor; }
.part-row.crit { border-left-color: var(--crit); }
.part-row.warn { border-left-color: var(--warn); }
.part-row.ok   { border-left-color: var(--ok); }
.part-row-top { display: flex; justify-content: space-between; gap: 10px; }
.part-name { font-weight: 600; font-size: .86rem; }
.part-hp { color: var(--muted); font-size: .84rem; font-variant-numeric: tabular-nums; }
.part-flags { color: var(--muted); font-size: .78rem; }

.part-card { background: #1c1c21; border: 1px solid var(--edge); border-radius: 6px; padding: 10px 12px; }
.part-card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.part-close {
  font: inherit; font-size: 1.1rem; line-height: 1; cursor: pointer;
  background: none; border: none; color: var(--dim); padding: 0 2px;
}
.part-close:hover { color: var(--text); }
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.chip {
  font-size: .72rem; padding: 2px 7px; border-radius: 999px;
  background: rgba(224,108,108,.14); color: var(--crit);
}

/* --- ranked concerns ------------------------------------------------------ */
.concerns ol { margin: 0; padding: 0; list-style: none; }
.concern {
  display: flex; align-items: flex-start; gap: 11px;
  padding: 10px 13px; margin-bottom: 6px;
  background: var(--card); border-radius: 8px;
  border-left: 3px solid var(--muted);
}
.concern.clickable { cursor: pointer; }
.concern.clickable:hover { background: #1c1c21; }
.concern.crit { border-left-color: var(--crit); }
.concern.warn { border-left-color: var(--warn); }
.concern.mild { border-left-color: #4a4a52; }
.concern .ci { flex: none; display: flex; align-items: center; justify-content: center; width: 20px; height: 20px; margin-top: 1px; }
.concern.crit .ci { color: var(--crit); }
.concern.warn .ci { color: var(--warn); }
.concern.mild .ci { color: var(--dim); }
.ci.dot::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.ct { flex: 1; min-width: 0; }
.c-title { font-weight: 600; font-size: .9rem; }
.c-detail { color: var(--muted); font-size: .82rem; }
.c-meta { flex: none; color: var(--dim); font-size: .82rem; font-variant-numeric: tabular-nums; }
.none { color: var(--dim); padding: 13px; background: var(--card); border-radius: 8px; }

/* --- right rail: the moodle column --------------------------------------- */
.rail-right { position: sticky; top: 22px; }
.stack { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 0; list-style: none; }
.stack-empty { color: var(--dim); font-size: .84rem; margin: 0; }

/* Circular, like the game's, because that is what the viewer is matching
   against -- and stacked in payload order, which IS slot order. */
.chip-icon {
  display: flex; align-items: center; gap: 9px;
  padding: 6px 10px 6px 6px;
  background: var(--card); border: 1px solid var(--edge); border-radius: 999px;
  color: var(--muted); cursor: help;
}
.chip-icon.bad { color: var(--crit); border-color: rgba(224,108,108,.4); }
.chip-icon.good { color: var(--ok); border-color: rgba(111,207,111,.4); }
.chip-icon .ring {
  flex: none; display: flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 50%;
  background: #202026; border: 2px solid currentColor;
}
.moodle-icon { display: block; }
.chip-text { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.chip-label {
  font-size: .74rem; color: var(--text); line-height: 1.15;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chip-raw { font-size: .7rem; color: currentColor; font-variant-numeric: tabular-nums; line-height: 1; }
.pips { display: flex; gap: 2px; }
.pip { width: 4px; height: 4px; border-radius: 50%; background: #3a3a42; }
.pip.on { background: currentColor; }

/* --- reference, below the map -------------------------------------------- */
.reference { margin-top: 26px; }
.ref-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; align-items: start; }
.reference details { background: var(--card); border-radius: 8px; margin: 0; border: 1px solid #212127; }
.reference summary {
  padding: 11px 14px; cursor: pointer; font-size: .88rem; font-weight: 600;
  display: flex; justify-content: space-between; gap: 10px;
}
.reference summary::-webkit-details-marker { display: none; }
.reference summary::after { content: "+"; color: var(--dim); font-weight: 400; }
.reference details[open] summary::after { content: "\2212"; }
.sum { color: var(--dim); font-weight: 400; margin-left: auto; margin-right: 8px; font-size: .82rem; }
.reference details > div { padding: 0 14px 14px; }

.row-label { font-size: .7rem; color: var(--dim); text-transform: uppercase; letter-spacing: .05em; margin: 0 0 6px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 18px; }
.need { min-width: 0; }
.need-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.garment { padding: 6px 0; border-bottom: 1px solid var(--line); }
.garment:last-child { border-bottom: none; }
.garment-meta { color: var(--muted); font-size: .78rem; }
.garment-meta.bad { color: var(--warn); }
.kv { display: flex; justify-content: space-between; gap: 10px; padding: 4px 0; border-bottom: 1px solid var(--line); }
.k { color: var(--muted); font-size: .84rem; }
.v { color: var(--text); font-size: .84rem; font-variant-numeric: tabular-nums; }
.muted { color: var(--dim); font-size: .84rem; margin: 6px 0 0; }

.bar {
  height: .5em; border-radius: 999px; background: rgba(255,255,255,.13);
  overflow: hidden; margin: .3em 0 .25em;
}
.bar.thin { height: .28em; }
.bar .fill { height: 100%; border-radius: 999px; background: var(--muted); }
.bar .fill.ok { background: var(--ok); }
.bar .fill.warn { background: var(--warn); }
.bar .fill.crit { background: var(--crit); }

footer {
  margin-top: 28px; padding-top: 14px; border-top: 1px solid var(--line);
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  color: #5f5f68; font-size: .8rem;
}

/* Narrow: the map collapses, but the reading order still matches the game --
   moodles first because that is what a phone viewer is glancing at. */
@media (max-width: 1000px) {
  .screen { grid-template-columns: 1fr; }
  .rail-left, .rail-right { position: static; }
  .rail-right { order: -1; }
  .stack { flex-direction: row; flex-wrap: wrap; }
  .chip-icon { flex: 0 1 auto; }
  .rail-left { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 8px; }
  .rail-left h2 { grid-column: 1 / -1; margin-bottom: 0; }
  .slot { margin-bottom: 0; }
}
@media (max-width: 640px) {
  .body-wrap { grid-template-columns: 1fr; }
  .ref-grid { grid-template-columns: 1fr; }
  .grid2 { grid-template-columns: 1fr; }
}
