/* ============ TableTorch — gothic horror theme ============ */
:root {
  --bg: #14100f;
  --bg-raise: #1e1817;
  --bg-panel: #241c1a;
  --parchment: #e8dcc3;
  --parchment-dim: #b3a487;
  --ink: #2a2018;
  --accent: #b03a2e;      /* dried-blood red */
  --accent-hi: #d4553f;
  --gold: #c9a227;
  --ghost: #7fd4c1;       /* spectral green-teal */
  --hag: #7e57c2;
  --ok: #5f9e6e;
  --bad: #c0524d;
  --border: #3a2e2a;
  --serif: 'EB Garamond', Palatino, 'Palatino Linotype', Georgia, serif;
  --display: 'Cinzel', Palatino, Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  background:
    radial-gradient(ellipse 90% 60% at 50% -10%, rgba(176,58,46,.10), transparent 60%),
    radial-gradient(ellipse 70% 50% at 85% 110%, rgba(126,87,194,.06), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  color: var(--parchment);
  font-family: var(--serif);
  font-size: 17px;
  overscroll-behavior: none;
}
/* film-grain texture + candlelight vignette over everything */
body::before {
  content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 1;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)' opacity='0.05'/%3E%3C/svg%3E");
}
body::after {
  content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 1;
  box-shadow: inset 0 0 24vmin rgba(0,0,0,.55);
}
.screen, .roll-overlay, .modal-backdrop, .toast { position: relative; z-index: 2; }
h1, h2, h3 { font-family: var(--display); }
button { font-family: inherit; cursor: pointer; }
input, textarea, select {
  font-family: inherit; font-size: 16px;
  background: var(--bg-raise); color: var(--parchment);
  border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px;
  width: 100%;
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); border-color: var(--accent); }
label { display: block; margin: 14px 0 6px; color: var(--parchment-dim); font-size: 14px; letter-spacing: .04em; text-transform: uppercase; }
h1, h2, h3 { font-weight: 600; letter-spacing: .02em; }
.hidden { display: none !important; }
.hint { color: var(--parchment-dim); font-size: 14px; margin-top: 8px; }
.error { color: var(--bad); margin-top: 10px; min-height: 1.2em; }

/* ---------- screens ---------- */
.screen { display: none; min-height: 100dvh; }
.screen.active { display: block; }
.game-screen.active { display: flex; flex-direction: column; height: 100dvh; }

/* ---------- buttons ---------- */
.btn {
  border: 1px solid var(--border); border-radius: 10px;
  background: linear-gradient(175deg, #2a211e, #1c1513); color: var(--parchment);
  padding: 10px 16px; font-size: 16px; transition: transform .06s, background .15s;
  box-shadow: inset 0 1px 0 rgba(232,220,195,.06), 0 2px 6px rgba(0,0,0,.4);
}
.btn:active { transform: scale(.97); }
.btn-primary {
  background: linear-gradient(170deg, var(--accent-hi) 0%, var(--accent) 40%, #6e241b 100%);
  border-color: #8a2f24; color: #fff8ef; text-shadow: 0 1px 2px rgba(0,0,0,.5);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.18), 0 3px 10px rgba(126,42,32,.5);
}
.btn-primary:hover { background: linear-gradient(170deg, #e0664e 0%, var(--accent-hi) 40%, var(--accent) 100%); }
.btn-big { font-family: var(--display); letter-spacing: .04em; }
.btn-outline { background: transparent; border-color: var(--accent); color: var(--accent-hi); }
.btn-big { width: 100%; padding: 16px; font-size: 19px; margin-top: 14px; }
.btn-sm { padding: 6px 10px; font-size: 14px; border-radius: 8px; }
.btn.danger { border-color: var(--bad); color: var(--bad); background: transparent; }
.btn-back { background: none; border: none; color: var(--parchment-dim); font-size: 15px; margin-bottom: 12px; }

/* ---------- landing ---------- */
.landing-wrap { max-width: 480px; margin: 0 auto; padding: 8dvh 22px 40px; }
.landing-hero { text-align: center; margin-bottom: 30px; }
.hero-dice { font-size: 56px; filter: drop-shadow(0 0 18px rgba(176,58,46,.6)); }
.landing-hero h1 {
  font-size: 46px; margin: 8px 0 12px; font-weight: 900; letter-spacing: .06em;
  background: linear-gradient(175deg, #f3e9d2 30%, #c9a227 85%);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
  text-shadow: 0 4px 30px rgba(201,162,39,.25);
}
.landing-hero h1 span { -webkit-text-fill-color: var(--accent-hi); }
.landing-hero h1::after {
  content: '❖ ─────── ❖ ─────── ❖'; display: block; -webkit-text-fill-color: var(--border);
  font-size: 12px; letter-spacing: .2em; margin-top: 12px; font-family: var(--serif);
}
.tagline { color: var(--parchment-dim); line-height: 1.6; font-size: 17px; }

/* floating embers */
.embers { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 0; }
.embers i {
  position: absolute; bottom: -10px; width: 4px; height: 4px; border-radius: 50%;
  background: radial-gradient(circle, #ffb45e, #b03a2e 70%, transparent);
  opacity: 0; animation: emberRise linear infinite;
}
.embers i:nth-child(1)  { left: 8%;  animation-duration: 11s; animation-delay: 0s; }
.embers i:nth-child(2)  { left: 18%; animation-duration: 14s; animation-delay: 3s; width: 3px; height: 3px; }
.embers i:nth-child(3)  { left: 27%; animation-duration: 9s;  animation-delay: 6s; }
.embers i:nth-child(4)  { left: 36%; animation-duration: 16s; animation-delay: 1s; width: 5px; height: 5px; }
.embers i:nth-child(5)  { left: 47%; animation-duration: 12s; animation-delay: 8s; }
.embers i:nth-child(6)  { left: 55%; animation-duration: 10s; animation-delay: 4s; width: 3px; height: 3px; }
.embers i:nth-child(7)  { left: 64%; animation-duration: 15s; animation-delay: 2s; }
.embers i:nth-child(8)  { left: 72%; animation-duration: 11s; animation-delay: 9s; width: 5px; height: 5px; }
.embers i:nth-child(9)  { left: 81%; animation-duration: 13s; animation-delay: 5s; }
.embers i:nth-child(10) { left: 89%; animation-duration: 10s; animation-delay: 7s; width: 3px; height: 3px; }
.embers i:nth-child(11) { left: 94%; animation-duration: 17s; animation-delay: 0s; }
.embers i:nth-child(12) { left: 41%; animation-duration: 12s; animation-delay: 10s; }
@keyframes emberRise {
  0% { transform: translateY(0) translateX(0); opacity: 0; }
  8% { opacity: .9; }
  50% { transform: translateY(-55dvh) translateX(24px); opacity: .5; }
  100% { transform: translateY(-105dvh) translateX(-14px); opacity: 0; }
}
.resume-section { margin-top: 36px; border-top: 1px solid var(--border); padding-top: 18px; }
.resume-section h3 { color: var(--parchment-dim); font-size: 15px; margin-bottom: 10px; text-transform: uppercase; letter-spacing: .06em; }
.resume-item {
  width: 100%; text-align: left; display: flex; justify-content: space-between; align-items: center;
  background: var(--bg-panel); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 14px; margin-bottom: 8px; color: var(--parchment);
}
.resume-item small { color: var(--parchment-dim); display: block; }
.resume-item .code { font-family: monospace; color: var(--gold); font-size: 18px; }

/* ---------- panels / forms ---------- */
.panel { max-width: 860px; margin: 0 auto; padding: 24px 20px 60px; }
.panel.narrow { max-width: 460px; }
.panel h2 { margin-bottom: 6px; }
.code-input { font-family: monospace; font-size: 26px; letter-spacing: .35em; text-align: center; text-transform: uppercase; }
.campaign-list { display: grid; gap: 10px; }
.campaign-card {
  text-align: left; background: var(--bg-panel); border: 1px solid var(--border); border-radius: 12px;
  padding: 0; color: var(--parchment); display: flex; gap: 0; overflow: hidden;
  transition: transform .15s, border-color .2s, box-shadow .2s;
}
.campaign-card:hover { transform: translateY(-2px); box-shadow: 0 8px 22px rgba(0,0,0,.5); }
.campaign-card.selected { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold), 0 8px 24px rgba(201,162,39,.15); }
.campaign-card .cc-cover {
  width: 86px; min-height: 110px; flex: none; background-size: cover; background-position: center top;
  border-right: 1px solid var(--border);
}
.campaign-card .cc-cover.placeholder {
  display: flex; align-items: center; justify-content: center; font-size: 34px;
  background: linear-gradient(160deg, #2c1f1c, #1a1210);
}
.campaign-card .cc-body { padding: 12px 14px; }
.campaign-card strong { display: block; font-size: 17px; font-family: var(--display); letter-spacing: .02em; }
.campaign-card .cc-level { color: var(--gold); font-size: 12px; text-transform: uppercase; letter-spacing: .1em; margin: 3px 0 5px; }
.campaign-card span.cc-desc { color: var(--parchment-dim); font-size: 14px; line-height: 1.45; display: block; }
.campaign-card.selected .cc-body::before { content: '✦ chosen'; color: var(--gold); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; float: right; }
.dm-mode-picker { display: grid; gap: 8px; }
.dm-mode-card {
  text-align: left; background: var(--bg-panel); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 14px; color: var(--parchment);
}
.dm-mode-card.selected { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold); }
.dm-mode-card strong { display: block; margin-bottom: 4px; }
.dm-mode-card span { color: var(--parchment-dim); font-size: 14px; line-height: 1.35; }

/* ---------- lobby ---------- */
.lobby-header { text-align: center; margin-bottom: 22px; }
.room-code-badge {
  display: inline-block; background: var(--bg-panel); border: 1px dashed var(--gold);
  border-radius: 10px; padding: 8px 18px; margin-top: 10px; color: var(--parchment-dim);
  box-shadow: 0 0 18px rgba(201,162,39,.12), inset 0 0 12px rgba(201,162,39,.06);
}
.room-code-badge strong { color: var(--gold); font-family: monospace; font-size: 26px; letter-spacing: .25em; margin-left: 8px; }
.room-code-badge.small { padding: 4px 10px; }
.room-code-badge.small strong { font-size: 16px; letter-spacing: .15em; }
.lobby-cols { display: grid; grid-template-columns: 1fr; gap: 24px; }
@media (min-width: 760px) { .lobby-cols { grid-template-columns: 240px 1fr; } }
.lobby-players .player-row {
  display: flex; align-items: center; gap: 10px; background: var(--bg-panel);
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px;
}
.player-row .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--bad); flex: none; }
.player-row .dot.on { background: var(--ok); }
.player-row small { color: var(--parchment-dim); }
.pregen-list { display: grid; gap: 8px; }
@media (min-width: 900px) { .pregen-list { grid-template-columns: 1fr 1fr; } }
.pregen-card {
  text-align: left; background: var(--bg-panel); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 14px; color: var(--parchment);
}
.pregen-card.selected { border-color: var(--ghost); box-shadow: 0 0 0 1px var(--ghost); }
.pregen-card.taken { opacity: .45; pointer-events: none; }
.pregen-card strong { font-size: 16px; }
.pregen-card .pregen-sub { color: var(--gold); font-size: 13px; margin: 2px 0 4px; }
.pregen-card span { color: var(--parchment-dim); font-size: 13px; line-height: 1.35; font-style: italic; }
.lobby-start { margin-top: 24px; text-align: center; }

/* ---------- vitals bar (player) ---------- */
.vitals-bar {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 10px 12px calc(6px); background: var(--bg-panel); border-bottom: 1px solid var(--border);
  padding-top: max(10px, env(safe-area-inset-top));
}
.scene-chip {
  background: rgba(127,212,193,.12); color: var(--ghost); padding: 4px 10px; border-radius: 20px;
  font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 44vw; display: inline-block;
}
.scene-chip.big { font-size: 15px; max-width: none; }
.vitals-right { display: flex; gap: 8px; }
.vital {
  background: var(--bg-raise); border: 1px solid var(--border); border-radius: 10px;
  padding: 4px 10px; text-align: center; color: var(--parchment); min-width: 54px;
}
.vital .vital-label { display: block; font-size: 10px; color: var(--parchment-dim); text-transform: uppercase; letter-spacing: .08em; }
.vital.hp { border-color: var(--accent); }
.vital.dim { opacity: .7; }
#pv-hp-val { color: var(--accent-hi); font-weight: 700; }

/* ---------- tabs ---------- */
.tab-pages { flex: 1; overflow: hidden; display: flex; }
.tab-page { display: none; flex: 1; flex-direction: column; overflow: hidden; }
.tab-page.active { display: flex; }
.tab-bar {
  display: flex; border-top: 1px solid var(--border); background: var(--bg-panel);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab-btn {
  flex: 1; background: none; border: none; color: var(--parchment-dim);
  padding: 8px 0 6px; font-size: 20px; display: flex; flex-direction: column; align-items: center; gap: 1px;
}
.tab-btn span { font-size: 11px; font-family: var(--sans); }
.tab-btn.active { color: var(--accent-hi); }

/* ---------- feed ---------- */
.feed { flex: 1; overflow-y: auto; padding: 14px 12px; display: flex; flex-direction: column; gap: 10px; scroll-behavior: smooth; }
.fe { max-width: 720px; width: 100%; margin: 0 auto; animation: fadein .25s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; } }
.fe-narration {
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='p'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='2'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23p)' opacity='0.05'/%3E%3C/svg%3E"),
    linear-gradient(175deg, #f0e4c9 0%, #e5d6b3 55%, #d8c69e 100%);
  color: var(--ink);
  border-radius: 3px; padding: 16px 20px; line-height: 1.62; font-size: 17px;
  box-shadow: 0 3px 14px rgba(0,0,0,.55), inset 0 0 40px rgba(140,110,60,.14);
  border-left: 4px solid var(--accent);
  white-space: pre-wrap;
}
.fe-narration::first-letter {
  font-family: var(--display); font-size: 2.4em; font-weight: 700; float: left;
  line-height: .85; padding: 2px 8px 0 0; color: var(--accent);
}
.fe-narration.dm-note { border-left-color: var(--hag); }
.fe-chat { display: flex; gap: 8px; align-items: baseline; }
.fe-chat .who { color: var(--gold); font-weight: 600; flex: none; }
.fe-chat .txt { color: var(--parchment); }
.fe-scene {
  text-align: center; color: var(--ghost); letter-spacing: .14em; text-transform: uppercase;
  font-size: 13px; font-family: var(--display);
  display: flex; align-items: center; gap: 12px; margin: 10px 0;
}
.fe-scene::before { content: '❖ '; flex: 1; height: 1px; background: linear-gradient(90deg, transparent, var(--ghost)); opacity: .4; }
.fe-scene::after { content: ''; flex: 1; height: 1px; background: linear-gradient(90deg, var(--ghost), transparent); opacity: .4; }
.fe-system { text-align: center; color: var(--parchment-dim); font-size: 13px; font-style: italic; }
.fe-roll {
  display: flex; align-items: center; gap: 12px; background: var(--bg-panel);
  border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px;
}
.fe-roll .die { font-size: 24px; }
.fe-roll .total { font-size: 26px; font-weight: 700; min-width: 44px; text-align: center; }
.fe-roll.success { border-color: var(--ok); } .fe-roll.success .total { color: var(--ok); }
.fe-roll.failure { border-color: var(--bad); } .fe-roll.failure .total { color: var(--bad); }
.fe-roll.crit { border-color: var(--gold); box-shadow: 0 0 12px rgba(201,162,39,.35); } .fe-roll.crit .total { color: var(--gold); }
.fe-roll .meta { flex: 1; }
.fe-roll .meta .who { color: var(--gold); font-size: 14px; }
.fe-roll .meta .what { color: var(--parchment-dim); font-size: 13px; }
.fe-roll.secret { opacity: .75; border-style: dashed; }
.fe-combat { text-align: center; color: var(--accent-hi); font-size: 14px; letter-spacing: .04em; }
.fe-loot {
  background: rgba(201,162,39,.1); border: 1px solid var(--gold); border-radius: 10px; padding: 10px 14px;
}
.fe-loot strong { color: var(--gold); }
.fe-loot span { color: var(--parchment-dim); font-size: 14px; display: block; margin-top: 2px; }
.fe-handout img { width: 100%; border-radius: 8px; border: 1px solid var(--border); }
.fe-check-prompt {
  background: rgba(127,212,193,.08); border: 1px solid var(--ghost); border-radius: 10px; padding: 12px 14px;
}
.fe-check-prompt .cp-reason { color: var(--ghost); margin-bottom: 8px; }
.fe-check-prompt button { width: 100%; }
.fe-check-prompt.done { opacity: .55; }

/* ---------- suggestions / chat ---------- */
.suggestions { display: flex; gap: 8px; overflow-x: auto; padding: 8px 12px 4px; flex: none; }
.suggestions:empty { display: none; }
.sug-chip {
  flex: none; background: var(--bg-panel); border: 1px solid var(--ghost); color: var(--ghost);
  border-radius: 20px; padding: 7px 14px; font-size: 14px;
}
.chat-bar { display: flex; gap: 8px; padding: 8px 12px; border-top: 1px solid var(--border); background: var(--bg-panel); flex: none; }
.chat-bar .btn { flex: none; width: 52px; }

/* ---------- character sheet ---------- */
#ptab-sheet { overflow-y: auto; }
#sheet-content { padding: 14px; max-width: 560px; margin: 0 auto; width: 100%; }
.sheet-head { text-align: center; margin-bottom: 14px; }
.sheet-head h2 { font-size: 24px; }
.sheet-head p { color: var(--gold); }
.ability-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; margin-bottom: 14px; }
.ability-cell {
  background: var(--bg-panel); border: 1px solid var(--border); border-radius: 10px;
  padding: 8px 2px; text-align: center; color: var(--parchment);
}
.ability-cell .ab-name { font-size: 11px; color: var(--parchment-dim); text-transform: uppercase; }
.ability-cell .ab-mod { font-size: 20px; font-weight: 700; }
.ability-cell .ab-score { font-size: 11px; color: var(--parchment-dim); }
.sheet-section h4 { color: var(--parchment-dim); text-transform: uppercase; font-size: 12px; letter-spacing: .08em; margin: 14px 0 8px; }
.skill-row, .attack-row {
  display: flex; justify-content: space-between; align-items: center; width: 100%;
  background: var(--bg-panel); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 14px; margin-bottom: 6px; color: var(--parchment); font-size: 15px;
}
.skill-row .mod, .attack-row .mod { color: var(--gold); font-weight: 700; }
.skill-row.prof { border-left: 3px solid var(--gold); }
.attack-row { border-left: 3px solid var(--accent); }
.attack-row small { color: var(--parchment-dim); display: block; }
.inv-list { color: var(--parchment-dim); font-size: 14px; line-height: 1.6; }
.feature-list li { margin-left: 18px; color: var(--parchment-dim); font-size: 14px; line-height: 1.5; }

/* ---------- dice tab ---------- */
.dice-page { padding: 20px 16px; max-width: 460px; margin: 0 auto; width: 100%; overflow-y: auto; }
.roll-mode { display: flex; gap: 6px; margin-bottom: 18px; }
.mode-btn {
  flex: 1; background: var(--bg-panel); border: 1px solid var(--border); color: var(--parchment-dim);
  border-radius: 10px; padding: 10px 0; font-size: 14px;
}
.mode-btn.selected { border-color: var(--parchment); color: var(--parchment); }
.mode-btn.adv.selected { border-color: var(--ok); color: var(--ok); }
.mode-btn.dis.selected { border-color: var(--bad); color: var(--bad); }
.dice-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.die-btn {
  background: var(--bg-panel); border: 1px solid var(--border); color: var(--parchment);
  border-radius: 14px; padding: 22px 0; font-size: 22px; font-weight: 700;
}
.die-btn:active { border-color: var(--accent); color: var(--accent-hi); }
.die-btn.d20 { border-color: var(--accent); color: var(--accent-hi); }
.dice-custom { display: flex; gap: 8px; margin-top: 16px; }

/* ---------- map ---------- */
.map-wrap { flex: 1; overflow: auto; padding: 10px; text-align: center; }
.map-wrap img { max-width: 100%; border-radius: 8px; display: none; }
.map-wrap img.visible { display: inline-block; }

/* ---------- DM screen ---------- */
.dm-header {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 10px 14px; background: var(--bg-panel); border-bottom: 1px solid var(--border);
}
.dm-title { font-size: 17px; }
.dm-header-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.dm-cols { flex: 1; display: grid; grid-template-columns: 300px 1fr 320px; overflow: hidden; }
@media (max-width: 1020px) { .dm-cols { grid-template-columns: 240px 1fr; } .dm-right { display: none; } }
@media (max-width: 700px) { .dm-cols { grid-template-columns: 1fr; } .dm-scenes { display: none; } }
.dm-col { overflow-y: auto; padding: 12px; border-right: 1px solid var(--border); display: flex; flex-direction: column; }
.dm-col h3 { color: var(--parchment-dim); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; margin: 12px 0 8px; }
.dm-col h3:first-child { margin-top: 0; }
.dm-center { padding: 0; }
.dm-center .feed { padding: 14px; }
.scene-list { flex: none; max-height: 34%; overflow-y: auto; margin-bottom: 10px; }
.scene-item {
  display: block; width: 100%; text-align: left; background: none; border: none;
  color: var(--parchment-dim); padding: 6px 8px; border-radius: 6px; font-size: 14px;
}
.scene-item:hover { background: var(--bg-raise); }
.scene-item.current { color: var(--ghost); background: rgba(127,212,193,.1); }
.scene-item.visited { color: var(--parchment); }
.scene-detail { flex: 1; overflow-y: auto; font-size: 14px; }
.scene-detail .sd-read { background: #efe3c8; color: var(--ink); border-radius: 4px; padding: 10px; margin: 8px 0; line-height: 1.45; font-size: 13px; }
.scene-detail .sd-notes { color: var(--hag); background: rgba(126,87,194,.08); border: 1px solid rgba(126,87,194,.35); border-radius: 8px; padding: 10px; line-height: 1.45; font-size: 13px; margin: 8px 0; }
.scene-detail .btn { width: 100%; margin-bottom: 6px; }
.sd-action-btn { text-align: left; font-size: 13px; }
.dm-narrate { border-top: 1px solid var(--border); background: var(--bg-panel); padding: 10px 12px; }
.dm-narrate textarea { resize: vertical; }
.dm-narrate-btns { display: flex; gap: 8px; margin-top: 8px; }
.dm-entity {
  background: var(--bg-panel); border: 1px solid var(--border); border-radius: 10px;
  padding: 8px 10px; margin-bottom: 6px; font-size: 14px;
}
.dm-entity .ent-head { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.dm-entity .hp-controls { display: flex; align-items: center; gap: 4px; }
.hp-controls button {
  width: 26px; height: 26px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--bg-raise); color: var(--parchment); font-size: 15px; line-height: 1;
}
.hp-pill { font-family: monospace; font-size: 13px; min-width: 62px; text-align: center; }
.hp-bar { height: 4px; border-radius: 2px; background: var(--bg); margin-top: 6px; overflow: hidden; }
.hp-bar i { display: block; height: 100%; background: var(--ok); transition: width .3s; }
.hp-bar i.low { background: var(--bad); }
.dm-entity .ent-traits { color: var(--parchment-dim); font-size: 12px; margin-top: 5px; line-height: 1.4; display: none; }
.dm-entity.open .ent-traits { display: block; }
.dm-initiative .init-row { display: flex; gap: 8px; padding: 4px 8px; border-radius: 6px; font-size: 14px; color: var(--parchment-dim); }
.dm-initiative .init-row.current { background: rgba(176,58,46,.18); color: var(--parchment); }
.dm-initiative .init-row .init-num { color: var(--gold); font-family: monospace; min-width: 22px; }
.dm-combat-controls { display: flex; gap: 6px; flex-wrap: wrap; }
.dm-check-builder { display: grid; grid-template-columns: 1fr 64px auto; gap: 6px; }

/* ---------- table speaker view ---------- */
.btn-ghosted { background: transparent; border-color: var(--ghost); color: var(--ghost); }
.table-header {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 12px 18px; background: var(--bg-panel); border-bottom: 1px solid var(--border);
}
.table-title { font-size: 18px; color: var(--parchment-dim); }
.table-header-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.table-main { flex: 1; display: grid; grid-template-columns: 1fr; overflow: hidden; }
.table-main:has(.table-map:not(.hidden)) { grid-template-columns: 1.1fr 1fr; }
.table-feed { font-size: 19px; padding: 22px; }
.table-feed .fe-narration { font-size: 20px; line-height: 1.6; padding: 18px 22px; }
.table-feed .fe-roll .total { font-size: 32px; }
.table-map { overflow: auto; padding: 14px; border-left: 1px solid var(--border); background: #0e0b0a; }
.table-map img { width: 100%; border-radius: 8px; }
.table-start {
  position: fixed; inset: 0; background: rgba(20,16,15,.9); z-index: 70;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 30px;
}
.table-start .btn { max-width: 420px; }

/* ---------- host party controls ---------- */
.row-controls { display: flex; gap: 4px; flex: none; }
.mini-btn {
  background: var(--bg-raise); border: 1px solid var(--border); color: var(--parchment);
  border-radius: 6px; padding: 4px 8px; font-size: 13px; line-height: 1;
}
.mini-btn:hover { border-color: var(--gold); }
.mini-btn.danger { color: var(--bad); }
.mini-btn.danger:hover { border-color: var(--bad); }
.ent-actions { display: flex; gap: 4px; margin-top: 6px; }

/* ---------- animations & juice ---------- */

/* landing dice float */
.hero-dice { animation: heroFloat 3.6s ease-in-out infinite; }
@keyframes heroFloat {
  0%, 100% { transform: translateY(0) rotate(-4deg); filter: drop-shadow(0 0 18px rgba(176,58,46,.55)); }
  50% { transform: translateY(-10px) rotate(5deg); filter: drop-shadow(0 6px 26px rgba(176,58,46,.85)); }
}

/* buttons: hover glow + press squash */
.btn { transition: transform .08s, background .15s, box-shadow .2s, border-color .2s; }
.btn-primary:hover { box-shadow: 0 0 16px rgba(212,85,63,.4); }
.btn:active { transform: scale(.95); }
.die-btn { transition: transform .1s, border-color .15s, box-shadow .2s; }
.die-btn:active { transform: scale(.88) rotate(-8deg); }
.die-btn:hover { box-shadow: 0 0 12px rgba(176,58,46,.3); }

/* feed entrances */
.fe-narration { animation: unfurl .5s cubic-bezier(.2,.9,.3,1) both; transform-origin: top center; }
@keyframes unfurl { from { opacity: 0; transform: translateY(12px) scaleY(.94); } to { opacity: 1; } }
.fe-roll { animation: rollSlide .35s cubic-bezier(.2,1.4,.4,1) both; }
@keyframes rollSlide { from { opacity: 0; transform: translateX(-18px) scale(.95); } to { opacity: 1; } }
.fe-scene { animation: sceneReveal .8s ease both; }
@keyframes sceneReveal { from { opacity: 0; letter-spacing: .5em; } to { opacity: 1; letter-spacing: .12em; } }
.fe-loot { animation: lootPop .45s cubic-bezier(.2,1.5,.4,1) both; }
@keyframes lootPop { from { opacity: 0; transform: scale(.85); } to { opacity: 1; } }

/* suggestion chips: staggered pop */
.sug-chip { animation: chipPop .34s cubic-bezier(.2,1.4,.4,1) both; }
@keyframes chipPop { from { opacity: 0; transform: translateY(10px) scale(.8); } to { opacity: 1; } }
.sug-chip:active { transform: scale(.92); }

/* pending check prompts pulse until answered */
.fe-check-prompt:not(.done) { animation: promptPulse 1.8s ease-in-out infinite; }
@keyframes promptPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(127,212,193,0); }
  50% { box-shadow: 0 0 14px 2px rgba(127,212,193,.35); }
}

/* HP flash on change */
.vital.hp.hurt { animation: hpHurt .55s ease; }
@keyframes hpHurt { 0% { background: rgba(192,82,77,.55); transform: scale(1.12); } 100% { background: var(--bg-raise); } }
.vital.hp.healed { animation: hpHealed .55s ease; }
@keyframes hpHealed { 0% { background: rgba(95,158,110,.55); transform: scale(1.12); } 100% { background: var(--bg-raise); } }

/* current-turn pulse in initiative */
.dm-initiative .init-row.current { animation: turnPulse 1.6s ease-in-out infinite; }
@keyframes turnPulse { 0%,100% { background: rgba(176,58,46,.18); } 50% { background: rgba(176,58,46,.34); } }

/* screen shake on crits */
body.shake { animation: screenShake .45s cubic-bezier(.36,.07,.19,.97); }
@keyframes screenShake {
  10%, 90% { transform: translate(-2px, 1px); }
  20%, 80% { transform: translate(3px, -1px); }
  30%, 50%, 70% { transform: translate(-4px, 2px); }
  40%, 60% { transform: translate(4px, -2px); }
}

/* tab pages fade in */
.tab-page.active { animation: fadein .22s ease; }

/* ---------- dice tray (flick to roll) ---------- */
.dice-tray {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 18px 0 22px; margin-bottom: 14px; touch-action: none;
  border: 1px dashed var(--border); border-radius: 16px;
  background: radial-gradient(ellipse at center, rgba(176,58,46,.08), transparent 70%);
}
.tray-die {
  width: 108px; height: 108px; position: relative; cursor: grab;
  display: flex; align-items: center; justify-content: center;
  user-select: none; -webkit-user-select: none; will-change: transform;
}
.tray-die:active { cursor: grabbing; }
.tray-die-shape {
  position: absolute; inset: 6px;
  background: linear-gradient(150deg, #3a2622, #241614);
  border: 2px solid var(--accent);
  clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
  box-shadow: 0 0 22px rgba(176,58,46,.35);
  transition: box-shadow .2s;
}
.tray-die-label { position: relative; font-size: 26px; font-weight: 800; color: var(--parchment); text-shadow: 0 0 10px rgba(212,85,63,.8); pointer-events: none; }
.tray-die.idle { animation: dieIdle 3s ease-in-out infinite; }
@keyframes dieIdle { 0%,100% { transform: rotate(-3deg); } 50% { transform: rotate(3deg) translateY(-3px); } }
.tray-die.thrown { animation: dieThrow .8s cubic-bezier(.2,.8,.3,1); }
@keyframes dieThrow {
  0% { transform: translateY(0) rotate(0) scale(1); }
  35% { transform: translateY(-90px) rotate(400deg) scale(.8); }
  70% { transform: translateY(8px) rotate(690deg) scale(1.05); }
  85% { transform: translateY(-6px) rotate(714deg) scale(.98); }
  100% { transform: translateY(0) rotate(720deg) scale(1); }
}
.tray-hint { margin-top: 6px; }

/* ---------- roll overlay ---------- */
.roll-overlay {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  pointer-events: none; z-index: 90;
}
.roll-card {
  position: relative; overflow: visible;
  background: rgba(20,16,15,.92); border: 1px solid var(--border); border-radius: 18px;
  padding: 26px 42px; text-align: center; backdrop-filter: blur(6px);
  box-shadow: 0 10px 50px rgba(0,0,0,.7); animation: rollpop .3s cubic-bezier(.2,1.6,.4,1);
}
@keyframes rollpop { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.ro-actor { color: var(--gold); font-size: 16px; margin-bottom: 4px; }
.ro-die { font-size: 54px; line-height: 1; margin-bottom: 4px; display: inline-block; }
.roll-card.rolling .ro-die { animation: dieTumble .38s linear infinite; }
@keyframes dieTumble {
  0% { transform: rotate(0deg) translateY(0) scale(1); }
  25% { transform: rotate(90deg) translateY(-10px) scale(1.12); }
  50% { transform: rotate(180deg) translateY(0) scale(.94); }
  75% { transform: rotate(270deg) translateY(-6px) scale(1.06); }
  100% { transform: rotate(360deg) translateY(0) scale(1); }
}
.roll-card.rolling .ro-total { color: var(--parchment-dim); filter: blur(1px); }
.ro-total.revealed { animation: totalSlam .35s cubic-bezier(.2,1.6,.4,1); }
@keyframes totalSlam { 0% { transform: scale(2.1); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
.roll-particle {
  position: absolute; left: 50%; top: 45%; width: 7px; height: 7px; border-radius: 50%;
  background: var(--clr, var(--gold)); pointer-events: none;
  animation: particleBurst .85s ease-out forwards;
}
@keyframes particleBurst {
  0% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  100% { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(.2); opacity: 0; }
}
.ro-total { font-size: 74px; font-weight: 900; line-height: 1; font-family: var(--display); }
.ro-total.crit { color: var(--gold); text-shadow: 0 0 24px rgba(201,162,39,.8); }
.ro-total.fumble { color: var(--bad); }
.ro-detail { color: var(--parchment-dim); font-size: 14px; margin-top: 6px; font-family: monospace; }
.ro-outcome { font-size: 18px; margin-top: 8px; letter-spacing: .1em; text-transform: uppercase; }
.ro-outcome.success { color: var(--ok); } .ro-outcome.failure { color: var(--bad); }

/* ---------- modal / toast ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.7); z-index: 80;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal-box {
  background: var(--bg-panel); border: 1px solid var(--border); border-radius: 14px;
  padding: 20px; max-width: 440px; width: 100%; max-height: 86dvh; overflow-y: auto;
}
.modal-box h3 { margin-bottom: 12px; }
.modal-box .hp-adjust { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 10px 0; }
.toast {
  position: fixed; bottom: 84px; left: 50%; transform: translateX(-50%);
  background: var(--bg-panel); border: 1px solid var(--gold); color: var(--parchment);
  border-radius: 10px; padding: 10px 18px; z-index: 95; font-size: 14px; max-width: 90vw;
}
