/* Placeholder-era styling. The M4 art pass replaces this wholesale; keep it
   quiet, dark, and honest about being a dev tool. */

:root {
  --bg: #12101a;
  --panel: #1c1826;
  --ink: #d8d2e0;
  --dim: #7a7288;
  --accent: #b08d3e;
  --tile: 40px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }   /* beat the flex/overlay display rules below */

body {
  background: var(--bg);
  color: var(--ink);
  font-family: ui-monospace, "Cascadia Mono", Menlo, monospace;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 16px 12px 32px;
}

header { text-align: center; }
h1 { font-size: 1.1rem; letter-spacing: 0.35em; color: var(--accent); }
.sub { color: var(--dim); font-size: 0.7rem; letter-spacing: 0.15em; }

/* the game shell (web/play/) still wraps its canvas in <main>; give it a definite
   width so sizeCanvas (which measures the canvas's parent) fits the grid correctly. */
main { width: 100%; max-width: 680px; display: flex; justify-content: center; }

/* ---- full-width grid + one horizontal top bar (menu buttons | map status) ---- */

/* the grid canvas is full-size (fills the width up to the cap); result overlays it */
.grid-wrap { width: 100%; max-width: 560px; position: relative; display: flex; justify-content: center; }
.grid {
  display: block;
  background: #000;
  border: 2px solid #2c2638;
  border-radius: 4px;
  touch-action: none;
  max-width: 100%;
  height: auto;
  image-rendering: auto;
}

/* one horizontal bar (single line): map status on the LEFT, menu buttons on the RIGHT */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: nowrap; gap: 8px;
  width: 100%; max-width: 560px;
  background: var(--panel);
  border: 1px solid #2c2638; border-radius: 6px;
  padding: 4px 6px;
}
.menu-btns { display: flex; gap: 4px; flex: 0 0 auto; }
.menu-btn {
  border: 1px solid #2c2638; border-radius: 6px;
  background: #17131f; color: var(--ink); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; padding: 0; font: inherit;
}
.menu-btn .ic { font-size: 1.05rem; line-height: 1; }
.menu-btn:active { transform: translateY(1px); }
.menu-btn:hover { border-color: var(--accent); }

/* map status: icons + counts of what the board holds, left-aligned, one tight line */
.board-strip {
  display: flex; flex-wrap: nowrap; gap: 7px;
  align-items: center; justify-content: flex-start;
  flex: 0 1 auto; min-width: 0; overflow: hidden;
  font-size: 0.72rem; letter-spacing: 0;
}
.board-strip .ent { display: inline-flex; align-items: center; gap: 2px; }
.board-strip .ent b { color: var(--ink); font-weight: 600; }
.board-strip .sep { color: #2c2638; }
.board-strip .pips { letter-spacing: 0.12em; color: var(--accent); }
.board-strip .safe { color: #6fbf7a; }
.board-strip .dim { color: var(--dim); }

/* rolling game status: where messages roll through */
/* message panel: a reaction FACE on the left + a rolling 3-line message LOG on the right */
.status-strip {
  width: 100%; max-width: 560px;
  display: flex; align-items: stretch; gap: 10px;
  background: var(--panel); border: 1px solid #2c2638; border-radius: 8px;
  padding: 8px 10px;
}
.status-strip .face {
  flex: 0 0 auto; width: 56px; height: 56px; align-self: center;
  border: 1px solid #2c2638; border-radius: 8px; background: #100e17; overflow: hidden;
}
.status-strip .face svg { width: 100%; height: 100%; display: block; }
.status-strip .face.react { animation: face-react 0.3s ease-out; }
@keyframes face-react { 0% { transform: scale(1); } 40% { transform: scale(1.13); } 100% { transform: scale(1); } }

.status-strip .log {
  flex: 1 1 auto; min-width: 0; min-height: 56px;
  display: flex; flex-direction: column; justify-content: center; gap: 2px;
}
.log .line {
  font-size: 0.78rem; letter-spacing: 0.02em; color: var(--accent);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: opacity 0.35s ease; animation: line-in 0.25s ease-out;
}
.log .line:nth-child(1) { opacity: 1; }              /* newest = brightest, older = dimmer */
.log .line:nth-child(2) { opacity: 0.5; }
.log .line:nth-child(3) { opacity: 0.24; }
@keyframes line-in { from { opacity: 0; transform: translateY(-6px); } }
.log .safe { color: #6fbf7a; font-weight: 600; }
.log .dim { color: var(--dim); }

/* player pocket: slot 0 = dedicated sword slot; the rest hold key + trinkets (below grid) */
.pocket {
  display: flex; gap: 6px; justify-content: center;
  width: 100%; max-width: 560px;
}
.pocket .slot {
  width: min(46px, calc((100% - 30px) / 6)); aspect-ratio: 1;
  border: 1px solid #2c2638; border-radius: 6px; background: #17131f;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem; line-height: 1;
}
.pocket .slot.filled { border-color: #4a4030; background: #221a10; }
.pocket .slot.pop { animation: slot-in 0.2s ease-out; }   /* fires only when a slot's content changes */
.pocket .slot .more { font-size: 0.85rem; color: var(--accent); font-weight: 700; }
@keyframes slot-in { from { transform: scale(0.7); opacity: 0; } to { transform: none; opacity: 1; } }

/* the dedicated sword slot: always-present 🗡️ + count badge, dim at 0, bump on change */
.pocket .slot.sword { position: relative; border-color: #4a4030; background: #221a10; }
.pocket .slot.sword .sw-ic { transition: opacity 0.2s; }
.pocket .slot.sword.empty { border-color: #2c2638; background: #17131f; }
.pocket .slot.sword.empty .sw-ic { opacity: 0.28; }
.pocket .slot.sword .sw-n {
  position: absolute; right: 3px; bottom: 1px;
  font-size: 0.72rem; font-weight: 700; color: var(--accent);
  font-family: ui-monospace, monospace;
}
.pocket .slot.sword.bump { animation: sword-bump 0.32s ease-out; }
@keyframes sword-bump { 0% { transform: scale(1); } 35% { transform: scale(1.25); } 100% { transform: scale(1); } }

/* player pocket: 6 horizontal slots, filled with what you're carrying (below the grid) */
.pocket {
  display: flex; gap: 6px; justify-content: center;
  width: 100%; max-width: 560px;
}
.pocket .slot {
  width: min(46px, calc((100% - 30px) / 6)); aspect-ratio: 1;
  border: 1px solid #2c2638; border-radius: 6px; background: #17131f;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem; line-height: 1;
}
.pocket .slot.filled { border-color: #4a4030; background: #221a10; }
.pocket .slot.pop { animation: slot-in 0.2s ease-out; }   /* fires only when a slot's content changes */
.pocket .slot .more { font-size: 0.85rem; color: var(--accent); font-weight: 700; }
@keyframes slot-in { from { transform: scale(0.7); opacity: 0; } to { transform: none; opacity: 1; } }

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  color: var(--dim);
}
.controls input[type="date"], .controls input[type="number"] {
  background: var(--panel);
  border: 1px solid #2c2638;
  color: var(--ink);
  border-radius: 4px;
  padding: 6px 8px;
  font: inherit;
  width: 9.5em;
}
.controls button {
  background: var(--accent);
  color: #1a1408;
  border: none;
  border-radius: 4px;
  padding: 7px 16px;
  font: inherit;
  font-weight: 700;
  letter-spacing: 0.08em;
  cursor: pointer;
}
.controls button:active { transform: translateY(1px); }
.controls button.ghost { background: transparent; color: var(--accent); border: 1px solid #2c2638; }
.controls input[type="range"] { width: 90px; accent-color: var(--accent); vertical-align: middle; }
.toggle { display: flex; gap: 5px; align-items: center; }
.rangeval { color: var(--accent); font-size: 0.68rem; min-width: 3.2em; }

.meta { color: var(--dim); font-size: 0.65rem; text-align: center; max-width: 420px; line-height: 1.6; }

/* ---- commit + execution movie + result card (M3) ---------------------------- */

.actions { display: flex; gap: 10px; align-items: center; justify-content: center; }
.actions button {
  background: var(--accent);
  color: #1a1408;
  border: none;
  border-radius: 4px;
  padding: 8px 20px;
  font: inherit;
  font-weight: 700;
  letter-spacing: 0.08em;
  cursor: pointer;
}
.actions button:active { transform: translateY(1px); }
.actions button:disabled { opacity: 0.4; cursor: default; }
.actions button.ghost { background: transparent; color: var(--accent); border: 1px solid #2c2638; }

/* end-game result: a panel that appears OVER the grid, toggleable (🏁 side button) */
.result-overlay {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(8, 6, 14, 0.62);
  border-radius: 4px;
  animation: result-in 0.3s ease-out;
  padding: 10px;
}
@keyframes result-in { from { opacity: 0; } to { opacity: 1; } }
.result-overlay .card {
  background: var(--panel);
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 16px 20px;
  text-align: center;
  box-shadow: 0 8px 30px #000a;
  max-width: 92%;
}
.result-overlay .tier { font-size: 1.5rem; letter-spacing: 0.05em; }
.result-overlay .tier .emoji { font-size: 1.7rem; }
.result-overlay .tier.clear    { color: #e7c877; }
.result-overlay .tier.exit     { color: #8fd0ff; }
.result-overlay .tier.dead     { color: #d2556a; }
.result-overlay .tier.incomplete { color: var(--dim); }
.result-overlay .detail { color: var(--dim); font-size: 0.78rem; line-height: 1.8; margin-top: 10px; }
.result-overlay .detail b { color: var(--ink); }
.result-overlay .probes { font-size: 1.1rem; letter-spacing: 0.12em; margin-top: 8px; }

/* end-card flow hooks: streak seam, share, countdown-to-tomorrow (the daily hard stop) */
.result-overlay .streak { font-size: 0.72rem; color: var(--ink); margin-top: 12px; }
.result-overlay .streak .dim { color: var(--dim); }
.result-overlay .end-actions { margin-top: 12px; display: flex; justify-content: center; gap: 10px; }
.end-btn {
  background: var(--accent); color: #12101a;
  border: none; border-radius: 6px;
  padding: 8px 22px; font: inherit; font-size: 0.82rem; font-weight: 700;
  letter-spacing: 0.06em; cursor: pointer;
}
.end-btn:active { transform: translateY(1px); }
.result-overlay .countdown-wrap { margin-top: 12px; font-size: 0.68rem; color: var(--dim); letter-spacing: 0.06em; }
.result-overlay .countdown { color: var(--ink); font-variant-numeric: tabular-nums; letter-spacing: 0.1em; }

/* start panel: the census "open" over the dark grid, gated behind Begin (§3) */
.start-overlay {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(8, 6, 14, 0.72);
  border-radius: 4px;
  animation: result-in var(--introFade, 0.26s) ease-out;
  padding: 12px;
}
.start-card {
  background: var(--panel);
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 20px 22px;
  text-align: center;
  box-shadow: 0 8px 30px #000a;
  max-width: 94%;
}
.start-title { font-size: 0.9rem; color: var(--accent); letter-spacing: 0.04em; line-height: 1.5; }
.start-census { color: var(--ink); font-size: 0.76rem; line-height: 1.7; margin-top: 12px; }
.start-census b { color: var(--accent); font-weight: 700; }
.start-budget { color: var(--dim); font-size: 0.74rem; margin-top: 10px; }
.start-budget .pips { letter-spacing: 0.08em; }
.start-how { color: var(--dim); font-size: 0.68rem; line-height: 1.7; margin-top: 12px; }
.start-begin {
  margin-top: 16px;
  background: var(--accent); color: #12101a;
  border: none; border-radius: 6px;
  padding: 9px 30px; font: inherit; font-size: 0.86rem; font-weight: 700;
  letter-spacing: 0.1em; cursor: pointer;
}
.start-begin:active { transform: translateY(1px); }

/* ---- Bag / Hoard / Bestiary modal ------------------------------------------- */
.modal {
  position: fixed; inset: 0; z-index: 20;
  display: flex; align-items: center; justify-content: center;
  background: rgba(6, 5, 10, 0.72);
  padding: 20px;
}
.modal-card {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--accent);
  border-radius: 10px;
  padding: 22px 24px;
  max-width: 440px; width: 100%;
  max-height: 80vh; overflow-y: auto;
}
.modal-close {
  position: absolute; top: 8px; right: 10px;
  background: none; border: none; color: var(--dim);
  font-size: 1rem; cursor: pointer;
}
.modal-card h2 { font-size: 0.95rem; letter-spacing: 0.15em; color: var(--accent); margin-bottom: 4px; }
.modal-card .modal-sub { color: var(--dim); font-size: 0.72rem; margin-bottom: 14px; }
.modal-card .entry { border-top: 1px solid #2c2638; padding: 10px 0; display: flex; gap: 12px; align-items: flex-start; }
.modal-card .entry .glyph { font-size: 1.6rem; line-height: 1; }
.modal-card .entry .name { color: var(--ink); font-weight: 600; font-size: 0.85rem; }
.modal-card .entry .flavor { color: var(--dim); font-size: 0.72rem; line-height: 1.5; margin-top: 2px; }
.modal-card .entry .tell { color: var(--accent); font-size: 0.72rem; line-height: 1.45; margin-top: 5px; }
.modal-card .empty { color: var(--dim); font-size: 0.78rem; line-height: 1.7; text-align: center; padding: 16px 0; }

/* resting-status accents inside the shared message strip (safe = located, dim = unknown) */
