:root {
  --font-display: 'Cinzel', 'Palatino Linotype', 'Book Antiqua', Georgia, serif;
  --font-body: 'Alegreya', 'Iowan Old Style', Georgia, serif;
  --bg: #0a0c11;
  --bg-deep: #07090d;
  --bg-soft: #10131b;
  --panel: #151925;
  --panel-2: #1a1f2c;
  --panel-3: #202637;
  --ink: #ece2cd;
  --ink-soft: #d3c6ac;
  --ink-muted: #9b927f;
  --ink-faint: #6e675b;
  --gold: #c9a45c;
  --gold-bright: #e8cb86;
  --gold-dim: #8e713c;
  --line: rgba(201, 164, 92, 0.22);
  --line-soft: rgba(201, 164, 92, 0.11);
  --danger: #b9564f;
  --danger-bright: #e57f76;
  --heal: #79a783;
  --magic: #9485cf;
  --cold: #7eb3d3;
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.45);
  --radius: 14px;
  --radius-sm: 9px;
  --font-scale: 1;
  --topbar-height: 68px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  font-size: calc(16px * var(--font-scale, 1));
  scroll-behavior: smooth;
  color-scheme: dark;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.62;
  color: var(--ink);
  background:
    radial-gradient(ellipse 70% 55% at 50% -15%, rgba(201, 164, 92, 0.12), transparent 60%),
    radial-gradient(ellipse 45% 40% at 100% 10%, rgba(90, 76, 130, 0.12), transparent 70%),
    radial-gradient(ellipse 60% 50% at 0% 80%, rgba(54, 91, 85, 0.08), transparent 70%),
    linear-gradient(180deg, #0b0d13 0%, #090b10 55%, #07090d 100%);
  background-attachment: fixed;
  overflow-x: hidden;
}

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

::selection {
  background: rgba(201, 164, 92, 0.35);
  color: #fff8e8;
}

::-webkit-scrollbar {
  width: 11px;
  height: 11px;
}
::-webkit-scrollbar-track {
  background: #0b0d12;
}
::-webkit-scrollbar-thumb {
  background: #35312a;
  border-radius: 20px;
  border: 3px solid #0b0d12;
}
::-webkit-scrollbar-thumb:hover {
  background: #51493b;
}

h1, h2, h3, h4, h5 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.16;
  color: var(--ink);
  margin: 0 0 0.5em;
  letter-spacing: 0.01em;
}

p {
  margin: 0 0 1em;
}

a {
  color: var(--gold-bright);
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

img,
svg {
  display: inline-block;
  vertical-align: middle;
}

.icon {
  flex: none;
}

.skip-link {
  position: fixed;
  top: -100px;
  left: 1rem;
  z-index: 1000;
  background: var(--gold);
  color: #18130a;
  padding: 0.6rem 1rem;
  border-radius: 0 0 8px 8px;
  font-weight: 700;
}
.skip-link:focus {
  top: 0;
}

.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;
}

:focus-visible {
  outline: 2px solid var(--gold-bright);
  outline-offset: 3px;
}

.ambient {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.ambient-glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.22;
}
.ambient-glow-1 {
  width: 42vw;
  height: 42vw;
  top: -16vw;
  left: 12vw;
  background: radial-gradient(circle, #c9a45c, transparent 68%);
}
.ambient-glow-2 {
  width: 38vw;
  height: 38vw;
  right: -10vw;
  bottom: -8vw;
  background: radial-gradient(circle, #525c9a, transparent 70%);
  opacity: 0.15;
}
.ambient-grain {
  position: absolute;
  inset: 0;
  opacity: 0.5;
  background-image: radial-gradient(rgba(255, 255, 255, 0.018) 1px, transparent 1px);
  background-size: 3px 3px;
}
.ambient-embers {
  position: absolute;
  inset: 0;
}
.ambient-embers i {
  position: absolute;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: #e0b869;
  box-shadow: 0 0 8px 2px rgba(224, 184, 105, 0.55);
  bottom: -10px;
  opacity: 0;
  animation: ember-rise 15s linear infinite;
}
.ambient-embers i:nth-child(1) { left: 12%; animation-delay: 1s; animation-duration: 17s; }
.ambient-embers i:nth-child(2) { left: 27%; animation-delay: 7s; animation-duration: 21s; }
.ambient-embers i:nth-child(3) { left: 45%; animation-delay: 3s; animation-duration: 14s; }
.ambient-embers i:nth-child(4) { left: 63%; animation-delay: 11s; animation-duration: 19s; }
.ambient-embers i:nth-child(5) { left: 79%; animation-delay: 5s; animation-duration: 23s; }
.ambient-embers i:nth-child(6) { left: 91%; animation-delay: 13s; animation-duration: 16s; }

@keyframes ember-rise {
  0% { transform: translate3d(0, 0, 0) scale(0.6); opacity: 0; }
  12% { opacity: 0.8; }
  65% { opacity: 0.5; }
  100% { transform: translate3d(-30px, -105vh, 0) scale(1.1); opacity: 0; }
}

#app {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

#screen-root {
  flex: 1;
  outline: none;
}

.screen {
  width: min(1280px, calc(100% - 2.5rem));
  margin: 0 auto;
  padding: 2rem 0 4rem;
}

.boot-splash {
  min-height: 60vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  color: var(--gold);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-family: var(--font-display);
  font-size: 0.8rem;
}
.boot-mark {
  font-size: 3rem;
  animation: pulse-glow 2s ease-in-out infinite;
}

@keyframes pulse-glow {
  0%, 100% { opacity: 0.45; transform: scale(0.96); }
  50% { opacity: 1; transform: scale(1.04); text-shadow: 0 0 24px rgba(201, 164, 92, 0.5); }
}

/* ------------------------------------------------------------------ */
/* Barra superior                                                      */
/* ------------------------------------------------------------------ */

#topbar-root {
  position: sticky;
  top: 0;
  z-index: 40;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  width: min(1380px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 0.7rem 0.4rem;
  min-height: var(--topbar-height);
  border-bottom: 1px solid var(--line-soft);
  background: linear-gradient(180deg, rgba(10, 12, 17, 0.94), rgba(10, 12, 17, 0.78));
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.25rem;
  background: none;
  border: 0;
  color: var(--ink);
  text-align: left;
  flex: none;
}
.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--gold-bright);
  background: radial-gradient(circle at 35% 30%, rgba(201, 164, 92, 0.2), transparent 70%);
  box-shadow: inset 0 0 14px rgba(201, 164, 92, 0.12);
}
.brand-copy {
  display: flex;
  flex-direction: column;
  line-height: 1.02;
  font-family: var(--font-display);
}
.brand-copy strong {
  font-size: 0.58rem;
  font-weight: 500;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--ink-muted);
}
.brand-copy em {
  font-style: normal;
  font-size: 1.05rem;
  letter-spacing: 0.08em;
  color: var(--gold-bright);
}

.main-nav {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.main-nav::-webkit-scrollbar { display: none; }

.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 0.42rem;
  padding: 0.5rem 0.78rem;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-muted);
  font-family: var(--font-display);
  font-size: 0.71rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
  transition: color 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}
.nav-link:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.035);
}
.nav-link.is-active {
  color: var(--gold-bright);
  border-color: var(--line);
  background: rgba(201, 164, 92, 0.08);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex: none;
}

.save-status {
  font-size: 0.68rem;
  color: var(--ink-faint);
  letter-spacing: 0.04em;
  white-space: nowrap;
  margin-right: 0.25rem;
}
.save-status.ok { color: var(--heal); }
.save-status.muted { color: var(--ink-faint); }
.save-status.error { color: var(--danger-bright); }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-muted);
  transition: all 0.18s ease;
}
.icon-btn:hover {
  color: var(--gold-bright);
  border-color: var(--line);
  background: rgba(201, 164, 92, 0.07);
}

/* ------------------------------------------------------------------ */
/* Tipografía y estructura                                             */
/* ------------------------------------------------------------------ */

.eyebrow {
  display: inline-block;
  font-family: var(--font-display);
  font-size: 0.63rem;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 0.5rem;
}

.page-head {
  padding: 1rem 0 1.8rem;
  border-bottom: 1px solid var(--line-soft);
  margin-bottom: 1.8rem;
}

.breadcrumb {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem 0;
  border: 0;
  background: transparent;
  color: var(--ink-muted);
  font-family: var(--font-display);
  font-size: 0.67rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 1.4rem;
}
.breadcrumb:hover { color: var(--gold-bright); }

.page-title-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 2rem;
  flex-wrap: wrap;
}
.page-title-row h1 {
  font-size: clamp(1.9rem, 4vw, 3rem);
  margin: 0;
  letter-spacing: 0.02em;
}
.page-title-row .eyebrow { margin-bottom: 0.35rem; }

.page-subtitle {
  max-width: 560px;
  margin: 0;
  color: var(--ink-muted);
  font-size: 0.94rem;
  font-style: italic;
}

.section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.2rem;
}

.subsection-title {
  font-size: 0.86rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold);
  border-bottom: 1px solid var(--line-soft);
  padding-bottom: 0.5rem;
  margin: 1.6rem 0 0.9rem;
}
.subsection-title:first-child { margin-top: 0; }

.hint-text {
  color: var(--ink-muted);
  font-size: 0.86rem;
  font-style: italic;
  line-height: 1.55;
}
.muted { color: var(--ink-muted); }

.danger-text { color: var(--danger-bright); }

/* ------------------------------------------------------------------ */
/* Botones                                                            */
/* ------------------------------------------------------------------ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 42px;
  padding: 0.55rem 1.05rem;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  text-decoration: none;
  transition: transform 0.16s ease, background 0.18s ease, border-color 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}
.btn:hover {
  border-color: var(--gold);
  color: var(--gold-bright);
}
.btn:active { transform: translateY(1px); }
.btn:disabled,
.btn[data-disabled="true"] {
  opacity: 0.45;
  pointer-events: none;
}
.btn .icon { flex: none; }

.btn-primary {
  background: linear-gradient(180deg, #d5b46c, #a98543);
  border-color: #dcc082;
  color: #1b1509;
  box-shadow: 0 6px 18px rgba(169, 133, 67, 0.2);
}
.btn-primary:hover {
  background: linear-gradient(180deg, #e7c982, #b8954d);
  color: #161006;
  box-shadow: 0 8px 24px rgba(201, 164, 92, 0.3);
}
.btn-secondary {
  background: rgba(201, 164, 92, 0.08);
  border-color: rgba(201, 164, 92, 0.4);
  color: var(--gold-bright);
}
.btn-secondary:hover {
  background: rgba(201, 164, 92, 0.16);
}
.btn-ghost {
  border-color: rgba(255, 255, 255, 0.09);
  color: var(--ink-soft);
}
.btn-ghost:hover {
  border-color: var(--line);
  color: var(--gold-bright);
  background: rgba(255, 255, 255, 0.025);
}
.btn-danger {
  background: rgba(185, 86, 79, 0.14);
  border-color: rgba(185, 86, 79, 0.5);
  color: #f0a49e;
}
.btn-danger:hover {
  background: rgba(185, 86, 79, 0.24);
  border-color: var(--danger-bright);
  color: #ffd1cc;
}
.btn-small {
  min-height: 34px;
  padding: 0.35rem 0.75rem;
  font-size: 0.65rem;
}
.btn-lg {
  min-height: 52px;
  padding: 0.75rem 1.5rem;
  font-size: 0.79rem;
}
.btn.is-loading { opacity: 0.6; pointer-events: none; }

.text-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0;
  border: 0;
  background: none;
  color: var(--gold);
  font-size: 0.8rem;
  font-family: var(--font-display);
  letter-spacing: 0.04em;
}
.text-link:hover { color: var(--gold-bright); }

/* ------------------------------------------------------------------ */
/* Formularios                                                        */
/* ------------------------------------------------------------------ */

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 1rem;
  min-width: 0;
}
.field-label {
  font-family: var(--font-display);
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-muted);
}
.field-label small {
  text-transform: none;
  letter-spacing: 0;
  color: var(--ink-faint);
  font-family: var(--font-body);
  font-size: 0.75rem;
}

.input {
  width: 100%;
  min-height: 42px;
  padding: 0.55rem 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 7px;
  background: rgba(8, 10, 15, 0.62);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 0.95rem;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}
.input:hover { border-color: rgba(201, 164, 92, 0.32); }
.input:focus {
  outline: none;
  border-color: var(--gold);
  background: rgba(10, 12, 18, 0.85);
  box-shadow: 0 0 0 3px rgba(201, 164, 92, 0.13);
}
select.input {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--gold) 50%), linear-gradient(135deg, var(--gold) 50%, transparent 50%);
  background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 2rem;
}
.textarea {
  resize: vertical;
  min-height: 90px;
  line-height: 1.55;
}
.select-small {
  min-height: 38px;
  padding: 0.3rem 2rem 0.3rem 0.55rem;
  font-size: 0.85rem;
}
.range {
  width: 100%;
  accent-color: var(--gold);
}
.input-with-action {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
}
.input-with-action .input { flex: 1; }

.form-grid {
  display: grid;
  gap: 0.4rem 1rem;
}
.form-grid.two { grid-template-columns: 1fr 1fr; }

.segmented {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.2rem;
  padding: 0.25rem;
  margin-bottom: 1rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: rgba(8, 10, 15, 0.5);
}
.segmented button {
  padding: 0.45rem 0.9rem;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--ink-muted);
  font-family: var(--font-display);
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.segmented button:hover { color: var(--ink); }
.segmented button.is-active {
  background: rgba(201, 164, 92, 0.14);
  border-color: var(--line);
  color: var(--gold-bright);
}
.segmented.small button {
  padding: 0.3rem 0.55rem;
  font-size: 0.61rem;
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.8rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  cursor: pointer;
}
.switch-row span {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}
.switch-row strong {
  font-family: var(--font-display);
  font-size: 0.8rem;
  color: var(--ink);
}
.switch-row small {
  color: var(--ink-muted);
  font-size: 0.78rem;
}
.switch-row input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: var(--gold);
}

/* ------------------------------------------------------------------ */
/* Etiquetas, chips y medidores                                       */
/* ------------------------------------------------------------------ */

.tag {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.13rem 0.48rem;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 999px;
  color: var(--ink-muted);
  font-family: var(--font-display);
  font-size: 0.58rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  white-space: nowrap;
}
.tag.gold {
  color: var(--gold-bright);
  border-color: rgba(201, 164, 92, 0.4);
  background: rgba(201, 164, 92, 0.08);
}
.tag.danger {
  color: #e9a09a;
  border-color: rgba(185, 86, 79, 0.45);
  background: rgba(185, 86, 79, 0.08);
}
.tag.heal {
  color: #9ec7a6;
  border-color: rgba(121, 167, 131, 0.45);
  background: rgba(121, 167, 131, 0.08);
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.22rem 0.55rem;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  background: rgba(255, 255, 255, 0.025);
  color: var(--ink-soft);
  font-size: 0.76rem;
}
.chip.granted {
  border-color: rgba(121, 167, 131, 0.3);
  color: #a8cdb0;
  background: rgba(121, 167, 131, 0.06);
}
.chip small {
  color: var(--ink-faint);
  font-size: 0.65rem;
}

.meter {
  position: relative;
  display: block;
  width: 100%;
  height: 20px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.06);
  overflow: hidden;
}
.meter-fill {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #7b3a36, #b9564f 60%, #d67b72);
  transition: width 0.45s ease;
}
.meter-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.63rem;
  font-family: var(--font-display);
  letter-spacing: 0.04em;
  color: #f4e9d7;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
}
.meter-hp.warn .meter-fill { background: linear-gradient(90deg, #8a612b, #c5944c 60%, #e0b66c); }
.meter-hp.danger .meter-fill { background: linear-gradient(90deg, #722b28, #b9564f 70%, #d36962); }
.meter.compact { height: 8px; }
.meter-xp { height: 7px; }
.meter-xp .meter-fill { background: linear-gradient(90deg, #4d6b8c, #7ea5c9 60%, #b5d1e8); }

/* ------------------------------------------------------------------ */
/* Retratos y emblemas                                                */
/* ------------------------------------------------------------------ */

.portrait {
  position: relative;
  display: inline-block;
  flex: none;
  width: var(--portrait-size, 74px);
  height: var(--portrait-size, 74px);
}
.emblem {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: var(--emblem-size, 64px);
  height: var(--emblem-size, 64px);
  border-radius: 50%;
  border: 1px solid color-mix(in srgb, var(--emblem-color) 55%, transparent);
  background:
    radial-gradient(circle at 35% 28%, color-mix(in srgb, var(--emblem-color) 30%, transparent), transparent 62%),
    radial-gradient(circle at 65% 80%, rgba(0, 0, 0, 0.55), rgba(8, 10, 15, 0.85));
  color: var(--emblem-color);
  box-shadow:
    inset 0 0 24px color-mix(in srgb, var(--emblem-color) 18%, transparent),
    0 6px 18px rgba(0, 0, 0, 0.35);
}
.emblem-ring {
  position: absolute;
  inset: 5px;
  border-radius: 50%;
  border: 1px solid color-mix(in srgb, var(--emblem-color) 30%, transparent);
}
.portrait-level {
  position: absolute;
  right: -3px;
  bottom: -3px;
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 5px;
  border-radius: 999px;
  background: #17130b;
  border: 1px solid var(--gold-dim);
  color: var(--gold-bright);
  font-family: var(--font-display);
  font-size: 0.62rem;
  line-height: 1;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.5);
}

/* ------------------------------------------------------------------ */
/* Accesos / estados vacíos                                           */
/* ------------------------------------------------------------------ */

.tag,
.nav-link,
.btn,
.choice-card,
.tabs button,
.codex-tabs button {
  -webkit-tap-highlight-color: transparent;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 2.5rem 1rem;
  text-align: center;
  color: var(--ink-muted);
  border: 1px dashed var(--line-soft);
  border-radius: var(--radius);
}
.empty-state h3 {
  font-size: 1.2rem;
  margin: 0;
  color: var(--ink);
}
.empty-state p {
  max-width: 44ch;
  margin: 0;
  font-size: 0.9rem;
}
.empty-state .icon { color: var(--gold); opacity: 0.7; }

.fatal-error {
  max-width: 620px;
  margin: 12vh auto;
  padding: 2rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  text-align: center;
}
.fatal-error h1 { font-size: 1.8rem; }
.fatal-error p { color: var(--ink-muted); }

.noscript {
  position: fixed;
  inset: 0;
  z-index: 999;
  display: grid;
  place-items: center;
  padding: 2rem;
  background: #0a0c11;
  color: var(--ink);
  text-align: center;
}

.is-paused {
  filter: blur(2px) saturate(0.8);
  pointer-events: none;
  transition: filter 0.25s ease;
}

/* ------------------------------------------------------------------ */
/* Pie                                                                */
/* ------------------------------------------------------------------ */

.site-footer {
  width: min(1280px, calc(100% - 2.5rem));
  margin: 0 auto;
  padding: 1.2rem 0 2rem;
  border-top: 1px solid var(--line-soft);
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  color: var(--ink-faint);
  font-size: 0.72rem;
  font-style: italic;
}

/* ------------------------------------------------------------------ */
/* Toasts                                                             */
/* ------------------------------------------------------------------ */

.toast-root {
  position: fixed;
  right: 1.2rem;
  bottom: 1.2rem;
  z-index: 900;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  width: min(390px, calc(100vw - 2.4rem));
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(20, 24, 33, 0.96);
  color: var(--ink-soft);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  transform: translateY(12px);
  opacity: 0;
  transition: transform 0.24s ease, opacity 0.24s ease;
  pointer-events: auto;
  font-size: 0.85rem;
  line-height: 1.45;
}
.toast.is-visible { transform: translateY(0); opacity: 1; }
.toast-icon { color: var(--gold); margin-top: 0.12rem; }
.toast-success { border-color: rgba(121, 167, 131, 0.4); }
.toast-success .toast-icon { color: var(--heal); }
.toast-error { border-color: rgba(185, 86, 79, 0.5); }
.toast-error .toast-icon { color: var(--danger-bright); }
.toast-level { border-color: rgba(201, 164, 92, 0.55); background: rgba(36, 30, 17, 0.97); }
.toast-loot { border-color: rgba(201, 164, 92, 0.45); }
.toast-text { flex: 1; }

/* ------------------------------------------------------------------ */
/* Modal                                                              */
/* ------------------------------------------------------------------ */

.modal {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--ink);
  max-width: min(660px, calc(100vw - 2rem));
  width: 100%;
  margin: auto;
}
.modal::backdrop {
  background: rgba(4, 5, 8, 0.78);
  backdrop-filter: blur(4px);
}
.modal-shell {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    radial-gradient(ellipse 80% 50% at 50% 0%, rgba(201, 164, 92, 0.09), transparent 70%),
    linear-gradient(180deg, #171b26, #11151d);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.65);
  padding: 1.6rem;
  max-height: calc(100vh - 2rem);
  overflow: auto;
}
.modal-wide { max-width: min(900px, calc(100vw - 2rem)); }
.modal-head {
  position: relative;
  padding-right: 2.4rem;
  margin-bottom: 1rem;
}
.modal-head h2 {
  margin: 0;
  font-size: 1.55rem;
}
.modal-close {
  position: absolute;
  top: -0.4rem;
  right: -0.4rem;
}
.modal-body {
  color: var(--ink-soft);
  font-size: 0.96rem;
}
.modal-text { color: var(--ink-soft); }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-top: 1.4rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line-soft);
}

.asi-form {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  margin-top: 1rem;
}
.asi-option {
  padding: 0.9rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.018);
}
.asi-option label {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.6rem;
  cursor: pointer;
}
.asi-option input[type="radio"] { accent-color: var(--gold); }
.asi-two-selects {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}

/* ------------------------------------------------------------------ */
/* Overlay de dados                                                   */
/* ------------------------------------------------------------------ */

dialog.dice-overlay {
  position: fixed;
  inset: 0;
  width: 100vw;
  max-width: 100vw;
  height: 100vh;
  max-height: 100vh;
  margin: 0;
  padding: 1.2rem;
  border: 0;
  background: transparent;
  color: var(--ink);
  overflow: auto;
  display: none;
  place-items: center;
  opacity: 0;
  transition: opacity 0.2s ease;
}
dialog.dice-overlay[open] { display: grid; }
dialog.dice-overlay.is-open { opacity: 1; }
dialog.dice-overlay::backdrop {
  background: rgba(4, 5, 8, 0.82);
  backdrop-filter: blur(6px);
}
.dice-panel {
  width: min(520px, 100%);
  padding: 1.6rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    radial-gradient(ellipse 80% 50% at 50% 0%, rgba(201, 164, 92, 0.14), transparent 65%),
    linear-gradient(180deg, #191d29, #0f131b);
  box-shadow: 0 35px 90px rgba(0, 0, 0, 0.7);
  text-align: center;
  transform: translateY(14px) scale(0.98);
  transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.dice-overlay.is-revealed .dice-panel { transform: none; }
.dice-panel h3 {
  font-size: 1.4rem;
  margin: 0 0 0.35rem;
}
.dice-subtitle {
  color: var(--ink-muted);
  font-size: 0.88rem;
  margin-bottom: 1rem;
}
.roll-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.3rem;
  margin: 1.2rem 0 1rem;
}
.dice-face {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 110px;
  height: 110px;
  color: var(--gold-bright);
  filter: drop-shadow(0 12px 22px rgba(0, 0, 0, 0.45));
  transform: rotate(-8deg);
  animation: dice-tumble 0.85s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.dice-face::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 35% 28%, rgba(232, 203, 134, 0.28), transparent 55%),
    linear-gradient(145deg, #3a3122, #17130b 65%);
  clip-path: polygon(50% 2%, 94% 25%, 94% 75%, 50% 98%, 6% 75%, 6% 25%);
  border: 1px solid var(--gold);
}
.dice-face::after {
  content: '';
  position: absolute;
  inset: 12px;
  border: 1px solid rgba(201, 164, 92, 0.26);
  clip-path: polygon(50% 2%, 94% 25%, 94% 75%, 50% 98%, 6% 75%, 6% 25%);
}
.dice-face-inner {
  position: relative;
  z-index: 1;
  font-family: var(--font-display);
  font-size: 2.6rem;
  font-weight: 600;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.75);
}
.dice-d100::before { clip-path: polygon(50% 2%, 92% 22%, 98% 62%, 72% 96%, 28% 96%, 2% 62%, 8% 22%); }
.dice-d4::before { clip-path: polygon(50% 4%, 96% 92%, 4% 92%); }
.dice-d6::before { clip-path: none; border-radius: 18px; }
.dice-d6::after { clip-path: none; border-radius: 12px; }
.dice-d8::before { clip-path: polygon(50% 2%, 94% 50%, 50% 98%, 6% 50%); }
.dice-d10::before { clip-path: polygon(50% 2%, 92% 30%, 78% 92%, 22% 92%, 8% 30%); }
.dice-d12::before { clip-path: polygon(50% 2%, 90% 22%, 96% 68%, 68% 96%, 32% 96%, 4% 68%, 10% 22%); }

@keyframes dice-tumble {
  0% { transform: rotate(-32deg) scale(0.6); opacity: 0; }
  45% { transform: rotate(14deg) scale(1.08); opacity: 1; }
  75% { transform: rotate(-4deg) scale(0.98); }
  100% { transform: rotate(-8deg) scale(1); }
}

.roll-total {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15rem;
  text-align: left;
}
.roll-number {
  font-family: var(--font-display);
  font-size: 2.6rem;
  line-height: 1;
  color: var(--ink);
}
.roll-compare {
  color: var(--ink-muted);
  font-size: 0.82rem;
}
.roll-compare strong { color: var(--gold-bright); }
.roll-mode {
  display: inline-block;
  margin-bottom: 0.6rem;
  color: var(--gold);
  font-family: var(--font-display);
  font-size: 0.64rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.roll-breakdown {
  font-size: 0.82rem;
  color: var(--ink-muted);
  letter-spacing: 0.03em;
  margin: 0.2rem 0 0.6rem;
}
.roll-lines {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin: 0.7rem auto;
  max-width: 46ch;
}
.roll-line {
  margin: 0;
  font-size: 0.88rem;
  color: var(--ink-soft);
}
.roll-verdict {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.8rem;
  margin: 0.4rem auto 0.8rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-family: var(--font-display);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.roll-verdict.success { color: #a8d1b0; border-color: rgba(121, 167, 131, 0.45); background: rgba(121, 167, 131, 0.08); }
.roll-verdict.fail { color: #eda39d; border-color: rgba(185, 86, 79, 0.45); background: rgba(185, 86, 79, 0.08); }
.roll-verdict.critical { color: var(--gold-bright); border-color: var(--gold); background: rgba(201, 164, 92, 0.12); }
.roll-verdict.heal { color: #a8d1b0; border-color: rgba(121, 167, 131, 0.45); }
.roll-verdict.buff { color: #b5acef; border-color: rgba(148, 133, 207, 0.45); }
.roll-verdict.damage { color: #e8a08f; border-color: rgba(185, 86, 79, 0.45); }
.roll-dismiss { margin-top: 0.4rem; }

/* ------------------------------------------------------------------ */
/* Iconos y utilidades                                               */
/* ------------------------------------------------------------------ */

.icon { color: currentColor; }

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.summary-line {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.045);
  font-size: 0.9rem;
}
.summary-line span {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--ink-muted);
}
.summary-line strong {
  font-family: var(--font-display);
  font-weight: 500;
  color: var(--ink-soft);
  text-align: right;
}

.resource-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.14rem 0.45rem;
  border: 1px solid rgba(201, 164, 92, 0.22);
  border-radius: 999px;
  color: var(--gold);
  font-size: 0.65rem;
  font-family: var(--font-display);
  letter-spacing: 0.03em;
  white-space: nowrap;
}
.resource-chip.subtle {
  border-color: rgba(255, 255, 255, 0.08);
  color: var(--ink-faint);
}

@media (max-width: 760px) {
  .screen {
    width: min(1280px, calc(100% - 1.4rem));
    padding-top: 1.1rem;
  }
  .topbar {
    width: calc(100% - 1rem);
    gap: 0.6rem;
    min-height: 60px;
  }
  .brand-copy { display: none; }
  .brand-mark { width: 36px; height: 36px; }
  .main-nav { gap: 0; }
  .nav-link { padding: 0.45rem 0.55rem; }
  .nav-link span { display: none; }
  .topbar-right { gap: 0.1rem; }
  .save-status { display: none; }
  .icon-btn { width: 34px; height: 34px; }
  .toast-root { right: 0.7rem; bottom: 0.7rem; }
  .modal-shell { padding: 1.1rem; }
  .dice-panel { padding: 1.2rem; }
  .dice-face { width: 86px; height: 86px; }
  .dice-face-inner { font-size: 2rem; }
  .roll-number { font-size: 2.1rem; }
  .site-footer { flex-direction: column; gap: 0.3rem; font-size: 0.66rem; }
  .form-grid.two { grid-template-columns: 1fr; }
}

@media (max-width: 460px) {
  .nav-link { padding: 0.4rem; }
  .topbar-right { gap: 0; }
  .topbar-right .icon-btn { width: 32px; height: 32px; }
  .roll-stage { gap: 0.8rem; }
  .dice-face { width: 74px; height: 74px; }
  .dice-face-inner { font-size: 1.7rem; }
}


/* ------------------------------------------------------------------ */
/* Movimiento reducido                                                */
/* ------------------------------------------------------------------ */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .ambient-embers { display: none; }
}

:root[data-motion="reduced"] {
  scroll-behavior: auto;
}
:root[data-motion="reduced"] *,
:root[data-motion="reduced"] *::before,
:root[data-motion="reduced"] *::after {
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.01ms !important;
}
:root[data-motion="reduced"] .ambient-embers { display: none; }
