@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;600;700;900&family=Cinzel+Decorative:wght@700&family=IM+Fell+English:ital@0;1&display=swap');

/* ============================================================
   CUSTOM PROPERTIES
   ============================================================ */
:root {
  --bg:           #09080b;
  --bg-surface:   #0e0b09;
  --bg-card:      #181410;
  --bg-card-hi:   #201a13;
  --border:       #342619;
  --border-gold:  #644c22;
  --gold-deep:    #5c4418;
  --gold:         #b88a0a;
  --gold-mid:     #d4a022;
  --gold-bright:  #f0c042;
  --red-deep:     #3a0e0e;
  --red:          #801818;
  --red-bright:   #c03030;
  --text:         #dece9a;
  --text-dim:     #a89058;
  --text-muted:   #7c6030;
  --white:        #f0e8d0;
  --shadow:       rgba(0,0,0,0.85);

  /* D&D Rarity */
  --r-mundane:    #888888;
  --r-common:     #bbbbbb;
  --r-uncommon:   #1ec800;
  --r-rare:       #2070ff;
  --r-very_rare:  #a855f7;
  --r-legendary:  #ff8c00;
  --r-artifact:   #e8c040;
}

/* ============================================================
   RESET & BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  background-color: var(--bg);
  color: var(--text);
  font-family: 'IM Fell English', Georgia, serif;
  font-size: 17px;
  line-height: 1.7;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ============================================================
   ATMOSPHERIC BACKGROUND
   ============================================================ */
.bg-effects {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.bg-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(130px);
}

.bg-orb--red {
  width: 90vw;
  height: 55vh;
  background: radial-gradient(circle, rgba(100,18,18,0.7) 0%, transparent 65%);
  top: -25%;
  left: 50%;
  transform: translateX(-50%);
  opacity: 0.18;
  animation: orb-breathe 18s ease-in-out infinite alternate;
}

.bg-orb--gold {
  width: 55vw;
  height: 45vh;
  background: radial-gradient(circle, rgba(100,80,20,0.6) 0%, transparent 70%);
  bottom: -15%;
  right: -5%;
  opacity: 0.10;
  animation: orb-breathe-gold 24s ease-in-out infinite alternate-reverse;
}

@keyframes orb-breathe {
  from { transform: translateX(-50%) scale(1); }
  to   { transform: translateX(-50%) scale(1.12) translateY(3%); }
}

@keyframes orb-breathe-gold {
  from { transform: scale(1); }
  to   { transform: scale(1.2); }
}

/* Grain overlay */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 0;
  opacity: 0.5;
}

.site-header,
.site-main {
  position: relative;
  z-index: 1;
}

/* ============================================================
   LAYOUT
   ============================================================ */
.container {
  max-width: 680px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.site-main { padding: 2.5rem 0 6rem; }

/* ============================================================
   FOOTER
   ============================================================ */
.site-footer {
  position: relative;
  z-index: 1;
  border-top: 1px solid var(--border);
  padding: 1.25rem 0;
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-muted);
  letter-spacing: 0.03em;
}

.site-footer a {
  color: var(--gold);
  text-decoration: none;
  transition: color 0.2s;
}

.site-footer a:hover {
  color: var(--gold-bright);
}

/* ============================================================
   HEADER
   ============================================================ */
.site-header {
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  background: linear-gradient(180deg, rgba(9,8,11,0.97) 0%, rgba(9,8,11,0.88) 100%);
  backdrop-filter: blur(12px);
}

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.site-logo {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  color: var(--gold-bright);
  font-family: 'Cinzel Decorative', serif;
  font-size: 1.05rem;
  letter-spacing: 0.04em;
  transition: color 0.2s;
}

.site-logo:hover { color: var(--white); }

.logo-symbol {
  font-size: 1.2rem;
  animation: logo-glow 3s ease-in-out infinite;
}

@keyframes logo-glow {
  0%, 100% { filter: drop-shadow(0 0 6px rgba(240,192,64,0.45)); }
  50%       { filter: drop-shadow(0 0 14px rgba(240,192,64,0.9)); }
}

/* ============================================================
   SITE NAV
   ============================================================ */
.site-nav {
  display: flex;
  gap: 0.25rem;
  align-items: center;
}

.site-nav__link {
  font-family: 'Cinzel', serif;
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.28rem 0.75rem;
  border: 1px solid transparent;
  transition: all 0.2s;
}

.site-nav__link:hover {
  color: var(--gold-bright);
  border-color: var(--border-gold);
  background: rgba(92,68,24,0.2);
}

/* ============================================================
   LANGUAGE SWITCH
   ============================================================ */
.lang-switch {
  display: flex;
  gap: 0.4rem;
  align-items: center;
}

.lang-switch a {
  font-family: 'Cinzel', serif;
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.28rem 0.65rem;
  border: 1px solid var(--border);
  transition: all 0.2s;
}

.lang-switch a:hover,
.lang-switch a.active {
  color: var(--gold-bright);
  border-color: var(--border-gold);
  background: rgba(92,68,24,0.2);
}

.github-link {
  display: flex;
  align-items: center;
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.28rem;
  border: 1px solid transparent;
  transition: all 0.2s;
  margin-left: 0.5rem;
}

.github-link:hover {
  color: var(--gold-bright);
  border-color: var(--border-gold);
  background: rgba(92,68,24,0.2);
}

/* ============================================================
   WIZARD PROGRESS INDICATOR
   ============================================================ */
.wizard-progress {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 2.5rem;
}

.step-node {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
}

.step-circle {
  width: 2.3rem;
  height: 2.3rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Cinzel', serif;
  font-size: 0.8rem;
  font-weight: 700;
  border: 1px solid var(--border);
  color: var(--text-muted);
  background: var(--bg-card);
  transition: all 0.3s;
}

.step-node.active .step-circle {
  border-color: var(--gold);
  color: var(--gold-bright);
  background: var(--bg-card-hi);
  box-shadow: 0 0 18px rgba(184,138,10,0.45), inset 0 0 10px rgba(184,138,10,0.1);
}

.step-node.done .step-circle {
  border-color: var(--gold-deep);
  color: var(--gold);
  background: var(--bg-card);
}

.step-label {
  font-family: 'Cinzel', serif;
  font-size: 0.58rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.step-node.active .step-label { color: var(--text-dim); }

.step-connector {
  width: 4.5rem;
  height: 1px;
  background: var(--border);
  margin: 0 0.25rem;
  align-self: flex-start;
  margin-top: 1.15rem;
}

.step-connector.done { background: var(--gold-deep); }

/* ============================================================
   PAGE TITLE
   ============================================================ */
h1.page-title,
.page-title {
  font-family: 'Cinzel', serif;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.07em;
  text-align: center;
  margin-top: 0;
  margin-bottom: 2rem;
}

.page-title .title-ornament {
  display: block;
  font-family: 'Cinzel Decorative', serif;
  font-size: 0.65rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 0.4rem;
}

/* ============================================================
   CARD
   ============================================================ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-top: 1px solid var(--border-gold);
  padding: 1.75rem;
  position: relative;
  margin-bottom: 1.25rem;
}

.card::before,
.card::after {
  content: '✦';
  position: absolute;
  font-size: 0.55rem;
  color: var(--gold-deep);
  line-height: 1;
}

.card::before { top: 0.5rem; left: 0.7rem; }
.card::after  { top: 0.5rem; right: 0.7rem; }

/* ============================================================
   FIELD LABELS
   ============================================================ */
.field-label {
  display: block;
  font-family: 'Cinzel', serif;
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 0.85rem;
}

.field-hint {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-style: italic;
  margin-top: 0.45rem;
}

/* ============================================================
   CR PRESET BUTTONS
   ============================================================ */
.cr-presets {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.7rem;
  margin-bottom: 1.5rem;
}

.cr-preset {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 0.85rem 0.5rem;
  text-align: center;
  cursor: pointer;
  font-family: 'Cinzel', serif;
  transition: all 0.2s;
  position: relative;
}

.cr-preset:hover {
  border-color: var(--border-gold);
  color: var(--text);
  background: var(--bg-card);
}

.cr-preset.active {
  border-color: var(--gold);
  color: var(--gold-bright);
  background: var(--bg-card-hi);
  box-shadow: 0 0 22px rgba(184,138,10,0.22), inset 0 0 18px rgba(184,138,10,0.07);
}

.cr-preset-value {
  font-size: 1.1rem;
  font-weight: 900;
  display: block;
  margin-bottom: 0.2rem;
}

.cr-preset-sublabel {
  font-size: 0.58rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-muted);
  display: block;
}

.cr-preset.active .cr-preset-sublabel { color: var(--gold-deep); }

/* ============================================================
   CR RANGE INPUTS
   ============================================================ */
.cr-range-inputs {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 0.75rem;
}

.input-sublabel {
  display: block;
  font-family: 'Cinzel', serif;
  font-size: 0.6rem;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
  text-transform: uppercase;
}

.cr-separator {
  color: var(--text-muted);
  font-family: 'Cinzel', serif;
  font-size: 0.8rem;
  text-align: center;
}

/* ============================================================
   LOOT TYPE TOGGLE
   ============================================================ */
.loot-type-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--border);
}

.loot-type-toggle input[type="radio"] { display: none; }

.loot-type-label {
  padding: 0.85rem 1rem;
  text-align: center;
  cursor: pointer;
  font-family: 'Cinzel', serif;
  font-size: 0.76rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--bg);
  transition: all 0.2s;
  display: block;
  border-right: 1px solid var(--border);
  user-select: none;
}

.loot-type-label:last-of-type { border-right: none; }

.loot-type-toggle input:checked + .loot-type-label {
  color: var(--gold-bright);
  background: var(--bg-card-hi);
  box-shadow: inset 0 0 20px rgba(184,138,10,0.1);
}

/* ============================================================
   NUMBER INPUTS
   ============================================================ */
input[type="number"] {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.6rem 0.85rem;
  font-family: 'Cinzel', serif;
  font-size: 0.95rem;
  width: 100%;
  outline: none;
  transition: border-color 0.2s;
  -moz-appearance: textfield;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; }

input[type="number"]:focus {
  border-color: var(--border-gold);
  box-shadow: 0 0 0 2px rgba(100,76,32,0.25);
}

/* ============================================================
   ITEM COUNT SLIDER
   ============================================================ */
.count-wrapper {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.count-display {
  font-family: 'Cinzel Decorative', serif;
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--gold-bright);
  min-width: 2.8rem;
  text-align: center;
  text-shadow: 0 0 22px rgba(240,192,64,0.55);
  line-height: 1;
}

input[type="range"] {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: var(--gold);
  border: 2px solid var(--gold-bright);
  box-shadow: 0 0 10px rgba(184,138,10,0.65);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.25);
  box-shadow: 0 0 18px rgba(240,192,64,0.85);
}

/* ============================================================
   ITEM TYPE CHECKBOXES
   ============================================================ */
.type-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 0.45rem;
}

.type-item { position: relative; }

.type-item input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.type-item label {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.42rem 0.65rem;
  border: 1px solid var(--border);
  background: var(--bg);
  cursor: pointer;
  font-family: 'Cinzel', serif;
  font-size: 0.66rem;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  transition: all 0.15s;
  user-select: none;
}

.type-item label::before {
  content: '◻';
  font-size: 0.72rem;
  color: var(--text-muted);
  flex-shrink: 0;
  transition: all 0.15s;
}

.type-item input:checked + label {
  border-color: var(--border-gold);
  background: var(--bg-card-hi);
  color: var(--text);
}

.type-item input:checked + label::before {
  content: '◼';
  color: var(--gold);
}

.type-item label:hover {
  border-color: var(--border-gold);
  color: var(--text-dim);
}

.type-actions {
  display: flex;
  gap: 1rem;
  margin-bottom: 0.85rem;
}

.type-select-btn {
  font-family: 'Cinzel', serif;
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color 0.15s;
}

.type-select-btn:hover { color: var(--gold); }

/* ── Source chip-toggles ──────────────────────────────────── */
.source-chip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.source-chip { position: relative; }

.source-chip input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.source-chip label {
  display: inline-block;
  padding: 0.32rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--bg);
  cursor: pointer;
  font-family: 'Cinzel', serif;
  font-size: 0.65rem;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  transition: all 0.15s;
  user-select: none;
}

.source-chip input:checked + label {
  border-color: var(--border-gold);
  background: var(--bg-card-hi);
  color: var(--text);
}

.source-chip label:hover {
  border-color: var(--border-gold);
  color: var(--text-dim);
}

/* ============================================================
   ORNAMENTAL DIVIDER
   ============================================================ */
.ornament-divider {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 1.75rem 0;
  color: var(--text-muted);
}

.ornament-divider::before,
.ornament-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border), transparent);
}

.ornament-divider span {
  font-size: 0.68rem;
  letter-spacing: 0.3em;
  font-family: 'Cinzel', serif;
  white-space: nowrap;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  font-family: 'Cinzel', serif;
  font-size: 0.78rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  border: none;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.2s;
  padding: 0.75rem 2rem;
  position: relative;
  overflow: hidden;
}

.btn-primary {
  background: linear-gradient(135deg, var(--gold-deep) 0%, var(--gold) 50%, var(--gold-deep) 100%);
  color: #0e0a04;
  font-weight: 700;
  box-shadow: 0 0 20px rgba(184,138,10,0.28), inset 0 1px 0 rgba(255,255,255,0.08);
}

.btn-primary:hover {
  box-shadow: 0 0 36px rgba(240,192,64,0.5), inset 0 1px 0 rgba(255,255,255,0.12);
  transform: translateY(-1px);
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold-bright) 50%, var(--gold) 100%);
}

.btn-primary::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.08), transparent);
  transform: translateX(-120%);
  transition: transform 0.45s;
}

.btn-primary:hover::after { transform: translateX(120%); }

.btn-ghost {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
  padding: 0.7rem 1.5rem;
}

.btn-ghost:hover {
  color: var(--text);
  border-color: var(--border-gold);
  background: var(--bg-card);
}

.btn-roll {
  background: linear-gradient(135deg, var(--red-deep) 0%, var(--red) 50%, var(--red-deep) 100%);
  color: var(--white);
  font-size: 0.88rem;
  font-weight: 900;
  letter-spacing: 0.22em;
  padding: 0.9rem 2.5rem;
  box-shadow: 0 0 22px rgba(128,24,24,0.4);
}

.btn-roll:hover {
  box-shadow: 0 0 42px rgba(192,48,48,0.65);
  transform: translateY(-2px);
}

.btn-roll .dice-icon {
  font-size: 1.05rem;
  animation: dice-idle 5s ease-in-out infinite;
}

.btn-roll:hover .dice-icon { animation: dice-spin 0.5s ease-in-out; }

@keyframes dice-idle {
  0%, 100% { transform: rotate(0deg); }
  50%       { transform: rotate(6deg) scale(1.05); }
}

@keyframes dice-spin {
  0%   { transform: rotate(0deg) scale(1); }
  50%  { transform: rotate(180deg) scale(1.35); }
  100% { transform: rotate(360deg) scale(1); }
}

.btn-actions {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

/* ============================================================
   RESULT HEADER
   ============================================================ */
.result-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.75rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.result-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-family: 'Cinzel', serif;
  letter-spacing: 0.1em;
}

/* ============================================================
   LOOT ITEM CARDS
   ============================================================ */
.loot-list {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.loot-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 1.1rem 1.3rem 1.1rem 1.55rem;
  position: relative;
  animation: item-reveal 0.4s ease-out both;
}

.loot-item:nth-child(1)  { animation-delay: 0.04s; }
.loot-item:nth-child(2)  { animation-delay: 0.09s; }
.loot-item:nth-child(3)  { animation-delay: 0.14s; }
.loot-item:nth-child(4)  { animation-delay: 0.19s; }
.loot-item:nth-child(5)  { animation-delay: 0.24s; }
.loot-item:nth-child(6)  { animation-delay: 0.29s; }
.loot-item:nth-child(7)  { animation-delay: 0.34s; }
.loot-item:nth-child(8)  { animation-delay: 0.39s; }
.loot-item:nth-child(9)  { animation-delay: 0.44s; }
.loot-item:nth-child(10) { animation-delay: 0.49s; }
.loot-item:nth-child(11) { animation-delay: 0.54s; }
.loot-item:nth-child(12) { animation-delay: 0.59s; }

@keyframes item-reveal {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.loot-item::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
}

.loot-item[data-rarity="mundane"]::before   { background: var(--r-mundane); }
.loot-item[data-rarity="common"]::before    { background: var(--r-common); }
.loot-item[data-rarity="uncommon"]::before  { background: var(--r-uncommon);  box-shadow: 0 0 8px  rgba(30,200,0,0.5); }
.loot-item[data-rarity="rare"]::before      { background: var(--r-rare);      box-shadow: 0 0 10px rgba(32,112,255,0.5); }
.loot-item[data-rarity="very_rare"]::before { background: var(--r-very_rare); box-shadow: 0 0 12px rgba(168,85,247,0.55); }
.loot-item[data-rarity="legendary"]::before { background: var(--r-legendary); box-shadow: 0 0 14px rgba(255,140,0,0.7); }
.loot-item[data-rarity="artifact"]::before  { background: var(--r-artifact);  box-shadow: 0 0 18px rgba(232,192,64,0.75); }

.loot-item[data-rarity="legendary"] {
  box-shadow: inset 2px 0 30px rgba(255,140,0,0.04), 0 0 0 1px rgba(255,140,0,0.08);
}
.loot-item[data-rarity="artifact"] {
  box-shadow: inset 2px 0 30px rgba(232,192,64,0.07), 0 0 0 1px rgba(232,192,64,0.14);
}

.item-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 0.45rem;
}

.item-name {
  font-family: 'Cinzel', serif;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--white);
  letter-spacing: 0.03em;
  line-height: 1.3;
  text-decoration: none;
}
a.item-name:hover {
  color: var(--gold-bright);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.item-rarity {
  font-family: 'Cinzel', serif;
  font-size: 0.58rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  white-space: nowrap;
  padding: 0.18rem 0.5rem;
  border: 1px solid;
  flex-shrink: 0;
}

.item-source {
  font-family: 'Cinzel', serif;
  font-size: 0.6rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--border-gold);
  flex-shrink: 0;
  align-self: center;
  cursor: default;
}

.item-rarity[data-rarity="mundane"]   { color: var(--r-mundane);  border-color: rgba(136,136,136,0.35); }
.item-rarity[data-rarity="common"]    { color: var(--r-common);   border-color: rgba(187,187,187,0.35); }
.item-rarity[data-rarity="uncommon"]  { color: var(--r-uncommon); border-color: rgba(30,200,0,0.4); }
.item-rarity[data-rarity="rare"]      { color: var(--r-rare);     border-color: rgba(32,112,255,0.4); }
.item-rarity[data-rarity="very_rare"] { color: var(--r-very_rare);border-color: rgba(168,85,247,0.45); }
.item-rarity[data-rarity="legendary"] { color: var(--r-legendary);border-color: rgba(255,140,0,0.5); }
.item-rarity[data-rarity="artifact"]  { color: var(--r-artifact); border-color: rgba(232,192,64,0.55); }

.item-desc {
  font-size: 0.87rem;
  color: var(--text-dim);
  line-height: 1.55;
}

.item-flavor {
  font-size: 0.86rem;
  font-style: italic;
  color: var(--text-muted);
  margin-top: 0.4rem;
  line-height: 1.5;
}

.item-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.65rem;
}

.item-tag {
  font-family: 'Cinzel', serif;
  font-size: 0.54rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 0.12rem 0.4rem;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.item-tag.attunement { border-color: var(--gold-deep);          color: var(--gold-deep); }
.item-tag.cursed     { border-color: rgba(128,24,24,0.6);       color: var(--red-bright); }
.item-tag.consumable { border-color: rgba(40,80,140,0.5);       color: #6688cc; }

/* ============================================================
   GOLD BOX
   ============================================================ */
.gold-box {
  border: 1px solid var(--border-gold);
  border-top: 2px solid var(--gold);
  background: linear-gradient(135deg, var(--bg-card) 0%, rgba(92,68,24,0.15) 100%);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.75rem;
  position: relative;
  animation: item-reveal 0.3s ease-out both;
}

.gold-box::before,
.gold-box::after {
  content: '✦';
  position: absolute;
  font-size: 0.55rem;
  color: var(--gold);
  line-height: 1;
}

.gold-box::before { top: 0.5rem; left: 0.7rem; }
.gold-box::after  { top: 0.5rem; right: 0.7rem; }

.gold-box__label {
  font-family: 'Cinzel', serif;
  font-size: 0.68rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 1rem;
}

.gold-box__coins {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}

.coin {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  padding: 0.6rem 1rem;
  border: 1px solid;
  min-width: 4rem;
  text-align: center;
}

.coin__value {
  font-family: 'Cinzel Decorative', serif;
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1;
}

.coin__label {
  font-family: 'Cinzel', serif;
  font-size: 0.6rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.coin--pp { border-color: rgba(192,192,230,0.4); color: #c8c8f0; }
.coin--pp .coin__value { text-shadow: 0 0 12px rgba(200,200,240,0.5); }

.coin--gp { border-color: rgba(232,192,64,0.45); color: var(--gold-bright); }
.coin--gp .coin__value { text-shadow: 0 0 14px rgba(240,192,64,0.6); }

.coin--ep { border-color: rgba(180,200,160,0.4);  color: #a8c890; }
.coin--sp { border-color: rgba(180,180,180,0.35); color: #b8b8b8; }
.coin--cp { border-color: rgba(180,100,50,0.35);  color: #c8845a; }

.gold-box__total {
  font-family: 'Cinzel', serif;
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  font-style: italic;
}

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
  text-align: center;
  padding: 3.5rem 1.5rem;
  color: var(--text-muted);
}

.empty-icon {
  font-size: 2.5rem;
  display: block;
  margin-bottom: 1rem;
  opacity: 0.35;
}

.empty-state p { font-style: italic; font-size: 0.95rem; }

/* ============================================================
   SCROLLBAR
   ============================================================ */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border-gold); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gold); }

/* ============================================================
   SHARE LINK
   ============================================================ */
.print-share-url {
  display: none;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
  font-family: 'Cinzel', serif;
  word-break: break-all;
}

/* ============================================================
   MERCHANT TABLE
   ============================================================ */
.inventory-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1.5rem;
}

.inventory-table th {
  font-family: 'Cinzel', serif;
  font-size: 0.65rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold);
  border-bottom: 1px solid var(--border-gold);
  padding: 0.5rem 0.75rem;
  text-align: left;
}

.inventory-table td {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
  color: var(--text);
  vertical-align: top;
}

.inventory-table tr:hover td { background: var(--bg-card-hi); }

.inventory-table .col-price {
  font-family: 'Cinzel', serif;
  font-size: 0.82rem;
  color: var(--gold-bright);
  white-space: nowrap;
}

.inventory-table .col-price--base {
  color: var(--text-muted);
  text-decoration: line-through;
}

.merchant-type-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  border: 1px solid var(--border);
  gap: 0;
}

.merchant-type-grid input[type="radio"] { display: none; }

.merchant-type-label {
  padding: 0.85rem 0.5rem;
  text-align: center;
  cursor: pointer;
  font-family: 'Cinzel', serif;
  font-size: 0.68rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--bg);
  transition: all 0.2s;
  display: block;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  user-select: none;
  overflow-wrap: break-word;
  word-break: break-word;
  hyphens: auto;
}

.merchant-type-label:last-of-type { border-right: none; }

.merchant-type-grid input:checked + .merchant-type-label {
  color: var(--gold-bright);
  background: var(--bg-card-hi);
  box-shadow: inset 0 0 20px rgba(184,138,10,0.1);
}

.merchant-type-label:hover {
  color: var(--text);
  background: var(--bg-card);
}

.merchant-type-icon {
  display: block;
  font-size: 1.3rem;
  margin-bottom: 0.35rem;
}

.town-size-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border: 1px solid var(--border);
}

.town-size-grid input[type="radio"] { display: none; }

.town-size-label {
  padding: 0.85rem 1rem;
  text-align: center;
  cursor: pointer;
  font-family: 'Cinzel', serif;
  font-size: 0.76rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--bg);
  transition: all 0.2s;
  display: block;
  border-right: 1px solid var(--border);
  user-select: none;
}

.town-size-label:last-of-type { border-right: none; }

.town-size-grid input:checked + .town-size-label {
  color: var(--gold-bright);
  background: var(--bg-card-hi);
  box-shadow: inset 0 0 20px rgba(184,138,10,0.1);
}

.town-size-sublabel {
  display: block;
  font-size: 0.58rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
  letter-spacing: 0.08em;
}

/* ============================================================
   LOOT FILTER
   ============================================================ */
.loot-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
  margin-bottom: 1rem;
}

.filter-input {
  flex: 1 1 180px;
  padding: 0.45rem 0.75rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 0.82rem;
  outline: none;
}

.filter-input:focus { border-color: var(--gold); }

.filter-rarities {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  border: none;
  padding: 0;
  margin: 0;
}

.filter-rarity-btn {
  padding: 0.3rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.72rem;
  cursor: pointer;
  transition: all 0.15s;
}

.filter-rarity-btn:hover  { border-color: var(--gold); color: var(--gold); }
.filter-rarity-btn.active { background: var(--gold); border-color: var(--gold); color: #09080b; }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* ============================================================
   PRINT
   ============================================================ */
@media print {
  @page { margin: 1.5cm; }

  .bg-effects,
  .site-header,
  .site-footer,
  .wizard-progress,
  .btn-actions,
  .btn,
  .loot-filter,
  .page-title { display: none !important; }

  .result-header { margin-bottom: 0.75rem; }
  .result-meta   { color: #555; font-size: 0.85rem; }

  .print-share-url {
    display: block !important;
    color: #444;
    font-size: 0.78rem;
    margin-top: 1rem;
    word-break: break-all;
  }

  body {
    background: #fff;
    color: #111;
    font-family: Georgia, serif;
  }

  .loot-list { display: block; }

  .loot-item {
    border: 1px solid #ccc;
    background: #fff;
    box-shadow: none;
    break-inside: avoid;
    margin-bottom: 0.6rem;
    padding: 0.6rem 0.75rem;
  }

  .item-header { display: flex; gap: 0.5rem; align-items: baseline; flex-wrap: wrap; }
  .item-name   { color: #111; font-weight: bold; text-decoration: none; }
  .item-rarity { color: #555; font-size: 0.8rem; }
  .item-source { color: #888; font-size: 0.75rem; }
  .item-tag    { border: 1px solid #999; color: #333; background: none; font-size: 0.72rem; }
  .item-desc,
  .item-flavor { color: #333; margin: 0.2rem 0 0; }
  .item-tags   { margin-top: 0.3rem; }

  .gold-box {
    border: 1px solid #ccc;
    background: #fff;
    color: #111;
    box-shadow: none;
    break-inside: avoid;
    margin-bottom: 0.75rem;
  }
  .gold-box__label,
  .gold-box__total { color: #555; }
  .gold-box__coins { flex-wrap: wrap; gap: 0.4rem; }
  .coin            { background: #eee; color: #111; box-shadow: none; }

  /* Merchant table */
  .inventory-table {
    border-collapse: collapse;
    width: 100%;
    font-size: 0.82rem;
  }
  .inventory-table th,
  .inventory-table td {
    border: 1px solid #ccc;
    padding: 0.35rem 0.5rem;
    color: #111;
  }
  .inventory-table thead { background: #f0f0f0; }
  .inventory-table tr    { break-inside: avoid; }
}
