/* hud.css — the overlay chrome. A muted parchment-and-ink fantasy HUD with the four bilattice
   glyphs as a first-class motif (t alive, f slain, ⊤ Anomaly, ⊥ unknown). No images; all CSS. */

:root {
  --ink: #e8e2d2;
  --panel: rgba(18, 16, 24, 0.72);
  --edge: rgba(180, 150, 210, 0.35);
  --t: #6fcf6f; --f: #8a8a90; --top: #c45cff; --bot: #5a6b86;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0a0b10; }
body { font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif; color: var(--ink); }
#view { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; cursor: crosshair; }
#hud { position: fixed; inset: 0; pointer-events: none; }
#hud > * { pointer-events: auto; }

/* vitals (bottom-left) + target (top-center) */
#vitals { position: fixed; left: 18px; bottom: 18px; display: flex; gap: 10px; align-items: center; }
#target { position: fixed; top: 18px; left: 50%; transform: translateX(-50%); display: flex; gap: 10px; align-items: center;
  background: var(--panel); border: 1px solid var(--edge); padding: 7px 12px; border-radius: 8px; }
.charge { font-size: 30px; width: 42px; height: 42px; line-height: 42px; text-align: center; border-radius: 8px;
  background: var(--panel); border: 1px solid var(--edge); }
.bars { min-width: 180px; }
.name { font-size: 15px; margin-bottom: 3px; text-shadow: 0 1px 2px #000; }
/* [marks] the conserved-marks readout + settle hint under the vitals bar */
.marks { font-size: 12px; margin-top: 3px; color: #b9c4d6; text-shadow: 0 1px 2px #000; }
.marks::after { content: " · " attr(data-hint); color: #7f8aa0; }
.marks.ready { color: #cfd9e8; }
.marks.ready::after { color: #9ec7d8; }
/* [tide] the world's settledness readout — the arrow of time toward calm equilibrium */
.settledness { font-size: 12px; margin-top: 2px; color: #8fe6c4; text-shadow: 0 1px 2px #000; }
/* [economy] the player's total worth readout (marks + fiber richness) + the inventory hint */
.worth { font-size: 12px; margin-top: 2px; color: #e6d28f; text-shadow: 0 1px 2px #000; }
.worth::after { content: " · " attr(data-hint); color: #8a8266; }
.bar { position: relative; height: 16px; width: 230px; background: rgba(0,0,0,0.45); border: 1px solid var(--edge); border-radius: 6px; overflow: hidden; }
.bar.small { width: 150px; height: 10px; }
.fill { position: absolute; inset: 0; width: 100%; transform-origin: left; background: linear-gradient(90deg, #b14d4d, #d98a4d); transition: width .12s linear; }
.bar span { position: absolute; inset: 0; text-align: center; font-size: 12px; line-height: 16px; text-shadow: 0 1px 1px #000; }

/* minimap (top-right) */
#minimap { position: fixed; top: 16px; right: 16px; border: 1px solid var(--edge); border-radius: 50%;
  background: rgba(8, 10, 18, 0.66); }

/* combat / chat log (left, above vitals) */
#log { position: fixed; left: 18px; bottom: 92px; width: 360px; max-height: 38vh; overflow: hidden;
  display: flex; flex-direction: column; justify-content: flex-end; font-size: 13.5px; }
#log div { padding: 1px 0; text-shadow: 0 1px 2px #000; opacity: 0.92; }
#log .sys { color: #c9a7ef; } #log .you { color: #ffe08a; } #log .slain { color: #ff9b6b; }
#log .anom { color: var(--top); font-weight: bold; }

/* hotbar (bottom-center) */
#hotbar { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); display: flex; gap: 8px; }
.slot { width: 84px; height: 50px; background: var(--panel); border: 1px solid var(--edge); border-radius: 8px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.slot kbd { font-size: 11px; background: rgba(255,255,255,0.1); padding: 1px 5px; border-radius: 4px; }
.slot span { font-size: 12px; opacity: 0.85; }

/* [illocution] the Four Forces speak palette (bottom-center, above the hotbar) */
#forces { position: fixed; bottom: 74px; left: 50%; transform: translateX(-50%); display: flex; gap: 6px; }
.force { width: 44px; height: 44px; background: var(--panel); border: 1px solid var(--edge); border-radius: 8px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  cursor: pointer; font: inherit; color: var(--ink); transition: border-color .12s, transform .08s; }
.force:hover { border-color: rgba(215,184,255,0.7); transform: translateY(-2px); }
.force:active { transform: translateY(0); }
.force kbd { font-size: 9px; opacity: 0.6; background: rgba(255,255,255,0.08); padding: 0 4px; border-radius: 3px; }
.force .fg { font-size: 20px; font-weight: bold; line-height: 1; }

/* [powers] the K₄ power bar (bottom-center, above the speak palette) — Z X R B, each with its cost */
#powers { position: fixed; bottom: 122px; left: 50%; transform: translateX(-50%); display: flex; gap: 6px; }
.power { position: relative; width: 44px; height: 44px; background: var(--panel); border: 1px solid var(--edge); border-radius: 8px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  cursor: pointer; font: inherit; color: var(--ink); transition: border-color .12s, transform .08s, opacity .12s; }
.power:hover { border-color: rgba(215,184,255,0.7); transform: translateY(-2px); }
.power:active { transform: translateY(0); }
.power kbd { font-size: 9px; opacity: 0.6; background: rgba(255,255,255,0.08); padding: 0 4px; border-radius: 3px; }
.power .pg { font-size: 20px; font-weight: bold; line-height: 1; color: #d7b8ff; }
.power .pcost { position: absolute; right: 3px; bottom: 1px; font-size: 9px; color: #9ec7d8; }
.power.unaffordable { opacity: 0.4; filter: saturate(0.4); cursor: default; }
.power.unaffordable:hover { border-color: var(--edge); transform: none; }

/* [illocution] a spoken-force log line + the transient glyph badge that floats up and fades */
#log .said { font-style: italic; }
#log .said b { font-weight: bold; }
.force-badge { position: fixed; left: 50%; top: 46%; transform: translate(-50%, -50%); font-size: 64px; font-weight: bold;
  pointer-events: none; text-shadow: 0 2px 10px rgba(0,0,0,0.6); animation: force-rise 1.1s ease-out forwards; }
@keyframes force-rise {
  0% { opacity: 0; transform: translate(-50%, -40%) scale(0.7); }
  20% { opacity: 1; transform: translate(-50%, -50%) scale(1.05); }
  100% { opacity: 0; transform: translate(-50%, -80%) scale(1.1); }
}

/* chat input (bottom, hidden until Enter) */
#chat-form { position: fixed; bottom: 78px; left: 50%; transform: translateX(-50%); width: 460px; display: none; }
#chat-form.open { display: block; }
#chat-input { width: 100%; padding: 8px 12px; font: inherit; color: var(--ink); background: var(--panel);
  border: 1px solid var(--edge); border-radius: 8px; outline: none; }

/* legend (bottom-right) */
#legend { position: fixed; right: 16px; bottom: 18px; background: var(--panel); border: 1px solid var(--edge);
  border-radius: 8px; padding: 8px 10px; font-size: 12px; display: grid; grid-template-columns: auto auto; gap: 2px 10px; align-items: center; }
#legend b { grid-column: 1 / -1; opacity: 0.7; font-weight: normal; letter-spacing: 1px; text-transform: uppercase; font-size: 10px; }
#legend .g { display: inline-block; width: 18px; text-align: center; font-weight: bold; }
.g.t { color: var(--t); } .g.f { color: var(--f); } .g.top { color: var(--top); } .g.bot { color: var(--bot); }

/* codex toast — a brief line announcing a freshly-witnessed Way (reuses the log column) */
#log .codex { color: #d7b8ff; font-style: italic; }

/* codex panel (centered overlay, toggled with C) — the four Ways as cards */
#codex { position: fixed; inset: 0; display: grid; place-items: center; z-index: 9;
  background: radial-gradient(circle at 50% 30%, rgba(26,19,38,0.92), rgba(7,8,13,0.95) 75%); }
#codex[hidden] { display: none; }
#codex h2 { margin: 0 0 4px; text-align: center; letter-spacing: 4px; font-size: 26px;
  background: linear-gradient(90deg, #d7b8ff, #8ad0ff); -webkit-background-clip: text; background-clip: text; color: transparent; }
#codex .codex-sub { margin: 0 0 18px; text-align: center; opacity: 0.7; font-style: italic; font-size: 13px; }
#codex-cards { display: grid; grid-template-columns: repeat(2, minmax(260px, 340px)); gap: 16px;
  width: min(760px, 94vw); }
.codex-card { background: var(--panel); border: 1px solid var(--edge); border-radius: 12px; padding: 16px 18px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.5); }
.codex-card .head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 8px; }
.codex-card .cx-glyph { font-size: 34px; font-weight: bold; width: 44px; text-align: center; line-height: 1; }
.codex-card .cx-name { font-size: 18px; }
.codex-card .cx-way { font-size: 12px; opacity: 0.7; font-style: italic; }
.codex-card .cx-lore { font-size: 13px; line-height: 1.5; opacity: 0.92; margin: 6px 0 0; }
.codex-card .cx-lesson { font-size: 12.5px; line-height: 1.45; margin: 8px 0 0; padding-top: 8px;
  border-top: 1px solid rgba(180,150,210,0.18); color: #cdbfe6; }
.codex-card.locked { opacity: 0.45; filter: saturate(0.4); }
.codex-card.locked .cx-locked { font-size: 13px; font-style: italic; opacity: 0.8; margin-top: 6px; }

/* [economy] the inventory panel (centered overlay, toggled with I) — held items + their worth */
#inventory { position: fixed; inset: 0; display: grid; place-items: center; z-index: 9;
  background: radial-gradient(circle at 50% 30%, rgba(26,24,16,0.92), rgba(8,8,7,0.95) 75%); }
#inventory[hidden] { display: none; }
#inventory h2 { margin: 0 0 4px; text-align: center; letter-spacing: 4px; font-size: 24px;
  background: linear-gradient(90deg, #e6d28f, #c9a7ef); -webkit-background-clip: text; background-clip: text; color: transparent; }
#inventory .inv-sub { margin: 0 0 16px; text-align: center; opacity: 0.7; font-style: italic; font-size: 13px; }
#inv-items { list-style: none; margin: 0; padding: 0; width: min(520px, 92vw);
  background: var(--panel); border: 1px solid var(--edge); border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.5); overflow: hidden; }
.inv-item { display: flex; align-items: baseline; gap: 12px; padding: 9px 16px;
  border-bottom: 1px solid rgba(180,150,210,0.12); }
.inv-item:last-child { border-bottom: 0; }
.inv-name { flex: 1; font-size: 15px; }
.inv-kind { font-size: 11px; opacity: 0.6; font-style: italic; }
.inv-val { font-size: 13px; font-weight: bold; min-width: 48px; text-align: right; }
.inv-empty { padding: 16px; text-align: center; font-style: italic; opacity: 0.7; font-size: 13px; }
.inv-worth { width: min(520px, 92vw); margin-top: 10px; text-align: right; font-size: 13px; color: #e6d28f; }

/* [economy] the minimal trade prompt (centered card, propose/accept/close) */
#trade-prompt { position: fixed; top: 22%; left: 50%; transform: translateX(-50%); z-index: 9;
  background: var(--panel); border: 1px solid var(--edge); border-radius: 12px; padding: 16px 20px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.5); text-align: center; min-width: 280px; }
#trade-prompt[hidden] { display: none; }
#trade-prompt p { margin: 0 0 12px; font-size: 14px; }
#trade-prompt b { color: #e6d28f; }
.trade-btns { display: flex; gap: 8px; justify-content: center; }
.trade-btns button { font: inherit; font-size: 12.5px; color: var(--ink); cursor: pointer;
  background: rgba(255,255,255,0.07); border: 1px solid var(--edge); border-radius: 8px; padding: 7px 12px; }
.trade-btns button:hover { border-color: rgba(215,184,255,0.7); }

/* [dispute] the Parley panel — a side card (play continues behind it). Two stances (glyphs in
   bilattice colours), the last outcome, the FLOW meter (four-glyph histogram), the DEEP-PLAY
   ⊤-count, and the four illocutionary forces as the moves (the same palette as the speak bar). */
#parley { position: fixed; top: 78px; left: 50%; transform: translateX(-50%); z-index: 8; width: min(380px, 94vw);
  background: var(--panel); border: 1px solid var(--edge); border-radius: 12px; padding: 12px 16px 14px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.5); }
#parley[hidden] { display: none; }
#parley h2 { margin: 0 0 8px; font-size: 17px; letter-spacing: 2px; text-align: center;
  background: linear-gradient(90deg, #d7b8ff, #8ad0ff); -webkit-background-clip: text; background-clip: text; color: transparent; }
#parley h2 .pf-sub { font-size: 11px; letter-spacing: 0; -webkit-text-fill-color: #9aa3bb; opacity: 0.8; font-style: italic; }
.pf-stances { display: flex; align-items: center; justify-content: center; gap: 14px; margin-bottom: 8px; }
.pf-vs { font-size: 18px; opacity: 0.6; }
.pf-stance { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 10px; border-radius: 8px;
  border: 1px solid transparent; min-width: 84px; }
.pf-stance.pf-turn { border-color: rgba(215,184,255,0.6); background: rgba(215,184,255,0.08); }
.pf-glyph { font-size: 30px; font-weight: bold; line-height: 1; }
.pf-who { font-size: 11px; opacity: 0.78; max-width: 100px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pf-last { text-align: center; font-size: 12.5px; opacity: 0.9; min-height: 16px; }
.pf-last b { font-weight: bold; }
.pf-flowrow { display: flex; align-items: flex-end; gap: 8px; margin: 8px 0; justify-content: center; }
.pf-fllabel { font-size: 11px; opacity: 0.7; }
.pf-fllabel b { color: #8fe6c4; font-weight: bold; }
.pf-meter { display: flex; align-items: flex-end; gap: 4px; height: 26px; }
.pf-fl { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 26px; width: 16px; }
.pf-fl i { display: block; width: 10px; min-height: 2px; border-radius: 2px 2px 0 0; }
.pf-fl em { font-size: 9px; font-style: normal; opacity: 0.7; line-height: 1.1; }
.pf-deep { font-size: 12px; color: var(--top); font-weight: bold; }
.pf-turnline { text-align: center; font-size: 12px; opacity: 0.75; font-style: italic; margin-top: 2px; }
.pf-end { text-align: center; font-size: 13px; font-weight: bold; margin-top: 4px; }
.pf-end kbd { font-weight: normal; }
.pf-end.won { color: #8fe6c4; } .pf-end.lost { color: #ff9b6b; } .pf-end.stalemate { color: var(--top); }
#parley-forces { display: flex; gap: 6px; justify-content: center; margin-top: 10px; }
#parley-forces.await { opacity: 0.45; pointer-events: none; }

/* [claims] the Claim Altar panel (top-left side card) — author the world's truth by staking
   evidence through the four illocutionary forces, settled by the real kernel. The settled glyph
   (bilattice colour), the POSITIVE (assert→t) and NEGATIVE (deny→f) evidence bars, and the four
   forces as stakes (the same illocution palette as the speak bar; the focused force is ringed). */
#claim { position: fixed; top: 78px; left: 18px; z-index: 8; width: min(264px, 80vw);
  background: var(--panel); border: 1px solid var(--edge); border-radius: 12px; padding: 12px 14px 14px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.5); }
#claim[hidden] { display: none; }
#claim h2 { margin: 0 0 8px; font-size: 16px; letter-spacing: 2px; text-align: center;
  background: linear-gradient(90deg, #e6d28f, #c9a7ef); -webkit-background-clip: text; background-clip: text; color: transparent; }
#claim h2 .cl-sub { font-size: 11px; letter-spacing: 0; -webkit-text-fill-color: #9aa3bb; opacity: 0.8; font-style: italic; }
.cl-head { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 8px; }
.cl-glyph { font-size: 32px; font-weight: bold; line-height: 1; }
.cl-face { font-size: 12.5px; opacity: 0.85; }
.cl-bars { display: flex; flex-direction: column; gap: 5px; margin: 6px 0 2px; }
.cl-barrow { display: flex; align-items: center; gap: 7px; font-size: 11px; }
.cl-lbl { min-width: 54px; }
.cl-bar { flex: 1; height: 10px; background: rgba(0,0,0,0.45); border: 1px solid var(--edge);
  border-radius: 5px; overflow: hidden; }
.cl-bar i { display: block; height: 100%; min-width: 0; transition: width .12s linear; }
.cl-barrow em { font-size: 11px; font-style: normal; opacity: 0.8; min-width: 18px; text-align: right; }
#claim-forces { display: flex; gap: 6px; justify-content: center; margin-top: 10px; }
.cf-force.cf-focus { border-color: rgba(230,210,143,0.85); background: rgba(230,210,143,0.10); }

/* start gate */
#gate { position: fixed; inset: 0; display: grid; place-items: center; background: radial-gradient(circle at 50% 30%, #1a1326, #07080d 70%); z-index: 10; }
#gate.hidden { display: none; }
.panel { width: min(560px, 92vw); text-align: center; background: rgba(20, 16, 30, 0.8); border: 1px solid var(--edge);
  border-radius: 14px; padding: 30px 34px; box-shadow: 0 20px 80px rgba(0,0,0,0.6); }
.panel h1 { margin: 0; letter-spacing: 10px; font-size: 44px; background: linear-gradient(90deg, #d7b8ff, #8ad0ff); -webkit-background-clip: text; background-clip: text; color: transparent; }
.panel .sub { margin: 4px 0 18px; opacity: 0.75; font-style: italic; }
.panel .lore { font-size: 14px; line-height: 1.6; opacity: 0.9; text-align: left; }
.panel .lore b { color: #d7b8ff; }
#gate-form { display: flex; gap: 8px; margin: 18px 0 8px; }
#name-input { flex: 1; padding: 10px 12px; font: inherit; color: var(--ink); background: rgba(0,0,0,0.4); border: 1px solid var(--edge); border-radius: 8px; }
#gate-form button { padding: 10px 18px; font: inherit; color: #1a1024; background: linear-gradient(90deg, #d7b8ff, #8ad0ff); border: 0; border-radius: 8px; cursor: pointer; }
.controls { font-size: 12.5px; opacity: 0.7; margin: 12px 0 0; }
#gate-status { min-height: 18px; font-size: 13px; color: #ff9b6b; }
