/* Cinzel and Cinzel Decorative: Copyright 2012 The Cinzel Project Authors. SIL Open Font License 1.1. */
@font-face {
  font-family: "Cinzel";
  src: url("../vendor/fonts/cinzel-latin.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Cinzel Decorative";
  src: url("../vendor/fonts/cinzel-decorative-latin.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg0: #070605;
  --bg1: #14110e;
  --glow: rgba(176, 78, 32, 0.22);
  --page: #f6edd9;
  --page-dim: #f0e2c8;
  --ink: #24170f;
  --muted: #6a503c;
  --card: #f7f0df;
  --card-hover: #fff8ea;
  --line: #e4d3b4;
  --line-strong: #8d6840;
  --accent: #9a332c;
  --accent-soft: #f4ddc4;
  --gold: #f0d78c;
  --hint: #e4d0b0;
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.38);
  --display: "Cinzel", Palatino, "Palatino Linotype", Georgia, serif;
  --wordmark: "Cinzel Decorative", "Cinzel", Palatino, Georgia, serif;
  --serif: Palatino, "Palatino Linotype", "Book Antiqua", Georgia, serif;
  --sans: "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, "Courier New", monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
}

html { background: #070605; }

body {
  background-color: #070605;
  background-image:
    radial-gradient(ellipse 55% 32% at 50% -8%, rgba(176, 72, 28, 0.28), transparent 62%),
    radial-gradient(ellipse 36% 28% at 100% 100%, rgba(110, 22, 18, 0.35), transparent 58%),
    linear-gradient(180deg, #161310 0%, #070605 46%);
  color: var(--page);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.45;
  padding-bottom: 5.6rem;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(ellipse at center, transparent 28%, rgba(0, 0, 0, 0.72) 100%),
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)' opacity='0.55'/></svg>");
  background-size: auto, 180px 180px;
  opacity: 0.55;
  mix-blend-mode: multiply;
}

#topbar, #desknav, #crt { position: relative; z-index: 1; }

button, input, select { font: inherit; color: var(--ink); }
button { touch-action: manipulation; }

.ico {
  width: 1.35rem;
  height: 1.35rem;
  flex: none;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

#topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
  max-width: 68rem;
  margin: 0 auto;
  padding: 1.15rem 1.4rem 0.85rem;
}

.eyebrow, .kicker {
  margin: 0;
  font-family: var(--display);
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold);
}

.brand h1 {
  margin: 0.1rem 0 0;
  font-family: var(--display);
  font-size: 1.7rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  line-height: 1.15;
  color: var(--page);
}

.sub {
  margin: 0.15rem 0 0;
  color: var(--page-dim);
}

.tools { display: flex; gap: 0.45rem; flex-wrap: wrap; justify-content: flex-end; flex-shrink: 0; }

#uabtn[aria-pressed="true"] {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

#uabtn:disabled,
#uabtn:disabled:hover {
  cursor: default;
  box-shadow: none;
  opacity: 0.72;
}

#uabtn[aria-pressed="true"]:disabled,
#uabtn[aria-pressed="true"]:disabled:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.tools button, #pdfbtn, button.act, span.act {
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 0.45rem 0.95rem;
  min-height: 2.75rem;
  cursor: pointer;
  box-shadow: var(--shadow);
}

.tools button:hover, #pdfbtn:hover, button.act:hover,
button.mitem:hover, button.cmd:hover {
  background: var(--card-hover);
  border-color: var(--line-strong);
}

#crt {
  max-width: 68rem;
  margin: 0 auto;
  padding: 0 1.4rem 2.5rem;
}

#status {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.9rem;
}

.chip {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.02em;
}

#screen.menu { white-space: normal; }

#screen.menu .lead, .lead {
  margin: 0 0 0.75rem;
  font-family: var(--display);
  font-size: 1.55rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  line-height: 1.15;
  color: #f6edd9;
  text-shadow: none;
  text-rendering: geometricPrecision;
}
body[data-theme="light"] #screen.menu .lead,
body[data-theme="light"] .lead {
  color: #24170f;
  text-shadow: none;
}
body[data-theme="light"] #screen.home .lead { color: var(--gold); }
article.mitem {
  color: var(--ink);
  align-items: flex-start;
}
article.mitem strong { font-family: var(--display); font-size: 1.05rem; letter-spacing: 0.03em; }

#screen.menu .block {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(16.5rem, 1fr));
  gap: 0.55rem;
  margin: 0;
}

button.mitem,
article.mitem {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  width: 100%;
  text-align: left;
  padding: 0.8rem 0.95rem;
  min-height: 3.15rem;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.45), transparent 42%),
    var(--card);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.65) inset, 0 10px 24px rgba(0, 0, 0, 0.18);
  cursor: pointer;
  white-space: normal;
}

.dos-label { display: none; }

.mod-label {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  width: 100%;
}

button.mitem kbd, button.cmd kbd {
  font-family: var(--mono);
  font-size: 0.75rem;
  line-height: 1.2;
  min-width: 1.6rem;
  text-align: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.12rem 0.35rem;
  background: var(--bg);
  color: var(--accent);
  flex: none;
}

.statboard {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem 1.2rem;
  margin: 0 0 0.9rem;
  font-family: var(--sans);
}

.statboard div {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px solid var(--line);
  padding: 0.15rem 0;
}

.statboard .curstat { color: var(--accent); font-weight: 600; }

.backup {
  margin-top: 0.9rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

button.mitem:hover, button.mitem:focus-visible,
button.cmd:hover, button.cmd:focus-visible,
button.act:hover, button.act:focus-visible,
.tools button:hover, .tools button:focus-visible {
  border-color: var(--accent);
  background: var(--accent-soft);
}

button.mitem:focus-visible,
button.cmd:focus-visible,
button.act:focus-visible,
.tools button:focus-visible,
#line:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

#screen.prose, #screen.editor {
  white-space: pre-wrap;
  font-family: var(--mono);
  font-size: 0.95rem;
  line-height: 1.45;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow);
  min-height: 12rem;
}

#screen.editor {
  white-space: normal;
  font-family: "Donjon Sans", "Segoe UI", system-ui, sans-serif;
  font-size: 1.05rem;
  line-height: 1.55;
  padding: 1.2rem 1.35rem 1.15rem;
}

#screen.editor .record { margin: 0; }

#screen.editor .ln { margin: 0.04rem 0; }

#screen.editor .abilities,
#screen.editor .pairs {
  display: grid;
  row-gap: 0.08rem;
  margin: 0.2rem 0 0.35rem;
}

#screen.editor .abilities {
  grid-template-columns: 2.8rem minmax(2.7rem, max-content) max-content max-content max-content;
  column-gap: 1.25rem;
}

#screen.editor .pairs {
  grid-template-columns: max-content max-content;
  column-gap: 1.75rem;
}

#screen.editor .abilities > .ln,
#screen.editor .pairs > .ln {
  display: grid;
  grid-template-columns: subgrid;
  grid-column: 1 / -1;
  align-items: baseline;
  margin: 0;
  padding: 0.05rem 0.4rem;
}

#screen.editor .abilities .cell,
#screen.editor .pairs .cell {
  white-space: nowrap;
}

#screen.editor .abilities .cell.name,
#screen.editor .abilities .cell.score {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

#screen.editor .abilities .cell.score { text-align: right; }

#screen.editor .gap {
  display: inline-block;
  width: 0;
  overflow: hidden;
}

#screen.editor .spellgrid {
  display: grid;
  column-gap: 1.15rem;
  row-gap: 0.12rem;
  margin: 0.45rem 0 0.7rem;
  overflow-x: auto;
  align-items: start;
}

#screen.editor .spellgrid > .ln {
  display: grid;
  grid-template-columns: subgrid;
  grid-column: 1 / -1;
  align-items: baseline;
  margin: 0;
  padding: 0.04rem 0.35rem;
}

#screen.editor .spellgrid .cell { white-space: nowrap; }

#screen.editor .spellgrid > .ln:first-child {
  font-weight: 700;
  font-size: 0.82rem;
  letter-spacing: 0.04em;
}

#screen.editor .spellgrid > .ln:nth-child(2) .cell:first-child {
  color: var(--muted);
  font-weight: 600;
}

#screen.editor .ln-title {
  font-family: "Donjon Serif", Palatino, "Palatino Linotype", Georgia, serif;
  font-size: 1.45rem;
  line-height: 1.25;
  font-weight: 700;
  margin: 0 0 0.45rem;
}

#screen.editor .ln-section {
  margin: 0.95rem 0 0.2rem;
  font-weight: 600;
  font-size: 0.82rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--accent);
}

#screen.editor .ln-field .k,
#screen.editor .ln-title .k,
#screen.editor .ln-section .k {
  color: var(--muted);
  font-weight: 600;
}

#screen.editor .ln-title .k {
  font-family: "Donjon Sans", "Segoe UI", system-ui, sans-serif;
  font-size: 0.72em;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 600;
}

#screen.editor .ln-creature {
  margin: 0.28rem 0;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

#screen.editor .ln-text { margin: 0.16rem 0; }

#screen.editor .ln-gap { height: 0.55rem; }

#screen.title { white-space: normal; }

#screen.editor .block {
  white-space: normal;
  margin-top: 0.9rem;
  font-family: var(--sans);
}

#screen.editor .backup { white-space: normal; }

button.cmd {
  display: inline-block;
  width: auto;
  margin: 0.2rem 0.35rem 0.2rem 0;
  padding: 0.28rem 0.55rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg);
  font-family: var(--sans);
  font-size: 0.78rem;
  cursor: pointer;
  white-space: normal;
}

button.act {
  display: inline-flex;
  align-items: center;
  width: auto;
  margin: 0.35rem 0.45rem 0.35rem 0;
  border-radius: 999px;
  font-family: var(--sans);
  font-size: 0.92rem;
}

#lineform {
  display: flex;
  gap: 0.7rem;
  align-items: center;
  margin-top: 0.85rem;
  padding: 0.65rem 0.8rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

#lineform.off { display: none; }

#prompt {
  white-space: pre-wrap;
  color: var(--muted);
  font-size: 0.92rem;
}

#line {
  flex: 1;
  min-width: 8rem;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line-strong);
  padding: 0.2rem 0;
  font-family: "Donjon Sans", "Segoe UI", system-ui, sans-serif;
  caret-color: var(--accent);
}

#line:focus {
  outline: none;
  border-bottom: 2px solid var(--accent);
}

#hint {
  margin-top: 0.85rem;
  color: var(--hint);
  font-size: 0.95rem;
  max-width: 46rem;
}

#printactions { margin-top: 0.75rem; }
#printactions.off { display: none; }

#screen.editor .record { cursor: text; }

#screen.editor .ln-here {
  background: var(--accent-soft);
  border-radius: 6px;
  box-shadow: inset 3px 0 0 var(--accent);
}

#screen.editor .ln:hover {
  background: rgba(122, 49, 66, 0.06);
  border-radius: 6px;
}

#screen.editor .ln-here:hover {
  background: var(--accent-soft);
}

#screen.editor .caret {
  display: inline-block;
  width: 2px;
  height: 1.05em;
  margin: 0 -2px 0 0;
  background: var(--accent);
  vertical-align: text-bottom;
  border-radius: 1px;
  position: relative;
  z-index: 1;
}

.titlecard {
  max-width: 38rem;
  margin: 0.4rem auto;
  padding: 1.6rem 1.5rem 1.3rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  text-align: center;
}

.titlecard h2 {
  margin: 0.35rem 0 0;
  font-family: var(--serif);
  font-size: 2rem;
  font-weight: 600;
  line-height: 1.15;
}

.titlecard .vol {
  margin: 0.35rem 0 0;
  color: var(--muted);
}

.titlecard .ver {
  margin: 0.8rem 0 0;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.78rem;
  color: var(--accent);
}

.credits {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.7rem 1rem;
  margin: 1.1rem 0 0;
  text-align: left;
}

.credits div {
  padding-top: 0.45rem;
  border-top: 1px solid var(--line);
}

.credits dt {
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.credits dd { margin: 0.1rem 0 0; }

.titlecard .legal {
  margin: 1.1rem 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.titlecard .go {
  margin: 1rem 0 0;
  font-family: var(--serif);
}

.dos-only { display: none; }

.fieldlab {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin: 0 0 0.8rem;
  font-family: var(--serif);
  font-size: 1.05rem;
}

select, .adder input, #libsearch, #monsearch, #palette-q {
  font: inherit;
  color: var(--ink);
  background: #fffaf0;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 0.55rem 0.7rem;
  min-height: 2.75rem;
  color-scheme: light;
}

.names { grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr)); }

.letterrow {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin: 0 0 0.45rem;
}

.letterrow select { flex: 1; }

.sides {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1rem 1.25rem;
  align-items: start;
  margin: 0.9rem 0 0;
}

.sidehead {
  margin: 0 0 0.65rem;
  padding-bottom: 0.25rem;
  border-bottom: 1px solid var(--line);
  font-family: var(--serif);
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.side-col .letterrow { flex-wrap: wrap; }
.side-col .hoardcard:last-child { margin-bottom: 0; }

@media (max-width: 720px) {
  .brand h1 { font-size: 1.35rem; }
  #topbar { align-items: flex-start; flex-direction: column; }
  .credits { grid-template-columns: 1fr; }
  #screen.menu .block { grid-template-columns: 1fr; }
  .sides { grid-template-columns: minmax(0, 1fr); }
}

body[data-theme="light"] {
  --bg0: #c9b38a;
  --bg1: #efe2c8;
  --glow: rgba(255, 236, 196, 0.95);
  --page: #24170f;
  --page-dim: #3d2914;
  --hint: #3d2914;
  --gold: #6e3e0c;
  --shadow: 0 12px 28px rgba(80, 48, 16, 0.14);
  color-scheme: light;
  background-color: #e7d3b0;
  background-image: linear-gradient(180deg, #f4e6c8 0%, #dcc6a2 100%);
  color: #24170f;
}
body[data-theme="light"]::before {
  opacity: 0.22;
  mix-blend-mode: multiply;
  background: radial-gradient(ellipse at center, transparent 46%, rgba(70, 36, 12, 0.45) 100%);
}
html:has(body[data-theme="light"]) { background: #e7d3b0; }

body[data-theme="dark"] {
  color-scheme: dark;
}

body, #screen, button.mitem, #topbar, .hoardcard {
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

#screen.home .lead {
  font-family: var(--display);
  font-size: 2.15rem;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  text-align: center;
  margin: 0.35rem 0 0.85rem;
  color: #f0d78c;
  text-shadow: none;
}
#screen.home .lead::after {
  content: "";
  display: block;
  width: 9rem;
  height: 2px;
  margin: 0.7rem auto 0;
  background: linear-gradient(90deg, transparent, #f0d78c 20%, #9a332c 50%, #f0d78c 80%, transparent);
}

.entryname {
  display: block;
  overflow-wrap: anywhere;
  font-family: var(--serif);
  font-size: 1.05rem;
  font-weight: 600;
}

.hoardcard, .banner {
  background-color: #f7f0df;
  color: #24170f;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.8rem 0.95rem;
  margin: 0 0 0.75rem;
  box-shadow: var(--shadow);
  white-space: normal;
  font-family: var(--sans);
}

.banner {
  background: linear-gradient(90deg, #6e1814, #3a0e0c 70%);
  color: #fff6e6;
  border: 1px solid #f0d78c;
  font-family: var(--display);
  letter-spacing: 0.03em;
  text-align: center;
}
#screen.arena .lead {
  font-size: 2.3rem;
  letter-spacing: 0.18em;
  text-align: center;
  color: #f0d78c;
}
#screen.arena .fighter {
  border-color: #8d6840;
  box-shadow: 0 0 0 1px rgba(240, 215, 140, 0.25), 0 16px 32px rgba(0, 0, 0, 0.28);
}
#screen.editor,
#screen.prose {
  background-color: #f6edd9;
  background-image: linear-gradient(180deg, #fff8ea 0%, #f6edd9 7rem);
  color: #24170f;
}
#screen.editor {
  border: 1px solid #c4a46a;
  box-shadow: 0 0 0 1px rgba(154, 51, 44, 0.35), 0 28px 60px rgba(0, 0, 0, 0.55);
}
#screen.editor .record,
#screen.editor .ln { color: #24170f; }
#screen.editor .hoardcard {
  border-color: #b8893d;
  box-shadow: inset 0 0 0 1px rgba(255, 236, 190, 0.65);
}
.hoardtotal strong { color: #6e221c; font-size: 2.5rem; letter-spacing: 0.02em; }
#screen.editor .ln-title {
  font-family: var(--display);
  letter-spacing: 0.04em;
  color: #4a1814;
}

button.mitem.static { cursor: default; }
button.mitem.static:hover { background: var(--card); border-color: var(--line); }

.pips { display: flex; flex-wrap: wrap; gap: 4px; margin: 0.45rem 0; }
.pip {
  width: 1.35rem;
  height: 1.35rem;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: transparent;
  padding: 0;
  cursor: pointer;
}
.pip.on { background: var(--accent); border-color: var(--accent); }
button.act.on { background: var(--accent); color: #fff; border-color: var(--accent); }

#libsearch {
  font: inherit;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 0.45rem 0.6rem;
  width: 100%;
}

#notebox {
  position: fixed;
  inset: 0;
  background: rgba(12, 8, 6, 0.62);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 30;
}
#notebox.off { display: none; }
.notecard {
  max-width: 32rem;
  background: var(--card);
  color: var(--ink);
  border-radius: 16px;
  padding: 1.1rem 1.2rem;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.notecard h3 {
  margin: 0 0 0.4rem;
  font-family: var(--serif);
  font-weight: 600;
}

.dmap { width: 100%; height: 16rem; margin: 0 0 0.8rem; background: var(--card); border: 1px solid var(--line-strong); border-radius: 14px; }
.dmap line { stroke: var(--line-strong); stroke-width: 2; }
.dmap circle { fill: var(--card); stroke: var(--accent); stroke-width: 2; }
.dmap circle.mon { fill: var(--accent); }
.dmap circle.trap { fill: #c4a15a; stroke: #8a6a2f; }

#screen.editor .hoardcard { font-family: var(--sans); white-space: normal; }

span.act {
  display: inline-block;
  width: auto;
  margin: 0.7rem 0.5rem 0 0;
  border-radius: 8px;
  font-family: var(--sans);
  font-size: 0.85rem;
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--line);
  padding: 0.4rem 0.85rem;
  cursor: pointer;
  box-shadow: var(--shadow);
}
span.act:hover, span.act:focus-visible {
  border-color: var(--accent);
  background: var(--accent-soft);
}

#screen.editor,
#screen.prose,
.hoardcard,
.notecard,
button.mitem,
button.quick,
.adder,
#lineform,
.statboard,
.titlecard,
.palette-card,
.helpcard,
#toast {
  color: var(--ink);
}

.statboard {
  background: var(--card);
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  padding: 0.7rem 0.9rem;
}

.blurb {
  display: block;
  margin-top: 0.15rem;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 0.84rem;
  letter-spacing: 0;
  font-weight: 400;
}

.deck {
  margin: 0 auto 1rem;
  max-width: 40rem;
  text-align: center;
  color: #f0e2c8;
}
body[data-theme="light"] .deck,
body[data-theme="light"] #hint,
body[data-theme="light"] .fieldhelp,
body[data-theme="light"] .summaryline,
body[data-theme="light"] .empty-note,
body[data-theme="light"] .empty-side { color: #3d2914; }

.quickrow {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.7rem;
  margin: 0 0 1.15rem;
}

button.quick {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  text-align: left;
  min-height: 5.4rem;
  padding: 0.85rem 0.85rem;
  border-radius: 16px;
  border: 1px solid #e6c27a;
  background:
    radial-gradient(circle at 0 0, rgba(230, 194, 122, 0.35), transparent 55%),
    linear-gradient(180deg, #fffaf0, #f3e2c4);
  color: var(--ink);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.22);
  cursor: pointer;
}

button.quick .ico { color: var(--accent); width: 1.6rem; height: 1.6rem; margin-top: 0.15rem; }
button.quick strong {
  display: block;
  font-family: var(--display);
  font-size: 0.98rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}
button.quick small { display: block; margin-top: 0.2rem; color: var(--muted); font-size: 0.82rem; }
button.quick:hover, button.quick:focus-visible,
button.mitem:hover, button.mitem:focus-visible {
  border-color: #f0d78c;
  box-shadow: 0 0 0 1px rgba(240, 215, 140, 0.55), 0 0 22px rgba(176, 48, 32, 0.45), 0 14px 28px rgba(0, 0, 0, 0.4);
}
.tools button:hover, .tools button:focus-visible,
#dicebar button:hover, #dicebar button:focus-visible {
  box-shadow: 0 0 16px rgba(240, 215, 140, 0.45);
  border-color: #f0d78c;
}

.primary-go .mitem {
  justify-content: center;
  background: linear-gradient(180deg, #b2443a, #7d241f);
  color: #fff8ee;
  border-color: #5c1614;
  font-family: var(--display);
  letter-spacing: 0.06em;
  min-height: 3.4rem;
}
.primary-go .mitem:hover, .primary-go .mitem:focus-visible {
  background: linear-gradient(180deg, #c45448, #8e2c26);
  color: #fff8ee;
  border-color: #e6c27a;
}

.summaryline {
  margin: 0 0 0.75rem;
  color: var(--page);
  font-family: var(--display);
  letter-spacing: 0.02em;
}

.fieldhelp, .empty-note, .empty-side {
  margin: 0 0 0.85rem;
  color: var(--page-dim);
}

.advanced.off { display: none; }

ol.steps {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.7rem;
  list-style: none;
  padding: 0;
  margin: 0 0 0.9rem;
}
ol.steps li {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--page-dim);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
ol.steps li span {
  width: 1.45rem;
  height: 1.45rem;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid currentColor;
  font-family: var(--display);
}
ol.steps li.done span, ol.steps li.now span {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff8ee;
}
ol.steps li.now { color: var(--gold); }

#desknav {
  position: sticky;
  top: 0;
  z-index: 11;
  display: flex;
  gap: 0.2rem;
  overflow-x: auto;
  padding: 0.35rem 0.8rem;
  background: rgba(16, 10, 8, 0.92);
  border-bottom: 1px solid rgba(230, 194, 122, 0.45);
  backdrop-filter: blur(8px);
}
#desknav button {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.12rem;
  min-width: 4.7rem;
  min-height: 3.25rem;
  padding: 0.3rem 0.4rem;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: #f0e2c8;
  cursor: pointer;
  font-size: 0.68rem;
  letter-spacing: 0.04em;
}
#desknav button.on {
  background: rgba(246, 237, 217, 0.12);
  color: #f3d48a;
  box-shadow: inset 0 -2px 0 #e6c27a;
}
#desknav .ico { width: 1.2rem; height: 1.2rem; }

#dicebar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 12;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.5rem 0.75rem calc(0.5rem + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(32, 20, 14, 0.96), #100c0a);
  color: #f6edd9;
  border-top: 1px solid #e6c27a;
}
.dieface {
  width: 3.15rem;
  height: 3.15rem;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: linear-gradient(160deg, #fffaf0, #f0d7a8);
  color: #24170f;
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.35rem;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.35);
}
#dicebar { perspective: 700px; }
.dieface { transform-style: preserve-3d; }
.dieface.rolling { animation: tumble 0.78s cubic-bezier(.2, .7, .2, 1); }
.dieface.reveal { animation: reveal 0.38s ease; }
.dieface.crit {
  background: linear-gradient(160deg, #fff4c4, #e2b03a);
  color: #3a2208;
  box-shadow: 0 0 0 2px #f0d78c, 0 0 28px rgba(240, 200, 70, 0.95);
}
.dieface.fumble {
  background: linear-gradient(160deg, #f0b2aa, #7c1c18);
  color: #fff8f4;
  box-shadow: 0 0 0 2px #e07068, 0 0 28px rgba(180, 32, 28, 0.9);
}
#diecopy.crit { color: #f0d78c; }
#diecopy.fumble { color: #ffb4ac; }
@keyframes tumble {
  0% { transform: rotateX(0deg) rotateZ(0deg) scale(1); }
  25% { transform: rotateX(200deg) rotateZ(50deg) scale(1.16); }
  50% { transform: rotateX(420deg) rotateZ(-36deg) scale(0.9); }
  75% { transform: rotateX(640deg) rotateZ(24deg) scale(1.2); }
  100% { transform: rotateX(720deg) rotateZ(0deg) scale(1); }
}
@keyframes reveal {
  0% { transform: scale(0.72); }
  60% { transform: scale(1.18); }
  100% { transform: scale(1); }
}
.diecopy { display: flex; flex-direction: column; min-width: 7rem; }
.diecopy strong { font-family: var(--display); font-size: 0.95rem; color: #f3d48a; }
.diecopy span, #diehistory { color: #e4d0b0; font-size: 0.82rem; }
#diehistory { display: flex; gap: 0.45rem; flex-wrap: wrap; }
.dicebtns { display: flex; gap: 0.3rem; flex-wrap: wrap; }
.dicebtns button, #diceform button {
  min-width: 2.75rem;
  min-height: 2.75rem;
  border-radius: 10px;
  border: 1px solid #e6c27a;
  background: #f7f0df;
  color: #24170f;
  font-family: var(--display);
  cursor: pointer;
}
#diceform { display: flex; gap: 0.35rem; margin-left: auto; }
#diceexpr {
  width: 7rem;
  min-height: 2.75rem;
  border-radius: 10px;
  border: 1px solid #e6c27a;
  background: #2a1c16;
  color: #f6edd9;
  color-scheme: dark;
  padding: 0.35rem 0.55rem;
}

#palette, #helpbox {
  position: fixed;
  inset: 0;
  z-index: 24;
  background: rgba(12, 8, 6, 0.62);
  display: flex;
  justify-content: center;
  padding: 10vh 1rem 1rem;
}
#palette.off, #helpbox.off, #toast.off { display: none; }
.palette-card, .helpcard {
  width: min(38rem, 100%);
  max-height: min(32rem, 74vh);
  overflow: auto;
  background: var(--card);
  color: var(--ink);
  border-radius: 18px;
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow);
}
#palette-q {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 18px 18px 0 0;
  background: transparent;
  font-size: 1.15rem;
  padding: 1rem 1.1rem;
}
button.hit {
  display: flex;
  width: 100%;
  gap: 0.75rem;
  align-items: baseline;
  text-align: left;
  padding: 0.7rem 1rem;
  min-height: 2.75rem;
  border: 0;
  background: transparent;
  cursor: pointer;
  color: inherit;
}
button.hit.on, button.hit:hover { background: var(--accent-soft); }
.kind {
  flex: none;
  width: 4.6rem;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  font-family: var(--display);
}
.helpcard { padding: 1.1rem 1.2rem 1.2rem; }
.helpcard h2 { font-family: var(--display); margin: 0 0 0.4rem; }
.helpcard ul { margin: 0.4rem 0 0.8rem; padding-left: 1.1rem; }

#toast {
  position: fixed;
  left: 50%;
  bottom: 5.5rem;
  transform: translateX(-50%);
  z-index: 18;
  display: flex;
  gap: 0.55rem;
  align-items: center;
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 0.35rem 0.45rem 0.35rem 0.95rem;
  box-shadow: var(--shadow);
}
#toast button { min-height: 2.4rem; border-radius: 999px; border: 1px solid var(--line-strong); background: #fffaf0; cursor: pointer; padding: 0.2rem 0.75rem; }

.filters { display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 0 0 0.8rem; }
.filters button.on { background: var(--accent); color: #fff8ee; border-color: var(--accent); }

.hpbox {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0.35rem 0;
}
button.step {
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  background: #fffaf0;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}
.hpnum {
  font-family: var(--display);
  font-size: 1.8rem;
  min-width: 4.2rem;
  text-align: center;
}
.hpmax { font-size: 0.9rem; color: var(--muted); }
.hoardtotal { font-size: 1.15rem; }
.hoardtotal strong { font-family: var(--display); font-size: 1.8rem; }
.adder {
  margin-top: 0.8rem;
  padding: 0.8rem 0.9rem;
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: 14px;
}
.adder-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr 0.5fr 0.5fr;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}
.adder label, .fieldlab { color: inherit; }
.adder label { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.82rem; }
.fightlog { margin: 0.8rem 0 0; padding-left: 1.1rem; color: var(--page); }
.sidehead { font-family: var(--display); color: #f0d78c; letter-spacing: 0.14em; text-shadow: none; }
body[data-theme="light"] .sidehead { color: #6e221c; }
button.act.danger { background: #9a332c; color: #fff8ee; border-color: #9a332c; }

#screen.arrive { animation: rise 0.32s ease; }
@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

@media (max-width: 860px) {
  .quickrow { grid-template-columns: 1fr 1fr; }
  .adder-grid { grid-template-columns: 1fr 1fr; }
  .brand h1 { font-size: 1.35rem; }
  #screen.home .lead { font-size: 1.7rem; }
  #dicebar { flex-wrap: nowrap; overflow-x: auto; gap: 0.4rem; }
  #diedetail, #diehistory { display: none; }
  .diecopy { min-width: 3.2rem; }
  .dieface { width: 2.6rem; height: 2.6rem; font-size: 1.15rem; }
  .dicebtns { flex-wrap: nowrap; }
  #diceform { width: auto; margin-left: 0; flex: none; }
  #diceexpr { width: 5.2rem; }
  body { padding-bottom: 4.6rem; }
}
@media (max-width: 520px) {
  .quickrow { grid-template-columns: 1fr; }
  #crt { padding-left: 0.85rem; padding-right: 0.85rem; }
  #topbar { padding-left: 0.85rem; padding-right: 0.85rem; }
}

@media (prefers-reduced-motion: reduce) {
  #screen.arrive, .dieface.rolling, .dieface.reveal { animation: none; }
  button.quick:hover { transform: none; }
  body, #screen, button.mitem, #topbar, .hoardcard { transition: none; }
}
