/* Campfire — warm dark UI. */
:root {
  --bg: #0d0a08;
  --bg2: #14100c;
  --panel: #1a1410;
  --panel2: #211a14;
  --line: #2c241c;
  --line2: #41352a;
  --ink: #ece3d5;
  --dim: #a4937e;
  --faint: #6f6152;
  --ember: #ff6d3a;
  --ember2: #ffb35c;
  --gold: #ffd166;
  --blood: #e5484d;
  --serif: "Newsreader", Georgia, "Times New Roman", serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100dvh;
}
body::before {
  content: "";
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(60% 40% at 50% 108%, rgba(255, 109, 58, 0.14), transparent 70%),
    radial-gradient(45% 30% at 50% 112%, rgba(255, 179, 92, 0.10), transparent 70%),
    radial-gradient(120% 90% at 50% -20%, rgba(20, 16, 12, 0.0), rgba(0, 0, 0, 0.45) 90%);
}
::selection { background: rgba(255, 109, 58, 0.35); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line2); border-radius: 5px; border: 2px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }
a { color: var(--ember2); }
button { font-family: inherit; }

/* ---------- shared bits ---------- */
.btn {
  appearance: none; cursor: pointer;
  background: transparent; color: var(--dim);
  border: 1px solid var(--line); border-radius: 9px;
  padding: 7px 13px; font-size: 13px; font-weight: 500;
  transition: color .15s, border-color .15s, background .15s, transform .1s;
  white-space: nowrap;
}
.btn:hover { color: var(--ink); border-color: var(--line2); background: var(--panel); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .4; cursor: default; transform: none; }
.btn-primary {
  background: linear-gradient(135deg, var(--ember), #ff8f3a 60%, var(--ember2));
  border: none; color: #1a0e06; font-weight: 700;
  box-shadow: 0 2px 14px rgba(255, 109, 58, 0.25);
}
.btn-primary:hover { background: linear-gradient(135deg, #ff7d4d, #ffa24d 60%, #ffc476); color: #1a0e06; }
.btn-danger:hover { color: var(--blood); border-color: rgba(229, 72, 77, 0.5); background: rgba(229, 72, 77, 0.07); }
.icon-btn {
  appearance: none; cursor: pointer; background: transparent; border: none;
  color: var(--faint); font-size: 15px; padding: 6px 8px; border-radius: 8px; line-height: 1;
}
.icon-btn:hover { color: var(--ink); background: var(--panel); }
input[type=text], textarea, select {
  background: var(--bg2); color: var(--ink);
  border: 1px solid var(--line); border-radius: 9px;
  padding: 9px 11px; font-size: 14px; font-family: inherit; width: 100%;
}
input[type=text]:focus, textarea:focus, select:focus { outline: none; border-color: rgba(255, 109, 58, 0.55); box-shadow: 0 0 0 3px rgba(255, 109, 58, 0.12); }
textarea { resize: none; }
.chip-tag {
  display: inline-block; font-size: 10px; font-weight: 700; letter-spacing: .14em;
  color: var(--ember2); background: rgba(255, 141, 60, 0.09);
  border: 1px solid rgba(255, 141, 60, 0.25);
  padding: 3px 8px; border-radius: 99px;
}

/* ---------- home ---------- */
.home { max-width: 1060px; margin: 0 auto; padding: 48px 22px 90px; }
.hero { text-align: center; padding: 34px 0 44px; }
.flame { font-size: 44px; display: inline-block; animation: flicker 2.8s infinite ease-in-out; filter: drop-shadow(0 0 18px rgba(255, 122, 40, 0.5)); }
@keyframes flicker {
  0%, 100% { transform: scale(1) rotate(-1.5deg); filter: drop-shadow(0 0 14px rgba(255, 122, 40, 0.45)); }
  25% { transform: scale(1.05) rotate(1deg); filter: drop-shadow(0 0 24px rgba(255, 140, 40, 0.65)); }
  60% { transform: scale(0.97) rotate(-0.5deg); }
  80% { transform: scale(1.03) rotate(1.5deg); filter: drop-shadow(0 0 20px rgba(255, 122, 40, 0.6)); }
}
.wordmark {
  font-family: var(--sans); font-weight: 700; font-size: clamp(34px, 6vw, 54px);
  letter-spacing: .28em; text-indent: .28em; margin-top: 10px;
  background: linear-gradient(180deg, #fff2df 10%, var(--ember2) 55%, var(--ember) 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.tagline { color: var(--dim); font-family: var(--serif); font-style: italic; font-size: 19px; margin-top: 8px; }
.keywarn {
  margin: 0 auto 28px; max-width: 640px; text-align: center;
  border: 1px solid rgba(229, 72, 77, 0.4); background: rgba(229, 72, 77, 0.08);
  color: #ffb3b5; border-radius: 12px; padding: 12px 16px; font-size: 13.5px;
}
.section { margin-top: 44px; }
.section > h2 {
  font-size: 12px; font-weight: 700; letter-spacing: .22em; color: var(--faint);
  text-transform: uppercase; margin-bottom: 16px;
  display: flex; align-items: center; gap: 14px;
}
.section > h2::after { content: ""; flex: 1; height: 1px; background: linear-gradient(90deg, var(--line), transparent); }

.fires { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.fire-card {
  text-align: left; cursor: pointer;
  background: linear-gradient(180deg, var(--panel), var(--bg2));
  border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px;
  color: var(--ink); transition: border-color .15s, transform .15s, box-shadow .15s;
  display: flex; flex-direction: column; gap: 9px;
}
.fire-card:hover { border-color: rgba(255, 109, 58, 0.45); transform: translateY(-2px); box-shadow: 0 10px 30px rgba(0,0,0,.35), 0 0 0 1px rgba(255,109,58,.08); }
.fc-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.fc-time { color: var(--faint); font-size: 11.5px; }
.fc-title { font-family: var(--serif); font-size: 21px; font-weight: 600; letter-spacing: .01em; }
.fc-last { font-family: var(--serif); font-style: italic; color: var(--dim); font-size: 14.5px; line-height: 1.5; min-height: 1.5em;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.fc-party { display: flex; align-items: center; gap: 6px; margin-top: 2px; }
.fc-party .dot { width: 10px; height: 10px; border-radius: 50%; box-shadow: 0 0 6px rgba(0,0,0,.4) inset; }
.fc-party .dot.dead { background: #3c332b !important; position: relative; }
.fc-party .fallen-n { color: var(--faint); font-size: 11px; margin-left: 4px; }

.scenarios { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.sc-card {
  text-align: left; cursor: pointer; color: var(--ink);
  background: var(--bg2); border: 1px solid var(--line); border-radius: 14px; padding: 18px;
  display: flex; flex-direction: column; gap: 10px; min-height: 150px;
  transition: border-color .15s, transform .15s, background .15s;
}
.sc-card:hover { border-color: rgba(255, 109, 58, 0.5); transform: translateY(-2px); background: var(--panel); }
.sc-card .sc-title { font-family: var(--serif); font-size: 22px; font-weight: 600; }
.sc-card .sc-blurb { color: var(--dim); font-size: 13.5px; line-height: 1.55; }
.sc-card.custom { border-style: dashed; border-color: var(--line2); background: transparent; align-items: center; justify-content: center; text-align: center; }
.sc-card.custom:hover { border-color: var(--ember); }
.sc-card.custom .plus { font-size: 30px; color: var(--faint); line-height: 1; }
.empty-note { color: var(--faint); font-size: 14px; font-style: italic; font-family: var(--serif); }

/* ---------- adventure ---------- */
.adv { display: flex; flex-direction: column; height: 100dvh; }
.adv-header {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px; border-bottom: 1px solid var(--line);
  background: rgba(13, 10, 8, 0.85); backdrop-filter: blur(10px);
  position: relative; z-index: 5; flex: none;
}
.adv-title {
  background: transparent; border: 1px solid transparent; color: var(--ink);
  font-family: var(--serif); font-size: 19px; font-weight: 600; padding: 4px 8px;
  min-width: 0; flex: 1;
}
.adv-title:hover { border-color: var(--line); }
.adv-title:focus { background: var(--bg2); }
.presence { color: var(--faint); font-size: 12px; white-space: nowrap; display: flex; align-items: center; gap: 5px; }
.presence .pdot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; box-shadow: 0 0 7px rgba(0,0,0,.5); }
.entry.gm { position: relative; }
.read-btn {
  position: absolute; top: -6px; right: -6px; z-index: 2;
  appearance: none; background: transparent; border: none; cursor: pointer;
  font-size: 13px; opacity: 0; filter: grayscale(1); transition: opacity .15s;
  padding: 4px;
}
.entry.gm:hover .read-btn { opacity: .6; }
.read-btn:hover { opacity: 1 !important; filter: none; }
.sub-inline { color: var(--faint); font-weight: 400; letter-spacing: .02em; text-transform: none; font-size: 10px; margin-left: 6px; }
.cast-list { display: flex; flex-direction: column; gap: 7px; max-height: 200px; overflow-y: auto; }
.cast-row { display: flex; align-items: center; gap: 10px; }
.cast-row .cast-name { width: 96px; flex: none; font-size: 12.5px; font-weight: 600; color: var(--ember2); text-transform: capitalize; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cast-row select { flex: 1; font-size: 12.5px; padding: 6px 8px; }
.busybar { position: absolute; left: 0; right: 0; bottom: -2px; height: 2px; overflow: hidden; opacity: 0; transition: opacity .2s; }
.busybar.on { opacity: 1; }
.busybar i {
  display: block; height: 100%; width: 40%;
  background: linear-gradient(90deg, transparent, var(--ember), var(--ember2), transparent);
  animation: slide 1.2s infinite linear;
}
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(350%); } }

.layout { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) 252px; min-height: 0; }
.story-wrap { position: relative; min-width: 0; display: flex; flex-direction: column; min-height: 0; }
.story { flex: 1; overflow-y: auto; padding: 30px 26px 30px; scroll-behavior: smooth; }
.story-inner { max-width: 720px; margin: 0 auto; display: flex; flex-direction: column; gap: 20px; }

.entry.gm { font-family: var(--serif); font-size: 17.5px; line-height: 1.78; color: var(--ink); }
.entry.gm p + p { margin-top: 0.9em; }
.entry.gm em { color: var(--ember2); font-style: italic; }
.entry.player {
  border-left: 2px solid var(--pc, var(--ember));
  padding: 2px 0 2px 14px; margin: 4px 0;
}
.entry.player .p-name { font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--pc, var(--ember)); }
.entry.player .p-text { color: var(--dim); font-size: 14.5px; margin-top: 2px; }
.entry.player.m-say .p-text { font-family: var(--serif); font-style: italic; font-size: 16px; color: var(--ink); }
.entry.event { text-align: center; color: var(--faint); font-size: 12.5px; letter-spacing: .12em; text-transform: uppercase; padding: 6px 0; }
.entry.event.death { color: var(--blood); text-shadow: 0 0 18px rgba(229, 72, 77, 0.4); font-weight: 600; }

.roll-chip {
  display: inline-flex; align-items: center; gap: 7px; margin-top: 7px;
  font-size: 11.5px; font-weight: 700; letter-spacing: .05em;
  border: 1px solid var(--line); border-radius: 8px; padding: 4px 9px; color: var(--dim);
  background: var(--bg2);
}
.roll-chip .die { font-size: 13px; }
.roll-chip.t-TRIUMPH { color: var(--gold); border-color: rgba(255, 209, 102, 0.45); box-shadow: 0 0 14px rgba(255, 209, 102, 0.15); }
.roll-chip.t-SUCCESS { color: var(--ember2); border-color: rgba(255, 179, 92, 0.4); }
.roll-chip.t-COMPLICATION { color: #d8a25a; }
.roll-chip.t-FAILURE { color: var(--faint); }
.roll-chip.t-CATASTROPHE { color: var(--blood); border-color: rgba(229, 72, 77, 0.5); box-shadow: 0 0 14px rgba(229, 72, 77, 0.15); }

.caret { display: inline-block; width: 3px; height: 1.05em; vertical-align: text-bottom; margin-left: 2px; border-radius: 2px;
  background: var(--ember); animation: blink 0.9s infinite steps(2, start); box-shadow: 0 0 10px rgba(255, 109, 58, 0.8); }
@keyframes blink { 50% { opacity: 0; } }

.jump-pill {
  position: absolute; left: 50%; transform: translateX(-50%); bottom: 14px;
  background: var(--panel2); border: 1px solid var(--line2); color: var(--dim);
  border-radius: 99px; padding: 6px 14px; font-size: 12px; cursor: pointer;
  box-shadow: 0 6px 20px rgba(0,0,0,.5); z-index: 4;
}
.jump-pill:hover { color: var(--ink); }

/* rail */
.rail { border-left: 1px solid var(--line); padding: 18px 14px; overflow-y: auto; background: rgba(20, 16, 12, 0.5); }
.rail h3 { font-size: 10.5px; font-weight: 700; letter-spacing: .2em; color: var(--faint); text-transform: uppercase; margin: 4px 0 10px; }
.char-card {
  border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin-bottom: 10px;
  background: var(--bg2); position: relative;
}
.char-card .c-head { display: flex; align-items: center; gap: 9px; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; flex: none;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; color: #14100c;
  box-shadow: 0 0 12px color-mix(in srgb, var(--pc, var(--ember)) 40%, transparent);
  background: var(--pc, var(--ember));
}
.char-card .c-name { font-weight: 600; font-size: 14px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.char-card .c-you { color: var(--faint); font-size: 10px; letter-spacing: .1em; }
.hp { display: flex; gap: 3px; margin-top: 9px; }
.hp i { flex: 1; height: 6px; border-radius: 3px; background: var(--line); }
.hp i.on { background: var(--ember2); }
.hp.low i.on { background: #ff9d3a; }
.hp.crit i.on { background: var(--blood); box-shadow: 0 0 8px rgba(229, 72, 77, 0.5); }
.stats-mini { display: flex; gap: 8px; margin-top: 8px; color: var(--faint); font-size: 10.5px; letter-spacing: .04em; }
.stats-mini b { color: var(--dim); font-weight: 600; }
.hp-nudge { position: absolute; top: 8px; right: 8px; display: none; gap: 2px; }
.char-card:hover .hp-nudge { display: flex; }
.hp-nudge button { appearance: none; background: var(--panel2); border: 1px solid var(--line); color: var(--dim);
  width: 20px; height: 20px; border-radius: 6px; font-size: 12px; line-height: 1; cursor: pointer; }
.hp-nudge button:hover { color: var(--ink); border-color: var(--line2); }
.char-card.dead { opacity: .55; background: transparent; }
.char-card.dead .avatar { background: #3c332b; color: var(--faint); box-shadow: none; }
.char-card.dead .c-name { color: var(--faint); text-decoration: line-through; text-decoration-color: rgba(229,72,77,.6); }
.skull { font-size: 13px; margin-left: auto; }

/* composer */
.composer {
  flex: none; border-top: 1px solid var(--line); padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: rgba(16, 12, 9, 0.92); backdrop-filter: blur(12px);
}
.composer-inner { max-width: 720px; margin: 0 auto; display: flex; flex-direction: column; gap: 9px; }
.modes-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.seg { display: inline-flex; background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button {
  appearance: none; border: none; background: transparent; color: var(--faint);
  font-size: 12.5px; font-weight: 600; padding: 5px 13px; border-radius: 7px; cursor: pointer;
}
.seg button.sel { background: var(--panel2); color: var(--ember2); box-shadow: 0 1px 6px rgba(0,0,0,.4); }
.stat-pick { width: auto; font-size: 12px; padding: 6px 8px; color: var(--dim); }
.mode-hint { color: var(--faint); font-size: 11.5px; margin-left: auto; }
.input-row { display: flex; gap: 9px; align-items: flex-end; }
.input-row textarea { flex: 1; min-height: 42px; max-height: 130px; font-size: 15px; line-height: 1.45; }
.send { height: 42px; padding: 0 20px; border-radius: 10px; font-size: 14px; flex: none; }
.round-tray { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; padding: 2px 0 4px; }
.stage-chip {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%;
  border: 1px solid var(--line); border-left: 3px solid var(--pc, var(--ember));
  background: var(--bg2); border-radius: 8px; padding: 5px 9px; font-size: 12px; color: var(--dim);
}
.stage-chip b { color: var(--pc, var(--ember)); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; }
.stage-chip .sc-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 260px; }
.stage-chip .sc-x { appearance: none; background: none; border: none; color: var(--faint); cursor: pointer; font-size: 11px; padding: 0 2px; }
.stage-chip .sc-x:hover { color: var(--blood); }
.round-clock { font-size: 12px; font-weight: 700; color: var(--ember2); letter-spacing: .05em; }
.round-clock.urgent { color: var(--blood); animation: blink 1s infinite steps(2, start); }
.round-note { color: var(--faint); font-size: 11.5px; font-style: italic; }
.actions-row { display: flex; gap: 7px; flex-wrap: wrap; }
.actions-row .spacer { flex: 1; }
.dead-note { color: var(--blood); font-size: 13px; font-family: var(--serif); font-style: italic; }

/* ---------- modals ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(8, 5, 3, 0.7); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal {
  width: 100%; max-width: 460px; max-height: 88dvh; overflow-y: auto;
  background: linear-gradient(180deg, var(--panel2), var(--panel));
  border: 1px solid var(--line2); border-radius: 16px; padding: 26px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
}
.modal h2 { font-family: var(--serif); font-size: 24px; font-weight: 600; margin-bottom: 4px; }
.modal .sub { color: var(--dim); font-size: 13.5px; margin-bottom: 18px; }
.frow { margin-bottom: 14px; }
.frow label { display: block; font-size: 11px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--faint); margin-bottom: 6px; }
.modal .btn-row { display: flex; gap: 9px; justify-content: flex-end; margin-top: 20px; }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.sw { width: 26px; height: 26px; border-radius: 50%; cursor: pointer; border: 2px solid transparent; }
.sw.sel { border-color: var(--ink); box-shadow: 0 0 0 2px var(--bg); }
.stat-alloc { display: flex; flex-direction: column; gap: 8px; }
.stat-row { display: flex; align-items: center; gap: 10px; background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; }
.stat-row .stat-name { font-size: 12px; font-weight: 700; letter-spacing: .12em; width: 74px; color: var(--dim); }
.stat-row .stat-desc { flex: 1; color: var(--faint); font-size: 11.5px; }
.stat-row button { appearance: none; width: 24px; height: 24px; border-radius: 7px; border: 1px solid var(--line2); background: var(--panel2); color: var(--dim); cursor: pointer; font-size: 13px; line-height: 1; }
.stat-row button:hover:not(:disabled) { color: var(--ink); }
.stat-row button:disabled { opacity: .3; cursor: default; }
.stat-row .stat-val { width: 18px; text-align: center; font-weight: 700; color: var(--ember2); }
.points-left { text-align: right; font-size: 12px; color: var(--dim); margin-top: 8px; }
.points-left b { color: var(--ember2); }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.temp-out { color: var(--ember2); font-weight: 600; }
input[type=range] { width: 100%; accent-color: var(--ember); }

/* ---------- toasts ---------- */
#toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 90; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  background: var(--panel2); border: 1px solid var(--line2); color: var(--ink);
  border-radius: 10px; padding: 10px 16px; font-size: 13.5px;
  box-shadow: 0 10px 30px rgba(0,0,0,.5); animation: toastin .25s ease;
  max-width: 90vw;
}
.toast.err { border-color: rgba(229, 72, 77, 0.5); color: #ffb3b5; }
@keyframes toastin { from { opacity: 0; transform: translateY(8px); } }

/* ---------- responsive ---------- */
@media (max-width: 880px) {
  .layout { grid-template-columns: 1fr; }
  .layout { display: flex; flex-direction: column; }
  .story-wrap { flex: 1; min-height: 0; order: 2; }
  .rail { order: 1; flex: none; border-left: none; border-bottom: 1px solid var(--line); display: flex; align-items: flex-start; gap: 10px; overflow-x: auto; overflow-y: hidden; padding: 10px 14px; }
  .rail h3 { display: none; }
  .char-card { min-width: 168px; margin-bottom: 0; flex: none; }
  .story { padding: 20px 16px; }
  .entry.gm { font-size: 16.5px; }
  .mode-hint { display: none; }
  .home { padding: 28px 16px 70px; }
}
@media (prefers-reduced-motion: reduce) {
  .flame, .busybar i, .caret { animation: none; }
}
