:root {
  --bg: #171310;
  --bg-alt: #201a15;
  --panel: #26201a;
  --panel-2: #2e261e;
  --border: #443a2d;
  --text: #ece3d4;
  --text-dim: #b3a692;
  --accent: #c9973f;
  --accent-strong: #e0b25c;
  --danger: #b5493f;
  --danger-strong: #d15f52;
  --good: #5a8f5a;
  --radius: 8px;
  font-size: 16px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', Georgia, 'Iowan Old Style', serif;
  min-height: 100vh;
}

a { color: var(--accent-strong); }

button {
  font-family: inherit;
  cursor: pointer;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5em 0.9em;
  font-size: 0.95rem;
  transition: background 0.15s, border-color 0.15s, transform 0.1s ease-out;
}
button:hover { background: #3a3024; border-color: var(--accent); }
button:active:not(:disabled) { transform: scale(0.95); transition-duration: 0.05s; }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button.primary { background: var(--accent); color: #201a10; border-color: var(--accent); font-weight: 600; }
button.primary:hover { background: var(--accent-strong); }
button.danger { border-color: var(--danger); color: #f0d3ce; }
button.danger:hover { background: var(--danger); }
button.ghost { background: transparent; border-color: transparent; }
button.small { padding: 0.25em 0.55em; font-size: 0.8rem; }

input, select, textarea {
  font-family: inherit;
  background: var(--bg-alt);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.45em 0.6em;
  font-size: 0.95rem;
}
input:focus, select:focus, textarea:focus { outline: 1px solid var(--accent); border-color: var(--accent); }
input:disabled, select:disabled, textarea:disabled { opacity: 0.5; cursor: not-allowed; }

/* Bigger, easier-to-press fields — checkboxes/sliders keep their own compact
   sizing above, number fields get an extra bump on top of the text-field one. */
input:not([type=checkbox], [type=range]), select, textarea {
  padding: 0.65em 0.85em;
  font-size: 1.05rem;
  min-height: 2.7em;
}
input[type=number] {
  font-size: 1.25rem;
  font-weight: 600;
  padding: 0.7em 0.9em;
  min-height: 2.9em;
}
/* Native <select> chrome ignores padding/min-height in most browsers unless
   its default appearance is reset — without this it renders visibly
   smaller than a same-styled text input despite matching CSS. */
select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="12" height="8" viewBox="0 0 12 8"><path d="M1 1l5 5 5-5" stroke="%23b3a692" stroke-width="1.6" fill="none" stroke-linecap="round" stroke-linejoin="round"/></svg>');
  background-repeat: no-repeat;
  background-position: right 0.9em center;
  padding-right: 2.4em;
}
label { font-size: 0.78rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.03em; display: block; margin-bottom: 0.2em; }

.field { display: flex; flex-direction: column; gap: 2px; }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  transition: transform 0.15s ease-out, border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.card:hover {
  border-color: var(--accent);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(201, 151, 63, 0.12);
  transform: translateY(-2px);
}
/* No transform here — several cards (e.g. Ability Scores) hold range
   sliders that stay :active mid-drag, and shifting the card under the
   cursor while dragging would make that feel broken. */
.card:active {
  border-color: var(--accent-strong);
  background: var(--panel-2);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  transition-duration: 0.05s;
}

h1, h2, h3 { font-family: Georgia, 'Iowan Old Style', serif; color: var(--accent-strong); margin: 0 0 0.5em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; }

.hidden { display: none !important; }
.error-text { color: var(--danger-strong); font-size: 0.85rem; min-height: 1.2em; }
.muted { color: var(--text-dim); font-size: 0.85rem; }

/* --- login --- */
#loginWrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.auth-card {
  width: 100%;
  max-width: 360px;
  text-align: center;
}
.auth-card p.sub { color: var(--text-dim); margin-top: -0.4em; margin-bottom: 1.2em; }
.auth-form { display: flex; flex-direction: column; gap: 0.8em; text-align: left; }
.auth-switch { margin-top: 1em; font-size: 0.9rem; color: var(--text-dim); }
.auth-switch button { border: none; background: none; color: var(--accent-strong); padding: 0; text-decoration: underline; }

/* --- app shell --- */
#topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.7em 1.2em;
  background: var(--bg-alt);
  border-bottom: 1px solid var(--border);
}
#topbar .brand { font-family: Georgia, serif; font-size: 1.25rem; color: var(--accent-strong); }
#topbar .user-info { display: flex; align-items: center; gap: 0.8em; font-size: 0.9rem; }
.role-badge { background: var(--accent); color: #201a10; border-radius: 999px; padding: 0.1em 0.6em; font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; }

#tabs {
  display: flex;
  gap: 0.3em;
  padding: 0.6em 1.2em 0;
  background: var(--bg-alt);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}
#tabs button {
  background: none;
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  color: var(--text-dim);
  padding: 0.6em 1em;
  white-space: nowrap;
}
#tabs button.active { background: var(--bg); color: var(--accent-strong); border-color: var(--border); font-weight: 600; }

/* --- phone/tablet: keep the always-visible chrome from cramming up --- */
@media (max-width: 720px) {
  #topbar { flex-wrap: wrap; gap: 0.4em 0.8em; padding: 0.6em 0.9em; }
  #topbar .brand { font-size: 1.05rem; }
  #topbar .user-info { font-size: 0.82rem; gap: 0.5em; flex-wrap: wrap; }
  #tabs { padding: 0.5em 0.7em 0; }
  #tabs button { padding: 0.55em 0.8em; font-size: 0.88rem; }
  .combat-banner { flex-direction: column; align-items: stretch; padding: 0.6em 0.9em; }
  .combat-banner-text { text-align: center; }
  .combat-banner-actions { justify-content: center; }
}
@media (max-width: 480px) {
  #topbar .brand { display: none; }
}

#content {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.2rem;
  padding-bottom: 5rem;
}

.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.grid-6 { grid-template-columns: repeat(auto-fit, minmax(80px, 1fr)); }

.stat-box { background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.75em; text-align: center; }
.stat-box .label { font-size: 0.68rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.04em; }
.stat-box .score { font-size: 1.4rem; font-weight: 700; margin: 0.1em 0; }
.stat-box .mod { font-size: 0.85rem; color: var(--accent-strong); }
.stat-box input.score-input { width: 100%; text-align: center; font-size: 1.55rem; font-weight: 700; background: transparent; border: none; padding: 0.2em 0; min-height: 0; }

input[type=range] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: var(--border);
  border-radius: 999px;
  padding: 0;
  margin: 0.4em 0;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--accent-strong);
  cursor: pointer;
  margin-top: -6px;
}
input[type=range]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--accent-strong);
  cursor: pointer;
}
input[type=range]::-moz-range-track { background: var(--border); height: 4px; border-radius: 999px; }

.field label span { color: var(--accent-strong); font-weight: 700; text-transform: none; letter-spacing: 0; font-size: 0.85rem; }
.field select + input { width: 100%; }

/* --- checkboxes --- */
input[type=checkbox] {
  appearance: none;
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  min-width: 20px;
  border: 2px solid var(--border);
  border-radius: 5px;
  background: var(--bg-alt);
  cursor: pointer;
  display: inline-grid;
  place-content: center;
  flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s;
}
input[type=checkbox]:hover { border-color: var(--accent); }
input[type=checkbox]:checked {
  background: var(--accent);
  border-color: var(--accent-strong);
}
input[type=checkbox]:checked::after {
  content: '';
  width: 5px;
  height: 9px;
  border: solid #201a10;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg) translate(-1px, -1px);
}
input[type=checkbox]:focus-visible { outline: 2px solid var(--accent-strong); outline-offset: 2px; }

.checkbox-row {
  display: flex !important;
  flex-direction: row !important;
  align-items: center;
  gap: 0.5em;
  cursor: pointer;
  text-transform: none;
  letter-spacing: normal;
  color: var(--text);
  font-size: 0.95rem;
}

.toggle-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  padding: 0.4em 0.9em;
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text-dim);
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.toggle-pill:hover { border-color: var(--accent); }
.toggle-pill:has(input:checked) {
  background: var(--accent);
  border-color: var(--accent-strong);
  color: #201a10;
  font-weight: 700;
}
.toggle-pill input[type=checkbox] { width: 16px; height: 16px; }

.icon-picker { display: flex; flex-wrap: wrap; gap: 0.3em; }
.icon-picker .icon-pick {
  font-size: 1.1rem;
  line-height: 1;
  padding: 0.35em 0.5em;
}

.hp-bar-outer { background: var(--bg-alt); border: 1px solid var(--border); border-radius: 999px; height: 14px; overflow: hidden; }
.hp-bar-inner { height: 100%; background: linear-gradient(90deg, var(--good), #7fb87f); transition: width 0.2s; }
.hp-bar-inner.low { background: linear-gradient(90deg, var(--danger), var(--danger-strong)); }
.hp-bar-inner.mid { background: linear-gradient(90deg, #b58b3f, var(--accent)); }

.combat-subrow { display: flex; flex-wrap: wrap; gap: 0.8em; margin-top: 0.8em; }
.combat-subcard {
  flex: 1 1 220px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.6em 0.7em;
}
.combat-subcard .label { font-size: 0.68rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.04em; }
.death-save-row { display: flex; align-items: center; gap: 0.5em; margin-top: 0.4em; }
.death-save-label { font-size: 0.8rem; width: 5.2em; flex-shrink: 0; }
.death-save-label.good { color: var(--good); }
.death-save-label.bad { color: var(--danger); }
.death-save-box { width: 16px; height: 16px; accent-color: var(--good); }
.death-save-box.bad { accent-color: var(--danger); }
#carryingCapacityNote.over-capacity { color: var(--danger-strong); font-weight: 700; }

.condition-badges { display: flex; flex-wrap: wrap; gap: 0.4em; margin-top: 0.4em; }
.condition-badge {
  background: var(--panel-2);
  border: 1px solid var(--danger);
  color: #f0d3ce;
  border-radius: 999px;
  padding: 0.3em 0.8em;
  font-size: 0.85rem;
  font-weight: 600;
}
.condition-modal { max-width: 480px; }
.condition-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.5em; margin: 0.8em 0; }
.condition-chip {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.7em 0.4em;
  text-align: center;
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.25;
}
.condition-chip:hover { border-color: var(--accent); }
.condition-chip.selected { background: rgba(181, 73, 63, 0.25); border-color: var(--danger); color: #f0d3ce; }
.active-conditions-desc:not(:empty) {
  border-top: 1px dashed var(--border);
  margin-top: 0.6em;
  padding-top: 0.6em;
  max-height: 9em;
  overflow-y: auto;
}
.active-conditions-desc .move-detail-line { margin-bottom: 0.5em; }
.active-conditions-desc .move-detail-line strong { color: var(--text); }

.wild-shape-modal { max-width: 420px; }
.beast-form-list { max-height: 50vh; overflow-y: auto; }
.beast-form-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.6em;
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.6em 0.8em;
  margin-bottom: 0.4em;
  text-align: left;
}
.beast-form-row .name { font-weight: 600; }
.beast-form-row:hover { border-color: var(--accent); }
.beast-form-row.selected { border-color: var(--accent); background: rgba(201, 151, 63, 0.15); }
.beast-form-row:disabled { opacity: 0.45; cursor: not-allowed; }

.combat-lock-banner {
  background: rgba(181, 73, 63, 0.12);
  border: 1px solid var(--danger);
  border-radius: var(--radius);
  padding: 0.7em 1rem;
  color: #f0d3ce;
  font-size: 0.9rem;
  font-weight: 600;
}

.active-states-row:not(:empty) { display: flex; flex-direction: column; gap: 0.5em; margin: -0.2em 0 0.2em; }
.active-state-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.6em;
  flex-wrap: wrap;
  background: var(--panel-2);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 0.7em 1rem;
  font-weight: 600;
}
.active-state-banner.rage { border-color: var(--danger); }
.active-state-banner.infusions { display: block; border-color: var(--border); }
.infusion-list { display: flex; flex-wrap: wrap; gap: 0.4em; }
.infusion-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.3em 0.4em 0.3em 0.8em;
  font-size: 0.85rem;
  font-weight: 600;
}
.infusion-remove {
  background: none;
  border: none;
  color: var(--text-dim);
  padding: 0.1em 0.4em;
  cursor: pointer;
  line-height: 1;
}
.infusion-remove:hover { color: var(--danger-strong); }

table.simple { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
table.simple th, table.simple td { text-align: left; padding: 0.4em 0.5em; border-bottom: 1px solid var(--border); }
table.simple th { color: var(--text-dim); font-weight: 600; font-size: 0.75rem; text-transform: uppercase; }

.skill-row {
  display: flex;
  align-items: center;
  gap: 0.6em;
  padding: 0.4em 0.4em;
  margin: 0 -0.4em;
  font-size: 0.88rem;
  border-bottom: 1px dashed var(--border);
  cursor: pointer;
  border-radius: 5px;
  transition: background 0.12s;
}
.skill-row:hover { background: var(--panel-2); }
.skill-row .name { flex: 1; }
.skill-row .mod { width: 2.6em; text-align: right; color: var(--accent-strong); font-weight: 600; }

.party-card { display: flex; flex-direction: column; gap: 0.5em; }
.party-card .top-row { display: flex; justify-content: space-between; align-items: baseline; }
.party-card .sub { color: var(--text-dim); font-size: 0.85rem; }

/* --- combat / initiative --- */
.combat-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6em 1em;
  padding: 0.6em 1.2em;
  background: var(--panel-2);
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
  flex-wrap: wrap;
  transition: background 0.2s, border-color 0.2s;
}
.combat-banner-actions button { padding: 0.4em 0.8em; }
/* On the gold "my-turn" banner, buttons that normally rely on blending
   into a dark background (primary = accent-on-dark, ghost = transparent
   text) become nearly invisible against gold-on-gold — give them their
   own high-contrast treatment scoped to this state instead. */
.combat-banner.my-turn .combat-banner-actions button.primary {
  background: #201a10;
  color: var(--accent-strong);
  border-color: #201a10;
}
.combat-banner.my-turn .combat-banner-actions button.primary:hover { background: #2c2417; }
.combat-banner.my-turn .combat-banner-actions button.ghost {
  border-color: rgba(32, 26, 16, 0.55);
  color: #201a10;
}
.combat-banner.my-turn .combat-banner-actions button.ghost:hover { background: rgba(32, 26, 16, 0.12); }
.combat-banner.my-turn .combat-banner-actions button:disabled { opacity: 0.4; }
.combat-banner-actions { display: flex; align-items: center; gap: 0.5em; flex-wrap: wrap; }
.combat-banner.exploration {
  background: rgba(90, 143, 90, 0.14);
  border-bottom: 1px solid var(--good);
}
.combat-banner.exploration .combat-banner-text { color: var(--good); font-weight: 600; }
.combat-banner .enter-combat-btn { animation-duration: 2s; }

.combat-log {
  max-height: 180px;
  overflow-y: auto;
  margin-top: 0.5em;
  padding: 0.5em 0.6em;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.82rem;
}
.combat-log-row { padding: 0.2em 0; border-bottom: 1px dashed var(--border); }
.combat-log-row:last-child { border-bottom: none; }
.combat-log-row .muted { margin-right: 0.5em; }

.enter-combat-btn {
  background: linear-gradient(135deg, var(--danger-strong), var(--accent));
  color: #1a1006;
  font-weight: 800;
  border-color: var(--danger-strong);
  animation: enter-combat-pulse 1.6s ease-in-out infinite;
}
.enter-combat-btn:hover { background: linear-gradient(135deg, var(--danger), var(--accent-strong)); }
@keyframes enter-combat-pulse {
  0%, 100% { box-shadow: 0 0 0 0 #d15f5266; }
  50% { box-shadow: 0 0 0 9px #d15f5200; }
}

/* --- big full-screen "combat begins" splash --- */
.battle-splash {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  overflow: hidden;
}
.battle-splash::before {
  content: '';
  position: absolute;
  inset: 0;
  background: #fff;
  animation: battle-flash-anim 0.35s ease-out forwards;
}
@keyframes battle-flash-anim {
  0% { opacity: 0.9; }
  100% { opacity: 0; }
}
.battle-splash-bg {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle, #7a1010dd 0%, #10030388 55%, transparent 85%);
  animation: battle-bg-anim 2.6s ease-in-out forwards;
}
@keyframes battle-bg-anim {
  0% { opacity: 0; }
  10% { opacity: 1; }
  78% { opacity: 1; }
  100% { opacity: 0; }
}
.battle-splash-text {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  animation: battle-text-anim 2.6s cubic-bezier(.2,.9,.3,1) forwards;
}
.battle-splash-line1 {
  font-family: Georgia, 'Iowan Old Style', serif;
  font-size: 1.8rem;
  letter-spacing: 0.2em;
  color: #ffd27a;
  text-shadow: 0 0 30px #ff8a3c, 0 4px 12px #000;
}
.battle-splash-line2 {
  font-family: Georgia, 'Iowan Old Style', serif;
  font-weight: 900;
  font-size: 4.2rem;
  letter-spacing: 0.1em;
  color: #fff;
  text-shadow: 0 0 50px #ff2020, 0 6px 16px #000;
  margin-top: 0.1em;
}
@keyframes battle-text-anim {
  0% { opacity: 0; transform: scale(2.8); }
  18% { opacity: 1; transform: scale(1); }
  25% { transform: scale(1.06); }
  32% { transform: scale(1); }
  78% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(0.9); }
}

@media (max-width: 640px) {
  .battle-splash-line1 { font-size: 1.2rem; }
  .battle-splash-line2 { font-size: 2.6rem; }
}
.combat-banner.my-turn { background: var(--accent); color: #201a10; }
.combat-banner.my-turn strong { color: #201a10; }
.combat-banner-text strong { color: var(--accent-strong); }

.token-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  min-width: 24px;
  border-radius: 50%;
  font-size: 0.8rem;
  border: 1px solid #fff5;
  color: #fff;
  text-shadow: 0 1px 2px #000;
}

.setup-row {
  display: flex;
  align-items: center;
  gap: 0.6em;
  padding: 0.35em 0;
  border-bottom: 1px dashed var(--border);
}

.combatant-row {
  display: flex;
  align-items: center;
  gap: 0.6em;
  padding: 0.45em 0.5em;
  margin: 0 -0.5em;
  border-radius: 6px;
  border-bottom: 1px dashed var(--border);
}
.combatant-row.current { background: var(--accent); color: #201a10; }
.combatant-row.current .muted { color: #201a10cc; }
.combatant-row .name { flex: 1; font-weight: 600; }
.init-badge {
  min-width: 2em;
  text-align: center;
  font-weight: 700;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.1em 0.4em;
  font-size: 0.85rem;
}
.combatant-row.current .init-badge { background: #201a10; color: var(--accent-strong); border-color: #201a10; }

/* --- map ---
   #mapArea is the clipping viewport (fixed size, overflow hidden).
   .map-container is the pannable/zoomable layer inside it — a CSS
   transform (translate + scale) is applied to it in JS, which moves its
   background image and percentage-positioned token children together. */
#mapArea {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: #0d0b09;
  /* Panning/dragging tokens shouldn't ever highlight text or trigger the
     browser's native drag-to-select — it fights with pointer dragging. */
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.map-container {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: center/cover no-repeat;
  transform-origin: 0 0;
  cursor: grab;
  touch-action: none;
}
.map-container.panning { cursor: grabbing; }
.map-container.empty { display: flex; align-items: center; justify-content: center; color: var(--text-dim); cursor: default; }
.range-ring {
  position: absolute;
  border-radius: 50%;
  border: 2px dashed var(--accent-strong);
  background: #e0b25c22;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
}
.range-ring span {
  background: #000a;
  color: var(--accent-strong);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.15em 0.5em;
  border-radius: 999px;
}

/* --- turn flourish fx (attack/spell/heal) --- */
.fx-hint-banner {
  position: fixed;
  top: 6.5rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 14;
  display: flex;
  align-items: center;
  gap: 0.7em;
  background: var(--panel);
  border: 1px solid var(--accent);
  border-radius: 999px;
  padding: 0.5em 0.5em 0.5em 1em;
  box-shadow: 0 10px 28px #000a;
  font-size: 0.9rem;
}

.fx-effect {
  position: absolute;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 9;
  width: 0;
  height: 0;
}
.fx-core { position: absolute; left: 0; top: 0; transform: translate(-50%, -50%); }

/* shared particle system: JS sets --dx/--dy (the final flung offset) per
   particle; each type just recolors/resizes them */
.fx-particle {
  position: absolute;
  left: 0;
  top: 0;
  border-radius: 50%;
  animation: fx-particle-anim 1.1s cubic-bezier(.2,.7,.3,1) forwards;
}
@keyframes fx-particle-anim {
  0% { opacity: 0; transform: translate(-50%, -50%) translate(0, 0) scale(0.4); }
  15% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -50%) translate(var(--dx), var(--dy)) scale(0.2); }
}

/* --- slash: a big double cross-slash flash --- */
@keyframes fx-slash-core-anim {
  0% { opacity: 0; transform: translate(-50%, -50%) rotate(-30deg) scaleX(0.1); }
  20% { opacity: 1; transform: translate(-50%, -50%) rotate(-30deg) scaleX(1); }
  55% { opacity: 1; transform: translate(-50%, -50%) rotate(-30deg) scaleX(1.15); }
  100% { opacity: 0; transform: translate(-50%, -50%) rotate(-30deg) scaleX(1.5); }
}
@keyframes fx-slash-core2-anim {
  0%, 30% { opacity: 0; transform: translate(-50%, -50%) rotate(35deg) scaleX(0.1); }
  50% { opacity: 1; transform: translate(-50%, -50%) rotate(35deg) scaleX(1); }
  100% { opacity: 0; transform: translate(-50%, -50%) rotate(35deg) scaleX(1.5); }
}
.fx-slash .fx-core {
  width: 220px;
  height: 16px;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, #fff 30%, #fff 70%, transparent);
  box-shadow: 0 0 40px 8px #ffffffcc;
  animation: fx-slash-core-anim 0.9s ease-out forwards;
}
.fx-slash .fx-core::after {
  content: '';
  position: absolute;
  inset: 0;
  margin: auto;
  width: 220px;
  height: 12px;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, #e0b25c 30%, #e0b25c 70%, transparent);
  animation: fx-slash-core2-anim 0.9s ease-out forwards;
}
.fx-slash .fx-particle {
  width: 6px;
  height: 6px;
  background: #fff;
  box-shadow: 0 0 8px 2px #fff9;
}

/* --- arrow: streaking projectile impact with a shockwave ring --- */
@keyframes fx-arrow-core-anim {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.2); }
  30% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.3); }
}
@keyframes fx-arrow-ring-anim {
  0% { opacity: 0.9; transform: translate(-50%, -50%) scale(0.2); border-width: 8px; }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(3.2); border-width: 1px; }
}
.fx-arrow .fx-core {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: radial-gradient(circle, #fff, var(--accent) 45%, transparent 75%);
  box-shadow: 0 0 46px 18px #c9973fbb;
  animation: fx-arrow-core-anim 0.7s ease-out forwards;
}
.fx-arrow .fx-core::after {
  content: '';
  position: absolute;
  inset: 0;
  margin: auto;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 8px solid #e0b25c;
  animation: fx-arrow-ring-anim 1.1s ease-out forwards;
}
.fx-arrow .fx-particle {
  width: 5px;
  height: 5px;
  background: #e0b25c;
  box-shadow: 0 0 8px 2px #e0b25c99;
}

/* --- burst: a big layered fireball with a screen flash --- */
@keyframes fx-burst-core-anim {
  0% { opacity: 1; transform: translate(-50%, -50%) scale(0.15); }
  35% { opacity: 1; transform: translate(-50%, -50%) scale(1.4); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(3.4); }
}
@keyframes fx-burst-ring-anim {
  0% { opacity: 1; transform: translate(-50%, -50%) scale(0.1); border-width: 14px; }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(4.2); border-width: 1px; }
}
.fx-burst .fx-core {
  width: 130px;
  height: 130px;
  border-radius: 50%;
  background: radial-gradient(circle, #fff9 0%, #ffcf6acc 20%, #ff8a3cdd 45%, #d1493c88 65%, transparent 78%);
  animation: fx-burst-core-anim 1.1s cubic-bezier(.15,.7,.3,1) forwards;
}
.fx-burst .fx-core::after {
  content: '';
  position: absolute;
  inset: 0;
  margin: auto;
  width: 130px;
  height: 130px;
  border-radius: 50%;
  border: 14px solid #ff8a3c;
  animation: fx-burst-ring-anim 1.3s ease-out forwards;
}
.fx-burst .fx-particle {
  width: 9px;
  height: 9px;
  background: radial-gradient(circle, #fff, #ff8a3c 60%, transparent 100%);
  box-shadow: 0 0 12px 3px #ff8a3caa;
  animation-duration: 1.3s;
}
.fx-screen-flash {
  position: fixed;
  inset: 0;
  z-index: 30;
  pointer-events: none;
  background: radial-gradient(circle, #ff8a3c55 0%, transparent 65%);
  animation: fx-screen-flash-anim 0.5s ease-out forwards;
}
@keyframes fx-screen-flash-anim {
  0% { opacity: 1; }
  100% { opacity: 0; }
}
.fx-screen-flash-lightning {
  background: radial-gradient(circle, #cfe8ff99 0%, transparent 60%);
  animation-duration: 0.3s;
}

/* --- heal: a tall rising glow with drifting motes --- */
@keyframes fx-heal-core-anim {
  0% { opacity: 0; transform: translate(-50%, -50%) translateY(10px) scale(0.5); }
  30% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -50%) translateY(-90px) scale(1.6); }
}
.fx-heal .fx-core {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: radial-gradient(circle, #d7ffdfcc 0%, #9be8a8bb 35%, #5a8f5a66 60%, transparent 78%);
  animation: fx-heal-core-anim 1.8s ease-out forwards;
}
.fx-heal .fx-particle {
  width: 6px;
  height: 6px;
  background: #d7ffdf;
  box-shadow: 0 0 10px 3px #9be8a8aa;
  animation-duration: 2s;
  animation-timing-function: ease-out;
}
.fx-heal .fx-particle { animation-name: fx-particle-rise-anim; }
@keyframes fx-particle-rise-anim {
  0% { opacity: 0; transform: translate(-50%, -50%) translate(0, 10px) scale(0.4); }
  20% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -50%) translate(var(--dx), calc(var(--dy) - 60px)) scale(0.3); }
}

/* --- lightning: a snappy bolt crackle --- */
@keyframes fx-lightning-core-anim {
  0%, 100% { opacity: 0; }
  8%, 22% { opacity: 1; }
  15% { opacity: 0.3; }
  40% { opacity: 0; }
}
.fx-lightning .fx-core {
  width: 10px;
  height: 260px;
  margin-top: -220px;
  background: linear-gradient(180deg, transparent, #fff 20%, #bfe0ff 50%, #fff 80%, transparent);
  box-shadow: 0 0 30px 6px #9fd4ffcc;
  clip-path: polygon(40% 0%, 60% 0%, 80% 25%, 55% 30%, 85% 55%, 50% 62%, 70% 100%, 30% 65%, 55% 58%, 20% 32%, 45% 28%);
  animation: fx-lightning-core-anim 0.7s steps(2, jump-none) forwards;
}
.fx-lightning .fx-particle {
  width: 4px;
  height: 4px;
  background: #cfe8ff;
  box-shadow: 0 0 10px 3px #9fd4ffcc;
  animation-duration: 0.6s;
}

/* --- ice: a spreading frost burst --- */
@keyframes fx-ice-core-anim {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.2) rotate(0deg); }
  30% { opacity: 1; transform: translate(-50%, -50%) scale(1.1) rotate(20deg); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.7) rotate(35deg); }
}
.fx-ice .fx-core {
  width: 100px;
  height: 100px;
  background: radial-gradient(circle, #eaf9ffee 0%, #a9d8f0bb 40%, #6fb3d9 60%, transparent 78%);
  clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
  animation: fx-ice-core-anim 1.4s ease-out forwards;
}
.fx-ice .fx-particle {
  width: 6px;
  height: 6px;
  background: #eaf9ff;
  box-shadow: 0 0 8px 2px #a9d8f0bb;
  animation-duration: 1.6s;
}

/* --- poison: a lingering toxic cloud --- */
@keyframes fx-poison-core-anim {
  0% { opacity: 0; transform: translate(-50%, -50%) translateY(6px) scale(0.4); }
  25% { opacity: 0.95; }
  100% { opacity: 0; transform: translate(-50%, -50%) translateY(-30px) scale(1.9); }
}
.fx-poison .fx-core {
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: radial-gradient(circle, #b9e86688 0%, #6a9e3fcc 40%, #3d5c2688 65%, transparent 80%);
  filter: blur(1px);
  animation: fx-poison-core-anim 2.2s ease-out forwards;
}
.fx-poison .fx-particle {
  width: 7px;
  height: 7px;
  background: #a8d15c;
  box-shadow: 0 0 10px 3px #6a9e3f99;
  animation-duration: 2.4s;
  animation-name: fx-particle-rise-anim;
}

/* --- shield: a protective ward that holds then fades --- */
@keyframes fx-shield-core-anim {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.5); }
  20% { opacity: 1; transform: translate(-50%, -50%) scale(1.05); }
  70% { opacity: 0.9; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.15); }
}
.fx-shield .fx-core {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  border: 4px solid #cfe0ff;
  background: radial-gradient(circle, #cfe0ff33 0%, transparent 70%);
  box-shadow: 0 0 30px 6px #cfe0ff88, inset 0 0 20px 4px #cfe0ff55;
  animation: fx-shield-core-anim 1.6s ease-out forwards;
}
.fx-shield .fx-particle {
  width: 5px;
  height: 5px;
  background: #eaf1ff;
  box-shadow: 0 0 8px 2px #cfe0ffbb;
  animation-duration: 1.6s;
}

/* --- shared screen shake for punchy impacts --- */
@keyframes fx-shake-anim {
  0%, 100% { transform: translate(0, 0); }
  15% { transform: translate(-10px, 6px); }
  30% { transform: translate(9px, -7px); }
  45% { transform: translate(-8px, -5px); }
  60% { transform: translate(8px, 5px); }
  75% { transform: translate(-5px, 3px); }
  90% { transform: translate(4px, -2px); }
}
#mapArea.fx-shake { animation: fx-shake-anim 0.55s ease-in-out; }

.token {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid #fff8;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 2px #000;
  cursor: default;
  user-select: none;
  box-shadow: 0 2px 6px #0008;
}
.token.draggable { cursor: grab; }
.token.dragging { cursor: grabbing; opacity: 0.85; z-index: 10; }
.token.active-turn {
  z-index: 11;
  border-color: #fff;
  animation: token-active-glow 1.4s ease-in-out infinite;
}
@keyframes token-active-glow {
  0%, 100% { box-shadow: 0 2px 6px #0008, 0 0 0 0 #ffd76688, 0 0 14px 4px #ffd76699; }
  50% { box-shadow: 0 2px 6px #0008, 0 0 0 6px #ffd76600, 0 0 26px 10px #ffd766cc; }
}
.token .hp {
  position: absolute;
  bottom: -16px;
  font-size: 0.62rem;
  color: var(--text-dim);
  background: #000a;
  padding: 0 4px;
  border-radius: 4px;
  white-space: nowrap;
}

/* --- full-bleed map mode: the map fills the viewport behind floating,
   shadowed UI chrome, like a tabletop VTT rather than a page layout --- */
body.map-mode { overflow: hidden; }

body.map-mode #topbar,
body.map-mode #tabs {
  position: relative;
  z-index: 10;
  box-shadow: 0 10px 30px #000a;
}
body.map-mode #topbar {
  background: linear-gradient(to bottom, #14100c, var(--bg-alt));
}
body.map-mode #tabs {
  background: linear-gradient(to bottom, var(--bg-alt), #1c1712);
  border-bottom: 1px solid #000a;
}
body.map-mode .combat-banner {
  position: relative;
  z-index: 10;
  box-shadow: 0 8px 20px #0008;
}

body.map-mode #content {
  padding: 0;
  max-width: none;
  margin: 0;
}
body.map-mode #content > h1 {
  position: relative;
  z-index: 6;
  display: inline-block;
  vertical-align: top;
  margin: 1rem 1rem 0;
  padding: 0.35em 0.8em;
  font-size: 1rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: 0 10px 28px #000a;
}

body.map-mode #mapArea {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  aspect-ratio: unset;
  border: none;
  border-radius: 0;
  z-index: 1;
}
body.map-mode #mapArea::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, #000a 0%, transparent 220px);
  pointer-events: none;
  z-index: 2;
}

body.map-mode #content > .toolbar-wrap,
body.map-mode #content > p.muted {
  position: relative;
  z-index: 6;
  display: inline-flex;
  align-items: center;
  vertical-align: top;
  gap: 0.5em;
  margin: 1rem;
}
body.map-mode #content > p.muted {
  padding: 0.7em 0.9em;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 10px 28px #000a;
}
.toolbar-wrap #toolbarToggleBtn {
  border-radius: 999px;
  box-shadow: 0 10px 28px #000a;
  flex-shrink: 0;
}
.toolbar-wrap .toolbar {
  padding: 0.7em 0.9em;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 10px 28px #000a;
  margin: 0;
}
.toolbar-divider {
  width: 1px;
  align-self: stretch;
  background: var(--border);
  margin: 0 0.1em;
}
/* Overrides the base .field's label-above-input stack — in a single-row
   toolbar that makes this field much taller than its sibling buttons,
   throwing off the whole bar's height. Keep label and input side by side. */
.toolbar-field {
  flex: 0 0 auto;
  flex-direction: row;
  align-items: center;
  gap: 0.5em;
}
.toolbar-field label { white-space: nowrap; margin-bottom: 0; }
/* input[type=number] elsewhere is deliberately oversized for touch (see the
   stat-box rule above) — that's what was blowing this field up to ~58px
   tall next to ~35px buttons. Put it back to normal input sizing here. */
.toolbar-field input {
  width: 4em;
  padding: 0.45em 0.6em;
  font-size: 0.95rem;
  font-weight: 400;
  min-height: 0;
}

/* token editor floats top-right so it never collides with the roll/zoom
   controls that live in the bottom corners */
body.map-mode #tokenEditor:not(:empty) {
  position: fixed;
  right: 1.2rem;
  top: 6.5rem;
  z-index: 12;
  max-width: min(340px, calc(100vw - 2.4rem));
  max-height: calc(100vh - 8rem);
  overflow-y: auto;
}
body.map-mode #tokenEditor .card {
  margin-top: 0 !important;
  box-shadow: 0 16px 40px #000c;
}

@media (max-width: 640px) {
  body.map-mode #content > .toolbar-wrap,
  body.map-mode #content > p.muted {
    margin: 0.6rem;
  }
  .toolbar-wrap .toolbar { flex-wrap: wrap; }
  .toolbar-divider { display: none; }
}

/* --- zoom controls, always floating bottom-center over the map --- */
#zoomControls {
  position: fixed;
  left: 50%;
  bottom: 1.2rem;
  transform: translateX(-50%);
  z-index: 8;
  display: flex;
  gap: 0.3em;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.3em;
  box-shadow: 0 10px 28px #000a;
}
#zoomControls button {
  border-radius: 999px;
  padding: 0.4em 0.8em;
  min-width: 2.4em;
  font-weight: 700;
}
#zoomControls #zoomResetBtn { font-weight: 400; font-size: 0.8rem; }

/* --- generic floating dropdown panel (map pack picker etc.) --- */
.dropdown-panel {
  position: absolute;
  top: calc(100% + 0.4em);
  left: 0;
  z-index: 15;
  min-width: 220px;
  max-width: 300px;
  max-height: 320px;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 14px 34px #000c;
}
.dropdown-item {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  padding: 0.55em 0.8em;
}
.dropdown-item:last-child { border-bottom: none; }
.dropdown-item:hover { background: var(--panel-2); }
.dropdown-heading {
  padding: 0.5em 0.8em 0.2em;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  background: var(--panel-2);
}

/* --- dice --- */
#rollFab {
  position: fixed;
  right: 1.2rem;
  bottom: 1.2rem;
  border-radius: 999px;
  padding: 0.8em 1.2em;
  font-size: 1rem;
  font-weight: 700;
  background: var(--accent);
  color: #201a10;
  border-color: var(--accent);
  box-shadow: 0 4px 14px #0007;
  z-index: 20;
}
#rollFab:hover { background: var(--accent-strong); }

/* --- dice toast: tumble-and-pop feedback for every roll, table-wide --- */
.dice-toast {
  position: fixed;
  right: 1.2rem;
  bottom: 5.4rem;
  z-index: 25;
  display: flex;
  align-items: center;
  gap: 0.7em;
  background: var(--panel);
  border: 2px solid var(--accent);
  border-radius: var(--radius);
  padding: 0.6em 1.1em;
  box-shadow: 0 10px 30px #000a;
  pointer-events: none;
  animation: dice-toast-life 2.2s ease forwards;
}
@keyframes dice-toast-life {
  0% { opacity: 0; transform: translateY(16px) scale(0.85); }
  10% { opacity: 1; transform: translateY(0) scale(1); }
  85% { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(-8px) scale(0.96); }
}
.dice-toast-icon {
  font-size: 2rem;
  display: inline-block;
  animation: dice-toast-tumble 0.6s ease-out;
}
@keyframes dice-toast-tumble {
  0% { transform: rotate(0deg) scale(0.6); }
  30% { transform: rotate(200deg) scale(1.25); }
  60% { transform: rotate(330deg) scale(0.9); }
  100% { transform: rotate(360deg) scale(1); }
}
.dice-toast-value {
  font-size: 1.5rem;
  font-weight: 800;
  line-height: 1;
  color: var(--accent-strong);
  animation: dice-toast-pop 0.35s ease-out 0.5s both;
}
@keyframes dice-toast-pop {
  0% { transform: scale(0.3); opacity: 0; }
  70% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1); }
}
.dice-toast-who { font-size: 0.78rem; color: var(--text-dim); margin-top: 0.15em; }

.modal-backdrop {
  position: fixed; inset: 0;
  background: #000c;
  display: flex; align-items: center; justify-content: center;
  z-index: 50;
  padding: 1rem;
}
.modal {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem;
  width: 100%;
  max-width: 340px;
}
.numpad-display {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 2.2rem;
  text-align: right;
  padding: 0.3em 0.5em;
  margin-bottom: 0.7em;
  min-height: 1.3em;
  letter-spacing: 0.05em;
}
.numpad-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.5em; margin-bottom: 0.8em; }
.numpad-grid button { font-size: 1.3rem; padding: 0.6em 0; }

.roll-type-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.5em; margin-bottom: 0.9em; }
.roll-type-chip {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 600;
  padding: 0.8em 0.5em;
  text-align: center;
  line-height: 1.25;
}
.roll-type-chip:hover { border-color: var(--accent); background: #362c22; }
.roll-type-chip.selected {
  background: var(--accent);
  border-color: var(--accent-strong);
  color: #201a10;
  box-shadow: 0 0 0 2px var(--accent-strong);
}

.adv-toggle-row { display: flex; gap: 0.4em; margin-bottom: 0.9em; }
.adv-toggle-btn {
  flex: 1;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-dim);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.6em 0.3em;
  text-align: center;
}
.adv-toggle-btn:hover { border-color: var(--accent); }
.adv-toggle-btn[data-adv="adv"].selected { background: var(--good); border-color: var(--good); color: #12210f; }
.adv-toggle-btn[data-adv="dis"].selected { background: var(--danger); border-color: var(--danger-strong); color: #2a0f0c; }
.adv-toggle-btn[data-adv="normal"].selected { background: var(--panel); border-color: var(--accent); color: var(--text); }

#rollFeedToggle {
  position: fixed;
  left: 1.2rem;
  bottom: 1.2rem;
  z-index: 20;
}
#rollFeed {
  position: fixed;
  left: 1.2rem;
  bottom: 4rem;
  width: 260px;
  max-height: 40vh;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.6em;
  z-index: 20;
  font-size: 0.85rem;
}
#rollFeed .roll-entry { display: flex; justify-content: space-between; gap: 0.5em; padding: 0.25em 0; border-bottom: 1px dashed var(--border); }
#rollFeed .roll-entry .who { color: var(--text-dim); }
#rollFeed .roll-entry .val { font-weight: 700; color: var(--accent-strong); }

/* On a narrow phone, the roll-log toggle (left), zoom controls (center),
   and roll FAB (right) all share the same bottom row and can crowd into
   each other — shrink them just enough to keep clear space between. */
@media (max-width: 480px) {
  #zoomControls { padding: 0.2em; gap: 0.15em; }
  #zoomControls button { padding: 0.35em 0.55em; min-width: 1.8em; font-size: 0.82rem; }
  #zoomControls #zoomResetBtn { font-size: 0.68rem; padding: 0.35em 0.5em; }
  #rollFab { padding: 0.6em 0.85em; font-size: 0.88rem; right: 0.8rem; }
  #rollFeedToggle { padding: 0.35em 0.6em; font-size: 0.75rem; left: 0.8rem; }
  #rollFeed { left: 0.8rem; width: calc(100vw - 1.6rem); }
}

.item-row-wrap { border-bottom: 1px solid var(--border); }
.item-row-wrap:last-child { border-bottom: none; }

.equipped-row {
  display: flex;
  align-items: center;
  gap: 0.7em;
  padding: 0.4em 0.2em;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}
.equipped-row:last-child { border-bottom: none; }
.equipped-row .name { flex: 1; font-weight: 600; }
.equipped-row .equipped-stats { color: var(--accent-strong); font-size: 0.82rem; }
.item-row { display: flex; gap: 0.5em; align-items: center; padding: 0.3em 0; font-size: 0.9rem; }
.item-row .name { flex: 1; }
.item-row input[type=text] { width: 100%; }
.item-row input[type=number] { width: 4.8em; }
.item-name-btn {
  flex: 1;
  text-align: left;
  background: none;
  border: none;
  padding: 0.2em 0.3em;
  margin: 0 -0.3em;
  border-radius: 5px;
  color: var(--text);
  font-size: 0.9rem;
  transition: background 0.12s;
}
.item-name-btn:not(:disabled) { cursor: pointer; }
.item-name-btn:hover:not(:disabled) { background: var(--panel-2); }

/* --- item detail: a proper RPG item-card dialog --- */
.item-detail-modal {
  max-width: 360px;
  text-align: center;
  border: 2px solid var(--accent);
  background: linear-gradient(180deg, var(--panel) 0%, var(--bg-alt) 100%);
  padding-top: 2.4rem;
  position: relative;
  overflow: visible;
}
.item-detail-icon {
  font-size: 2.4rem;
  width: 76px;
  height: 76px;
  line-height: 1;
  margin: -3.6rem auto 0.7rem;
  background: var(--panel-2);
  border: 3px solid var(--accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 20px #000a;
}
.item-detail-name { margin-bottom: 0; }
.item-detail-divider {
  width: 55%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  margin: 0.7em auto;
}
.item-detail-stats {
  display: inline-block;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.4em 0.9em;
  color: var(--accent-strong);
  font-weight: 700;
  font-size: 0.9rem;
  margin-bottom: 0.7em;
}
.item-detail-desc { color: var(--text-dim); font-style: italic; line-height: 1.5; margin: 0; }
.qty-stepper { display: flex; align-items: center; gap: 0.25em; flex-shrink: 0; }
.qty-stepper button { padding: 0.4em 0.75em; line-height: 1.4; font-size: 1rem; }
.qty-stepper .qty-input { width: 4.8em; text-align: center; padding: 0.55em 0.3em; font-size: 1.2rem; font-weight: 600; min-height: 0; }

/* --- container items (packs) holding their own sub-items --- */
.item-contents {
  margin: 0 0 0.6em 2.2em;
  padding: 0.5em 0.7em;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 6px;
}
.item-contents .toolbar { margin: 0.5em 0 0; }
.content-row {
  display: flex;
  align-items: center;
  gap: 0.6em;
  padding: 0.25em 0;
  border-bottom: 1px dashed var(--border);
  font-size: 0.85rem;
}
.content-row:last-child { border-bottom: none; }
.content-row .name { flex: 1; color: var(--text-dim); }

.toolbar { display: flex; gap: 0.5em; flex-wrap: wrap; align-items: center; margin-bottom: 0.8em; }

.creature-row {
  display: flex;
  align-items: center;
  gap: 0.7em;
  padding: 0.4em 0.5em;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}
.creature-row .name { font-weight: 600; flex: 1; }
.creature-row:last-child { border-bottom: none; }

/* --- class/race/custom move cards (character sheet) --- */
.move-card {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3em 0.7em;
  padding: 0.5em 0.6em;
  margin-bottom: 0.5em;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.1s ease-out;
}
.move-card:hover { border-color: var(--accent); background: #362c22; }
.move-card:active { transform: scale(0.99); background: var(--panel); transition-duration: 0.05s; }
.move-card-head { display: flex; align-items: center; gap: 0.6em; flex: 1 0 100%; }
.move-card-name { font-weight: 600; flex: 1; }
.move-card-effect { color: var(--good); font-size: 0.85rem; }
.move-card-roll { color: var(--text-dim); font-size: 0.85rem; }
.move-card-weapon { color: var(--accent-strong); font-size: 0.85rem; flex: 1 0 100%; }
.move-card-weapon.muted { color: var(--text-dim); }
.move-row-weapon { padding: 0 0 0.4em 0.2em; margin-top: -0.3em; }
.move-row-weapon .move-card-weapon { font-size: 0.8rem; }
.move-detail-line { font-size: 0.9rem; color: var(--text-dim); margin: 0 0 0.5em; }
.move-detail-line.good { color: var(--good); }

.race-class-profs { margin-bottom: 0.8em; }
.prof-line { display: flex; gap: 0.6em; padding: 0.3em 0; border-bottom: 1px dashed var(--border); font-size: 0.88rem; }
.prof-line:last-child { border-bottom: none; }
.prof-label { color: var(--text-dim); text-transform: uppercase; font-size: 0.7rem; letter-spacing: 0.03em; flex: 0 0 6.5em; padding-top: 0.15em; }
.prof-items { flex: 1; }
.move-charge-badge {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent-strong);
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.15em 0.6em;
  white-space: nowrap;
}
.move-charge-badge.at-will { color: var(--text-dim); }
.item-row .move-charge-badge { flex-shrink: 0; }
.item-row .move-use-btn { flex-shrink: 0; }
.move-item-row { cursor: pointer; border-radius: 6px; padding-left: 0.3em; padding-right: 0.3em; margin: 0 -0.3em; transition: background 0.12s; }
.move-item-row:hover { background: var(--panel-2); }
.move-item-row:active { background: var(--bg-alt); }

/* Use buttons get a much bigger, easier-to-press target than the standard
   .small buttons everything else in these rows uses. */
.move-card .move-use-btn, .item-row .move-use-btn {
  margin-left: auto;
  padding: 0.65em 1.4em;
  font-size: 1rem;
  font-weight: 700;
}

@media (max-width: 640px) {
  #content { padding: 0.8rem; }
  #rollFeed { width: calc(100vw - 2.4rem); }
}
