:root {
  --bg: #0d0a08; --stone: #1a1511; --panel: #231b15; --panel-2: #2c221a; --line: #4a3824;
  --parch: #efe0bd; --parch-2: #e2cc9c; --parch-ink: #2a1d10;
  --gold: #d7a943; --gold-2: #f3d27a; --gold-dim: #8d6b2a;
  --crimson: #7d1d22; --crimson-2: #a3262c;
  --ink: #f1e6cf; --muted: #b5a281; --good: #74c47a; --bad: #e65a4c; --mana: #5aa0ef;
  --r: 10px;
  --head: 'Cinzel', 'Trajan Pro', Georgia, serif;
  --body: 'Alegreya', Georgia, 'Times New Roman', serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--body); font-size: 16px; line-height: 1.4; }
body { min-height: 100vh; min-height: 100dvh;
  background: radial-gradient(ellipse at 50% -10%, #3a2614 0%, transparent 60%), radial-gradient(ellipse at 50% 120%, #2a0d0f 0%, transparent 55%), var(--bg); }
a { color: var(--gold-2); }
h1, h2, h3, .head { font-family: var(--head); letter-spacing: .04em; margin: 0; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; touch-action: manipulation; }
button:disabled { opacity: .38; cursor: default; }
input, select { font: inherit; color: var(--parch-ink); background: #fbf3df; border: 2px solid var(--gold-dim); border-radius: 8px; padding: 10px 12px; width: 100%; }
input:focus, select:focus { outline: 2px solid var(--gold-2); outline-offset: 1px; }
.hidden { display: none !important; }
.wrap { max-width: 1040px; margin: 0 auto; padding: 16px; }
.logo { display: block; width: min(440px, 86vw); margin: 10px auto 2px; filter: drop-shadow(0 6px 14px #000); border-radius: 6px;
  -webkit-mask-image: radial-gradient(ellipse 72% 80% at 50% 50%, #000 70%, transparent 100%); mask-image: radial-gradient(ellipse 72% 80% at 50% 50%, #000 70%, transparent 100%); }
.tagline { text-align: center; color: var(--muted); font-style: italic; margin: 0 0 14px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 11px 18px; border-radius: 9px; font-family: var(--head); font-weight: 700; letter-spacing: .05em; font-size: 15px;
  background: linear-gradient(#b3302f, #7a1b1f); color: #fff3d8; border: 2px solid var(--gold); box-shadow: 0 3px 0 #3b0d0f, inset 0 1px 0 #ffffff30; text-shadow: 0 1px 0 #0008; }
.btn:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 #3b0d0f; }
.btn.gold { background: linear-gradient(#f0cd70, #b9862c); color: #2a1a07; border-color: #fff0b8; text-shadow: none; box-shadow: 0 3px 0 #5e4313; }
.btn.ghost { background: #0005; border-color: var(--line); color: var(--ink); box-shadow: none; }
.btn.small { padding: 7px 11px; font-size: 13px; }
.btn.wide { width: 100%; }

.card { background: linear-gradient(#2a2119, #1e1712); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; box-shadow: 0 8px 24px #0007, inset 0 1px 0 #ffffff0d; }
.parch { background: linear-gradient(var(--parch), var(--parch-2)); color: var(--parch-ink); border: 2px solid var(--gold-dim); border-radius: var(--r); padding: 14px; box-shadow: 0 6px 20px #0008, inset 0 0 30px #a0782f40; }
.parch h2, .parch h3 { color: var(--crimson); }
.banner { display: inline-block; background: linear-gradient(#9b2529, #6c171b); color: #ffe9b8; font-family: var(--head); padding: 4px 14px; border: 1px solid var(--gold); border-radius: 4px; letter-spacing: .06em; font-size: 14px; }
.muted { color: var(--muted); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grid { display: grid; gap: 12px; }
.err { color: #ffb4a8; background: #4d1414; border: 1px solid #a43a2f; padding: 8px 10px; border-radius: 8px; margin: 8px 0; }

.portrait { width: 56px; height: 56px; border-radius: 8px; object-fit: cover; object-position: 50% 30%; border: 2px solid var(--gold); background: #000; flex: none; }
.portrait.lg { width: 84px; height: 84px; }
.portrait.sm { width: 38px; height: 38px; border-width: 1px; }
.hearts { display: inline-flex; gap: 2px; flex-wrap: wrap; vertical-align: middle; }
.hearts i { width: 13px; height: 12px; display: inline-block; background: center/contain no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 22'%3E%3Cpath d='M12 21s-9-6-9-12a5 5 0 0 1 9-3 5 5 0 0 1 9 3c0 6-9 12-9 12z' fill='%23e0443a' stroke='%23300' stroke-width='1.5'/%3E%3C/svg%3E"); }
.hearts i.e { filter: grayscale(1) brightness(.35); }
.pips { display: inline-flex; gap: 2px; vertical-align: middle; flex-wrap: wrap; }
.pips i { width: 8px; height: 10px; border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%; background: var(--mana); box-shadow: 0 0 4px #5aa0ef90; display: inline-block; }
.pips i.e { background: #24364d; box-shadow: none; }
.stat { display: inline-flex; align-items: center; gap: 4px; font-weight: 700; }
.die-ico { width: 18px; height: 18px; vertical-align: -4px; }

/* dice */
.dice { display: inline-flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.die { width: 42px; height: 42px; border-radius: 9px; background: linear-gradient(145deg, #2e241b, #120d09); border: 2px solid #c79a42; display: grid; place-items: center; box-shadow: inset 0 0 8px #000, 0 3px 6px #000a; }
.die svg { width: 76%; height: 76%; }
.die.win { box-shadow: 0 0 0 2px #fff3b0, 0 0 14px #f3d27a; }
.die.dim { opacity: .45; }
.die.pip { background: linear-gradient(145deg, #fffdf6, #ddd4c2); border-color: #9c8c6a; }
.die.roll { animation: tumble .6s cubic-bezier(.3,.7,.4,1) both; }
@keyframes tumble { 0% { transform: rotate(-200deg) scale(.3); opacity: 0; } 70% { transform: rotate(14deg) scale(1.08); opacity: 1; } 100% { transform: rotate(0) scale(1); } }
@media (prefers-reduced-motion: reduce) { .die.roll { animation: none; } }

/* modal sheet */
.sheet-bg { position: fixed; inset: 0; background: #000a; z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: min(560px, 100%); max-height: 86vh; max-height: 86dvh; overflow: auto; background: linear-gradient(#2b2119, #181210); border-top: 2px solid var(--gold); border-radius: 16px 16px 0 0; padding: 14px 14px calc(14px + env(safe-area-inset-bottom)); box-shadow: 0 -10px 40px #000; }
.sheet h3 { color: var(--gold-2); margin-bottom: 8px; }
.sheet .close { float: right; font-size: 26px; line-height: 1; padding: 0 6px; color: var(--muted); }
.list { display: grid; gap: 8px; }
.li { display: flex; align-items: center; gap: 10px; padding: 9px; border: 1px solid var(--line); border-radius: 9px; background: #0004; text-align: left; width: 100%; }
.li:active:not(:disabled) { background: #3a2a1a; }
.li .grow { flex: 1; min-width: 0; }
.li .name { font-weight: 700; }
.li .sub { font-size: 13px; color: var(--muted); }
.tag { font-size: 11px; font-family: var(--head); padding: 1px 6px; border-radius: 4px; border: 1px solid var(--gold-dim); color: var(--gold-2); white-space: nowrap; }
.tag.red { border-color: var(--crimson-2); color: #ffb3a6; }
.toast { position: fixed; left: 50%; top: 12px; transform: translateX(-50%); z-index: 90; background: #2a1310; border: 1px solid #b04436; color: #ffd9cf; padding: 10px 14px; border-radius: 10px; max-width: 92vw; box-shadow: 0 8px 20px #000; font-size: 15px; }
.toast.ok { background: #1b2a17; border-color: #5d9a4c; color: #dcf5d3; }
