/* Katabasis, cozy game world skin. Night camp palette: deep indigo dark, warm
   amber light. Every region card carries its own lantern hue via --hue. */

:root {
  --night: #14101d;
  --night-2: #1c1629;
  --card: #251d36;
  --card-edge: #3a2f52;
  --ink: #e8e0d5;
  --ink-dim: #a99e91;
  --amber: #ffb454;
  --amber-deep: #e8894a;
  --moss: #9ac07a;
  --ember-red: #ff7854;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(ellipse at 50% 120%, #2b1d33 0%, var(--night-2) 45%, var(--night) 100%);
  color: var(--ink);
  font-family: "Segoe UI", "Trebuchet MS", system-ui, sans-serif;
  line-height: 1.5;
}

h1, h2, .brand, .gate-title { font-family: Georgia, "Times New Roman", serif; letter-spacing: 0.02em; }
h1 { font-size: 1.9rem; margin: 0.4rem 0; }
h2 { font-size: 1.25rem; color: var(--amber); font-weight: normal; }

main { max-width: 900px; margin: 0 auto; padding: 1rem 1.2rem 4rem; position: relative; }

/* stars */
.stars {
  position: fixed; inset: 0; pointer-events: none; opacity: 0.7;
  background-image:
    radial-gradient(1px 1px at 12% 18%, #fff8 50%, transparent 51%),
    radial-gradient(1px 1px at 34% 8%, #fff6 50%, transparent 51%),
    radial-gradient(2px 2px at 58% 22%, #ffe9c455 50%, transparent 51%),
    radial-gradient(1px 1px at 76% 12%, #fff7 50%, transparent 51%),
    radial-gradient(1px 1px at 89% 30%, #fff5 50%, transparent 51%),
    radial-gradient(2px 2px at 22% 34%, #ffe9c444 50%, transparent 51%),
    radial-gradient(1px 1px at 47% 15%, #fff6 50%, transparent 51%),
    radial-gradient(1px 1px at 66% 38%, #fff4 50%, transparent 51%);
  animation: twinkle 7s ease-in-out infinite alternate;
}
@keyframes twinkle { from { opacity: 0.45; } to { opacity: 0.8; } }

/* top bar */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.7rem 1.2rem; position: relative;
}
.brand { color: var(--amber); text-decoration: none; font-size: 1.3rem; }
.navlinks { display: flex; gap: 1rem; align-items: center; }
.navlinks a { color: var(--ink-dim); text-decoration: none; }
.navlinks a:hover { color: var(--amber); }
.inline { display: inline; }

/* xp bar */
.xpbar-wrap { display: flex; align-items: center; gap: 0.7rem; padding: 0 1.2rem 0.4rem; max-width: 900px; margin: 0 auto; }
.xpbar-label { color: var(--amber); font-size: 0.85rem; white-space: nowrap; }
.xpbar { flex: 1; height: 8px; background: #ffffff14; border-radius: 6px; overflow: hidden; }
.xpbar-fill {
  height: 100%; border-radius: 6px;
  background: linear-gradient(90deg, var(--amber-deep), var(--amber));
  box-shadow: 0 0 8px var(--amber);
  transition: width 0.6s ease;
}
.xpbar-num { color: var(--ink-dim); font-size: 0.75rem; white-space: nowrap; }

/* campfire hero */
.campfire-hero { display: flex; align-items: center; gap: 1.4rem; padding: 1rem 0 0.4rem; }
.fire-glyph { position: relative; width: 84px; height: 90px; flex-shrink: 0; }
.fire-glyph .logs {
  position: absolute; bottom: 0; left: 10px; width: 64px; height: 12px;
  background: #4a3222; border-radius: 6px; transform: rotate(-4deg);
  box-shadow: 0 4px 14px #000a;
}
.flame {
  position: absolute; bottom: 8px; border-radius: 50% 50% 50% 50% / 62% 62% 38% 38%;
  transform-origin: bottom center;
  animation: flick 1.6s ease-in-out infinite alternate;
}
.f1 { left: 22px; width: 40px; height: 58px; background: radial-gradient(circle at 50% 80%, #ffdf8e, var(--amber-deep) 60%, transparent); filter: blur(1px); }
.f2 { left: 30px; width: 24px; height: 40px; background: radial-gradient(circle at 50% 80%, #fff3c4, var(--amber) 65%, transparent); animation-delay: 0.35s; }
.f3 { left: 14px; width: 22px; height: 34px; background: radial-gradient(circle at 50% 85%, var(--ember-red), transparent 75%); animation-delay: 0.7s; filter: blur(1.5px); }
@keyframes flick { from { transform: scaleY(0.92) rotate(-2deg); } to { transform: scaleY(1.08) rotate(2.5deg); } }
.warmth { color: var(--ink-dim); margin: 0; }

/* energy picker */
.ember-picker { margin-top: 1.4rem; }
.energy-row { display: flex; gap: 0.8rem; flex-wrap: wrap; }
.energy-chip {
  flex: 1; min-width: 150px; text-align: center; text-decoration: none;
  padding: 0.7rem 0.6rem; border-radius: 14px; color: var(--ink);
  background: var(--card); border: 1px solid var(--card-edge);
  display: flex; flex-direction: column; gap: 0.1rem;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.energy-chip small { color: var(--ink-dim); }
.energy-chip:hover { transform: translateY(-2px); }
.energy-chip.spark.on, .energy-chip.spark:hover { box-shadow: 0 0 14px #ffd45455; border-color: #ffd454aa; }
.energy-chip.steady.on, .energy-chip.steady:hover { box-shadow: 0 0 14px #ff985455; border-color: #ff9854aa; }
.energy-chip.deep.on, .energy-chip.deep:hover { box-shadow: 0 0 14px #b678ff44; border-color: #b678ffaa; }

.ember-list { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 0.6rem; margin: 1rem 0 0; }
.ember a {
  display: flex; flex-direction: column; gap: 0.15rem; text-decoration: none;
  background: var(--card); border: 1px solid var(--card-edge); border-left: 3px solid var(--amber);
  padding: 0.7rem 0.9rem; border-radius: 12px; color: var(--ink);
}
.ember a:hover { border-color: var(--amber); }
.ember-quest { font-weight: 600; }
.ember-step { color: var(--amber); font-size: 0.9rem; }

/* region map */
.region-map { margin-top: 2rem; }
.regions { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1rem; }
.region {
  --hue: 38;
  position: relative;
  display: flex; flex-direction: column; gap: 0.25rem;
  background: var(--card);
  border: 1px solid hsl(var(--hue), 45%, 38%, 0.65);
  border-radius: 16px; padding: 1rem 1.1rem;
  color: var(--ink); text-decoration: none;
  box-shadow: 0 0 18px hsla(var(--hue), 80%, 60%, 0.10), inset 0 0 30px hsla(var(--hue), 80%, 60%, 0.05);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  animation: floaty 6s ease-in-out infinite alternate;
}
.region:nth-child(2n) { animation-delay: 1.6s; }
.region:nth-child(3n) { animation-delay: 3.1s; }
@keyframes floaty { from { transform: translateY(0); } to { transform: translateY(-4px); } }
.region:hover { box-shadow: 0 0 26px hsla(var(--hue), 90%, 62%, 0.28); transform: translateY(-3px); }
.region-sigil { font-size: 1.6rem; }
.region-name { font-weight: 600; font-size: 1.05rem; }
.region-state { color: var(--ink-dim); font-size: 0.82rem; }
.region-why { color: var(--ink-dim); font-size: 0.85rem; font-style: italic; }
.region.surfaced { opacity: 0.55; filter: saturate(0.6); }
.region.resting { opacity: 0.7; }
.ghost-slot {
  border: 1px dashed var(--card-edge); background: transparent; text-align: center;
  justify-content: center; color: var(--ink-dim); animation: none;
}

/* panels and forms */
.new-panel { margin-top: 1.2rem; }
.new-panel summary { cursor: pointer; color: var(--amber); }
.stack { display: flex; flex-direction: column; gap: 0.6rem; margin-top: 0.8rem; }
.row { display: flex; gap: 0.8rem; align-items: center; flex-wrap: wrap; margin-top: 0.6rem; }
input, select, button, textarea {
  font: inherit; color: var(--ink);
  background: var(--night-2); border: 1px solid var(--card-edge);
  border-radius: 10px; padding: 0.55rem 0.8rem;
}
input::placeholder { color: #7d7466; }
input.tiny { width: 4rem; text-align: center; }
label { color: var(--ink-dim); font-size: 0.9rem; display: inline-flex; gap: 0.5rem; align-items: center; }
label.check { cursor: pointer; }
button { cursor: pointer; background: var(--card); transition: box-shadow 0.15s ease; }
button:hover { border-color: var(--amber); }
button.glow {
  background: linear-gradient(160deg, var(--amber-deep), var(--amber));
  color: #241505; border: none; font-weight: 600;
  box-shadow: 0 0 16px #ffb45444;
}
button.glow:hover { box-shadow: 0 0 24px #ffb45488; }
button.ghost { background: transparent; color: var(--ink-dim); }
button.ghost:hover { color: var(--ink); }
.surface-btn {
  background: linear-gradient(160deg, #7a9a5a, var(--moss)); border: none;
  color: #1c2410; font-weight: 600; box-shadow: 0 0 16px #9ac07a44;
}

/* quests */
.crumb { color: var(--ink-dim); text-decoration: none; font-size: 0.9rem; }
.crumb:hover { color: var(--amber); }
.why { color: var(--ink-dim); font-style: italic; margin: 0.2rem 0; }
.quest-list { margin-top: 1.4rem; display: flex; flex-direction: column; gap: 0.7rem; }
.quest-card {
  display: flex; flex-direction: column; gap: 0.3rem;
  background: var(--card); border: 1px solid var(--card-edge);
  border-radius: 14px; padding: 0.85rem 1rem; color: var(--ink); text-decoration: none;
}
.quest-card:hover { border-color: var(--amber); }
.quest-card.done { opacity: 0.5; }
.quest-card.resting { opacity: 0.72; }
.quest-card.tender { border-left: 3px solid #d89ae0; }
.q-title { font-weight: 600; }
.q-meta { display: flex; gap: 0.7rem; flex-wrap: wrap; font-size: 0.82rem; color: var(--ink-dim); align-items: center; }
.q-next { color: var(--amber); font-size: 0.9rem; }
.energy-dot { padding: 0.1rem 0.5rem; border-radius: 8px; background: #ffffff10; }
.energy-dot.spark { color: #ffd454; }
.energy-dot.steady { color: #ff9854; }
.energy-dot.deep { color: #c99aff; }
.soft-tag { color: #d89ae0; }
.waypoint { color: var(--ink-dim); }
.done-fold { margin-top: 0.6rem; color: var(--ink-dim); }
.done-fold summary { cursor: pointer; }

/* the one next step */
.next-step-card {
  margin-top: 1.2rem; padding: 1.2rem 1.3rem; border-radius: 16px;
  background: linear-gradient(160deg, #2d2340, var(--card));
  border: 1px solid var(--amber-deep);
  box-shadow: 0 0 22px #e8894a33;
  display: flex; flex-direction: column; gap: 0.5rem;
}
.next-step-card.empty { border-style: dashed; box-shadow: none; }
.nsc-label { font-size: 0.75rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--amber); }
.nsc-text { font-size: 1.2rem; font-family: Georgia, serif; }
.addstep { margin-top: 0.9rem; }
.addstep input { flex: 1; }
.step-trail { list-style: none; padding: 0.4rem 0 0 0.4rem; margin: 0; }
.step-trail li { padding: 0.2rem 0; color: var(--ink-dim); }
.step-trail li.done::before { content: "\1F702  "; color: var(--amber); }
.step-trail li.done { color: var(--ink); }
.step-trail li.open::before { content: "\25CB  "; }
.step-trail li.skipped { text-decoration: line-through; opacity: 0.6; }
.quest-actions { margin-top: 1.4rem; }

.mist { color: var(--ink-dim); font-style: italic; }
.foot { text-align: center; color: #5e5570; padding: 2rem 0 1rem; font-style: italic; font-family: Georgia, serif; }

/* sentinel */
.sentinel .ledger { width: 100%; border-collapse: collapse; margin-top: 0.8rem; font-size: 0.85rem; }
.ledger th { text-align: left; color: var(--amber); font-weight: normal; padding: 0.3rem 0.5rem; border-bottom: 1px solid var(--card-edge); }
.ledger td { padding: 0.3rem 0.5rem; border-bottom: 1px solid #ffffff0d; color: var(--ink-dim); }
.ledger tr.face_ok td, .ledger tr.recovery_ok td { color: var(--moss); }
.ledger tr.face_fail td, .ledger tr.recovery_fail td, .ledger tr.denied td { color: var(--ember-red); }
.verdicts { display: flex; flex-direction: column; gap: 0.4rem; margin-top: 0.8rem; }
.verdict { padding: 0.5rem 0.8rem; border-radius: 10px; background: var(--card); border-left: 3px solid var(--moss); }
.verdict.ok { border-color: var(--moss); }
.verdict.unverifiable { border-color: var(--amber); }
.verdict.altered, .verdict.chain_broken, .verdict.truncated,
.verdict.anchor_missing, .verdict.anchor_forged { border-color: var(--ember-red); }
.pager { justify-content: center; color: var(--ink-dim); font-size: 0.85rem; }
.pager a { color: var(--amber); text-decoration: none; }

/* gate */
.gatepage main.gate-main {
  max-width: 460px; text-align: center; padding-top: 8vh;
  display: flex; flex-direction: column; align-items: center; gap: 0.6rem;
}
.gate-title { font-size: 2.4rem; color: var(--amber); margin: 0; text-shadow: 0 0 24px #ffb45444; }
.gate-sub { color: var(--ink-dim); margin: 0 0 1rem; }
.cam-frame { position: relative; width: 320px; height: 240px; }
.cam-frame video {
  width: 100%; height: 100%; object-fit: cover; border-radius: 18px;
  background: #000; filter: sepia(0.15) contrast(1.02);
}
.cam-ring {
  position: absolute; inset: -6px; border-radius: 24px; pointer-events: none;
  border: 2px solid var(--card-edge);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.cam-ring.snap { border-color: var(--amber); box-shadow: 0 0 24px #ffb45466; }
.gate-actions { display: flex; flex-direction: column; gap: 0.7rem; align-items: center; width: 100%; }
.recovery-fold { color: var(--ink-dim); }
.recovery-fold summary { cursor: pointer; }
.recovery-reveal[hidden] { display: none; }
.recovery-reveal {
  background: var(--card); border: 1px solid var(--amber-deep); border-radius: 16px;
  padding: 1.2rem 1.4rem; box-shadow: 0 0 28px #e8894a33;
  display: flex; flex-direction: column; gap: 0.7rem; align-items: center;
}
.recovery-reveal code {
  font-size: 1.25rem; letter-spacing: 0.08em; background: var(--night);
  padding: 0.6rem 1rem; border-radius: 10px; color: var(--amber);
}

/* toybox and campfire */
.region.toy { --hue: 300; }
.campfire-toy { text-align: center; }
.campfire-toy canvas {
  width: 100%; max-width: 900px; border-radius: 18px;
  background: radial-gradient(ellipse at 50% 100%, #241629 0%, #120e1a 70%);
  border: 1px solid var(--card-edge);
}
.burn-row { display: flex; gap: 0.7rem; justify-content: center; margin-top: 0.9rem; }
.burn-row input { flex: 1; max-width: 460px; }
.ash { min-height: 1.4rem; color: var(--ink-dim); font-style: italic; font-family: Georgia, serif; }

@media (max-width: 640px) {
  .campfire-hero { flex-direction: column; text-align: center; }
  .topbar { flex-direction: column; gap: 0.5rem; }
}
