/* app.css — phase 2 is "no styling beyond legibility" (SPEC §13), so this is
   deliberately plain: a readable dark theme, safe-area insets so the meter bar
   clears the notch (§12), and nothing that would have to be thrown away when
   DESIGN.md arrives in phase 4. No animation, no art. */

:root {
  --bg: #0F1210;
  --panel: #171B18;
  --panel-2: #1D2320;
  --line: #2A312C;
  --text: #E8E6E0;
  --dim: #98A09A;
  --accent: #C9A227;   /* ochre — dry, not branded */
  --good: #7FB069;
  --bad: #C4553B;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

body {
  max-width: 680px;
  margin-inline: auto;
  padding-bottom: calc(64px + var(--safe-b));
}

/* ---------- top bar: act, turn, meters ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  padding: calc(8px + var(--safe-t)) 12px 8px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.actline { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.actline h1 { font-size: 16px; margin: 0; font-weight: 650; }
.actline .sub { color: var(--dim); font-size: 13px; }
.actline .turn { margin-left: auto; color: var(--dim); font-size: 13px; font-variant-numeric: tabular-nums; }

.meters { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 8px; }
.meter {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 5px 7px;
}
.meter .k { color: var(--dim); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
.meter .v { font-size: 17px; font-weight: 650; font-variant-numeric: tabular-nums; }
.meter .v.unknown { color: var(--dim); }
.meter.low .v { color: var(--bad); }

.apline { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.pips { display: flex; gap: 4px; }
.pip { width: 12px; height: 12px; border-radius: 50%; border: 1px solid var(--line); background: transparent; }
.pip.on { background: var(--accent); border-color: var(--accent); }
.apline .lbl { color: var(--dim); font-size: 12px; }
.apline .grow { margin-left: auto; }

/* ---------- tabs ---------- */

.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 5;
  display: flex;
  max-width: 680px;
  margin-inline: auto;
  background: var(--panel);
  border-top: 1px solid var(--line);
  padding-bottom: var(--safe-b);
}
.tabbar button {
  flex: 1;
  background: none;
  border: 0;
  color: var(--dim);
  font: inherit;
  font-size: 13px;
  padding: 12px 4px;
  cursor: pointer;
}
.tabbar button[aria-selected="true"] { color: var(--text); box-shadow: inset 0 2px 0 var(--accent); }
.tabbar button .badge {
  display: inline-block;
  min-width: 17px;
  margin-left: 4px;
  padding: 0 4px;
  border-radius: 9px;
  background: var(--accent);
  color: #1A1600;
  font-size: 11px;
  font-weight: 700;
}

/* ---------- content ---------- */

.screen { padding: 12px; display: grid; gap: 10px; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
}
.card h2 { margin: 0 0 6px; font-size: 14px; font-weight: 650; }
.card h3 { margin: 0 0 2px; font-size: 14px; font-weight: 600; }
.card p { margin: 4px 0; }
.muted { color: var(--dim); font-size: 13px; }
.rowline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grow { margin-left: auto; }

.btn {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 11px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.btn:hover:not(:disabled) { border-color: var(--dim); }
.btn:disabled { opacity: .38; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #1A1600; font-weight: 650; }
.btn.danger { border-color: var(--bad); color: var(--bad); }
.btn.wide { width: 100%; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------- people ---------- */

.person { display: flex; gap: 10px; align-items: flex-start; }
.person .portrait { flex: none; width: 56px; height: 56px; border-radius: 6px; background: var(--panel-2); overflow: hidden; }
.person .portrait svg { display: block; width: 100%; height: 100%; }
.portrait .sprite-head {
  width: 100%;
  height: 100%;
  background-repeat: no-repeat;
  image-rendering: pixelated;
}
.sprite-figure { background-repeat: no-repeat; image-rendering: pixelated; }
.person .who { flex: 1; min-width: 0; }
.person .role { color: var(--dim); font-size: 12px; }

.bar { height: 6px; border-radius: 3px; background: var(--panel-2); overflow: hidden; margin: 5px 0 3px; }
.bar > span { display: block; height: 100%; background: var(--accent); }

/* ---------- parcels ---------- */

.parcel { display: grid; gap: 4px; }
.parcel .top { display: flex; gap: 8px; align-items: baseline; }
.parcel .status {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--dim);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 5px;
}
.parcel .status.owned, .parcel .status.leased { color: var(--good); border-color: var(--good); }
.parcel .status.frozen { color: var(--bad); border-color: var(--bad); }

/* ---------- log ---------- */

.log { display: grid; gap: 3px; font-size: 13px; }
.log .e { display: flex; gap: 8px; }
.log .t { color: var(--dim); font-variant-numeric: tabular-nums; flex: none; width: 2.6em; text-align: right; }
.log .good { color: var(--good); }
.log .bad { color: var(--bad); }

/* ---------- overlay: event cards and the end card ---------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  background: rgba(8, 10, 9, .82);
  display: grid;
  place-items: center;
  padding: 16px;
  overflow-y: auto;
}
.overlay[hidden] { display: none; }
.sheet {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
  max-width: 460px;
  width: 100%;
  display: grid;
  gap: 10px;
}
.sheet h2 { margin: 0; font-size: 17px; }
.sheet .body { color: var(--text); }
.sheet .choices { display: grid; gap: 6px; }
.sheet .score { display: grid; gap: 2px; font-variant-numeric: tabular-nums; }
.sheet .score .total { font-size: 22px; font-weight: 700; }

/* Parcels collapse: summary is the header row, the rest opens on demand. */
details.parcel > summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  gap: 8px;
  align-items: baseline;
  flex-wrap: wrap;
}
details.parcel > summary::-webkit-details-marker { display: none; }
details.parcel > summary::before {
  content: '▸';
  color: var(--dim);
  font-size: 11px;
}
details.parcel[open] > summary::before { content: '▾'; }
details.parcel[open] > summary { margin-bottom: 6px; }

/* ============================================================
   Title, explainer, sprite animation
   ============================================================ */

/* One row of frames stepped across; the travel distance differs per character
   because each sheet was cropped to its own figure, so it rides in a custom
   property set inline. */
@keyframes spritewalk { to { background-position-x: var(--travel); } }

.screen.full {
  min-height: calc(100vh - var(--safe-t) - var(--safe-b));
  align-content: center;
  padding: 20px 16px calc(28px + var(--safe-b));
  gap: 0;
}

/* ---------- title ---------- */

.title { display: grid; justify-items: center; gap: 14px; text-align: center; }

.title .mark { width: 76px; height: 76px; }
.title .mark circle { animation: pulse 3.2s ease-in-out infinite; transform-origin: center; }
.title .mark circle:nth-of-type(2) { animation-delay: .5s; }
.title .mark circle:nth-of-type(3) { animation-delay: 1s; }
@keyframes pulse { 0%, 100% { opacity: .7; } 50% { opacity: 1; } }

.wordmark {
  margin: 0;
  font-size: clamp(44px, 16vw, 68px);
  font-weight: 800;
  letter-spacing: .22em;
  text-indent: .22em;          /* letter-spacing pads the right; re-centre */
  color: var(--accent);
  line-height: 1;
}

.tagline { margin: 0; color: var(--dim); font-size: 14px; max-width: 30ch; }

.titlebtns { display: grid; gap: 8px; width: 100%; max-width: 300px; margin-top: 4px; }

.linkish {
  background: none; border: 0; color: var(--dim);
  font: inherit; font-size: 13px; cursor: pointer; padding: 6px;
  text-decoration: underline; text-underline-offset: 3px;
}
.linkish:hover { color: var(--text); }
.title .sound { text-decoration: none; letter-spacing: .04em; }

.credit { margin: 0; color: var(--dim); font-size: 12px; opacity: .75; }

/* ---------- explainer ---------- */

.explainer { display: grid; gap: 14px; justify-items: center; text-align: center; max-width: 460px; margin-inline: auto; }
.explainer h2 { margin: 0; font-size: 22px; color: var(--accent); }
.explainer p { margin: 0; max-width: 42ch; }
.explainer .lede { font-size: 16px; }
.explainer .panelbody { display: grid; gap: 12px; justify-items: center; }

.dots { display: flex; gap: 6px; }
.dots span { width: 7px; height: 7px; border-radius: 50%; background: var(--line); }
.dots span.on { background: var(--accent); }

.navrow { display: flex; gap: 8px; width: 100%; max-width: 320px; }
.navrow .btn { flex: 1; }
.grow-btn { flex: 2 !important; }

.hero { min-height: 200px; display: grid; place-items: end center; }

.keyrow { display: grid; gap: 8px; width: 100%; text-align: left; }
.keycell {
  display: grid; gap: 2px;
  border-left: 3px solid var(--accent);
  background: var(--panel);
  padding: 8px 10px; border-radius: 0 6px 6px 0;
}
.keycell b { color: var(--text); }
.keycell span { color: var(--dim); font-size: 13px; }

.castrow { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.castcell { display: grid; gap: 4px; justify-items: center; }
.castcell span { font-size: 11px; color: var(--dim); }
.castcell .portrait { border-radius: 6px; overflow: hidden; background: var(--panel-2); }

.acts { text-align: left; margin: 0; padding-left: 1.4em; color: var(--dim); display: grid; gap: 2px; }
.acts li { font-size: 14px; }

.scorekey { display: grid; gap: 6px; width: 100%; max-width: 320px; }
.scorekey > div {
  display: flex; justify-content: space-between; align-items: baseline;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 6px; padding: 7px 10px;
}
.scorekey span { color: var(--accent); font-variant-numeric: tabular-nums; }
.scorekey .zero { border-style: dashed; }
.scorekey .zero b, .scorekey .zero span { color: var(--dim); }

/* Respect a reduced-motion preference: the idle loops are decoration. */
@media (prefers-reduced-motion: reduce) {
  .sprite-figure, .title .mark circle { animation: none !important; }
}
