@import url("paper.css");
/* Rollscribe design system. Tokens first; components use tokens only. */

@font-face {
  font-family: "Crimson Pro";
  src: url("../fonts/crimsonpro-latin.woff2") format("woff2");
  font-weight: 400 800;
  font-display: swap;
}

:root {
  --bg: #efe6d2;
  --surface: #faf5ea;
  --surface-2: #f1e8d6;
  --ink: #2a211a;
  --ink-soft: #6b5d4f;
  --line: #d8c9ad;
  --accent: #8e1d1d;          /* crimson fills: top bar, primary buttons, active chips */
  --accent-ink: #fff8ee;       /* text on --accent */
  --accent-text: #8e1d1d;      /* crimson as text on page surfaces (links, active tabs) */
  --gold: #b0801f;
  --crit-success: #1d7a4a;
  --success: #3d8b5a;
  --failure: #b3651f;
  --crit-failure: #a1272b;
  --felt: #1f4a3a;
  --shadow: 0 2px 10px rgba(42, 33, 26, .12);
  --shadow-lift: 0 10px 30px rgba(42, 33, 26, .25);
  --radius: 14px;
  --radius-sm: 9px;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Crimson Pro", "Palatino Linotype", Palatino, Georgia, serif;
  --font-brand: "Cinzel", "Crimson Pro", Georgia, serif;
  /* A faint paper grain under everything (the paper sheet has its own, stronger one). */
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .35 0 0 0 0 .28 0 0 0 0 .2 0 0 0 .05 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  --nav-h: 62px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14110e;
    --surface: #1f1a15;
    --surface-2: #2a231c;
    --ink: #efe5d3;
    --ink-soft: #a89986;
    --line: #3b3128;
    --accent: #a8322a;
    --accent-ink: #fff;
    --accent-text: #ef7a68;
    --gold: #d9a441;
    --crit-success: #3fbf7f;
    --success: #5fae7c;
    --failure: #e0913d;
    --crit-failure: #e25555;
    --felt: #173a2d;
    --shadow: 0 2px 10px rgba(0, 0, 0, .4);
    --shadow-lift: 0 10px 30px rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #14110e; --surface: #1f1a15; --surface-2: #2a231c; --ink: #efe5d3; --ink-soft: #a89986;
  --line: #3b3128; --accent: #a8322a; --accent-ink: #fff; --accent-text: #ef7a68; --gold: #d9a441; --crit-success: #3fbf7f;
  --success: #5fae7c; --failure: #e0913d; --crit-failure: #e25555; --felt: #173a2d;
  --shadow: 0 2px 10px rgba(0, 0, 0, .4); --shadow-lift: 0 10px 30px rgba(0, 0, 0, .6); color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--ink); font-family: var(--font-body); font-size: 16px; }
body { background-image: var(--grain); background-attachment: fixed; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
body { -webkit-tap-highlight-color: transparent; overscroll-behavior-y: none; }
button { font: inherit; color: inherit; }
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 650; margin: 0; letter-spacing: .005em; text-wrap: balance; }
p { margin: .4em 0; }

/* ---------- Shell ---------- */
.app { min-height: 100dvh; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; padding: calc(8px + var(--safe-t)) 16px 8px;
  background: var(--accent); color: var(--accent-ink); display: flex; align-items: center; gap: 12px;
  box-shadow: var(--shadow);
}
.topbar .title { font-family: var(--font-display); font-size: 1.15rem; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .sub { font-size: .75rem; opacity: .85; }
.topbar .hp-mini { font-weight: 700; font-variant-numeric: tabular-nums; background: rgba(0,0,0,.2); border-radius: 999px; padding: 3px 10px; }
.content { flex: 1; width: 100%; max-width: 760px; margin: 0 auto; padding: 12px 16px calc(var(--nav-h) + var(--safe-b) + 24px); }
.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; height: calc(var(--nav-h) + var(--safe-b));
  padding-bottom: var(--safe-b); display: flex; background: var(--surface); border-top: 1px solid var(--line);
}
.bottomnav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--ink-soft); text-decoration: none; font-size: .72rem; font-weight: 600;
}
.bottomnav a .icon { font-size: 1.3rem; line-height: 1; }
.bottomnav a.active { color: var(--accent-text); }

/* ---------- Primitives ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; margin-bottom: 12px; }
.card h2 { font-size: 1.1rem; margin-bottom: 8px; }
.card h3 { font-size: .95rem; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .06em; margin: 10px 0 6px; font-family: var(--font-body); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--ink-soft); font-size: .85rem; }
.small { font-size: .8rem; }
.center { text-align: center; }
.stack > * + * { margin-top: 8px; }

.btn {
  border: 1px solid var(--line); background: var(--surface-2); border-radius: var(--radius-sm); padding: 9px 14px;
  font-weight: 600; cursor: pointer; min-height: 40px; user-select: none; -webkit-user-select: none;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.ghost { background: transparent; }
.btn.small { padding: 5px 10px; min-height: 32px; font-size: .85rem; }
.btn:disabled { opacity: .45; cursor: default; }
.btn.block { width: 100%; }

.chip {
  display: inline-flex; align-items: center; gap: 4px; border-radius: 999px; padding: 3px 10px; font-size: .78rem;
  background: var(--surface-2); border: 1px solid var(--line); white-space: nowrap;
}
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.chip.trait { text-transform: capitalize; font-size: .7rem; padding: 2px 8px; }
button.chip { cursor: pointer; }
.chip.legacy { font-size: .65rem; padding: 1px 7px; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-soft); border-style: dashed; }

.pill { margin-left: 6px; vertical-align: 1px; display: inline-block; border-radius: 6px; padding: 1px 6px; font-size: .7rem; font-weight: 700; background: var(--surface-2); border: 1px solid var(--line); }
.rank-U { opacity: .55; }
.rank-T { background: #e8dcc4; }
.rank-E { background: #cfe0f5; color: #173a63; }
.rank-M { background: #e3d3f3; color: #43206b; }
.rank-L { background: #f7e1b3; color: #6b4a0b; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .rank-T { background: #3a3126; } }

input[type=number], input[type=text], input[type=search], textarea, select {
  font: inherit; color: inherit; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 8px 10px; min-height: 40px;
}
textarea { width: 100%; min-height: 120px; font-family: ui-monospace, Consolas, monospace; font-size: .8rem; }
input[type=number] { width: 84px; }

/* ---------- Tabs ---------- */
.tabs { position: sticky; top: calc(52px + var(--safe-t)); z-index: 10; display: flex; gap: 4px; overflow-x: auto; padding: 6px 0 8px; background: var(--bg); scrollbar-width: none; }
.tabs button { border: none; background: transparent; padding: 8px 12px; border-radius: 999px; font-weight: 700; color: var(--ink-soft); white-space: nowrap; cursor: pointer; }
.tabs button.active { background: var(--ink); color: var(--bg); }

/* ---------- Stat buttons (tap = roll, hold = composer) ---------- */
.stat {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 10px;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: manipulation;
}
.stat:active, .stat.pressing { background: var(--surface-2); }
.stat .label { flex: 1; min-width: 0; }
.stat .value { font-family: var(--font-display); font-size: 1.25rem; font-weight: 700; font-variant-numeric: tabular-nums; min-width: 3ch; text-align: right; }
.stat.big { flex-direction: column; gap: 2px; align-items: center; text-align: center; padding: 10px 6px; }
.stat.big .value { font-size: 1.6rem; text-align: center; }
.stat.big .label { font-size: .75rem; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .05em; }
.stat.shielded .value { color: var(--gold); }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.list { display: grid; gap: 6px; }

/* ---------- HP ---------- */
.hp { display: grid; gap: 8px; }
.hp-bar { position: relative; height: 22px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); overflow: hidden; }
.hp-bar .fill { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, #7a1a1a, var(--accent)); transition: width .3s ease; }
.hp-bar .temp { position: absolute; inset: 0 auto 0 0; background: rgba(80, 140, 220, .55); transition: width .3s ease; }
.hp-bar .text { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: .8rem; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.6); font-variant-numeric: tabular-nums; }
/* Coins: platinum, gold, silver, copper. */
.coins { display: flex; flex-wrap: wrap; gap: 4px 14px; color: var(--ink-soft); }
.coins span { display: inline-flex; align-items: center; gap: 5px; font-variant-numeric: tabular-nums; }
.coin {
  display: inline-block; flex: none; width: 13px; height: 13px; border-radius: 50%; vertical-align: -2px; margin-right: 4px;
  box-shadow: inset 0 0 0 1.5px rgba(0, 0, 0, .18), inset -1px -2px 2px rgba(0, 0, 0, .2), 0 1px 1px rgba(0, 0, 0, .25);
}
.coins .coin { margin-right: 0; }
.coin.pp { background: radial-gradient(circle at 35% 30%, #ffffff, #d9dde3 45%, #9aa3ad); }
.coin.gp { background: radial-gradient(circle at 35% 30%, #fff3b0, #e0b12e 45%, #9c6d10); }
.coin.sp { background: radial-gradient(circle at 35% 30%, #ffffff, #c4c7cc 45%, #7d838b); }
.coin.cp { background: radial-gradient(circle at 35% 30%, #f7c9a0, #c0703a 45%, #7a3d17); }
.spell-quick { display: inline-flex; gap: 4px; }
.spell-quick .chip { font-size: .72rem; padding: 2px 9px; }
.spell > summary, .row.inked { position: relative; }
.hp-steppers { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.hp-num { display: inline-block; min-width: 3ch; text-align: center; font-family: var(--font-display); font-size: 1.35rem; font-weight: 800; font-variant-numeric: tabular-nums; }

/* − value + with a floating "ghost" of the running change (HpStepper). */
.hp-step { display: inline-flex; align-items: center; gap: 4px; }
.hp-step .step {
  width: 34px; height: 34px; padding: 0; border: 1px solid var(--line); border-radius: 50%; background: var(--surface);
  font-size: 1.15rem; font-weight: 800; line-height: 1; cursor: pointer; touch-action: manipulation;
}
.hp-step .step:hover { background: var(--surface-2); }
.hp-step .step:active { transform: scale(.92); }
.hp-step .step-value { position: relative; display: inline-block; }
.ghost-delta {
  position: absolute; left: 88%; bottom: 78%; z-index: 2; pointer-events: none; white-space: nowrap;
  font-weight: 800; font-size: .95rem; font-variant-numeric: tabular-nums; text-shadow: 0 1px 0 var(--surface), 0 0 6px var(--surface);
  animation: ghost 2.8s ease-out forwards;
}
.ghost-delta.loss { color: var(--crit-failure); }
.ghost-delta.gain { color: var(--crit-success); }
@keyframes ghost { 0% { transform: translateY(4px) scale(.8); opacity: 0; } 8% { transform: none; opacity: 1; } 75% { opacity: 1; } 100% { transform: translateY(-6px); opacity: 0; } }

/* Conditions screen */
.cond-row { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2); }
.cond-name { border: 0; background: none; padding: 0; text-align: left; cursor: pointer; }
.cond-value { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); overflow: hidden; }
.cond-value button { width: 34px; height: 32px; border: 0; background: none; font-weight: 800; font-size: 1.05rem; cursor: pointer; }
.cond-value span { min-width: 2ch; text-align: center; font-weight: 800; }

.pips { display: inline-flex; gap: 4px; }
.pip { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--gold); background: transparent; padding: 0; cursor: pointer; }
.pip.on { background: var(--gold); }
.pip.slot { border-color: var(--accent); }
.pip.slot.on { background: var(--accent); }

/* ---------- Strikes ---------- */
.strike { display: grid; gap: 8px; }
.strike .attacks { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.strike .attacks .btn { font-variant-numeric: tabular-nums; font-size: 1.05rem; }
.strike .attacks .btn.next { outline: 2px solid var(--gold); outline-offset: 1px; }
.strike .damage { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.traits { display: flex; flex-wrap: wrap; gap: 4px; }

/* ---------- Spells ---------- */
.spell { border-top: 1px solid var(--line); padding: 8px 0; }
.spell:first-child { border-top: none; }
.spell summary { list-style: none; display: flex; align-items: center; gap: 8px; cursor: pointer; }
.spell summary::-webkit-details-marker { display: none; }
.actions-glyph { font-family: var(--font-display); color: var(--accent-text); letter-spacing: -1px; white-space: nowrap; }
.rules { font-size: .92rem; line-height: 1.45; }
.rules table { border-collapse: collapse; font-size: .85rem; margin: 6px 0; }
.rules td, .rules th { border: 1px solid var(--line); padding: 3px 6px; }
.rules hr { border: none; border-top: 1px solid var(--line); }
.roll { color: var(--accent-text); font-weight: 700; border-bottom: 1px dashed currentColor; cursor: pointer; white-space: nowrap; }
.roll::before { content: "🎲 "; font-size: .8em; }
.ref { color: var(--ink); font-weight: 600; border-bottom: 1px dotted var(--ink-soft); cursor: pointer; }

/* ---------- Sheets / overlays ---------- */
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 40; animation: fade .15s ease; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; max-height: 88dvh; overflow-y: auto; background: var(--surface);
  border-radius: 20px 20px 0 0; box-shadow: var(--shadow-lift); padding: 8px 16px calc(16px + var(--safe-b));
  animation: rise .22s cubic-bezier(.2,.9,.3,1.2); max-width: 760px; margin: 0 auto;
}
.sheet .grab { width: 44px; height: 5px; border-radius: 3px; background: var(--line); margin: 4px auto 10px; }
.sheet h2 { font-size: 1.2rem; margin-bottom: 6px; }
@keyframes rise { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } }

/* ---------- Breakdown ---------- */
.breakdown { display: grid; gap: 2px; font-size: .85rem; margin: 6px 0; }
.breakdown .line { display: flex; justify-content: space-between; gap: 8px; }
.breakdown .line .v { font-variant-numeric: tabular-nums; font-weight: 700; }
.breakdown .line.off { opacity: .55; text-decoration: line-through; }
.breakdown .note { font-size: .72rem; color: var(--ink-soft); }

/* ---------- Result card ---------- */
.result-dock { position: fixed; left: 0; right: 0; bottom: calc(var(--nav-h) + var(--safe-b) + 8px); z-index: 35; padding: 0 12px; pointer-events: none; }
.result {
  pointer-events: auto; max-width: 560px; margin: 0 auto; background: var(--surface); border-radius: 18px; box-shadow: var(--shadow-lift);
  border: 2px solid var(--line); padding: 12px 14px; animation: pop .28s cubic-bezier(.2,.9,.3,1.3);
}
.result.inline { animation: none; box-shadow: none; margin-bottom: 8px; }
.result.crit-success { border-color: var(--crit-success); }
.result.success { border-color: var(--success); }
.result.failure { border-color: var(--failure); }
.result.crit-failure { border-color: var(--crit-failure); }
.result.partial { border-color: var(--gold); }
.snapshot-tracks { display: grid; gap: 2px; margin-top: 3px; }
.snapshot-track { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.snapshot-track .pips { display: inline-flex; gap: 2px; }
.snapshot-track .pips span { width: 9px; height: 9px; border: 1.5px solid var(--ink-soft); border-radius: 2px; }
.snapshot-track .pips span.on { background: var(--accent); border-color: var(--accent); }
.result .head { display: flex; align-items: flex-start; gap: 8px; }
.result .title { font-family: var(--font-display); font-weight: 700; font-size: 1.05rem; }
.result .total { font-family: var(--font-display); font-size: 2.6rem; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.result .degree { font-weight: 800; text-transform: uppercase; letter-spacing: .04em; font-size: .8rem; }
.result.crit-success .degree { color: var(--crit-success); }
.result.success .degree { color: var(--success); }
.result.failure .degree { color: var(--failure); }
.result.crit-failure .degree { color: var(--crit-failure); }
.result.partial .degree { color: var(--gold); }
.result .dice { display: flex; flex-wrap: wrap; gap: 4px; margin: 8px 0; }
.result .actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.result.nat20 { box-shadow: 0 0 0 3px var(--gold), var(--shadow-lift); }
@keyframes pop { from { transform: translateY(20px) scale(.96); opacity: 0; } to { transform: none; opacity: 1; } }

.die {
  display: inline-flex; align-items: center; justify-content: center; min-width: 30px; height: 30px; padding: 0 6px;
  border-radius: 7px; background: var(--ink); color: var(--bg); font-weight: 800; font-variant-numeric: tabular-nums; font-size: .9rem;
  position: relative;
}
.die small { position: absolute; top: -7px; right: -5px; font-size: .55rem; background: var(--surface-2); color: var(--ink-soft); border-radius: 4px; padding: 0 3px; border: 1px solid var(--line); }
.die.dropped { opacity: .35; text-decoration: line-through; }
.die.max { background: var(--gold); color: #1a1208; }
.die.min { background: var(--crit-failure); color: #fff; }
.die.fire { background: #c2410c; } .die.cold { background: #2563eb; } .die.electricity { background: #ca8a04; color: #111; }
.die.acid { background: #4d7c0f; } .die.sonic { background: #7c3aed; } .die.force { background: #6d28d9; }
.die.vitality { background: #e8c547; color: #111; } .die.void { background: #3f3f46; } .die.mental { background: #db2777; }
.die.poison { background: #15803d; } .die.bleed { background: #7f1d1d; } .die.spirit { background: #0e7490; }

/* ---------- Tray ---------- */
/* The dice tray: a wooden tray lined with stitched felt. The 3D dice land inside .tray-felt. */
.dice-tray {
  --wood-hi: #9a6436; --wood: #6f4221; --wood-lo: #45260f; --felt-hi: #2f7a5d;
  --felt-fibers: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='f'><feTurbulence type='fractalNoise' baseFrequency='1.4' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 .9 -.35'/></filter><rect width='100%' height='100%' filter='url(%23f)' opacity='.16'/></svg>");
  --wood-grain: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='400' height='80'><filter id='g'><feTurbulence type='fractalNoise' baseFrequency='.004 .09' numOctaves='3' seed='7'/><feColorMatrix values='0 0 0 0 .16  0 0 0 0 .08  0 0 0 0 .02  0 0 0 .55 0'/></filter><rect width='100%' height='100%' filter='url(%23g)'/></svg>");
  max-width: 760px; margin: 0 auto 14px;
}
.tray-rim {
  position: relative; padding: 18px; border-radius: 28px;
  background-color: var(--wood);
  background-image: var(--wood-grain), linear-gradient(160deg, var(--wood-hi), var(--wood) 45%, var(--wood-lo));
  box-shadow:
    0 18px 36px rgba(20, 10, 2, .45), 0 3px 6px rgba(20, 10, 2, .35),
    inset 0 2px 0 rgba(255, 214, 170, .35), inset 0 -4px 8px rgba(0, 0, 0, .45), inset 0 0 0 1px rgba(0, 0, 0, .35);
}
.tray-felt {
  position: relative; display: grid; place-items: center; height: clamp(260px, 44vh, 400px); border-radius: 14px; overflow: hidden;
  color: rgba(232, 245, 236, .6);
  background-color: var(--felt);
  background-image:
    var(--felt-fibers),
    radial-gradient(ellipse 70% 60% at 50% 42%, color-mix(in srgb, var(--felt-hi) 70%, transparent), transparent 70%),
    radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 0, .38));
  box-shadow: inset 0 12px 24px rgba(0, 0, 0, .7), inset 0 -3px 10px rgba(0, 0, 0, .35), inset 0 0 0 2px rgba(0, 0, 0, .35);
}
/* Stitching around the felt edge. */
.tray-felt::before {
  content: ""; position: absolute; inset: 11px; border-radius: 8px; pointer-events: none;
  border: 2px dashed rgba(236, 226, 196, .22); box-shadow: 0 1px 0 rgba(0, 0, 0, .25);
}
.felt-label { padding: 0 24px; text-align: center; font-family: var(--font-display); letter-spacing: .04em; text-shadow: 0 -1px 0 rgba(0, 0, 0, .45), 0 1px 0 rgba(255, 255, 255, .06); }
.felt-pool { font-size: clamp(1.4rem, 4.5vw, 2.2rem); font-weight: 700; color: rgba(240, 250, 242, .78); }
.felt-hint { font-size: 1.05rem; font-style: italic; }

/* The rack: dice-shaped tokens in the character's dice colour. */
.dice-rack { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px 8px; justify-items: center; margin: 16px 0 6px; }
.die-token {
  position: relative; display: grid; place-items: center; width: 64px; height: 64px; padding: 0; border: 0; background: none; cursor: pointer;
  filter: drop-shadow(0 3px 3px rgba(0, 0, 0, .35)); transition: transform .1s ease;
}
.die-token::before {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(circle at 35% 28%, color-mix(in srgb, var(--die) 55%, white), var(--die) 55%, color-mix(in srgb, var(--die) 70%, black));
  clip-path: var(--shape);
}
.die-token:hover { transform: translateY(-2px) rotate(-4deg); }
.die-token:active { transform: scale(.92); }
.die-token:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 8px; }
.die-face { position: relative; font-family: var(--font-display); font-weight: 800; font-size: 1rem; color: var(--die-ink); }
.die-count {
  position: absolute; top: -6px; right: -4px; min-width: 22px; height: 22px; padding: 0 5px; border-radius: 11px; display: grid; place-items: center;
  font-size: .75rem; font-weight: 800; color: var(--accent-ink); background: var(--accent); box-shadow: 0 1px 3px rgba(0, 0, 0, .35);
}
.die-token.d4 { --shape: polygon(50% 3%, 97% 90%, 3% 90%); }
.die-token.d4 .die-face { margin-top: 18px; }
.die-token.d6 { --shape: inset(8% round 18%); }
.die-token.d8 { --shape: polygon(50% 1%, 99% 50%, 50% 99%, 1% 50%); }
.die-token.d10, .die-token.d100 { --shape: polygon(50% 1%, 97% 44%, 50% 99%, 3% 44%); }
.die-token.d12 { --shape: polygon(50% 1%, 98% 36%, 80% 96%, 20% 96%, 2% 36%); }
.die-token.d20 { --shape: polygon(25% 5%, 75% 5%, 99% 50%, 75% 95%, 25% 95%, 1% 50%); }
.die-token.d2 { --shape: circle(44%); }

.tray-controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: center; margin-top: 8px; }
.tray-mod { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); overflow: hidden; }
.tray-mod button { width: 42px; height: 40px; border: 0; background: none; font-size: 1.2rem; font-weight: 800; cursor: pointer; }
.tray-mod button:hover { background: var(--surface-2); }
.tray-mod span { min-width: 4ch; text-align: center; font-weight: 800; font-variant-numeric: tabular-nums; }
.tray-roll { min-width: 140px; font-size: 1.1rem; }
.tray-shake { margin-top: 10px; opacity: .8; }
@media (min-width: 560px) { .dice-rack { grid-template-columns: repeat(8, 1fr); } }

/* ---------- Misc ---------- */
.empty { text-align: center; padding: 40px 16px; color: var(--ink-soft); }
.empty .big { font-size: 3rem; }
.issue { font-size: .82rem; padding: 6px 8px; border-radius: 8px; background: var(--surface-2); margin: 4px 0; }
.issue.warning { border-left: 3px solid var(--failure); }
.issue.error { border-left: 3px solid var(--crit-failure); }
.issue.info { border-left: 3px solid var(--line); }
.change.Improved::before { content: "▲ "; color: var(--success); }
.change.Added::before { content: "+ "; color: var(--success); }
.change.Removed::before { content: "− "; color: var(--crit-failure); }
.change.Decreased::before { content: "▼ "; color: var(--failure); }
.toolbar { display: flex; gap: 8px; align-items: center; margin: 8px 0; flex-wrap: wrap; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.seg button { border: none; background: transparent; padding: 6px 12px; font-weight: 700; cursor: pointer; }
.seg button.on { background: var(--ink); color: var(--bg); }

/* Keyboard/switch users: a clear focus ring everywhere. */
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.result-dock:empty { display: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Licenses page */
.license-text { font-size: .85rem; line-height: 1.5; overflow-wrap: anywhere; }
.license-text h2 { font-size: 1.1rem; }
.license-text h3 { font-size: .95rem; margin: 14px 0 4px; }
.license-text ul { padding-left: 18px; margin: 4px 0 10px; }
.licenses-link { display: block; text-align: center; margin: 18px 0 8px; }
.linklike { background: none; border: 0; padding: 0; color: var(--accent-text); text-decoration: underline; font: inherit; cursor: pointer; }

/* ---------- Desktop (≥ 900px): side rail, wide multi-column sheet, floating result dock ---------- */
.sheet:focus { outline: none; }
@media (min-width: 900px) {
  :root { --rail-w: 96px; }
  .app { padding-left: var(--rail-w); }
  .topbar { padding-left: 28px; padding-right: 28px; }
  .bottomnav {
    top: 0; right: auto; width: var(--rail-w); height: auto; flex-direction: column; justify-content: flex-start; gap: 4px;
    padding: calc(12px + var(--safe-t)) 0 12px; border-top: 0; border-right: 1px solid var(--line);
  }
  .bottomnav a { flex: 0 0 auto; padding: 12px 0; border-radius: 12px; margin: 0 8px; font-size: .75rem; }
  .bottomnav a:hover { background: var(--surface-2); }
  .bottomnav a.active { background: var(--surface-2); }
  .content { max-width: 1240px; padding: 20px 28px 40px; }
  .content > .card, .content > .empty, .content > .licenses-link { max-width: 760px; margin-left: auto; margin-right: auto; }
  .content > .card.wide { max-width: none; }
  .tabs { top: calc(56px + var(--safe-t)); }
  .tab-body { display: grid; grid-template-columns: repeat(auto-fill, minmax(440px, 1fr)); gap: 12px; align-items: start; }
  .tab-body > .card { margin-bottom: 0; }
  .result-dock { left: auto; right: 24px; bottom: 24px; width: 440px; padding: 0; }
  .sheet { left: var(--rail-w); bottom: 0; }
}

/* ---------- Right-click menu ---------- */
.ctx-scrim { position: fixed; inset: 0; z-index: 60; }
.ctx-menu {
  position: fixed; z-index: 61; min-width: 190px; max-width: 240px; padding: 4px; display: grid;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-lift);
  animation: fade .1s ease;
}
.ctx-menu:focus { outline: none; }
.ctx-title { padding: 6px 10px 4px; font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ctx-menu button { padding: 8px 10px; border: 0; border-radius: 6px; background: none; text-align: left; cursor: pointer; }
.ctx-menu button:hover, .ctx-menu button:focus-visible { background: var(--surface-2); outline: none; }
/* About page and the top bar's info button */
.topbar-info {
  display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; flex: none;
  color: var(--accent-ink); text-decoration: none; font-size: 1.2rem; opacity: .85;
}
.topbar-info:hover, .topbar-info.active { opacity: 1; background: rgba(0, 0, 0, .2); }
.about-hero { display: flex; gap: 16px; align-items: center; }
.about-logo { width: 84px; height: 84px; flex: none; filter: drop-shadow(0 3px 6px rgba(0, 0, 0, .25)); }
.about-meta { display: flex; flex-wrap: wrap; gap: 4px 14px; color: var(--ink-soft); }
.support-links { display: grid; gap: 8px; margin-top: 8px; }
.support-link { display: flex; justify-content: space-between; align-items: center; gap: 12px; text-decoration: none; }
.licenses-link a { color: inherit; }
@media (max-width: 420px) { .about-hero { flex-direction: column; text-align: center; } .about-meta { justify-content: center; } }
.rest-buttons { display: inline-flex; gap: 6px; flex-wrap: wrap; }

/* Links styled as buttons keep the button look (no link blue or underline). */
a.btn { color: inherit; text-decoration: none; display: inline-flex; align-items: center; }
a.btn.primary { color: var(--accent-ink); }

/* Destructive confirmations (remove a player, leave a table). */
.btn.danger { background: var(--crit-failure); border-color: transparent; color: #fff; }

/* ---------- Portraits & story ---------- */
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.portrait { --size: 44px; flex: none; display: inline-grid; place-items: center; width: var(--size); height: var(--size); border-radius: 50%; overflow: hidden;
  background: radial-gradient(circle at 35% 30%, var(--surface), var(--surface-2)); border: 2px solid var(--gold); box-shadow: 0 1px 3px rgba(0, 0, 0, .25); }
.portrait img { width: 100%; height: 100%; object-fit: cover; display: block; }
.portrait .initials { font-family: var(--font-display); font-weight: 700; color: var(--accent-text); font-size: calc(var(--size) * .38); letter-spacing: .02em; }
.portrait.sm { --size: 34px; border-width: 1.5px; }
.portrait.md { --size: 44px; }
.portrait.lg { --size: 72px; }
.portrait.xl { --size: 132px; border-width: 3px; }
.topbar-portrait { display: flex; margin-right: 10px; text-decoration: none; }
.topbar-portrait .portrait { border-color: rgba(255, 248, 238, .85); }
.character-row { gap: 12px; }
.character-row .label { text-align: left; }

.story-head { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.portrait-button { position: relative; padding: 0; border: 0; background: none; cursor: pointer; border-radius: 50%; }
.portrait-button .portrait-hint { position: absolute; left: 50%; bottom: -6px; transform: translateX(-50%); white-space: nowrap; font-size: .72rem; padding: 2px 10px;
  border-radius: 999px; background: var(--accent); color: var(--accent-ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .3); }
.story-ids { flex: 1; min-width: 200px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 12px; }
.id-field { display: flex; flex-direction: column; gap: 2px; }
.id-field input { width: 100%; }
.story-section h3 { margin: 0; }
.story-text { font-family: var(--font-body); font-size: .95rem; line-height: 1.45; min-height: 4.5em; resize: vertical; field-sizing: content; margin-top: 6px; }
.chip.visibility { font-size: .72rem; padding: 2px 10px; }
.chip.visibility.gmonly { background: color-mix(in srgb, var(--gold) 22%, transparent); border-color: var(--gold); }
.chip.visibility.table { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.portrait-editor { display: flex; flex-direction: column; align-items: center; }
.crop-frame { position: relative; width: min(280px, 72vw); aspect-ratio: 1; display: grid; place-items: center; border-radius: 16px; overflow: hidden; background: var(--surface-2); }
.crop-frame canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: none; touch-action: none; cursor: grab; }
.crop-frame.loaded canvas { display: block; }
.crop-frame.loaded::after { content: ""; position: absolute; inset: 0; pointer-events: none; border-radius: 50%; box-shadow: 0 0 0 999px rgba(0, 0, 0, .35); }
.portrait-editor .row { justify-content: center; }
.party-avatar { position: relative; display: inline-flex; }
.party-avatar .presence { position: absolute; right: -1px; bottom: -1px; width: 11px; height: 11px; border-radius: 50%; background: var(--line); border: 2px solid var(--surface); }
.party-avatar .presence.online { background: var(--success); }
.story-read { white-space: pre-wrap; margin: 4px 0 12px; line-height: 1.45; }

/* ---------- Journal ---------- */
.journal-tabs { margin-bottom: 10px; }
.journal-head .notebook-picker { font-family: var(--font-display); font-size: 1.05rem; }
.journal-link { margin: 6px 0 8px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.journal-search { width: 100%; margin: 4px 0 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.journal-kinds, .journal-tags { margin-top: 4px; }
.journal-new { display: flex; gap: 6px; overflow-x: auto; padding: 4px 2px 10px; scrollbar-width: thin; }
.journal-new .chip { white-space: nowrap; text-decoration: none; color: inherit; }
.journal-group { margin: 14px 4px 6px; font-size: .85rem; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .06em; }
.journal-row { text-decoration: none; color: inherit; gap: 10px; align-items: flex-start; }
.journal-row .label { text-align: left; min-width: 0; }
.journal-row .preview { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; }
.journal-row.shared { border-style: dashed; }
.journal-badges { display: flex; gap: 4px; align-items: center; flex: none; }
.kind-icon { flex: none; width: 1.6em; text-align: center; font-size: 1.15rem; line-height: 1.4; }
.kind-icon.big { font-size: 1.8rem; width: 1.4em; }
.note-head { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 8px; }
.note-head h2 { margin: 0 0 2px; }
.note-head .chips { margin-top: 6px; }
.chip.trait.quest-done { background: color-mix(in srgb, var(--success) 25%, transparent); }
.chip.trait.quest-failed { background: color-mix(in srgb, var(--crit-failure) 22%, transparent); }
.note-body { line-height: 1.5; overflow-wrap: anywhere; }
.note-body .note-p { margin: 0 0 10px; white-space: pre-line; }
.note-body .note-h1 { font-size: 1.15rem; margin: 14px 0 6px; color: var(--accent-text); text-transform: none; letter-spacing: 0; font-family: var(--font-display); }
.note-body h4 { margin: 12px 0 4px; font-size: 1rem; font-family: var(--font-display); }
.note-body .note-bullet { position: relative; padding-left: 18px; margin: 3px 0; }
.note-body .note-bullet::before { content: "•"; position: absolute; left: 5px; color: var(--accent-text); }
.note-body .note-check { display: flex; gap: 8px; align-items: flex-start; margin: 4px 0; }
.note-body .note-check input { margin-top: 4px; width: 18px; height: 18px; accent-color: var(--accent); }
.note-body .note-check.done span { text-decoration: line-through; color: var(--ink-soft); }
.note-body .note-quote { margin: 6px 0; padding: 4px 12px; border-left: 3px solid var(--gold); color: var(--ink-soft); font-style: italic; }
.note-link { display: inline; padding: 0; border: 0; background: none; font: inherit; color: var(--accent-text); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 2px; cursor: pointer; }
.note-link.missing { color: var(--ink-soft); text-decoration-style: dashed; }
.note-roll { display: inline-flex; gap: 4px; align-items: center; padding: 0 8px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface-2); font: inherit; font-size: .9em; font-weight: 700; color: var(--ink); cursor: pointer; }
.note-editor { display: grid; gap: 8px; }
.note-editor input[type=text], .note-editor select { width: 100%; }
.note-editor .row select { width: auto; }
.note-title-input { font-family: var(--font-display); font-size: 1.15rem; }
.session-number { width: 4.5em; }
.note-toolbar { display: flex; flex-wrap: wrap; gap: 6px; }
.note-text { font-family: var(--font-body); font-size: .95rem; line-height: 1.45; min-height: 14em; field-sizing: content; }
.link-suggestions { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px; border: 1px dashed var(--line); border-radius: 10px; }
.chip.trait.tag, .journal-tags .chip, .note-head .chip.trait { text-transform: none; }
a.chip { color: inherit; text-decoration: none; }
@media (min-width: 900px) {
  .content > .journal, .content > .journal-entry { max-width: 760px; margin-left: auto; margin-right: auto; }
}

/* ---------- Encounter & effects ---------- */
.effects-panel { margin-top: 8px; }
.chip.effect { background: color-mix(in srgb, var(--gold) 18%, var(--surface)); border-color: var(--gold); }
.chip.effect small { opacity: .75; margin-left: 4px; }
.chip.effect.persistent { background: color-mix(in srgb, var(--crit-failure) 16%, var(--surface)); border-color: color-mix(in srgb, var(--crit-failure) 60%, transparent); }
.chip.add-effect { border-style: dashed; }
.effect-builder { display: grid; gap: 8px; }
.effect-builder input[type=text] { width: 100%; }
/* Class resources: one row per resource (icon + name, then its controls); lit while active. */
.class-resources { display: grid; gap: 6px; }
.class-resources .chip.add-effect { justify-self: start; }
.resource { position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 6px 8px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.resource.lit { border-color: var(--gold); background: color-mix(in srgb, var(--gold) 12%, var(--surface)); }
.resource-head { display: inline-flex; align-items: center; gap: 6px; min-width: 8.5em; padding: 4px 2px; border: 0; background: none;
  color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; text-align: left; }
.resource-head .icon { width: 1.35em; height: 1.35em; color: var(--accent-text); }
.resource-body { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; flex: 1 1 15em; min-width: 0; }
.resource-counter, .resource-toggle, .resource-instances, .resource-roll { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.resource-body > * { flex: 1 1 auto; min-width: 0; }
.resource .pips .pip, .resource-controls .pips .pip { width: 14px; height: 14px; cursor: default; }
.resource-value { font-family: var(--font-display); font-size: 1.15rem; font-variant-numeric: lining-nums tabular-nums; }
.chip.instance { padding-right: 2px; background: color-mix(in srgb, var(--ink) 6%, var(--surface)); }
.chip.instance .btn { min-height: 24px; padding: 0 4px; }
.party-resources .chip.lit { border-color: var(--gold); background: color-mix(in srgb, var(--gold) 16%, var(--surface)); }
.resource-prompt { display: inline-flex; align-items: center; gap: 2px; animation: rise .25s ease-out; }
.resource-state { display: flex; align-items: center; gap: 6px; margin: 0 0 6px; }
.resource-state .icon { width: 1.5em; height: 1.5em; color: var(--accent-text); }
.resource-reminder { color: var(--accent-text); }
.resource-controls { display: grid; gap: 8px; margin: 10px 0; }
/* Class-resource flourishes: small decorative scenes over a resource card (FlourishArt). Never take taps; hidden
   when the OS asks for less motion (the setting is in the tray). */
.flourish { position: absolute; right: 4px; top: -40px; width: 120px; height: 90px; pointer-events: none; z-index: 3;
  --fl-ink: #2a211a; --fl-bone: #f1e8d2; --fl-earth: #8a6a3b; --fl-glass: color-mix(in srgb, var(--surface) 65%, #bfe3f0); --fl-brew: #3f9d62;
  --fl-steam: color-mix(in srgb, var(--crit-failure) 30%, #d9d4cc); --fl-arcane: #5b7cf0; --fl-smoke: color-mix(in srgb, var(--ink) 35%, transparent);
  --fl-curse: #6b3f8f; --fl-spirit: color-mix(in srgb, #cfe6ff 85%, var(--surface)); }
.flourish svg { width: 100%; height: 100%; overflow: visible; }
.p-resource .flourish { width: 96px; height: 72px; top: -34px; right: 0; --ink: var(--paper-ink); }
@media (prefers-reduced-motion: reduce) { .flourish { display: none; } }
@media (prefers-reduced-motion: no-preference) {
  .flourish { animation: fl-fade 1.7s ease-out both; }
  .fl-rise { animation: fl-rise .7s cubic-bezier(.2, 1.4, .4, 1) both; }
  .fl-fall { transform-box: fill-box; transform-origin: center bottom; animation: fl-fall .9s ease-in both; }
  .fl-pop { transform-box: fill-box; transform-origin: center; animation: fl-pop .45s cubic-bezier(.2, 1.6, .4, 1) both; }
  .fl-burst > * { animation: fl-burst .8s ease-out both; }
  .fl-burst-ring { transform-box: fill-box; transform-origin: center; animation: fl-ring .8s ease-out both; }
  .fl-rays { transform-box: fill-box; transform-origin: center; animation: fl-rays .7s ease-out both; }
  .fl-spin { transform-box: fill-box; transform-origin: center; animation: fl-spin 1.6s linear both; }
  .fl-spin.reverse { animation-direction: reverse; }
  .fl-float, .fl-floats > * { animation: fl-float 1.3s ease-out both; }
  .fl-draw { stroke-dasharray: 1; stroke-dashoffset: 1; animation: fl-draw .55s ease-out forwards; }
  .fl-pulse { transform-box: fill-box; transform-origin: center; animation: fl-pulse .45s ease-in-out 2 both; }
  .fl-sweep { animation: fl-sweep 1s ease-in-out both; }
}
@keyframes fl-fade { 0%, 75% { opacity: 1; } 100% { opacity: 0; } }
@keyframes fl-rise { from { transform: translateY(46px); } to { transform: none; } }
@keyframes fl-fall { 0% { transform: none; opacity: 1; } 30% { transform: rotate(-8deg); } 100% { transform: translateY(40px) rotate(14deg); opacity: 0; } }
@keyframes fl-pop { from { transform: scale(0); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes fl-burst { from { transform: none; opacity: 1; } to { transform: translate(var(--fl-x, 0), var(--fl-y, -12px)); opacity: 0; } }
@keyframes fl-ring { from { transform: scale(.3); opacity: 1; } to { transform: scale(1.35); opacity: 0; } }
@keyframes fl-rays { from { transform: scale(.4); opacity: 0; } 40% { opacity: 1; } to { transform: scale(1.15); opacity: 0; } }
@keyframes fl-spin { to { transform: rotate(360deg); } }
@keyframes fl-float { from { transform: translateY(8px); opacity: 0; } 30% { opacity: 1; } to { transform: translateY(-18px); opacity: 0; } }
@keyframes fl-draw { to { stroke-dashoffset: 0; } }
@keyframes fl-pulse { 50% { transform: scale(1.12); } }
@keyframes fl-sweep { from { transform: translateX(-20px) rotate(-10deg); } 50% { transform: translateX(10px); } to { transform: none; } }

.encounter-bar { margin-top: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); display: grid; gap: 6px; }
.encounter-bar.my-turn { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.encounter-bar .row { flex-wrap: wrap; gap: 8px; align-items: center; }
.encounter-bar .round { font-family: var(--font-display); font-weight: 700; }
.encounter-bar .pips { display: inline-flex; gap: 4px; }
.encounter-bar .pip { width: 30px; height: 30px; display: inline-grid; place-items: center; padding: 0; border-radius: 8px; border: 1.5px solid var(--accent); background: var(--surface); color: var(--accent-text); font-size: 1rem; line-height: 1; cursor: pointer; }
.encounter-bar .pip.used { background: var(--accent); color: var(--accent-ink); opacity: .55; }
.encounter-bar .pip.lost { border-style: dashed; color: var(--ink-soft); border-color: var(--line); cursor: not-allowed; }
.encounter-bar .pip.extra { border-color: var(--gold); color: var(--gold); }
.encounter-bar .pip.reaction { border-radius: 50%; border-color: var(--gold); color: var(--gold); }
.encounter-bar .pip.reaction.used { background: var(--gold); color: var(--surface); }
.turn-summary { position: relative; padding: 8px 34px 8px 10px; border-radius: 10px; background: var(--surface); border-left: 3px solid var(--gold); font-size: .9rem; display: grid; gap: 2px; }
.turn-summary .close { position: absolute; top: 4px; right: 4px; }
.paper-encounter { max-width: 816px; margin: 0 auto 10px; padding: 0 4px; }
.paper-encounter .encounter-bar { margin-top: 6px; }

/* ---------- Inventory ---------- */
.bulk-line { display: grid; gap: 4px; margin: 4px 0 10px; }
.bulk-bar { position: relative; height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; border: 1px solid var(--line); }
.bulk-bar .fill { height: 100%; background: var(--success); }
.bulk-bar .limit { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--ink-soft); }
.bulk-line.heavy .fill { background: var(--gold); }
.bulk-line.over .fill { background: var(--crit-failure); }
.inventory-row { gap: 8px; align-items: center; }
.inventory-row .link { padding: 0; border: 0; background: none; font: inherit; color: inherit; text-align: left; cursor: pointer; text-decoration: underline dotted; text-underline-offset: 3px; }
.chip.use { font-weight: 700; }
.coins-button { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 10px; padding: 6px 8px; width: 100%; border: 1px dashed var(--line); border-radius: 10px; background: none; color: inherit; font: inherit; cursor: pointer; }
.coin-form { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin: 8px 0; }
.coin-form label { display: flex; align-items: center; gap: 4px; }
.coin-form input { width: 100%; min-width: 0; }
.ledger-row { gap: 8px; padding: 3px 0; border-bottom: 1px dotted var(--line); }
.ledger-row .gain { color: var(--success); }
.ledger-row .loss { color: var(--crit-failure); }
.qty-stepper { display: inline-flex; gap: 8px; align-items: center; }
.play-changes { margin-top: 10px; color: var(--ink-soft); }
.play-changes summary { cursor: pointer; }
.item-text { margin-top: 8px; }
.gear-changes { margin-top: 10px; padding: 8px 10px; border-radius: 10px; background: var(--surface-2); }
.result .outcome { margin-top: 6px; padding: 6px 8px; border-left: 3px solid var(--gold); background: var(--surface-2); border-radius: 6px; }

/* ---------- Actions & quick reference ---------- */
.actions-panel .target-dc { width: 4.5em; }
.skill-action { padding: 8px 0; border-bottom: 1px dotted var(--line); }
.skill-action:last-child { border-bottom: 0; }
.skill-action-roll { text-align: left; padding: 6px 8px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: inherit; font: inherit; cursor: pointer; }
.skill-action-roll:disabled { cursor: not-allowed; opacity: .6; }
.skill-action .skill-pick { max-width: 11em; }
.skill-action.locked .locked-note { color: var(--failure); }
.topbar-search { margin-right: 6px; width: 34px; height: 34px; border-radius: 50%; border: 0; background: rgba(0, 0, 0, .18); color: inherit; font-size: 1.15rem; cursor: pointer; }
.backup-panel { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-start; } .backup-panel .backup-preview, .backup-panel .issue { flex-basis: 100%; }

/* ---------- Brand ---------- */
.wordmark { font-family: var(--font-brand); font-weight: 700; letter-spacing: .04em; }
.tagline { margin: 2px 0 0; font-style: italic; color: var(--ink-soft); }
.topbar-mark { display: flex; margin-right: 10px; }
.topbar-mark img { width: 34px; height: 34px; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .35)); }
.about-logo { width: 112px; height: 112px; flex: none; }

/* ---------- Icons ---------- */
.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 1.15em; height: 1.15em; flex: none; vertical-align: -0.2em; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; --icon-knob: var(--surface); }
.btn .icon, .chip .icon { margin-right: .3em; }
.btn.icon-only .icon, .chip.icon-only .icon { margin-right: 0; }
.action-cost { display: inline-flex; align-items: center; gap: 1px; color: var(--accent-text); white-space: nowrap; }
.action-cost .icon { width: .95em; height: .95em; vertical-align: 0; }
.action-cost .icon-action-2 { width: 1.27em; }
.action-cost .icon-action-3 { width: 1.58em; }
.action-cost .sep { font-size: .8em; margin: 0 1px; }
.empty .big .icon { width: 3rem; height: 3rem; stroke-width: 1.3; color: var(--ink-soft); }
.bottomnav .icon-wrap .icon { width: 24px; height: 24px; }

/* ---------- Boot screen (before the app starts; both hosts) ---------- */
.boot { min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 24px 16px; background: var(--bg); color: var(--ink); }
.boot-mark { width: 132px; height: 132px; overflow: visible; filter: drop-shadow(0 4px 10px rgba(0, 0, 0, .18)); }
.boot-word { font-family: var(--font-brand, Georgia, serif); font-weight: 700; font-size: 1.6rem; letter-spacing: .06em; }
.boot-note { font-style: italic; color: var(--ink-soft); font-size: .95rem; }
.boot-bar { width: min(220px, 60vw); height: 4px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.boot-bar span { display: block; height: 100%; width: var(--blazor-load-percentage, 0%); background: var(--accent); border-radius: inherit; transition: width .25s ease-out; }
.boot-indeterminate .boot-bar span { width: 35%; animation: boot-slide 1.3s ease-in-out infinite; }
.boot-ink line { stroke-dasharray: 50; stroke-dashoffset: 0; }
.boot-die { transform-box: fill-box; transform-origin: center; }
@media (prefers-reduced-motion: no-preference) {
  .boot-ink line { animation: boot-write 2.8s ease-out infinite; }
  .boot-ink line:nth-child(2) { animation-delay: .18s; }
  .boot-ink line:nth-child(3) { animation-delay: .36s; }
  .boot-ink line:nth-child(4) { animation-delay: .54s; }
  .boot-die { animation: boot-tumble 2.8s cubic-bezier(.3, .7, .4, 1) infinite; }
}
@keyframes boot-write { 0% { stroke-dashoffset: 50; } 22%, 100% { stroke-dashoffset: 0; } }
@keyframes boot-tumble {
  0%, 30% { transform: translate(38px, -120px) rotate(-280deg); opacity: 0; }
  36% { opacity: 1; }
  56% { transform: translate(0, 0) rotate(0); }
  63% { transform: translate(-2px, -7px) rotate(-9deg); }
  71%, 100% { transform: translate(0, 0) rotate(0); opacity: 1; }
}
@keyframes boot-slide { 0% { transform: translateX(-110%); } 100% { transform: translateX(310%); } }

/* Content packs warming up after start: a slim bar under the top bar. */
.content-loading { position: sticky; top: calc(56px + var(--safe-t, 0px)); z-index: 5; height: 3px; overflow: hidden; background: transparent; }
.content-loading span { display: block; width: 30%; height: 100%; background: var(--gold); border-radius: 999px; }
@media (prefers-reduced-motion: no-preference) { .content-loading span { animation: boot-slide 1.2s ease-in-out infinite; } }

/* Skeleton rows while lists load. */
.skeleton { display: grid; gap: 8px; }
.skeleton .bone { height: 58px; border-radius: 12px; background: linear-gradient(90deg, var(--surface-2) 0%, var(--surface) 50%, var(--surface-2) 100%); background-size: 200% 100%; }
@media (prefers-reduced-motion: no-preference) { .skeleton .bone { animation: bone-shimmer 1.4s linear infinite; } }
@keyframes bone-shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

/* ---------- Empty states ---------- */
.empty-state { display: grid; justify-items: center; gap: 8px; padding: 24px 12px; text-align: center; }
.empty-state .empty-art { width: 150px; max-width: 60%; height: auto; }
.empty-state .empty-title { font-size: 1.15rem; margin: 4px 0 0; }
.empty-state p { margin: 0; max-width: 34ch; }
.empty-state > :last-child:not(p):not(h2):not(svg) { margin-top: 6px; }
.card .empty-state { padding: 8px 0; }

/* ---------- Polish ---------- */
/* Crimson Pro's figures: lining and tabular wherever numbers are read or compared. */
.stat .value, .hp-num, .result .total, .topbar .hp-mini, .encounter-bar .pip, .bulk-line, .coins, .p-value { font-variant-numeric: lining-nums tabular-nums; }
.topbar { gap: 8px; }
.topbar .title { font-size: 1.2rem; font-weight: 650; }
.topbar .title.wordmark { font-size: 1.15rem; }
.topbar-search, .topbar-info { width: 32px; height: 32px; display: inline-grid; place-items: center; border-radius: 50%; color: inherit; flex: none; }
.topbar-info { text-decoration: none; }
.topbar .hp-mini { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; flex: none; }
.topbar .hp-mini .icon { width: 1em; height: 1em; }
.card h2 { font-size: 1.2rem; }
