/* ============================================================
   DnD Forever — hearthlit design system
   Palette: smoke #211C17 · oak #2C251E · iron #4A3F32
            vellum #E8DFCE · ash #9C8F7A · ember #C9772E
            woad #5E7E9B · rust #A34733
   ============================================================ */

:root {
  --smoke:  #211C17;
  --oak:    #2C251E;
  --oak-2:  #362E25;
  --iron:   #4A3F32;
  --vellum: #E8DFCE;
  --ash:    #9C8F7A;
  --ember:  #C9772E;
  --ember-2:#E09550;
  --woad:   #5E7E9B;
  --rust:   #A34733;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--smoke);
  color: var(--vellum);
  font-family: 'Alegreya', Georgia, serif;
  font-size: 17px;
  line-height: 1.6;
  min-height: 100vh;
}

h1, h2, h3 { font-family: 'IM Fell English', serif; font-weight: 400; letter-spacing: .02em; }
h1 { font-size: 2rem;   margin: 0 0 .25rem; }
h2 { font-size: 1.4rem; margin: 0 0 1rem; }
h3 { font-size: 1.15rem; margin: 0 0 .5rem; }

.rule-ember {
  height: 2px; border: 0; margin: .35rem 0 1.25rem;
  background: linear-gradient(90deg, var(--ember), transparent 70%);
}

a { color: var(--ember-2); text-decoration: none; }
a:hover { text-decoration: underline; }

.mono, .stat { font-family: 'IBM Plex Mono', monospace; font-size: .85em; }
.muted { color: var(--ash); }
.small { font-size: .85rem; }

/* ── Layout ─────────────────────────────────────────────── */
.site-header {
  display: flex; align-items: baseline; gap: 1.5rem;
  padding: 1rem 2rem; border-bottom: 1px solid var(--iron);
}
.site-header .brand { font-family: 'IM Fell English', serif; font-size: 1.3rem; color: var(--vellum); }
.site-header nav { margin-left: auto; display: flex; gap: 1.25rem; align-items: baseline; }

.wrap        { max-width: 1440px; margin: 0 auto; padding: 2rem; }
.wrap-narrow { max-width: 460px;  margin: 6vh auto; padding: 0 1.25rem; }

.cols { display: grid; grid-template-columns: 1fr 340px; gap: 2rem; align-items: start; }
@media (max-width: 860px) { .cols { grid-template-columns: 1fr; } }

/* ── Page & section heads (so no text floats bare on the art) ── */
.page-head { margin-bottom: 1.25rem; }
.page-head h1 { margin-top: 0; }
.page-head .rule-ember { margin-bottom: .9rem; }
.page-head > :last-child { margin-bottom: 0; }

/* Section headers (h2) sit INSIDE the panel that holds their
   content — never as a detached strip over the background art. */

/* ── Panels (iron-riveted) ──────────────────────────────── */
.panel {
  background: var(--oak);
  border: 1px solid var(--iron);
  border-radius: 3px;
  padding: 1.5rem;
  background-image:
    radial-gradient(circle 2px at 9px 9px,               var(--iron) 2px, transparent 3px),
    radial-gradient(circle 2px at calc(100% - 9px) 9px,  var(--iron) 2px, transparent 3px),
    radial-gradient(circle 2px at 9px calc(100% - 9px),  var(--iron) 2px, transparent 3px),
    radial-gradient(circle 2px at calc(100% - 9px) calc(100% - 9px), var(--iron) 2px, transparent 3px);
}
.panel + .panel { margin-top: 1.25rem; }

/* ── Forms ──────────────────────────────────────────────── */
label { display: block; margin: .9rem 0 .25rem; color: var(--ash); font-size: .9rem; }
input[type=text], input[type=password], input[type=email], input[type=number], select, textarea {
  width: 100%;
  background: #17130F;
  border: 1px solid var(--iron);
  border-radius: 3px;
  color: var(--vellum);
  font: inherit;
  padding: .55rem .7rem;
}
textarea { min-height: 90px; resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--woad); outline-offset: 1px;
}
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1.25rem; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 1.25rem; }
@media (max-width: 640px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

.check-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: .3rem 1rem; margin-top: .4rem;
}
@media (max-width: 640px) { .check-grid { grid-template-columns: 1fr 1fr; } }
.check-grid label { display: flex; gap: .45rem; align-items: center; margin: 0; color: var(--vellum); font-size: .95rem; }

/* ── Buttons ────────────────────────────────────────────── */
button, .btn {
  display: inline-block;
  font: inherit; font-size: .95rem;
  padding: .55rem 1.2rem;
  border-radius: 3px;
  border: 1px solid var(--ember);
  background: var(--ember);
  color: #1A130B;
  cursor: pointer;
}
button:hover, .btn:hover { background: var(--ember-2); border-color: var(--ember-2); text-decoration: none; }
.btn-ghost { background: transparent; color: var(--ember-2); }
.btn-ghost:hover { background: rgba(201,119,46,.12); }
.btn-danger { background: transparent; border-color: var(--rust); color: #D08A77; }
.btn-danger:hover { background: rgba(163,71,51,.15); }
.btn-row { display: flex; gap: .75rem; margin-top: 1.5rem; flex-wrap: wrap; align-items: center; }

/* ── Cards ──────────────────────────────────────────────── */
/* Campaign cards share ONE panel with their "Campaigns" header;
   a rule between cards keeps them readable inside it. */
.card-campaign { display: grid; grid-template-columns: 84px 1fr auto; gap: 1.25rem; align-items: center; padding: 1.1rem 0; border-top: 1px solid var(--iron); }
.card-campaign:last-of-type { padding-bottom: .35rem; }
.card-campaign .day {
  text-align: center; border-right: 1px solid var(--iron); padding-right: 1rem;
}
.card-campaign .day .n { font-family: 'IM Fell English', serif; font-size: 2rem; color: var(--ember-2); line-height: 1; }
.card-campaign .day .l { font-size: .7rem; letter-spacing: .12em; text-transform: uppercase; color: var(--ash); }

.roster-item { padding: .8rem 0; border-bottom: 1px solid var(--iron); }
.roster-item:last-child { border-bottom: 0; }

/* ── Quick stats: small labeled boxes under a character ──── */
.quick-stats { display: flex; flex-wrap: wrap; gap: .5rem; margin: .55rem 0 .35rem; }
.qstat {
  min-width: 72px; padding: .3rem .7rem .4rem;
  text-align: center;
  background: var(--oak-2);
  border: 1px solid var(--iron);
  border-radius: 3px;
}
.qstat .qlabel {
  display: block; font-size: .6rem; letter-spacing: .12em;
  text-transform: uppercase; color: var(--ash);
  margin-bottom: .15rem; white-space: nowrap;
}
.qstat .qval {
  font-family: 'IBM Plex Mono', monospace; font-size: .95rem;
  color: var(--vellum); white-space: nowrap;
}
.qstat.low .qval { color: #D08A77; }

/* Class resources line under a party member — labeled so the
   numbers (hit dice, second wind, …) explain themselves. */
.res-line { margin-top: .35rem; }
.res-label {
  display: inline-block; margin-right: .35rem;
  font-size: .6rem; letter-spacing: .12em; text-transform: uppercase;
  color: var(--ash);
}

/* "Your gear" — an expandable section under the player's character */
.gear-details { margin-top: .55rem; }
.gear-details summary {
  cursor: pointer;
  font-family: 'IM Fell English', serif;
  font-size: 1.05rem;
  color: var(--vellum);
  padding: .15rem 0;
}
.gear-details summary:hover { color: var(--ember-2); }
.gear-details[open] summary { margin-bottom: .25rem; }

.badge {
  display: inline-block; font-size: .7rem; letter-spacing: .1em; text-transform: uppercase;
  border: 1px solid var(--iron); border-radius: 2px; padding: .1rem .45rem; color: var(--ash);
}
.badge-ember { border-color: var(--ember); color: var(--ember-2); }

/* ── Messages ───────────────────────────────────────────── */
/* Solid base color first, tint on top — flashes often sit directly
   over the background art, so they need their own opaque panel. */
.flash       { border: 1px solid var(--woad); background: #202A33; padding: .7rem 1rem; border-radius: 3px; margin-bottom: 1.25rem; }
.flash-error { border-color: var(--rust); background: #33211B; }

/* ── Builder steps ──────────────────────────────────────── */
.builder { display: grid; grid-template-columns: 200px 1fr; gap: 2rem; align-items: start; }
/* On a narrow screen the rail stops being a sidebar and becomes a
   scrollable strip of tabs above the step — nine stacked list items
   would push the actual form off the bottom of the phone. */
@media (max-width: 780px) {
  .builder { grid-template-columns: 1fr; gap: 1rem; }
  .steprail {
    position: static; display: flex; gap: .3rem; padding: .45rem;
    overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: thin;
  }
  .steprail li {
    flex: 0 0 auto; margin: 0; white-space: nowrap;
    padding: .35rem .55rem; font-size: .82rem;
    border-left: none; border-bottom: 2px solid var(--iron);
  }
  .steprail li.done   { border-bottom-color: var(--ash); }
  .steprail li.active { border-bottom-color: var(--ember); }
}
.steprail {
  list-style: none; margin: 0; position: sticky; top: 1rem;
  background: var(--oak); border: 1px solid var(--iron);
  border-radius: 3px; padding: .75rem;
}
.steprail li {
  padding: .5rem .75rem; margin-bottom: .25rem; border-left: 2px solid var(--iron);
  color: var(--ash); font-size: .92rem; cursor: default;
}
.steprail li.done   { color: var(--vellum); border-left-color: var(--ash); }
.steprail li.active { color: var(--ember-2); border-left-color: var(--ember); }
.step { display: none; }
.step.active { display: block; }

.mod-pill {
  display: inline-block; min-width: 2.6em; text-align: center;
  font-family: 'IBM Plex Mono', monospace; font-size: .85rem;
  color: var(--ember-2); margin-left: .5rem;
}

/* ── Review charter ─────────────────────────────────────── */
.charter { border: 1px double var(--iron); padding: 1.25rem 1.5rem; background: var(--oak-2); }
.charter dt { color: var(--ash); font-size: .8rem; letter-spacing: .08em; text-transform: uppercase; margin-top: .7rem; }
.charter dd { margin: 0; }

@media (prefers-reduced-motion: no-preference) {
  .step.active { animation: stepin .18s ease-out; }
  @keyframes stepin { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
}

/* ── Play: the story pane ───────────────────────────────── */
.game-main { min-width: 0; }
.story {
  height: 62vh; overflow-y: auto;
  scroll-behavior: smooth;
}
.msg { margin: 0 0 1.15rem; }
.msg-player { color: var(--ember-2); }
.msg-player::before {
  content: "You — ";
  color: var(--ash); font-size: .72rem;
  letter-spacing: .1em; text-transform: uppercase;
}
.mech {
  font-family: 'IBM Plex Mono', monospace;
  font-size: .82em;
  color: var(--ember-2);
  background: rgba(201,119,46,.09);
  border: 1px solid rgba(201,119,46,.35);
  border-radius: 2px;
  padding: .05rem .4rem;
  white-space: nowrap;
}
.beginwrap { text-align: center; padding: 4rem 1rem; }

/* The action bar: dice, advantage toggle, modifier, Illustrate —
   one strip right above the composer */
.action-bar {
  display: flex; gap: .55rem; align-items: center; flex-wrap: wrap;
  margin: 0 0 .5rem; padding: .45rem .6rem;
  background: rgba(255, 255, 255, .02);
  border: 1px solid rgba(201, 119, 46, .18); border-radius: 10px;
}
.action-bar .spacer { flex: 1; }
.dice-group { display: flex; gap: .35rem; flex-wrap: wrap; }
.die {
  min-width: 46px; padding: .45rem .3rem;
  font-family: 'IBM Plex Mono', monospace; font-size: .8rem;
  color: var(--vellum); cursor: pointer;
  background: linear-gradient(180deg, rgba(255,255,255,.07), rgba(0,0,0,.28));
  border: 1px solid var(--iron); border-radius: 8px;
  transition: transform .12s, border-color .12s, color .12s, box-shadow .12s;
}
.die:hover {
  border-color: var(--ember); color: var(--ember-2);
  transform: translateY(-2px);
  box-shadow: 0 3px 10px rgba(0,0,0,.45), 0 0 8px rgba(201,119,46,.35);
}
.die.rolled { animation: dieroll .45s ease; }
@keyframes dieroll {
  0%   { transform: rotate(0deg)   scale(1); }
  30%  { transform: rotate(-14deg) scale(1.12); }
  60%  { transform: rotate(10deg)  scale(1.05); }
  100% { transform: rotate(0deg)   scale(1); }
}

/* Advantage / disadvantage — a segmented switch */
.adv-toggle {
  display: inline-flex; border: 1px solid var(--iron);
  border-radius: 8px; overflow: hidden;
}
.adv-toggle button {
  background: transparent; border: none; cursor: pointer;
  color: var(--vellum); font-size: .75rem; padding: .4rem .6rem;
}
.adv-toggle button + button { border-left: 1px solid var(--iron); }
.adv-toggle button.on {
  background: rgba(201, 119, 46, .2); color: var(--ember-2);
  box-shadow: inset 0 0 6px rgba(0, 0, 0, .45);
}
.mod-wrap { display: inline-flex; align-items: center; gap: .35rem; }
.mod-wrap input { width: 64px; }

.sayrow { display: flex; gap: .6rem; align-items: flex-end; }
.sayrow textarea { min-height: 56px; }

#thinking { display: none; color: var(--ash); font-style: italic; margin: 0 0 .6rem; }
#thinking.on { display: block; }
#thinking.on::after { content: '…'; }
@media (prefers-reduced-motion: no-preference) {
  #thinking.on::after { animation: think 1.2s steps(4, end) infinite; }
  @keyframes think { 0% { content: ''; } 25% { content: '.'; } 50% { content: '..'; } 75% { content: '...'; } }
}

/* ── Live sheet ──────────────────────────────────────────── */
.hpbar {
  height: 6px; margin: .35rem 0 .25rem;
  background: #17130F; border: 1px solid var(--iron); border-radius: 2px;
}
.hpfill { height: 100%; background: var(--ember); transition: width .4s ease; }
.hpfill.low { background: var(--rust); }
.invlist { margin: .3rem 0 0; padding-left: 1.1rem; }
.invlist li { margin: .1rem 0; }

/* ── Forge: pool, assignment, spells, modal ─────────────── */
.chips { display: flex; flex-wrap: wrap; gap: .45rem; margin: .75rem 0; min-height: 1.5rem; }
.chip {
  display: inline-block; padding: .25rem .7rem;
  font-family: 'IBM Plex Mono', monospace; font-size: .95rem;
  background: var(--oak-2); border: 1px solid var(--iron); border-radius: 3px;
}
.chip.used { opacity: .35; }
.chip a { color: var(--rust); margin-left: .3rem; text-decoration: none; }

.assignrow {
  display: grid; grid-template-columns: 120px 90px 1fr 110px;
  gap: .75rem; align-items: center; margin: .4rem 0;
}
.assignrow label { margin: 0; color: var(--vellum); }
@media (max-width: 640px) { .assignrow { grid-template-columns: 90px 80px 1fr 90px; } }

.pill {
  font-family: 'IBM Plex Mono', monospace; font-size: .72rem;
  border: 1px solid var(--iron); border-radius: 2px;
  padding: .1rem .45rem; color: var(--ember-2); margin-left: .5rem;
}

.acbox { border-left: 2px solid var(--ember); padding-left: 1.25rem; }

.spell-cols { columns: 2 260px; column-gap: 2rem; }
.spell-item {
  display: block; break-inside: avoid; margin: .25rem 0;
  color: var(--vellum); font-size: .95rem;
}
.spell-item input { margin-right: .4rem; }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15,12,9,.75);
  display: flex; align-items: center; justify-content: center; z-index: 40;
  padding: 1rem;
}
.modal { max-width: 640px; max-height: 82vh; overflow-y: auto; width: 100%; }

.ledger { width: 100%; border-collapse: collapse; font-size: .92rem; }
.ledger th {
  text-align: left; color: var(--ash); font-weight: 400; font-size: .72rem;
  letter-spacing: .1em; text-transform: uppercase;
  border-bottom: 1px solid var(--iron); padding: .35rem .6rem .35rem 0;
}
.ledger td { border-bottom: 1px solid rgba(74,63,50,.4); padding: .5rem .6rem .5rem 0; vertical-align: middle; }
.ledger tr:last-child td { border-bottom: 0; }

/* ── Campaign options & the Hall ─────────────────────────── */
.theme-grid {
  display: grid; grid-template-columns: 1fr 70px 70px 70px;
  gap: .3rem .5rem; align-items: center; margin: .5rem 0 1rem;
}
.theme-grid .th-col { text-align: center; font-size: .72rem; letter-spacing: .08em;
  text-transform: uppercase; color: var(--ash); }
.theme-grid span:not(.th-col) { font-size: .95rem; }
.mode-opt { display: block; color: var(--vellum); margin: .5rem 0; }
.mode-opt input { margin-right: .45rem; }
.tomb h2 { color: var(--ember-2); }

/* ── Character sheet tabs ────────────────────────────────── */
.tabbtn {
  background: transparent; color: var(--ash);
  border: 1px solid var(--iron); padding: .4rem 1rem;
}
.tabbtn:hover { background: transparent; color: var(--ember-2); border-color: var(--ember); }
.tabbtn.active { color: var(--ember-2); border-color: var(--ember); background: rgba(201,119,46,.08); }
.tab { display: none; }
.tab.active { display: block; }
.statline { display: flex; flex-wrap: wrap; gap: 1.75rem; }
.statline .l {
  display: block; font-size: .68rem; letter-spacing: .12em;
  text-transform: uppercase; color: var(--ash);
}
.statline .stat { font-size: 1.15rem; }

/* ══ App shell: background art, sidebar, mobile drawer ═════ */
/* Built on the owner's design: fixed art + vignette + glassy panel. */
body { background: #14100C; }
.global-bg {
  position: fixed; inset: 0; z-index: -2;
  background: url('../Images/bg_1920.jpg') center / cover no-repeat #14100C;
}
.global-bg::after {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(circle, rgba(15,13,10,.45) 20%, rgba(10,9,7,.96) 100%);
}

/* NOTE: no z-index here. Giving .app-layout its own z-index creates a
   stacking context that traps the mobile drawer (z-index 50) beneath the
   page-level backdrop (z-index 40) — the open menu then renders dimmed
   and every tap lands on the backdrop, which just closes it again.
   Content still paints above .global-bg because that layer is at z -2. */
.app-layout { display: flex; min-height: 100vh; position: relative; }

.app-sidebar {
  width: 260px; flex: 0 0 260px;
  background: rgba(18,15,12,.88);
  border-right: 1px solid var(--iron);
  box-shadow: 2px 0 10px rgba(0,0,0,.5);
  backdrop-filter: blur(4px);
  padding: 1.5rem 1.25rem;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.app-sidebar .brand, .topbar .brand {
  font-family: 'IM Fell English', serif; font-size: 1.4rem; color: var(--vellum);
}
.app-sidebar nav ul { list-style: none; margin: 1rem 0 0; padding: 0; }
.app-sidebar nav a {
  display: block; padding: .6rem .65rem; color: var(--ash);
  border-left: 2px solid transparent; border-radius: 2px;
}
.app-sidebar nav a:hover {
  color: var(--vellum); border-left-color: var(--ember);
  background: rgba(201,119,46,.08); text-decoration: none;
}
.side-account { margin-top: auto; padding-top: 1rem; border-top: 1px solid var(--iron); }
.credit-chip { margin: .5rem 0 .25rem; }
.side-leave { width: 100%; text-align: center; display: block; margin-top: 1rem; box-sizing: border-box; }

.app-main { flex: 1 1 auto; min-width: 0; }

.topbar { display: none; }
.backdrop { display: none; }

/* ── Landing (sign-in / join) over the art ── */
.landing-head { text-align: center; }
.landing-head h1 { margin-bottom: .25rem; }
.landing-header { text-shadow: 2px 2px 5px rgba(0,0,0,.9); }
.seo-pitch {
  background: rgba(20,18,15,.88);
  border: 1px solid var(--iron);
  padding: 1.25rem 1.5rem; border-radius: 4px;
  margin-bottom: 1.5rem; text-align: center;
  box-shadow: 0 4px 15px rgba(0,0,0,.5);
}
.seo-pitch p { margin: 0; line-height: 1.6; }
.seo-pitch strong { color: var(--vellum); }

/* ── Mobile: topbar + off-canvas drawer + touch comfort ── */
@media (max-width: 880px) {
  .global-bg { background-image: url('../Images/bg_900.jpg'); }

  .topbar {
    display: flex; align-items: center; gap: .9rem;
    position: sticky; top: 0; z-index: 30;
    background: rgba(18,15,12,.92); backdrop-filter: blur(4px);
    border-bottom: 1px solid var(--iron);
    padding: .55rem .9rem;
    padding-top: calc(.55rem + env(safe-area-inset-top));
  }
  .navtoggle {
    background: transparent; border: 1px solid var(--iron);
    color: var(--vellum); font-size: 1.15rem; padding: .25rem .7rem; min-height: 40px;
  }

  .app-sidebar {
    position: fixed; top: 0; left: 0; z-index: 50;
    height: 100vh; height: 100dvh; width: min(80vw, 300px);
    transform: translateX(-105%); transition: transform .22s ease;
  }
  .app-sidebar.open { transform: none; }
  .backdrop.on {
    display: block; position: fixed; inset: 0; z-index: 40;
    background: rgba(8,7,5,.6);
  }
  body.nav-open { overflow: hidden; }

  .wrap { padding: 1.1rem; }
  .wrap-narrow { margin: 3vh auto; }
  .cols { gap: 1.25rem; }

  /* Touch comfort: no iOS zoom, honest tap targets. */
  input, select, textarea, button, .btn { font-size: 16px; }
  button, .btn { min-height: 44px; }
  .die, .navtoggle, .tabbtn { min-height: 40px; }
  .story { height: 52vh; }
  .card-campaign { grid-template-columns: 64px 1fr; }
  .card-campaign > .btn-row { grid-column: 1 / -1; }

  /* Wide tables scroll sideways instead of breaking the page. */
  .ledger { display: block; overflow-x: auto; }
}
@media (prefers-reduced-motion: reduce) {
  .app-sidebar { transition: none; }
}

.side-panel-menu li a {
  display: block;
  padding: 0.4rem 0.5rem;
  color: inherit;
  text-decoration: none;
  border-radius: 4px;
  transition: background 0.15s ease;
}

.side-panel-menu li a:hover {
  background: rgba(255, 255, 255, 0.06);
}

/* ── D&D Beyond Style Sheet ─────────────────────────────── */
.dndb-sheet { background: #222; color: #eee; font-family: 'Alegreya', serif; padding: 1.5rem; border-radius: 4px; border: 1px solid var(--iron); box-shadow: 0 4px 20px rgba(0,0,0,0.5); }
.dndb-header { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 2px solid var(--iron); padding-bottom: 1rem; margin-bottom: 1.5rem; }
.dndb-header h1 { margin: 0; color: #fff; line-height: 1.1; }
.dndb-meta { font-size: 0.9rem; color: #aaa; margin-top: 0.25rem; }

.dndb-top-stats { display: flex; flex-wrap: wrap; gap: 0.75rem; justify-content: space-between; margin-bottom: 1.5rem; }
.dndb-box { background: #fff; color: #000; border: 2px solid #ccc; border-radius: 6px; text-align: center; padding: 0.5rem; min-width: 75px; display: flex; flex-direction: column; align-items: center; justify-content: center; position: relative; box-shadow: inset 0 0 5px rgba(0,0,0,0.1); }
.dndb-box .label { font-size: 0.65rem; font-weight: 700; text-transform: uppercase; color: #666; margin-top: auto; letter-spacing: 0.05em; font-family: 'IBM Plex Mono', monospace; }
.dndb-box .val { font-size: 1.8rem; line-height: 1; font-weight: bold; font-family: 'IM Fell English', serif; }
.dndb-box.ability { padding: 0.5rem 0.5rem 1rem; border-radius: 8px; border-width: 3px; min-width: 85px; }
.dndb-box.ability .val { font-size: 2.2rem; margin: 0.2rem 0; }
.dndb-box.ability .score { border: 2px solid #ccc; border-radius: 12px; font-size: 0.85rem; font-weight: bold; padding: 0.1rem 0.6rem; position: absolute; bottom: -12px; background: #fff; font-family: 'IBM Plex Mono', monospace; }
.dndb-box.hp { min-width: 150px; }

.dndb-main { display: grid; grid-template-columns: 240px 260px 1fr; gap: 1.25rem; }
@media (max-width: 960px) { .dndb-main { grid-template-columns: 1fr; } }
.dndb-col { display: flex; flex-direction: column; gap: 1rem; }
.dndb-panel { background: #f8f8f8; color: #111; border: 1px solid #ccc; border-radius: 6px; padding: 1rem; box-shadow: inset 0 0 10px rgba(0,0,0,0.05); }
.dndb-panel h3 { font-size: 0.8rem; text-transform: uppercase; color: #555; border-bottom: 2px solid #ddd; margin: 0 0 0.75rem; padding-bottom: 0.25rem; font-family: 'IBM Plex Mono', monospace; font-weight: bold; letter-spacing: 0.05em; }

.dndb-skill-row { display: flex; align-items: center; justify-content: space-between; font-size: 0.9rem; padding: 0.35rem 0; border-bottom: 1px solid #eee; }
.dndb-skill-row .prof { width: 12px; height: 12px; border-radius: 50%; border: 2px solid #aaa; display: inline-block; margin-right: 0.5rem; }
.dndb-skill-row.proficient .prof { background: #222; border-color: #222; }
.dndb-skill-row .name { flex: 1; }
.dndb-skill-row .attr { font-size: 0.7rem; color: #888; text-transform: uppercase; margin-right: 0.5rem; width: 25px; }
.dndb-skill-row .bonus { font-weight: bold; width: 25px; text-align: right; font-family: 'IBM Plex Mono', monospace; }

.dndb-tabs { display: flex; gap: 1.25rem; border-bottom: 2px solid #444; margin-bottom: 1rem; flex-wrap: wrap; }
.dndb-tab { font-size: 0.85rem; font-weight: bold; text-transform: uppercase; color: #aaa; cursor: pointer; padding-bottom: 0.4rem; border-bottom: 3px solid transparent; margin-bottom: -2.5px; font-family: 'IBM Plex Mono', monospace; }
.dndb-tab.active, .dndb-tab:hover { color: #fff; border-bottom-color: #fff; }
.dndb-tab-content { display: none; color: #fff; }
.dndb-tab-content.active { display: block; }
.dndb-tab-content .roster-item strong { color: #fff; }

/* ── Sheet: senses & proficiencies (left column) ─────────── */
.dndb-sense-row {
  display: flex; align-items: center; gap: .6rem;
  font-size: .9rem; padding: .35rem 0; border-bottom: 1px solid #eee;
}
.dndb-sense-row:last-child { border-bottom: 0; }
.dndb-sense-row .sn {
  min-width: 2.2rem; text-align: center; font-weight: bold;
  font-family: 'IBM Plex Mono', monospace;
  border: 2px solid #ccc; border-radius: 10px; padding: .05rem .3rem; background: #fff;
}
.dndb-prof-group {
  font-size: .85rem; padding: .45rem 0; border-bottom: 1px solid #eee;
}
.dndb-prof-group .pl {
  display: block; font-size: .62rem; letter-spacing: .1em; text-transform: uppercase;
  color: #888; font-family: 'IBM Plex Mono', monospace; margin-bottom: .1rem;
}

/* ── Sheet: the Actions tab ──────────────────────────────── */
.dndb-attack-head, .dndb-attack-row {
  display: grid; grid-template-columns: 1.4fr .6fr .5fr 1.2fr;
  gap: .6rem; align-items: center; padding: .45rem 0;
}
.dndb-attack-head {
  font-size: .68rem; letter-spacing: .1em; text-transform: uppercase; color: #888;
  font-family: 'IBM Plex Mono', monospace; border-bottom: 2px solid #444;
}
.dndb-attack-row { border-bottom: 1px solid #333; }
.atk-sub  { font-size: .78rem; color: #999; }
.atk-pill {
  display: inline-block; font-family: 'IBM Plex Mono', monospace; font-size: .85rem;
  border: 1px solid #555; border-radius: 6px; padding: .1rem .5rem; color: #fff;
  background: rgba(255,255,255,.04); white-space: nowrap;
}

/* ── Sheet: the interactive Inventory tab ────────────────── */
.inv-weight { margin-bottom: 1rem; }
.inv-weight-line { display: flex; justify-content: space-between; font-size: .85rem; color: #ccc; }
.inv-weight-bar {
  height: 6px; margin-top: .3rem; background: #17130F;
  border: 1px solid #444; border-radius: 2px;
}
.inv-weight-fill { height: 100%; background: var(--ember); transition: width .3s ease; }
.inv-weight.over .inv-weight-fill { background: var(--rust); }
.inv-weight.over .inv-weight-line { color: #D08A77; }

.inv-h {
  color: #aaa; margin: 1rem 0 0; border-bottom: 1px solid #444;
  padding-bottom: .25rem; font-size: .8rem; text-transform: uppercase;
  letter-spacing: .08em; font-family: 'IBM Plex Mono', monospace;
}
.inv-row {
  display: flex; gap: .75rem; align-items: flex-start; justify-content: space-between;
  padding: .55rem 0; border-bottom: 1px solid #333;
}
.inv-row.inv-sub { margin-left: 1.5rem; border-left: 2px solid #444; padding-left: .75rem; }
.inv-main { min-width: 0; }
.inv-w { font-size: .75rem; color: #888; margin-left: .5rem; font-family: 'IBM Plex Mono', monospace; }
.inv-controls { display: flex; gap: .4rem; align-items: center; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; }
.inv-controls select {
  width: auto; padding: .25rem .4rem; font-size: .78rem; max-width: 150px;
}
.btn-danger.small { padding: .25rem .6rem; font-size: .8rem; }
@media (max-width: 700px) {
  .inv-row { flex-direction: column; gap: .4rem; }
  .inv-controls { justify-content: flex-start; }
  .dndb-attack-head { display: none; }
  .dndb-attack-row { grid-template-columns: 1fr 1fr; }
}

.global-sheet-modal { position: fixed; inset: 0; background: rgba(0,0,0,0.85); z-index: 1000; display: none; align-items: center; justify-content: center; padding: 2rem; backdrop-filter: blur(6px); }
.global-sheet-modal.open { display: flex; }
.global-sheet-content { background: #222; width: 100%; max-width: 1200px; max-height: 90vh; overflow-y: auto; border-radius: 8px; box-shadow: 0 15px 50px rgba(0,0,0,0.9); position: relative; }
.global-sheet-close { position: absolute; top: 1.5rem; right: 1.5rem; background: transparent; color: #aaa; border: 1px solid #aaa; padding: 0.35rem 0.8rem; cursor: pointer; border-radius: 4px; font-weight: bold; text-transform: uppercase; font-size: 0.8rem; transition: 0.2s; }
.global-sheet-close:hover { background: #fff; color: #000; }

/* ── Media: narration, illustrations, portraits ─────────────
   (voice picker on account.php; 🔊 + offer cards + Illustrate
   modal on play.php; portrait column on character-sheet.php) */

/* The 🔊 read-aloud button on DM messages */
.speak-btn {
  float: right; margin: 0 0 .25rem .6rem; padding: .1rem .45rem;
  background: transparent; border: 1px solid rgba(201,119,46,.35);
  border-radius: 6px; font-size: .85rem; line-height: 1.4;
  cursor: pointer; opacity: .55; transition: opacity .15s;
}
.msg:hover .speak-btn { opacity: 1; }
.speak-btn.speaking { opacity: 1; border-color: var(--ember-2);
  box-shadow: 0 0 6px rgba(201,119,46,.5); }

/* Illustrations inside the chronicle */
.chat-image {
  display: block; max-width: 100%; border-radius: 8px;
  margin-top: .6rem; border: 1px solid rgba(201,119,46,.3);
}

/* The DM's offer card */
.offer-card { border-style: dashed; }
.offer-title { margin-bottom: .35rem; }
.offer-actions { margin-top: .75rem; }

/* The ⚙ beside the campaign name */
.page-title-row { display: flex; align-items: center; gap: .6rem; }
.gearbtn {
  background: transparent; border: 1px solid transparent;
  color: var(--vellum); font-size: 1.15rem; line-height: 1;
  padding: .25rem .5rem; border-radius: 8px; cursor: pointer;
  transition: transform .25s, color .15s, border-color .15s;
}
.gearbtn:hover { color: var(--ember-2); border-color: rgba(201,119,46,.4); transform: rotate(40deg); }

/* Campaign settings modal */
.settings-h { margin: 1rem 0 .4rem; color: var(--ember-2); font-size: .95rem; }
.settings-note { margin: .3rem 0 .6rem; }
.narrator-pick { display: inline-flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.narrator-pick select { max-width: 280px; }
.auto-narrate, .adv-narrate { display: inline-flex; align-items: center; gap: .35rem; cursor: pointer; }
.adv-narrate:has(input:disabled) { cursor: not-allowed; opacity: .6; }   /* locked until a premium narrator is seated */

/* Consent rows (signup terms + project-news opt-in) and the small note under a field */
.agree-row { display: flex; align-items: flex-start; gap: .55rem; margin: .7rem 0; cursor: pointer; }
.agree-row input[type=checkbox] { width: auto; margin-top: .25rem; flex: 0 0 auto; }
.field-note { margin: .25rem 0 .75rem; }
.artstyle-row { display: flex; gap: .5rem; align-items: center; }
.artstyle-row input { flex: 1; }

/* A 🔊 whose audio is ready but blocked by the browser's autoplay
   rules — one click plays the already-cached narration free */
.speak-btn.ready { opacity: 1; border-color: var(--ember-2);
  animation: emberpulse 1.2s ease-in-out infinite; }
@keyframes emberpulse { 50% { box-shadow: 0 0 10px rgba(201,119,46,.8); } }

/* Talk-to-type */
#micbtn.recording { border-color: #c0392b; color: #e74c3c;
  box-shadow: 0 0 8px rgba(231,57,43,.55);
  animation: emberpulse 1.2s ease-in-out infinite; }

/* Illustrate modal footer */
.img-modal-foot {
  display: flex; justify-content: space-between; align-items: center;
  gap: .75rem; flex-wrap: wrap; margin-top: .75rem;
}
#imagemodal textarea { width: 100%; }

/* The narrator voice picker (account.php) */
.voice-list { display: flex; flex-direction: column; gap: .5rem; margin: .75rem 0; }
.voice-row {
  display: flex; align-items: center; gap: .75rem;
  padding: .6rem .75rem; border: 1px solid rgba(201,119,46,.22);
  border-radius: 8px; cursor: pointer;
}
.voice-row:hover { border-color: rgba(201,119,46,.5); }
.voice-row.current { border-color: var(--ember-2); background: rgba(201,119,46,.07); }
.voice-main { flex: 1; display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.voice-desc { flex-basis: 100%; }
.voice-demo audio { height: 30px; max-width: 220px; }

/* Portrait on the character sheet */
.dndb-portrait-col { display: flex; flex-direction: column; gap: .4rem; align-items: center; margin-right: 1rem; }
.dndb-portrait {
  width: 108px; height: 108px; object-fit: cover; border-radius: 10px;
  border: 2px solid rgba(201,119,46,.45); box-shadow: 0 2px 10px rgba(0,0,0,.5);
}
.dndb-portrait-empty {
  display: flex; align-items: center; justify-content: center; text-align: center;
  color: #777; font-size: .72rem; background: rgba(255,255,255,.03);
}
.btn-ghost.small { padding: .25rem .6rem; font-size: .8rem; }
@media (max-width: 700px) {
  .dndb-portrait-col { margin-right: 0; }
  .voice-demo audio { max-width: 160px; }
}
/* The top section reads left to right: who they are, what they are
   wearing, and what they are doing. The portrait takes the first
   third, the figure sits in the middle, and the working tabs —
   actions, pack, spells — fill the right, which was dead space. */
.dndb-header {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) auto minmax(320px, 2fr);
  align-items: start;
  gap: 1.25rem;
}
.dndb-topright { min-width: 0; display: flex; flex-direction: column; min-height: 0; }

/* All three columns of the top section stand the same height, and
   the FIGURE is what sets it — the portrait stretches to match so
   it is a picture you can actually look at, not a thumbnail.
   The working tabs must not get a vote: `height: 0; min-height:
   100%` lets that column fill the row without its content being
   able to grow the row, which is what makes a long pack scroll
   instead of stretching the whole section down the page. */
.dndb-header { align-items: stretch; }
/* The figure keeps its natural height instead of stretching with
   the row — otherwise measuring it to size the working column
   feeds back on itself: tabs grow the row, the row stretches the
   figure, the bigger figure permits taller tabs, and the section
   creeps down the page. */
.dndb-header > .pd { align-self: start; }
.dndb-portrait-col {
  display: flex; flex-direction: column; gap: .4rem; min-height: 0;
}
.dndb-portrait, .dndb-portrait-empty {
  flex: 1 1 0; width: 100%; min-height: 140px;
  object-fit: cover; border-radius: 10px;
}
.dndb-portrait-empty { display: flex; align-items: center; justify-content: center; }
.dndb-portrait-col .btn-ghost { flex: 0 0 auto; }

.dndb-worktabs {
  min-width: 0; flex: 1 1 0; display: flex; flex-direction: column; min-height: 0;
}
.dndb-worktabs .dndb-tabs { flex: 0 0 auto; margin-top: .5rem; }
.dndb-worktabs .dndb-tab-content.active {
  flex: 1 1 auto; min-height: 0; overflow-y: auto; padding-right: .45rem;
  scrollbar-width: thin; scrollbar-color: var(--iron) transparent;
}
.dndb-worktabs .dndb-tab-content.active::-webkit-scrollbar { width: 9px; }
.dndb-worktabs .dndb-tab-content.active::-webkit-scrollbar-track { background: transparent; }
.dndb-worktabs .dndb-tab-content.active::-webkit-scrollbar-thumb {
  background: var(--iron); border-radius: 5px;
}
.dndb-worktabs .dndb-tab-content.active::-webkit-scrollbar-thumb:hover { background: var(--ember); }
.dndb-identity { margin-bottom: .6rem; }
.dndb-identity h1 { margin: 0; }
.dndb-worktabs { min-width: 0; }
.dndb-worktabs .dndb-tabs { margin-top: .5rem; }

/* The badges sat in their own right-hand column; now they ride
   along the top of the working third. */
.dndb-topright > div[style*="text-align: right"] { text-align: left !important; margin-bottom: .4rem; }

/* The pack moved upstairs, so what is left downstairs — saves,
   senses, proficiencies, skills — spreads across the full width
   rather than huddling in two columns beside a gap. */
.dndb-main {
  display: grid !important;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem; align-items: start;
}
.dndb-main > .dndb-col { display: contents; }
.dndb-main .dndb-panel { margin: 0 0 1rem; }

@media (max-width: 1100px) {
  .dndb-header { grid-template-columns: auto auto; }
  .dndb-topright { grid-column: 1 / -1; height: auto; min-height: 0; }
  .dndb-worktabs { max-height: 420px; }
}
@media (max-width: 700px) {
  .dndb-header { grid-template-columns: 1fr; justify-items: center; text-align: center; }
  .dndb-topright { text-align: left; width: 100%; }
}

/* ── Combat tracker (play sidebar) ─────────────────────────── */
.combat-strip {
  border: 1px solid var(--ember, #A34733);
  border-radius: 8px;
  padding: .6rem .7rem;
  margin-bottom: 1rem;
  background: rgba(163, 71, 51, 0.06);
}
.combat-head {
  font-weight: 700;
  color: var(--ember, #A34733);
  margin-bottom: .35rem;
  font-size: .95rem;
}
.combat-row {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .18rem .3rem;
  border-radius: 5px;
  font-size: .92rem;
}
.combat-row.acting { background: rgba(163, 71, 51, 0.14); font-weight: 600; }
.combat-row .ci {
  font-family: 'IBM Plex Mono', monospace;
  font-size: .8rem;
  min-width: 1.6rem;
  text-align: right;
  opacity: .7;
}
.combat-saves { font-size: .85rem; padding: .15rem .3rem; }
.combat-saves .ds { letter-spacing: .12em; margin-left: .3rem; }
.combat-saves .ds.ok  { color: #4E7A46; }
.combat-saves .ds.bad { color: var(--ember, #A34733); }

/* ── Clickable rolls ───────────────────────────────────────── */
.rollable { cursor: pointer; }
.rollable:hover { outline: 1px dashed var(--ember, #A34733); outline-offset: 2px; }
.roll-toast {
  position: fixed;
  z-index: 300;
  background: #26211B;
  color: #F3EDE3;
  border: 1px solid var(--ember, #A34733);
  border-radius: 8px;
  padding: .45rem .8rem;
  font-size: .9rem;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .35);
  pointer-events: none;
  transition: opacity .5s ease;
}
.roll-toast.fade { opacity: 0; }

/* ── Level-up banner (character sheet) ─────────────────────── */
.levelup-banner {
  display: flex;
  align-items: center;
  gap: .8rem;
  flex-wrap: wrap;
  border: 1px solid var(--ember, #A34733);
  border-radius: 8px;
  background: rgba(163, 71, 51, 0.07);
  padding: .7rem .9rem;
  margin-bottom: 1rem;
  font-size: .95rem;
}
.levelup-banner .btn { margin: 0; }

/* ── "Previously on..." recap (play screen) ────────────────── */
.recap-panel { padding: .7rem 1rem; margin-bottom: 1rem; }
.recap-panel summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--ember, #A34733);
}

/* ── Table links row (play sidebar) ────────────────────────── */
.table-links {
  margin-top: 1rem;
  padding-top: .7rem;
  border-top: 1px solid var(--line, #D8CFC0);
  text-align: center;
  font-size: .9rem;
}
.table-links a { margin: 0 .25rem; }

/* ── The Market (shop modal) ───────────────────────────────── */
.shop-modal { max-width: 560px; width: min(560px, 94vw); }
.shop-controls {
  display: flex;
  gap: .6rem;
  margin-bottom: .7rem;
}
.shop-controls input[type="search"] { flex: 1; margin: 0; }
.shop-controls select { width: auto; margin: 0; }
.shop-list {
  max-height: 46vh;
  overflow-y: auto;
  border: 1px solid var(--line, #D8CFC0);
  border-radius: 8px;
  padding: .3rem .5rem;
  margin-bottom: .7rem;
}
.shop-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .8rem;
  padding: .45rem .2rem;
  border-bottom: 1px solid var(--line, #D8CFC0);
}
.shop-row:last-child { border-bottom: 0; }
.shop-main { font-size: .92rem; }
.shop-buy {
  display: flex;
  align-items: center;
  gap: .5rem;
  white-space: nowrap;
}
.shop-buy .btn-ghost { margin: 0; }

/* ── Print: the character sheet on paper ───────────────────── */
@media print {
  body { background: #fff !important; color: #000 !important; }
  nav, .site-nav, .mobile-drawer, .no-print, footer,
  .inv-controls, .inv-act, .levelup-banner, #portraituploadbtn,
  #portrait-status, .dndb-tabs { display: none !important; }
  .wrap { max-width: 100%; padding: 0; }
  .panel, .dndb-panel, .dndb-box {
    background: #fff !important;
    color: #000 !important;
    border: 1px solid #999 !important;
    box-shadow: none !important;
  }
  .dndb-tab-content { display: block !important; page-break-inside: avoid; margin-top: .6rem; }
  .rollable:hover { outline: none; }
  a { text-decoration: none; color: #000; }
}

/* ── The Market: two counters face to face ─────────────────── */
.shop-modal { max-width: 940px; width: min(940px, 96vw); }
.shop-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.2rem;
  align-items: start;
}
.shop-col { min-width: 0; }
.shop-pack { max-height: 46vh; }
@media (max-width: 760px) {
  .shop-grid { grid-template-columns: 1fr; }
  .shop-list, .shop-pack { max-height: 30vh; }
}

/* ── The Market: three zones — vendor, the deal, your pack ── */
.shop-grid.three { grid-template-columns: 1fr 280px 1fr; }
.shop-modal { max-width: 1100px; width: min(1100px, 97vw); }
.shop-row.stageable { cursor: pointer; }
.shop-row.stageable:hover { background: rgba(163, 71, 51, 0.07); }
.shop-deal { text-align: left; }
.deal-zone {
  border: 1px solid var(--line, #D8CFC0);
  border-radius: 8px;
  padding: .45rem .6rem;
  margin-bottom: .6rem;
  min-height: 3.2rem;
}
.deal-head {
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--ember, #A34733);
  margin-bottom: .25rem;
}
.deal-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .4rem;
  font-size: .88rem;
  padding: .15rem 0;
}
.deal-qty { white-space: nowrap; }
.deal-qty button {
  border: 1px solid var(--line, #D8CFC0);
  background: transparent;
  color: inherit;
  border-radius: 5px;
  width: 1.4rem;
  height: 1.4rem;
  line-height: 1;
  cursor: pointer;
  margin: 0 .25rem;
}
.deal-qty button:hover { border-color: var(--ember, #A34733); }
.deal-net {
  text-align: center;
  font-size: 1rem;
  margin: .4rem 0 .6rem;
  min-height: 1.3rem;
}
@media (max-width: 900px) {
  .shop-grid.three { grid-template-columns: 1fr; }
  .shop-deal { order: 3; }
}

/* ── Pricing: plans and packs ──────────────────────────────── */
.plan-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}
.plan-card { text-align: center; }
.plan-price { font-size: 1.35rem; color: var(--ember, #A34733); margin: .4rem 0; }
.plan-features {
  list-style: none;
  padding: 0;
  margin: .6rem 0 1rem;
  font-size: .88rem;
  color: var(--ink-soft, #6B655C);
}
.plan-features li { padding: .18rem 0; }

/* ── Master Settings: sections, grids, tables ──────────────── */
.admin-section {
  font-size: 1.05rem;
  color: var(--ember, #A34733);
  border-bottom: 1px solid var(--line, #D8CFC0);
  padding-bottom: .3rem;
  margin: 1.4rem 0 .8rem;
}
.admin-section.small { font-size: .92rem; margin-top: 1rem; }
.admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: .7rem 1rem;
}
.admin-field { display: flex; flex-direction: column; gap: .25rem; }
.admin-label { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-soft, #6B655C); }
.admin-hint { font-size: .78rem; }
.admin-hint.ok { color: #4a7c46; }
.admin-hint.warn { color: #a3562f; }
.admin-toolbar { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; margin-bottom: .7rem; }
.admin-toolbar input[type=search] { flex: 1; min-width: 160px; }
.admin-scroll { overflow: auto; }
.admin-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.admin-table th {
  text-align: left;
  padding: .35rem .5rem;
  border-bottom: 2px solid var(--line, #D8CFC0);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}
.admin-table td { padding: .3rem .5rem; border-bottom: 1px solid var(--line, #D8CFC0); }
.admin-table input { width: 100%; box-sizing: border-box; }
.admin-newrow td { background: rgba(163, 71, 51, 0.05); }
.item-row { cursor: pointer; }
.item-row:hover { background: rgba(163, 71, 51, 0.07); }

/* ── Item editor: the dice picker ──────────────────────────── */
.dmg-row { display: flex; gap: .35rem; align-items: center; }
.dmg-row select { min-width: 3.5rem; }

/* ── Class resource rings: one segment per use ─────────────── */
.res-wrap { margin-top: .45rem; }
.res-label {
  display: block;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--ink-soft, #6B655C);
  margin-bottom: .25rem;
}
.res-cards { display: flex; flex-wrap: wrap; gap: .45rem; }
.res-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .15rem;
  min-width: 3.4rem;
  padding: .3rem .25rem;
  border: 1px solid var(--line, #D8CFC0);
  border-radius: .5rem;
  background: var(--panel, #FBF7EE);
}
.res-card svg { width: 2.6rem; height: 2.6rem; display: block; }
.res-card .rseg { stroke: var(--line, #D8CFC0); stroke-width: 7; }
.res-card .rseg.on { stroke: var(--ember, #A34733); }
.res-card .rtrack { stroke: var(--line, #D8CFC0); stroke-width: 7; }
.res-card .rtxt { font-size: 15px; font-weight: 700; fill: var(--ink, #2B2620); }
.res-card .rnum {
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 2.2rem;
  color: var(--ink, #2B2620);
}
.res-card .rlabel {
  font-size: .62rem;
  text-align: center;
  line-height: 1.15;
  max-width: 4.6rem;
  color: var(--ink-soft, #6B655C);
}

/* The DnDBeyond-dark sheet page gets dark ring cards. */
.dndb-tab-content .res-card { background: #2a2a2a; border-color: #444; }
.dndb-tab-content .res-card .rseg { stroke: #4a4a4a; }
.dndb-tab-content .res-card .rseg.on { stroke: #c9553d; }
.dndb-tab-content .res-card .rtrack { stroke: #4a4a4a; }
.dndb-tab-content .res-card .rtxt { fill: #fff; }
.dndb-tab-content .res-card .rnum { color: #fff; }
.dndb-tab-content .res-card .rlabel { color: #aaa; }

/* ── Account page: onboarding, ledger history, danger zone ── */
.onboard-panel { border-color: var(--ember-2); box-shadow: 0 0 0 1px var(--ember-2) inset; }
.plan-card.plan-current { border-color: var(--ember-2); }
.plan-card button[disabled] { opacity: .65; cursor: default; }

/* ── Plan cards: one row per billing period ────────────────── */
/* Monthly on top, yearly beneath, each with its own price and
   its own button — so the two are compared rather than toggled
   between, and the one you are actually on can be lit up. */
.plan-cycle {
  border-top: 1px solid var(--iron);
  padding: .8rem .1rem .2rem;
  margin-top: .8rem;
}
.plan-cycle-mine {
  border: 1px solid var(--ember-2);
  border-radius: 4px;
  background: rgba(224, 149, 80, .08);
  padding: .8rem .7rem .3rem;
}
.plan-cycle-head {
  display: flex; align-items: center; justify-content: center;
  gap: .5rem; margin: 0 0 .1rem;
}
.plan-cycle-name {
  font-size: .72rem; letter-spacing: .12em; text-transform: uppercase;
  color: var(--ash);
}
.plan-cycle .plan-price { margin: .1rem 0 .15rem; }
.plan-per { font-size: .85rem; color: var(--ash); }
.plan-cycle .btn-row { margin-top: .7rem; justify-content: center; }
.plan-cycle p { margin: .3rem 0; }

.table-scroll { overflow-x: auto; }
.ledger-table { width: 100%; border-collapse: collapse; }
.ledger-table th, .ledger-table td { padding: .45rem .5rem; text-align: left;
  border-bottom: 1px solid rgba(0,0,0,.12); vertical-align: top; }
.ledger-table th { font-size: .85rem; letter-spacing: .03em; color: var(--ember-2); }
.ledger-table .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.ledger-table tr:last-child td { border-bottom: none; }
.credit-in  { color: #2f6b34; font-weight: 600; }
.credit-out { color: #8a4a2a; }

.danger-panel { border-color: #8a3a2a; }
.danger-panel summary { cursor: pointer; color: #8a3a2a; margin-top: .5rem; }
.danger-form { margin-top: .8rem; }
.btn-danger, button.btn-danger { background: #8a3a2a; border-color: #8a3a2a; color: #fff; }
.btn-danger:hover { background: #a2422f; border-color: #a2422f; }

/* ── Character builder: era cards and measured inputs ─────── */
/* ── The era carousel ──────────────────────────────────────── */
/* One world on show at a time, flanked by its arrows. The card is
   a label wrapping a hidden radio: clicking the picture is what
   records the choice. The art is shown WHOLE — contain, not cover,
   so a tall portrait letterboxes rather than losing its head. */
.era-carousel { position: relative; display: flex; align-items: center; gap: .6rem; margin-top: .8rem; }
.era-stage { position: relative; flex: 1; min-width: 0; display: flex; justify-content: center; }
.era-card { position: relative; display: none; cursor: pointer; width: 100%; max-width: 420px; }
.era-card.era-active { display: block; }
.era-card input { position: absolute; opacity: 0; pointer-events: none; }
.era-body { display: block; border: 1px solid var(--rule, #4A3F32); border-radius: 10px;
  overflow: hidden; height: 100%; box-sizing: border-box;
  transition: border-color .12s, background .12s; }
.era-card:hover .era-body { border-color: var(--ember-2); }
.era-card input:checked + .era-body { border-color: var(--ember-2); background: rgba(201,119,46,.10);
  box-shadow: 0 0 0 1px var(--ember-2) inset; }

.era-shot { display: flex; justify-content: center; background: var(--oak-2); line-height: 0; }
.era-shot img {
  width: 100%; height: auto; display: block;
  /* The whole picture, bounded so a portrait cannot eat the page. */
  max-height: min(52vh, 460px);
  object-fit: contain;
}
.era-text { display: block; padding: .8rem .9rem; }
.era-title { display: block; font-size: 1.02rem; color: var(--ember-2); margin-bottom: .2rem; }
.era-blurb { display: block; font-size: .88rem; opacity: .85; }
.era-count { display: block; font-size: .78rem; opacity: .6; margin-top: .45rem; }

.era-nav { flex: 0 0 auto; width: 2.4rem; height: 2.4rem; padding: 0; line-height: 1;
  font-size: 1.6rem; border-radius: 50%; border: 1px solid var(--iron);
  background: var(--oak-2); color: var(--vellum); cursor: pointer;
  transition: border-color .12s, color .12s; }
.era-nav:hover { border-color: var(--ember-2); color: var(--ember-2); }

.era-step-h { margin: .2rem 0 .7rem; font-size: 1.1rem; }
.era-dots { display: flex; justify-content: center; gap: .45rem; margin-top: .7rem; flex-wrap: wrap; }
.era-dot { width: .6rem; height: .6rem; padding: 0; border-radius: 50%;
  border: 1px solid var(--iron); background: none; cursor: pointer; }
.era-dot-on { background: var(--ember-2); border-color: var(--ember-2); }

/* On a phone the arrows would squeeze the card to nothing, so they
   ride on top of the picture's edges instead of beside it. */
@media (max-width: 620px) {
  .era-carousel { gap: 0; }
  .era-card { max-width: none; }
  .era-shot img { max-height: 46vh; }
  .era-nav { position: absolute; top: 50%; transform: translateY(-50%); z-index: 2;
    width: 2.2rem; height: 2.2rem; font-size: 1.3rem;
    background: rgba(33,28,23,.78); backdrop-filter: blur(2px); }
  .era-nav[data-era-step="prev"] { left: .4rem; }
  .era-nav[data-era-step="next"] { right: .4rem; }
  .era-dot { width: .75rem; height: .75rem; }   /* a fingertip, not a pinhead */
}

.measure-row { display: flex; align-items: center; gap: .4rem; }
.measure-row input[type=number] { width: 100%; min-width: 0; margin: 0; }
.measure-row .unit { opacity: .7; font-size: .9rem; }
.measure-row .unit-select { width: auto; margin: 0; }
button.linkish { background: none; border: none; padding: .2rem 0; color: var(--ember-2);
  text-decoration: underline; cursor: pointer; font-size: .8rem; }

/* ── The paper doll ────────────────────────────────────────────
   A body with every slot in its own place. The picture is one
   grid-template-areas map: move a name here and the slot moves
   on the figure. Slot codes come from DnD_ref_body_slots, and
   character-sheet.php maps each to an area name. */
.pd {
  --pd-tile: 44px;
  --pd-gap: 5px;
  flex: 0 0 auto;
  -webkit-user-select: none; user-select: none;
}
.pd-vitals {
  display: grid; grid-template-columns: 1fr auto 1fr;
  align-items: center; gap: .4rem; margin-bottom: .4rem;
}
.pd-title-mid {
  font-family: 'IBM Plex Mono', monospace; font-size: .62rem;
  letter-spacing: .16em; text-transform: uppercase;
  color: var(--ember-2); opacity: .9; white-space: nowrap;
}
.pd-vital {
  border: 1px solid var(--iron); border-radius: 8px;
  padding: .2rem .35rem; background: rgba(0,0,0,.25); text-align: center;
}
.pd-vital .v {
  font-family: 'IBM Plex Mono', monospace; font-size: 1.05rem;
  line-height: 1.1; color: var(--vellum);
}
.pd-vital .v .sep { opacity: .45; margin: 0 .1em; }
.pd-vital .k {
  font-size: .52rem; letter-spacing: .08em; text-transform: uppercase;
  opacity: .7; margin-top: .05rem;
}
.pd-vital-hp { justify-self: start; border-color: rgba(163,71,51,.55); }
.pd-vital-hp .k { color: #C0705C; }
.pd-vital-ac { justify-self: end;  border-color: rgba(201,119,46,.55); }
.pd-vital-ac .k { color: var(--ember-2); }

.pd-body {
  position: relative;
  display: grid;
  justify-content: center;
  gap: var(--pd-gap);
  grid-template-columns: repeat(5, var(--pd-tile));
  grid-auto-rows: var(--pd-tile);
  grid-template-areas:
    ".      face   head   ears   ."
    "should .      neck   .      back"
    "rig    .      armor  .      under"
    "main   .      waist  .      off"
    "wleft  hands  legs   .      wright"
    "rleft  .      knees  .      rright"
    ".      .      feet   .      .";
  padding: .5rem;
  border: 1px solid var(--iron);
  border-radius: 12px;
  background:
    radial-gradient(ellipse at 50% 30%, rgba(201,119,46,.07), transparent 62%),
    rgba(0,0,0,.28);
}
.pd-figure {
  position: absolute; inset: .5rem;
  width: calc(100% - 1rem); height: calc(100% - 1rem);
  color: var(--vellum); opacity: .17; pointer-events: none;
}
.pd-figure g { fill: currentColor; fill-opacity: .45; stroke: currentColor; stroke-width: .7; }

/* One slot: a tile, a hover label, and (when empty) its picker. */
.pd-slot { position: relative; }
.pd-open, .pd-item {
  width: 100%; height: 100%; margin: 0; padding: 0;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--iron); border-radius: 9px;
  background: rgba(18,15,11,.72); color: var(--ash);
  cursor: pointer; transition: border-color .15s, background .15s, transform .1s, opacity .15s;
}
.pd-item { touch-action: none; }         /* the finger drags it, not the page */
.pd-open svg { width: 23px; height: 23px; opacity: .5; }
.pd-open:hover:not(:disabled), .pd-item:hover:not(:disabled) {
  border-color: var(--ember-2); color: var(--vellum); background: rgba(201,119,46,.12);
}
.pd-open:hover:not(:disabled) svg { opacity: .95; }
.pd-open:disabled { cursor: default; opacity: .55; }
.pd-slot.filled .pd-item {
  border-color: var(--ember); color: var(--vellum);
  background: linear-gradient(180deg, rgba(201,119,46,.22), rgba(201,119,46,.10));
  box-shadow: inset 0 0 12px rgba(201,119,46,.18);
}
.pd-slot.ghost .pd-item { border-style: dashed; opacity: .6; }
.pd-mono { font-family: 'IM Fell English', serif; font-size: 1.1rem; line-height: 1; }

/* The little cross that takes a worn item off. */
.pd-off {
  position: absolute; top: -6px; right: -6px; width: 17px; height: 17px;
  display: none; align-items: center; justify-content: center;
  border: 1px solid var(--rust); border-radius: 50%;
  background: var(--smoke); color: #D08A77;
  font-size: .8rem; line-height: 1; padding: 0; cursor: pointer; z-index: 14;
}
.pd-slot:hover .pd-off, .pd-off:focus-visible { display: flex; }
.pd-off:hover { background: var(--rust); color: #fff; }

/* The hover label — "Main hand — Greatsword". */
.pd-tip {
  position: absolute; top: calc(100% + 5px); left: 50%; transform: translateX(-50%);
  padding: .1rem .45rem; border: 1px solid var(--iron); border-radius: 6px;
  background: #17130F; color: var(--vellum);
  font-size: .7rem; line-height: 1.5; white-space: nowrap;
  opacity: 0; pointer-events: none; transition: opacity .12s; z-index: 15;
}
.pd-slot:hover .pd-tip { opacity: 1; }
.pd-slot[data-side="l"] .pd-tip { left: 0; transform: none; }
.pd-slot[data-side="r"] .pd-tip { left: auto; right: 0; transform: none; }
.pd-body.pd-dragging .pd-tip { opacity: 0 !important; }

/* Tap an empty slot: what you carry that would fit there. */
.pd-menu {
  position: absolute; top: calc(100% + 6px); left: 50%; transform: translateX(-50%);
  min-width: 165px; max-height: 220px; overflow-y: auto; z-index: 20;
  display: none; padding: .25rem;
  border: 1px solid var(--ember); border-radius: 9px; background: var(--oak);
  box-shadow: 0 12px 28px rgba(0,0,0,.7);
}
.pd-slot[data-side="l"] .pd-menu { left: 0; transform: none; }
.pd-slot[data-side="r"] .pd-menu { left: auto; right: 0; transform: none; }
.pd-slot.open .pd-menu { display: block; }
.pd-pick {
  display: block; width: 100%; text-align: left;
  border: 0; background: none; color: var(--vellum);
  padding: .3rem .45rem; border-radius: 5px; cursor: pointer; font-size: .82rem;
}
.pd-pick:hover { background: rgba(201,119,46,.22); }

/* ── A hand of rings ───────────────────────────────────────────
   One tile per hand on the figure, carrying the count; clicking it
   opens the hand itself, a slot on every finger. */
.pd-cluster .pd-open { position: relative; }
.pd-count {
  position: absolute; right: 2px; bottom: 1px;
  font-family: 'IBM Plex Mono', monospace; font-size: .62rem; line-height: 1;
  padding: .05rem .2rem; border-radius: 4px;
  background: rgba(0,0,0,.6); color: var(--ash);
}
.pd-cluster.filled .pd-open {
  border-color: var(--ember); color: var(--vellum);
  background: linear-gradient(180deg, rgba(201,119,46,.22), rgba(201,119,46,.10));
}
.pd-cluster.filled .pd-count { color: var(--ember-2); }

.pd-hand {
  position: absolute; top: calc(100% + 6px); left: 50%; transform: translateX(-50%);
  z-index: 22; display: none; padding: .5rem .55rem .6rem;
  border: 1px solid var(--ember); border-radius: 10px; background: var(--oak);
  box-shadow: 0 12px 30px rgba(0,0,0,.72);
}
.pd-slot[data-side="l"] .pd-hand { left: 0; transform: none; }
.pd-slot[data-side="r"] .pd-hand { left: auto; right: 0; transform: none; }
.pd-cluster.open .pd-hand { display: block; }
.pd-hand-h {
  font-family: 'IBM Plex Mono', monospace; font-size: .62rem;
  letter-spacing: .12em; text-transform: uppercase;
  color: var(--ember-2); text-align: center; margin-bottom: .4rem;
}
/* Thumb low and out, then four fingers rising to the middle —
   the tiles sit roughly where the fingers would be. */
.pd-fingers { display: flex; align-items: flex-end; gap: 4px; }
.pd-fingers .pd-finger { width: 38px; height: 38px; }
.pd-fingers .pd-finger:nth-child(1) { margin-bottom: 0; }
.pd-fingers .pd-finger:nth-child(2) { margin-bottom: 14px; }
.pd-fingers .pd-finger:nth-child(3) { margin-bottom: 22px; }
.pd-fingers .pd-finger:nth-child(4) { margin-bottom: 16px; }
.pd-fingers .pd-finger:nth-child(5) { margin-bottom: 6px; }
.pd-finger .pd-tip { top: auto; bottom: calc(100% + 5px); }


/* Slots the database grew that the figure has no place for yet. */
.pd-strays {
  display: flex; flex-wrap: wrap; gap: var(--pd-gap); justify-content: center;
  margin-top: var(--pd-gap);
}
.pd-strays .pd-slot { width: var(--pd-tile); height: var(--pd-tile); }

.pd-readout {
  max-width: calc(5 * var(--pd-tile) + 4 * var(--pd-gap) + 1rem);
  margin: .4rem auto 0; min-height: 2.2em;
  text-align: center; font-size: .72rem; line-height: 1.5; color: var(--ash);
}
.pd-readout.pd-warn { color: #D08A77; }

/* ── Dragging: dim the body, light up what will take the item ── */
.pd-body.pd-dragging .pd-open, .pd-body.pd-dragging .pd-item { opacity: .28; }
.pd-slot.pd-ok .pd-open, .pd-slot.pd-ok .pd-item {
  opacity: 1; border-color: var(--ember-2); color: var(--vellum);
  background: rgba(224,149,80,.18);
  animation: pd-pulse 1.15s ease-in-out infinite;
}
.pd-slot.pd-ok .pd-open svg { opacity: .95; }
.pd-slot.pd-hot .pd-open, .pd-slot.pd-hot .pd-item {
  opacity: 1; animation: none; transform: scale(1.09);
  border-color: #FFD9A8; background: rgba(224,149,80,.42);
  box-shadow: 0 0 14px rgba(224,149,80,.55);
}
@keyframes pd-pulse { 50% { box-shadow: 0 0 11px rgba(224,149,80,.6); } }

/* The tile that follows the pointer. */
.pd-ghost {
  position: fixed; z-index: 2000; pointer-events: none;
  transform: translate(-50%, -50%);
  display: flex; align-items: center; gap: .45rem;
  padding: .3rem .6rem .3rem .35rem; border-radius: 9px;
  border: 1px solid var(--ember-2); background: rgba(44,37,30,.96);
  color: var(--vellum); font-size: .8rem; white-space: nowrap;
  box-shadow: 0 8px 22px rgba(0,0,0,.65);
}
.pd-ghost .pd-mono {
  display: flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 6px;
  border: 1px solid var(--ember); background: rgba(201,119,46,.2); font-size: .9rem;
}
.pd-ghost.pd-ghost-off { border-color: var(--rust); }
.pd-ghost.pd-ghost-off .pd-mono { border-color: var(--rust); background: rgba(163,71,51,.25); }

/* The inventory list as a drag source. Selecting the row's text
   would let the browser start a native drag of that selection on
   the next press, which cancels ours — so it cannot be selected. */
.inv-row.inv-wearable, .inv-row[data-worn-item] {
  -webkit-user-select: none; user-select: none;
}
.inv-grip {
  display: inline-block; margin-right: .3rem; padding: 0 .15rem;
  color: var(--ash); opacity: .5; cursor: grab;
  font-size: .8rem; letter-spacing: -.18em; touch-action: none;
}
.inv-row.inv-wearable:hover .inv-grip { opacity: 1; color: var(--ember-2); }
.inv-row.pd-lifted { opacity: .45; }

/* On a phone the figure centres itself and loses a few pixels a
   side. This has to come AFTER .pd above, or the base tile size
   wins the cascade and nothing shrinks. */
@media (max-width: 700px) {
  .pd { --pd-tile: 40px; --pd-gap: 4px; margin: 0 auto; }
}


/* Speed that armour or a heavy pack has cut into. */
.dndb-box.slowed .val { color: #C0705C; }
.dndb-box.slowed .label { color: #C0705C; }


/* ── The narration transport ────────────────────────────────────
   Shown only while a passage is being read aloud. */
.narr-transport {
  display: flex; align-items: center; gap: .4rem;
  margin: .5rem 0 0; padding: .4rem .55rem;
  border: 1px solid var(--iron); border-radius: 10px;
  background: rgba(0,0,0,.3);
}
.narr-transport[hidden] { display: none; }
.narr-btn {
  min-width: 38px; height: 32px; padding: 0 .5rem;
  border: 1px solid var(--iron); border-radius: 7px;
  background: rgba(20,16,12,.8); color: var(--vellum);
  font-family: 'IBM Plex Mono', monospace; font-size: .8rem; line-height: 1;
  cursor: pointer; transition: border-color .15s, background .15s;
}
.narr-btn:hover:not(:disabled) { border-color: var(--ember-2); background: rgba(201,119,46,.16); }
.narr-btn:disabled { opacity: .35; cursor: not-allowed; }
.narr-main { min-width: 46px; font-size: 1rem; border-color: var(--ember); color: var(--ember-2); }
.narr-stop:hover:not(:disabled) { border-color: var(--rust); background: rgba(163,71,51,.22); color: #D08A77; }
.narr-label {
  margin-left: .3rem; font-size: .72rem; letter-spacing: .06em;
  text-transform: uppercase; color: var(--ash); opacity: .8;
}


/* ── The site's own voice: one dialog for every message ─────────
   Replaces the browser's grey alert()/confirm() boxes, which said
   "127.0.0.1 says" in a system font beside hand-lit parchment. */
.nfy-back {
  position: fixed; inset: 0; z-index: 4000;
  display: flex; align-items: center; justify-content: center;
  padding: 1.2rem; background: rgba(8,6,5,.72);
  -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
  animation: nfy-fade .14s ease-out;
}
.nfy-back[hidden] { display: none; }
body.nfy-open { overflow: hidden; }
@keyframes nfy-fade { from { opacity: 0; } }
@keyframes nfy-rise { from { opacity: 0; transform: translateY(10px) scale(.985); } }

.nfy {
  width: min(430px, 100%);
  border: 1px solid var(--ember); border-radius: 14px;
  background: linear-gradient(180deg, var(--oak), var(--smoke));
  box-shadow: 0 24px 60px rgba(0,0,0,.75);
  padding: 1.1rem 1.2rem 1rem;
  animation: nfy-rise .16s ease-out;
}
.nfy-head { display: flex; align-items: center; gap: .55rem; margin-bottom: .5rem; }
.nfy-mark {
  flex: 0 0 auto; width: 27px; height: 27px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--ember); color: var(--ember-2);
  background: rgba(201,119,46,.14); font-size: .85rem; line-height: 1;
}
.nfy-title {
  margin: 0; font-family: 'IM Fell English', serif;
  font-size: 1.12rem; font-weight: 400; color: var(--vellum);
}
.nfy-body {
  color: var(--ash); font-size: .93rem; line-height: 1.55;
  white-space: pre-line;                 /* honour line breaks in messages */
}
.nfy-input {
  width: 100%; margin-top: .7rem; padding: .45rem .55rem;
  border: 1px solid var(--iron); border-radius: 7px;
  background: rgba(0,0,0,.3); color: var(--vellum); font-size: .93rem;
}
.nfy-input:focus { outline: none; border-color: var(--ember-2); }
.nfy-input[hidden] { display: none; }
.nfy-actions {
  display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1rem;
}
.nfy-actions button[hidden] { display: none; }
.nfy-ok.btn-danger { background: var(--rust); border-color: var(--rust); color: #fff; }
.nfy-ok.btn-danger:hover { background: #b4503a; }

.nfy[data-tone="error"]   .nfy-mark { border-color: var(--rust); color: #D08A77; background: rgba(163,71,51,.18); }
.nfy[data-tone="success"] .nfy-mark { border-color: #6E8F5E; color: #9BC088; background: rgba(110,143,94,.18); }

/* ── The six ability scores read as their own group ────────────
   They sit beside proficiency, speed and initiative, which are
   derived numbers of a different kind; without a visual break the
   whole row reads as one undifferentiated wall of boxes. */
.dndb-box.ability {
  border-color: rgba(201,119,46,.55);
  background: linear-gradient(180deg, rgba(201,119,46,.13), rgba(0,0,0,.20));
}
.dndb-box.ability .label { color: var(--ember-2); letter-spacing: .1em; }
.dndb-box.ability .val   { color: var(--vellum); }
.dndb-box.ability .score { border-color: rgba(201,119,46,.5); color: var(--ember-2); }
.dndb-box.ability:hover  { border-color: var(--ember); }

/* ── Portrait controls: icons, not sentences ───────────────────
   Two full-width buttons ate a third of the portrait column. */
.portrait-tools {
  display: flex; justify-content: center; gap: .4rem; flex: 0 0 auto;
}
.portrait-tool {
  width: 34px; height: 30px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--iron); border-radius: 8px;
  background: rgba(20,16,12,.75); color: var(--ash);
  cursor: pointer; transition: border-color .15s, color .15s, background .15s;
}
.portrait-tool:hover { border-color: var(--ember-2); color: var(--vellum); background: rgba(201,119,46,.14); }
.portrait-tool svg { width: 17px; height: 17px; }

/* ── Phone polish ──────────────────────────────────────────── */
/* Written last so it wins: everything here is a narrow-screen
   adjustment to a component defined further up. */
@media (max-width: 620px) {
  .wrap { padding: 1rem .75rem; }   /* 2rem of gutter is a lot of a 360px screen */
  .charter { padding: .9rem 1rem; }
  .theme-grid { grid-template-columns: 1fr 54px 54px 54px; gap: .25rem .3rem; }
  .theme-grid .th-col { font-size: .62rem; letter-spacing: .04em; }
  .theme-grid span:not(.th-col) { font-size: .88rem; }
  .plan-cycle { padding-left: 0; padding-right: 0; }
  .plan-cycle-mine { padding-left: .55rem; padding-right: .55rem; }
  .ledger-table { font-size: .86rem; }
  .ledger-table th, .ledger-table td { padding: .4rem .35rem; }
  .btn-row { gap: .5rem; margin-top: 1rem; }
  .modal { max-height: 88vh; }
}
