/* Everpeach D&D: dark by default, parchment light theme via [data-theme="light"] or OS preference. */
:root {
  --bg: #13110f;
  --bg-grad: radial-gradient(1200px 600px at 10% -10%, #2a1612 0%, transparent 60%), radial-gradient(900px 500px at 110% 0%, #1b1a24 0%, transparent 55%);
  --surface: #1d1916;
  --surface-2: #26211d;
  --surface-3: #312a25;
  --border: #3b332d;
  --border-strong: #54483f;
  --text: #eee6da;
  --text-muted: #a99d8e;
  --text-faint: #7d7266;
  --accent: #d9483a;
  --accent-strong: #ef5b4b;
  --accent-ink: #fff4ee;
  --accent-soft: rgba(217, 72, 58, 0.14);
  --gold: #d9aa55;
  --gold-soft: rgba(217, 170, 85, 0.14);
  --good: #5cb87a;
  --good-soft: rgba(92, 184, 122, 0.15);
  --warn: #e0a43a;
  --bad: #e5574a;
  --info: #6aa7e0;
  --info-soft: rgba(106, 167, 224, 0.14);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  --radius: 10px;
  --radius-sm: 6px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Cinzel", Georgia, "Times New Roman", serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f3ece0;
    --bg-grad: radial-gradient(1200px 600px at 10% -10%, #f9e2d6 0%, transparent 60%), radial-gradient(900px 500px at 110% 0%, #e7e4f2 0%, transparent 55%);
    --surface: #fffaf2;
    --surface-2: #f6eee1;
    --surface-3: #ece1cf;
    --border: #e0d3bf;
    --border-strong: #c9b79c;
    --text: #2a2019;
    --text-muted: #6b5d4f;
    --text-faint: #958674;
    --accent: #b02b1f;
    --accent-strong: #c93526;
    --accent-ink: #fff;
    --accent-soft: rgba(176, 43, 31, 0.1);
    --gold: #9a6a12;
    --gold-soft: rgba(154, 106, 18, 0.12);
    --good: #2f8a4c;
    --good-soft: rgba(47, 138, 76, 0.12);
    --warn: #a86d07;
    --bad: #c2382b;
    --info: #2f6ea8;
    --info-soft: rgba(47, 110, 168, 0.1);
    --shadow: 0 10px 30px rgba(80, 50, 20, 0.15);
    color-scheme: light;
  }
}
:root[data-theme="light"] {
  --bg: #f3ece0;
  --bg-grad: radial-gradient(1200px 600px at 10% -10%, #f9e2d6 0%, transparent 60%), radial-gradient(900px 500px at 110% 0%, #e7e4f2 0%, transparent 55%);
  --surface: #fffaf2;
  --surface-2: #f6eee1;
  --surface-3: #ece1cf;
  --border: #e0d3bf;
  --border-strong: #c9b79c;
  --text: #2a2019;
  --text-muted: #6b5d4f;
  --text-faint: #958674;
  --accent: #b02b1f;
  --accent-strong: #c93526;
  --accent-ink: #fff;
  --accent-soft: rgba(176, 43, 31, 0.1);
  --gold: #9a6a12;
  --gold-soft: rgba(154, 106, 18, 0.12);
  --good: #2f8a4c;
  --good-soft: rgba(47, 138, 76, 0.12);
  --warn: #a86d07;
  --bad: #c2382b;
  --info: #2f6ea8;
  --info-soft: rgba(47, 110, 168, 0.1);
  --shadow: 0 10px 30px rgba(80, 50, 20, 0.15);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  background-image: var(--bg-grad);
  background-attachment: fixed;
  color: var(--text);
  font: 15px/1.5 var(--font);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--accent-strong); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 700; letter-spacing: 0.02em; margin: 0 0 0.5em; line-height: 1.2; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; }
h4 { font-size: 0.95rem; }
p { margin: 0 0 0.8em; }
hr { border: 0; border-top: 1px solid var(--border); margin: 1rem 0; }
[hidden] { display: none !important; }
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.small { font-size: 0.85em; }
.mono { font-family: var(--mono); }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.grow { flex: 1; }
.row { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; }
.row.tight { gap: 0.3rem; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 0.75rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---- top bar ---- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 1rem;
  padding: 0.55rem 1.25rem;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 0.5rem; color: var(--text); font-family: var(--font-display); font-size: 1.05rem; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand b { color: var(--accent-strong); }
.mainnav { display: flex; gap: 0.15rem; flex: 1; overflow-x: auto; scrollbar-width: none; }
.mainnav::-webkit-scrollbar { display: none; }
.mainnav a {
  color: var(--text-muted); padding: 0.4rem 0.75rem; border-radius: var(--radius-sm); font-weight: 500; white-space: nowrap; font-size: 0.93rem;
}
.mainnav a:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.mainnav a.active { color: var(--text); background: var(--accent-soft); box-shadow: inset 0 -2px 0 var(--accent); }
.mainnav a.live::after { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--accent-strong); margin-left: 6px; vertical-align: 2px; animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { opacity: 0.3; } }
.topbar-right { display: flex; align-items: center; gap: 0.5rem; }
.user-chip { display: flex; align-items: center; gap: 0.45rem; color: var(--text); font-size: 0.9rem; padding: 0.25rem 0.6rem 0.25rem 0.25rem; border-radius: 99px; border: 1px solid var(--border); white-space: nowrap; }
.user-chip:hover { text-decoration: none; background: var(--surface-2); }
.user-chip .avatar { width: 26px; height: 26px; font-size: 0.75rem; }
.role-tag { font-size: 0.68rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--gold); }

.app { flex: 1; width: 100%; max-width: 1320px; margin: 0 auto; padding: 1.25rem 1.25rem 6rem; }
.loading { padding: 3rem; text-align: center; color: var(--text-muted); }
.site-footer { text-align: center; color: var(--text-faint); font-size: 0.78rem; padding: 1rem 1rem 5rem; }
.site-footer a { color: var(--text-muted); }

/* ---- generic components ---- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem; }
.card.flush { padding: 0; }
.card-title { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.7rem; }
.card-title h2, .card-title h3 { margin: 0; }
.section-label { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase; color: var(--text-muted); margin: 0 0 0.5rem; font-family: var(--font); }
.grid { display: grid; gap: 1rem; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.1rem; }
.page-head h1 { margin: 0; }
.page-head p { margin: 0.2rem 0 0; color: var(--text-muted); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  font: 600 0.88rem/1 var(--font); color: var(--text);
  background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  padding: 0.55rem 0.85rem; cursor: pointer; white-space: nowrap; text-decoration: none;
}
.btn:hover { background: var(--surface-3); text-decoration: none; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-strong); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-muted); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 0.32rem 0.55rem; font-size: 0.8rem; }
.btn.xs { padding: 0.2rem 0.4rem; font-size: 0.74rem; }
.btn.on { background: var(--accent-soft); border-color: var(--accent); color: var(--text); }
.icon-btn { background: none; border: 1px solid transparent; color: var(--text-muted); font-size: 1.1rem; width: 34px; height: 34px; border-radius: var(--radius-sm); cursor: pointer; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface-2); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); padding: 0.45rem 0.6rem; min-width: 0;
}
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
textarea { width: 100%; min-height: 6rem; resize: vertical; line-height: 1.45; }
input[type="checkbox"] { accent-color: var(--accent); width: 1rem; height: 1rem; }
input[type="number"] { -moz-appearance: textfield; }
input[type="number"]::-webkit-inner-spin-button { opacity: 0.4; }
label.field { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.82rem; color: var(--text-muted); font-weight: 500; }
label.field > input, label.field > select, label.field > textarea { font-size: 0.95rem; color: var(--text); }
label.check { display: inline-flex; align-items: center; gap: 0.4rem; cursor: pointer; font-size: 0.9rem; }
.form-grid { display: grid; gap: 0.75rem; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.searchbox { position: relative; }
.searchbox input { width: 100%; padding-left: 2rem; }
.searchbox::before { content: "⌕"; position: absolute; left: 0.65rem; top: 50%; transform: translateY(-52%); color: var(--text-faint); font-size: 1.1rem; }

.pill { display: inline-flex; align-items: center; gap: 0.3rem; font-size: 0.74rem; font-weight: 600; padding: 0.12rem 0.5rem; border-radius: 99px; background: var(--surface-3); color: var(--text-muted); white-space: nowrap; }
.pill.accent { background: var(--accent-soft); color: var(--accent-strong); }
.pill.gold { background: var(--gold-soft); color: var(--gold); }
.pill.good { background: var(--good-soft); color: var(--good); }
.pill.info { background: var(--info-soft); color: var(--info); }
.pill .x { cursor: pointer; opacity: 0.7; }
.pill .x:hover { opacity: 1; }

.tabs { display: flex; gap: 0.2rem; border-bottom: 1px solid var(--border); margin-bottom: 1rem; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button, .tabs a {
  background: none; border: 0; border-bottom: 2px solid transparent; color: var(--text-muted); font: 600 0.88rem var(--font);
  padding: 0.6rem 0.85rem; cursor: pointer; white-space: nowrap; margin-bottom: -1px;
}
.tabs button:hover, .tabs a:hover { color: var(--text); text-decoration: none; }
.tabs .active { color: var(--text); border-bottom-color: var(--accent); }
.tabs .count { color: var(--text-faint); font-weight: 500; margin-left: 0.25rem; }

.avatar {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 44px; height: 44px; border-radius: 50%; overflow: hidden;
  background: linear-gradient(135deg, var(--accent), #7a2a5c); color: #fff; font-family: var(--font-display); font-weight: 700;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.lg { width: 84px; height: 84px; font-size: 1.8rem; border: 2px solid var(--border-strong); }

.empty { text-align: center; padding: 2rem 1rem; color: var(--text-muted); border: 1px dashed var(--border-strong); border-radius: var(--radius); }
.empty h3 { color: var(--text); }

table.data { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
table.data th { text-align: left; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-muted); font-weight: 700; padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--border-strong); white-space: nowrap; }
table.data td { padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data tr.clickable { cursor: pointer; }
table.data tr.clickable:hover td { background: var(--surface-2); }
.table-wrap { overflow-x: auto; }

.bar { height: 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--good); border-radius: inherit; transition: width 0.3s; }
.bar.mid > span { background: var(--warn); }
.bar.low > span { background: var(--bad); }
.bar .temp { background: var(--info); }

/* ---- markdown / rules text ---- */
.prose { line-height: 1.6; overflow-wrap: anywhere; }
.prose p { margin: 0 0 0.75em; }
.prose ul, .prose ol { margin: 0 0 0.8em; padding-left: 1.3rem; }
.prose li { margin: 0.15em 0; }
.prose h1, .prose h2, .prose h3, .prose h4 { margin: 1em 0 0.4em; }
.prose h1 { font-size: 1.35rem; } .prose h2 { font-size: 1.15rem; } .prose h3 { font-size: 1rem; } .prose h4 { font-size: 0.92rem; }
.prose table { border-collapse: collapse; margin: 0.4em 0 1em; font-size: 0.88rem; display: block; overflow-x: auto; max-width: 100%; }
.prose th, .prose td { border: 1px solid var(--border); padding: 0.3rem 0.55rem; text-align: left; vertical-align: top; }
.prose th { background: var(--surface-2); }
.prose blockquote { margin: 0 0 0.8em; padding: 0.3em 0.9em; border-left: 3px solid var(--gold); color: var(--text-muted); }
.prose code { font-family: var(--mono); font-size: 0.88em; background: var(--surface-3); padding: 0.05em 0.3em; border-radius: 4px; }
.prose > :last-child { margin-bottom: 0; }
.rollable { color: var(--accent-strong); font-weight: 600; cursor: pointer; border-bottom: 1px dotted currentColor; white-space: nowrap; }
.rollable:hover { color: var(--text); }

/* ---- login ---- */
.login-wrap { min-height: 80vh; display: grid; place-items: center; }
.login-card { width: min(400px, 100%); padding: 2rem 1.75rem; text-align: center; }
.login-card img { margin-bottom: 0.4rem; }
.login-card h1 { font-size: 1.6rem; }
.login-card form { display: flex; flex-direction: column; gap: 0.8rem; text-align: left; margin-top: 1.25rem; }
.login-card .btn { padding: 0.75rem; font-size: 0.95rem; }
.form-error { color: var(--bad); font-size: 0.88rem; min-height: 1.2em; }

/* ---- home ---- */
.hero { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.hero h1 { font-size: 2rem; margin: 0; }
.hero p { margin: 0.25rem 0 0; color: var(--text-muted); }
.party-grid { display: grid; gap: 0.9rem; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); margin-bottom: 1.5rem; }
.pc-card { display: flex; flex-direction: column; gap: 0.7rem; color: var(--text); transition: transform 0.15s, border-color 0.15s; position: relative; }
.pc-card:hover { text-decoration: none; border-color: var(--accent); transform: translateY(-2px); }
.pc-card .top { display: flex; gap: 0.75rem; align-items: center; }
.pc-card .name { font-family: var(--font-display); font-weight: 700; font-size: 1.08rem; line-height: 1.2; }
.pc-card .sub { color: var(--text-muted); font-size: 0.82rem; }
.pc-card .stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.4rem; text-align: center; }
.pc-card .stat { background: var(--surface-2); border-radius: var(--radius-sm); padding: 0.35rem 0.2rem; }
.pc-card .stat b { display: block; font-size: 1.05rem; }
.pc-card .stat span { font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); }
.pc-card .hpline { display: flex; justify-content: space-between; font-size: 0.8rem; color: var(--text-muted); margin-bottom: 0.25rem; }
.pc-card .mine { position: absolute; top: 0.6rem; right: 0.7rem; }
.combat-banner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; border-color: var(--accent); background: linear-gradient(90deg, var(--accent-soft), transparent); margin-bottom: 1.25rem; }
.feed-item { padding: 0.6rem 0; border-bottom: 1px solid var(--border); }
.feed-item:last-child { border-bottom: 0; }
.feed-item .meta { font-size: 0.76rem; color: var(--text-faint); }
.clamp { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* ---- character sheet ---- */
.sheet-head { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; margin-bottom: 1rem; }
.sheet-head .who { flex: 1; min-width: 220px; }
.sheet-head h1 { margin: 0; font-size: 1.9rem; }
.sheet-head .line { color: var(--text-muted); }
.sheet-head .actions { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.save-state { font-size: 0.78rem; color: var(--text-faint); min-width: 4.5rem; text-align: right; }
.save-state.err { color: var(--bad); }

.statstrip { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)) repeat(4, minmax(0, 1fr)); gap: 0.6rem; margin-bottom: 1rem; }
.ability, .bigstat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  text-align: center; padding: 0.55rem 0.3rem 0.5rem; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.1rem;
}
.ability .lbl, .bigstat .lbl { font-size: 0.68rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); }
.ability .mod { font-size: 1.65rem; font-weight: 700; line-height: 1.1; }
.ability .score { font-size: 0.8rem; color: var(--text-muted); background: var(--surface-2); border-radius: 99px; padding: 0 0.55rem; }
.ability input { width: 3.6rem; text-align: center; padding: 0.15rem; font-size: 0.85rem; }
.bigstat .val { font-size: 1.55rem; font-weight: 700; line-height: 1.15; }
.bigstat.ac .val { color: var(--gold); }
.clickroll { cursor: pointer; border-radius: var(--radius-sm); transition: background 0.12s, color 0.12s; }
.clickroll:hover { background: var(--accent-soft); color: var(--accent-strong); }

.hpbox { grid-column: span 2; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.55rem 0.7rem; display: flex; flex-direction: column; gap: 0.35rem; }
.hpbox .nums { display: flex; justify-content: space-between; align-items: baseline; gap: 0.4rem; }
.hpbox .cur { font-size: 1.6rem; font-weight: 700; }
.hpbox .cur small { font-size: 0.95rem; color: var(--text-muted); font-weight: 500; }
.hpbox .tmp { color: var(--info); font-size: 0.85rem; font-weight: 600; }
.hpbox .ctl { display: flex; gap: 0.3rem; }
.hpbox .ctl input { width: 3.8rem; text-align: center; padding: 0.25rem; }
.hpbox .ctl .btn { flex: 1; padding: 0.3rem 0.3rem; font-size: 0.75rem; }
.btn.heal { color: var(--good); }
.btn.dmg { color: var(--bad); }

.sheet-body { display: grid; grid-template-columns: 250px 250px minmax(0, 1fr); gap: 1rem; align-items: start; }
.sheet-col { display: flex; flex-direction: column; gap: 1rem; }
.list-rows { display: flex; flex-direction: column; }
.list-rows .r { display: flex; align-items: center; gap: 0.5rem; padding: 0.28rem 0.35rem; border-radius: var(--radius-sm); font-size: 0.9rem; }
.list-rows .r .nm { flex: 1; }
.list-rows .r .nm small { color: var(--text-faint); font-size: 0.72rem; text-transform: uppercase; margin-left: 0.25rem; }
.list-rows .r .bn { font-weight: 700; min-width: 2.4rem; text-align: right; }
.list-rows .r.clickroll:hover .bn { color: var(--accent-strong); }
.prof { width: 12px; height: 12px; border-radius: 50%; border: 1.5px solid var(--border-strong); flex: none; display: inline-block; }
.prof.p1 { background: var(--accent); border-color: var(--accent); }
.prof.p2 { background: var(--gold); border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold-soft); }
.prof.half { background: linear-gradient(90deg, var(--accent) 50%, transparent 50%); border-color: var(--accent); }
button.prof { cursor: pointer; padding: 0; }
.kv { display: flex; justify-content: space-between; gap: 0.5rem; padding: 0.3rem 0; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
.kv:last-child { border-bottom: 0; }
.kv b { font-weight: 700; }

.slot-row { display: flex; align-items: center; gap: 0.6rem; margin: 0.4rem 0 0.2rem; }
.slot-row .lv { font-family: var(--font-display); font-weight: 700; min-width: 4.8rem; }
.pips { display: inline-flex; gap: 0.25rem; flex-wrap: wrap; }
.pip { width: 16px; height: 16px; border-radius: 4px; border: 1.5px solid var(--accent); background: var(--accent); cursor: pointer; padding: 0; }
.pip.used { background: transparent; border-color: var(--border-strong); }
.pip:disabled { cursor: default; }
.pip.round { border-radius: 50%; }

.item-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 0.6rem; align-items: center; padding: 0.55rem 0.4rem; border-bottom: 1px solid var(--border); }
.item-row:last-child { border-bottom: 0; }
.item-row .title { font-weight: 600; cursor: pointer; }
.item-row .title:hover { color: var(--accent-strong); }
.item-row .meta { font-size: 0.78rem; color: var(--text-muted); }
.item-row .ctrls { display: flex; gap: 0.3rem; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.item-row .ctrls input { width: 3.6rem; text-align: center; padding: 0.2rem; }
.item-row.expanded .details { grid-column: 1 / -1; }
.details { font-size: 0.88rem; background: var(--surface-2); border-radius: var(--radius-sm); padding: 0.7rem 0.85rem; margin-top: 0.3rem; }

.attack-table td.hit, .attack-table td.dmgc { font-weight: 700; }
.attack-table .rollbtn { font-weight: 700; color: var(--text); background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 0.2rem 0.5rem; cursor: pointer; font: inherit; white-space: nowrap; }
.attack-table .rollbtn:hover { border-color: var(--accent); color: var(--accent-strong); }

.currency { display: grid; grid-template-columns: repeat(5, 1fr); gap: 0.4rem; }
.currency label { display: flex; flex-direction: column; align-items: center; gap: 0.15rem; font-size: 0.7rem; font-weight: 700; text-transform: uppercase; color: var(--text-muted); }
.currency input { width: 100%; text-align: center; }
.currency .gp { color: var(--gold); }

.conditions-box { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.death-saves { display: flex; gap: 1rem; align-items: center; font-size: 0.8rem; color: var(--text-muted); }
.death-saves .pip.s { border-color: var(--good); background: var(--good); }
.death-saves .pip.f { border-color: var(--bad); background: var(--bad); }
.death-saves .pip.used { background: transparent; }

.feature { padding: 0.65rem 0; border-bottom: 1px solid var(--border); }
.feature:last-child { border-bottom: 0; }
.feature .fh { display: flex; justify-content: space-between; gap: 0.6rem; align-items: center; cursor: pointer; }
.feature .fh h4 { margin: 0; font-family: var(--font); font-weight: 700; }
.feature .src { font-size: 0.74rem; color: var(--text-faint); }

.edit-banner { background: var(--gold-soft); border: 1px solid var(--gold); color: var(--text); border-radius: var(--radius); padding: 0.55rem 0.85rem; margin-bottom: 1rem; font-size: 0.88rem; display: flex; justify-content: space-between; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.class-edit { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 2fr) 70px auto; gap: 0.4rem; align-items: end; margin-bottom: 0.4rem; }

/* ---- compendium ---- */
.comp-cats { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 0.8rem; }
.comp-cat { display: flex; flex-direction: column; gap: 0.25rem; color: var(--text); }
.comp-cat:hover { text-decoration: none; border-color: var(--accent); }
.comp-cat .ico { font-size: 1.6rem; }
.comp-cat b { font-family: var(--font-display); font-size: 1.05rem; }
.comp-cat span { color: var(--text-muted); font-size: 0.82rem; }
.comp-layout { display: grid; grid-template-columns: minmax(300px, 420px) minmax(0, 1fr); gap: 1rem; align-items: start; }
.comp-list { max-height: calc(100vh - 230px); overflow-y: auto; }
.comp-list .li { display: flex; justify-content: space-between; gap: 0.5rem; align-items: center; padding: 0.5rem 0.8rem; border-bottom: 1px solid var(--border); cursor: pointer; color: var(--text); }
.comp-list .li:hover { background: var(--surface-2); text-decoration: none; }
.comp-list .li.active { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.comp-list .li .n { font-weight: 600; }
.comp-list .li .s { font-size: 0.78rem; color: var(--text-muted); }
.comp-filters { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 0.75rem; }
.comp-filters .searchbox { flex: 1 1 220px; }
.comp-filters select { flex: 0 1 auto; }
.comp-detail { position: sticky; top: 70px; max-height: calc(100vh - 90px); overflow-y: auto; }
.statblock .tagline { font-style: italic; color: var(--text-muted); margin-bottom: 0.6rem; }
.statblock .abil { display: grid; grid-template-columns: repeat(6, 1fr); gap: 0.3rem; text-align: center; margin: 0.6rem 0; }
.statblock .abil div { background: var(--surface-2); border-radius: var(--radius-sm); padding: 0.3rem 0; font-size: 0.85rem; }
.statblock .abil b { display: block; font-size: 0.7rem; letter-spacing: 0.08em; color: var(--text-muted); }
.statblock .line { margin: 0.15rem 0; font-size: 0.92rem; }
.statblock h3 { border-bottom: 1px solid var(--accent); padding-bottom: 0.2rem; margin-top: 1.1rem; color: var(--accent-strong); font-size: 1rem; }
.statblock .act { margin: 0.45rem 0; }
.statblock .act > b { font-style: italic; }
.statblock .act .prose { display: inline; }
.statblock .act .prose p { display: inline; }
.props-line { display: flex; gap: 0.35rem; flex-wrap: wrap; margin: 0.5rem 0; }

/* ---- campaign ---- */
.entry-card { display: flex; flex-direction: column; gap: 0.4rem; color: var(--text); cursor: pointer; }
.entry-card:hover { border-color: var(--accent); }
.entry-card .eh { display: flex; justify-content: space-between; gap: 0.5rem; align-items: flex-start; }
.entry-card h3 { margin: 0; font-size: 1.02rem; }
.entry-card .ex { color: var(--text-muted); font-size: 0.88rem; }
.entry-card.dm { border-style: dashed; border-color: var(--gold); }

/* ---- combat ---- */
.combat-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 1rem; align-items: start; }
.combatant { display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; gap: 0.75rem; align-items: center; padding: 0.65rem 0.8rem; border-bottom: 1px solid var(--border); }
.combatant:last-child { border-bottom: 0; }
.combatant.current { background: var(--accent-soft); box-shadow: inset 4px 0 0 var(--accent); }
.combatant.down { opacity: 0.55; }
.combatant.hiddenc { background: repeating-linear-gradient(135deg, transparent 0 8px, var(--surface-2) 8px 16px); }
.combatant .init { font-size: 1.4rem; font-weight: 700; text-align: center; }
.combatant .init input { width: 3.2rem; text-align: center; font-weight: 700; padding: 0.2rem; }
.combatant .cname { font-weight: 700; }
.combatant .cname .pill { margin-left: 0.3rem; vertical-align: 1px; }
.combatant .csub { font-size: 0.8rem; color: var(--text-muted); display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; margin-top: 0.15rem; }
.combatant .cctl { display: flex; gap: 0.3rem; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.combatant .cctl input { width: 3.6rem; text-align: center; padding: 0.25rem; }
.turnbar { display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; flex-wrap: wrap; padding: 0.8rem 1rem; border-bottom: 1px solid var(--border); }
.turnbar .round { font-family: var(--font-display); font-size: 1.15rem; }
.diff { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.4rem; text-align: center; margin: 0.5rem 0; }
.diff div { background: var(--surface-2); border-radius: var(--radius-sm); padding: 0.35rem; font-size: 0.8rem; }
.diff div b { display: block; font-size: 1rem; }
.diff div.hit { outline: 2px solid var(--accent); }
.monster-results { max-height: 260px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); margin-top: 0.4rem; }
.monster-results .li { display: flex; justify-content: space-between; align-items: center; gap: 0.4rem; padding: 0.35rem 0.6rem; border-bottom: 1px solid var(--border); font-size: 0.88rem; }
.monster-results .li:last-child { border-bottom: 0; }

/* ---- dice tray ---- */
.dicetray { position: fixed; right: 1rem; bottom: 1rem; z-index: 60; width: 340px; max-width: calc(100vw - 2rem); background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius); box-shadow: var(--shadow); display: flex; flex-direction: column; }
.dicetray.collapsed { width: auto; }
.dicetray .dt-head { display: flex; align-items: center; gap: 0.5rem; padding: 0.45rem 0.55rem 0.45rem 0.8rem; cursor: pointer; user-select: none; }
.dicetray .dt-head b { font-family: var(--font-display); flex: 1; }
.dicetray.collapsed .dt-body { display: none; }
.dicetray .dt-log { max-height: 300px; overflow-y: auto; padding: 0 0.8rem; border-top: 1px solid var(--border); display: flex; flex-direction: column; }
.dicetray .dt-roll { padding: 0.5rem 0; border-bottom: 1px solid var(--border); display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0 0.5rem; }
.dicetray .dt-roll:last-child { border-bottom: 0; }
.dicetray .dt-roll .w { font-size: 0.75rem; color: var(--text-faint); }
.dicetray .dt-roll .l { font-weight: 600; font-size: 0.88rem; }
.dicetray .dt-roll .d { font-size: 0.74rem; color: var(--text-muted); font-family: var(--mono); grid-column: 1; overflow-wrap: anywhere; }
.dicetray .dt-roll .d s { opacity: 0.55; }
.dicetray .dt-roll .t { grid-row: 1 / span 3; grid-column: 2; align-self: center; font-size: 1.5rem; font-weight: 700; min-width: 2.6rem; text-align: right; }
.dicetray .dt-roll.crit .t { color: var(--good); }
.dicetray .dt-roll.fumble .t { color: var(--bad); }
.dicetray .dt-roll.secret { background: repeating-linear-gradient(135deg, transparent 0 8px, var(--surface-2) 8px 16px); }
.dicetray .dt-ctl { padding: 0.6rem 0.8rem 0.75rem; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 0.45rem; }
.dicetray .dt-quick { display: flex; gap: 0.25rem; flex-wrap: wrap; }
.dicetray .dt-quick .btn { flex: 1; padding: 0.35rem 0.2rem; font-size: 0.78rem; }
.dicetray form { display: flex; gap: 0.35rem; }
.dicetray form input { flex: 1; font-family: var(--mono); }
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; }
.seg button { background: var(--surface-2); border: 0; color: var(--text-muted); font: 600 0.76rem var(--font); padding: 0.32rem 0.6rem; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--border-strong); }
.seg button.on { background: var(--accent); color: var(--accent-ink); }
.dt-badge { background: var(--accent); color: var(--accent-ink); border-radius: 99px; font-size: 0.7rem; font-weight: 700; padding: 0.05rem 0.45rem; }

/* ---- toasts & modals ---- */
.toasts { position: fixed; top: 4.2rem; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 0.5rem; align-items: center; pointer-events: none; width: min(92vw, 440px); }
.toast { pointer-events: auto; background: var(--surface-3); color: var(--text); border: 1px solid var(--border-strong); border-left: 4px solid var(--info); box-shadow: var(--shadow); border-radius: var(--radius-sm); padding: 0.6rem 0.9rem; font-size: 0.9rem; animation: toastin 0.2s ease-out; width: 100%; }
.toast.error { border-left-color: var(--bad); }
.toast.ok { border-left-color: var(--good); }
.toast.roll { border-left-color: var(--accent); display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; }
.toast.roll .t { font-size: 1.6rem; font-weight: 700; }
.toast.roll.crit .t { color: var(--good); }
.toast.roll.fumble .t { color: var(--bad); }
.toast.roll .d { font-family: var(--mono); font-size: 0.75rem; color: var(--text-muted); }
.toast.roll .d s { opacity: 0.55; }
@keyframes toastin { from { opacity: 0; transform: translateY(-6px); } }
.modal-backdrop { position: fixed; inset: 0; z-index: 150; background: rgba(0, 0, 0, 0.6); display: grid; place-items: center; padding: 1rem; animation: toastin 0.15s; }
.modal { width: min(640px, 100%); max-height: calc(100vh - 2rem); overflow-y: auto; background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius); box-shadow: var(--shadow); }
.modal.wide { width: min(900px, 100%); }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; padding: 0.9rem 1.1rem; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); z-index: 1; }
.modal-head h2 { margin: 0; font-size: 1.15rem; }
.modal-body { padding: 1rem 1.1rem; }
.modal-foot { display: flex; justify-content: flex-end; gap: 0.5rem; padding: 0.8rem 1.1rem; border-top: 1px solid var(--border); position: sticky; bottom: 0; background: var(--surface); }

/* ---- responsive ---- */
@media (max-width: 1150px) {
  .statstrip { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .hpbox { grid-column: span 3; }
  .sheet-body { grid-template-columns: 1fr 1fr; }
  .sheet-body > .sheet-main { grid-column: 1 / -1; order: -1; }
  .combat-layout { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .comp-layout { grid-template-columns: 1fr; }
  .comp-layout.has-detail .comp-listcol { display: none; }
  .comp-layout:not(.has-detail) .comp-detail { display: none; }
  .comp-detail { position: static; max-height: none; }
  .comp-list { max-height: none; }
}
@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; padding: 0.5rem 1rem; gap: 0.5rem; }
  .mainnav { order: 3; flex-basis: 100%; }
  .brand span { display: none; }
  .topbar-right { margin-left: auto; }
  .app { padding: 1rem 1rem 6rem; }
  .statstrip { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .hpbox { grid-column: 1 / -1; }
  .sheet-body { grid-template-columns: 1fr; }
  .sheet-head h1 { font-size: 1.5rem; }
  .hero h1 { font-size: 1.6rem; }
  .class-edit { grid-template-columns: 1fr 1fr; }
  .dicetray { right: 0.5rem; bottom: 0.5rem; }
  .combatant { grid-template-columns: 44px minmax(0, 1fr); }
  .combatant .cctl { grid-column: 1 / -1; justify-content: flex-start; }
  .grid.cols-2, .grid.cols-3 { grid-template-columns: 1fr; }
}
@media print {
  .topbar, .dicetray, .toasts, .site-footer, .sheet-head .actions, .hpbox .ctl { display: none !important; }
  body { background: #fff; color: #000; }
}

/* sheet: second strip (proficiency, speed, initiative, AC, HP) */
.statstrip { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.statstrip.combatstrip { grid-template-columns: repeat(4, minmax(0, 1fr)) minmax(0, 2.4fr); }
.statstrip.combatstrip .hpbox { grid-column: auto; }
@media (max-width: 1150px) { .statstrip.combatstrip { grid-template-columns: repeat(4, minmax(0, 1fr)); } .statstrip.combatstrip .hpbox { grid-column: 1 / -1; } }
@media (max-width: 720px) { .statstrip { grid-template-columns: repeat(3, minmax(0, 1fr)); } .statstrip.combatstrip { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* keep flex/grid children from forcing horizontal scroll on phones */
.mainnav, .sheet-col, .comp-listcol, .comp-detail, .combat-layout > *, .grid > * { min-width: 0; }
label.field > input, label.field > select, label.field > textarea { width: 100%; }
.item-row .meta { overflow-wrap: anywhere; }
.comp-list { position: relative; }

/* ---- background art (img/backdrop.svg, img/stars.svg: alpha masks painted in theme colours) ---- */
:root { --art: rgba(206, 160, 128, 0.11); --stars: rgba(255, 238, 214, 0.42); }
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) { --art: rgba(120, 86, 52, 0.085); --stars: transparent; }
}
:root[data-theme="light"] { --art: rgba(120, 86, 52, 0.085); --stars: transparent; }
body { isolation: isolate; }
body::before, body::after {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
}
body::before {
  background: var(--art);
  -webkit-mask-image: url("/img/backdrop.svg"); mask-image: url("/img/backdrop.svg");
  -webkit-mask-size: cover; mask-size: cover;
  -webkit-mask-position: center bottom; mask-position: center bottom;
}
body::after {
  background: var(--stars);
  -webkit-mask-image: url("/img/stars.svg"); mask-image: url("/img/stars.svg");
  -webkit-mask-size: cover; mask-size: cover;
  -webkit-mask-position: center top; mask-position: center top;
}
@media print { body::before, body::after { display: none; } }

/* ---- printable character sheet (#/characters/:id/print) ---- */
body.print-mode .topbar, body.print-mode .dicetray, body.print-mode .site-footer { display: none !important; }
body.print-mode::before, body.print-mode::after { display: none; }
.print-toolbar { display: flex; gap: .8rem; align-items: center; flex-wrap: wrap; max-width: 210mm; margin: 0 auto 1rem; }
.print-sheet {
  /* fixed "paper" palette, whatever the site theme */
  --text: #1d1712; --text-muted: #5b4f44; --text-faint: #8a7d70; --border: #d6cbbb; --border-strong: #b9a991;
  --surface-2: #f3ede3; --surface-3: #e9e0d2; --gold: #8a5d0a; --accent-strong: #9b2a1e;
  max-width: 210mm; margin: 0 auto; background: #fff; color: var(--text); padding: 14mm 14mm 10mm;
  box-shadow: 0 6px 30px rgba(0, 0, 0, .35); border-radius: 4px; font-size: 10.5pt; line-height: 1.4;
}
.print-sheet h1 { font-size: 22pt; margin: 0; color: #111; }
.print-sheet h2 { font-size: 11pt; text-transform: uppercase; letter-spacing: .08em; color: #8f2219; border-bottom: 1.5px solid #8f2219; padding-bottom: 2px; margin: 0 0 6px; }
.print-sheet h3 { font-size: 10pt; margin: 8px 0 3px; color: #111; }
.print-sheet p { margin: 0 0 4px; }
.print-sheet .prose { line-height: 1.4; }
.print-sheet .prose p { margin: 0 0 4px; }
.p-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; border-bottom: 3px double #8f2219; padding-bottom: 6px; margin-bottom: 10px; }
.p-brand { font-family: var(--font-display); color: #8f2219; font-size: 9pt; letter-spacing: .1em; text-transform: uppercase; white-space: nowrap; }
.p-sub { color: var(--text-muted); font-size: 8.5pt; }
.p-lbl { font-size: 7pt; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); }
.p-abilities { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; margin-bottom: 8px; }
.p-ab { border: 1.5px solid var(--border-strong); border-radius: 6px; text-align: center; padding: 4px 2px; display: flex; flex-direction: column; align-items: center; }
.p-ab b { font-size: 17pt; line-height: 1.1; }
.p-score { font-size: 9pt; border: 1px solid var(--border); border-radius: 99px; padding: 0 8px; }
.p-save { font-size: 8pt; margin-top: 3px; display: inline-flex; align-items: center; gap: 3px; }
.p-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 10px; }
.p-box { border: 1px solid var(--border-strong); border-radius: 6px; padding: 4px 6px; display: flex; flex-direction: column; }
.p-box b { font-size: 13pt; }
.p-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 16px; }
.p-sec { margin-bottom: 10px; break-inside: avoid; }
.p-sec.p-break-ok { break-inside: auto; }
.p-skills { columns: 2; column-gap: 14px; font-size: 9pt; }
.p-skills div { display: flex; align-items: center; gap: 4px; break-inside: avoid; }
.p-skills .nm { flex: 1; } .p-skills small { color: var(--text-faint); font-size: 7pt; text-transform: uppercase; }
.p-dot { width: 8px; height: 8px; border-radius: 50%; border: 1px solid #555; display: inline-block; flex: none; }
.p-dot.p1 { background: #333; } .p-dot.p2 { background: #a8741a; border-color: #a8741a; }
.p-sq { width: 9px; height: 9px; border: 1px solid #555; display: inline-block; margin-right: 2px; vertical-align: -1px; }
.p-sq.used { background: #555; }
.p-slot { margin-right: 12px; white-space: nowrap; }
.p-table { width: 100%; border-collapse: collapse; font-size: 9pt; }
.p-table th { text-align: left; font-size: 7pt; text-transform: uppercase; letter-spacing: .07em; color: var(--text-muted); border-bottom: 1px solid var(--border-strong); padding: 2px 4px; }
.p-table td { border-bottom: 1px solid var(--border); padding: 3px 4px; vertical-align: top; }
.p-item { padding: 2px 0; break-inside: avoid; }
.p-desc { font-size: 8.5pt; color: #333; margin: 1px 0 4px 12px; }
.p-foot { margin-top: 12px; border-top: 1px solid var(--border); padding-top: 4px; font-size: 7.5pt; color: var(--text-faint); text-align: center; }
@media (max-width: 720px) {
  .print-sheet { padding: 6mm; font-size: 9.5pt; }
  .p-abilities { grid-template-columns: repeat(3, 1fr); }
  .p-stats, .p-cols { grid-template-columns: 1fr 1fr; }
}
@media print {
  @page { size: auto; margin: 11mm; }
  :root { color-scheme: light !important; } /* dark scheme would paint the page margins black */
  html, body { background: #fff !important; }
  .print-toolbar { display: none !important; }
  .app { padding: 0; max-width: none; }
  .print-sheet { box-shadow: none; padding: 0; max-width: none; border-radius: 0; }
  .print-sheet * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ---- handouts & stash ---- */
.tabs.subtabs { border-bottom: 0; margin-top: -.6rem; }
.tabs.subtabs a { font-size: .82rem; padding: .4rem .7rem; }
.handout { cursor: pointer; display: flex; flex-direction: column; }
.handout:hover { border-color: var(--accent); }
.handout.hidden-ho { border-style: dashed; }
.ho-thumb { aspect-ratio: 4 / 3; border-radius: var(--radius-sm); overflow: hidden; background: var(--surface-2); display: grid; place-items: center; }
.ho-thumb img { width: 100%; height: 100%; object-fit: cover; }
.ho-icon { font-size: 3rem; }
.ho-full { max-width: 100%; border-radius: var(--radius-sm); display: block; margin: 0 auto .4rem; }
.ho-letter { background: #f3e7cf; color: #3a2b1a; padding: 1.2rem 1.4rem; border-radius: 4px; font-family: Georgia, "Times New Roman", serif; font-size: 1.02rem; box-shadow: inset 0 0 40px rgba(120, 80, 30, .25); }
.ho-letter a { color: #8f2219; }
.ho-strip { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: .6rem; }
.ho-mini { display: flex; flex-direction: column; gap: .2rem; color: var(--text); font-size: .85rem; }
.ho-mini:hover { text-decoration: none; color: var(--accent-strong); }
.ho-mini img, .ho-mini span { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: var(--radius-sm); background: var(--surface-2); display: grid; place-items: center; font-size: 2rem; }
.item-row .ctrls select { max-width: 9rem; padding: .2rem .3rem; font-size: .8rem; }

/* ---- rolling-dice overlay (js/dice-anim.js) ---- */
.dice-overlay {
  position: fixed; inset: 0; z-index: 250; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 45%, rgba(20, 12, 10, .55), rgba(0, 0, 0, .72)); backdrop-filter: blur(2px);
  cursor: pointer; animation: dice-fade .15s ease-out; color: #fff4ee; padding: 1rem;
}
.dice-overlay.leaving { opacity: 0; transition: opacity .2s; }
@keyframes dice-fade { from { opacity: 0; } }
.dice-stage { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 14px; max-width: 560px; min-height: 120px; perspective: 700px; }
.die { position: relative; width: 92px; height: 92px; transform-style: preserve-3d; filter: drop-shadow(0 10px 14px rgba(0, 0, 0, .55)); }
.dice-stage:has(.die:nth-child(4)) .die { width: 70px; height: 70px; }
.die svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.die svg polygon, .die svg rect { fill: #c8372d; stroke: #ffcdb8; stroke-width: 2.5; stroke-linejoin: round; }
.die svg .facet { fill: rgba(255, 255, 255, .06); stroke: rgba(255, 220, 205, .45); stroke-width: 1.5; }
.die .face { position: absolute; inset: 0; display: grid; place-items: center; font: 800 30px/1 var(--font); color: #fff; text-shadow: 0 2px 3px rgba(0, 0, 0, .55); }
.dice-stage:has(.die:nth-child(4)) .die .face { font-size: 23px; }
.die.d4 .face { padding-top: 26%; }
.die.d10 .face, .die.d100 .face { padding-bottom: 8%; }
.die.rolling { animation: dice-tumble .95s cubic-bezier(.2, .7, .3, 1) var(--delay, 0ms) both; }
@keyframes dice-tumble {
  0% { transform: translate(var(--dx), -260px) rotateX(0) rotateZ(0) scale(.5); opacity: 0; }
  15% { opacity: 1; }
  60% { transform: translate(calc(var(--dx) * .3), 14px) rotateX(calc(var(--spin) * 540deg)) rotateZ(calc(var(--spin) * 300deg)) scale(1.08); }
  80% { transform: translate(0, -16px) rotateX(calc(var(--spin) * 680deg)) rotateZ(calc(var(--spin) * 345deg)) scale(1); }
  100% { transform: translate(0, 0) rotateX(calc(var(--spin) * 720deg)) rotateZ(calc(var(--spin) * 360deg)) scale(1); }
}
.die.landed { animation: dice-land .28s ease-out; }
@keyframes dice-land { 0% { transform: scale(1.18); } 100% { transform: scale(1); } }
.die.dropped { opacity: .35; filter: grayscale(.8); }
.die-more { font: 700 1.2rem var(--font); color: #ffcdb8; }
.dice-result { text-align: center; margin-top: 18px; animation: dice-rise .25s ease-out; }
@keyframes dice-rise { from { opacity: 0; transform: translateY(8px); } }
.dice-label { font-weight: 600; font-size: 1.05rem; }
.dice-total { font: 800 4rem/1.05 var(--font); text-shadow: 0 4px 18px rgba(0, 0, 0, .6); }
.dice-detail { font-family: var(--mono); font-size: .8rem; opacity: .75; }
.dice-detail s { opacity: .6; }
.dice-hint { position: absolute; bottom: 1.5rem; font-size: .78rem; opacity: .55; }
.dice-banner { font: 700 1.5rem var(--font-display); letter-spacing: .12em; margin-bottom: .2rem; }
/* natural 20: gold dice and glow */
.dice-overlay.crit .die:not(.dropped) svg polygon, .dice-overlay.crit .die:not(.dropped) svg rect { fill: #d9a53f; stroke: #fff2c4; }
.dice-overlay.crit .die:not(.dropped) { filter: drop-shadow(0 0 18px rgba(255, 210, 110, .9)); }
.dice-overlay.crit .dice-total, .dice-banner.crit { color: #ffd77a; }
.dice-banner.crit { animation: dice-pulse 1s ease-in-out infinite; text-shadow: 0 0 18px rgba(255, 200, 90, .8); }
@keyframes dice-pulse { 50% { transform: scale(1.08); } }
/* natural 1: dark dice and a shake */
.dice-overlay.fumble .die:not(.dropped) svg polygon, .dice-overlay.fumble .die:not(.dropped) svg rect { fill: #3b2422; stroke: #e5574a; }
.dice-overlay.fumble .dice-stage { animation: dice-shake .45s ease-in-out; }
.dice-overlay.fumble .dice-total, .dice-banner.fumble { color: #ff6b5c; }
@keyframes dice-shake { 20%, 60% { transform: translateX(-9px) rotate(-2deg); } 40%, 80% { transform: translateX(9px) rotate(2deg); } }
/* other players' rolls */
.toast.roll.party { padding: .45rem .8rem; }
.toast.roll.party .t { font-size: 1.25rem; }
