/* ==========================================================================
   AVENTURAS FANTÁSTICAS — theme.css
   Grimório sombrio / masmorra. Tema escuro, pergaminho envelhecido,
   dourado-âmbar e vermelho-sangue. 100% offline: sem fontes ou imagens
   externas. CSS puro.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. TOKENS
   -------------------------------------------------------------------------- */
:root {
  /* superfícies */
  --bg:            #0d0b09;
  --bg-deep:       #080706;
  --panel:         #1c1712;
  --panel-2:       #241d15;
  --parchment:     #2a2117;
  --parchment-2:   #332818;
  --felt:          #12100d;

  /* tinta */
  --ink:           #e8ddc8;
  --ink-dim:       #b3a688;
  --ink-faint:     #8a7d63;

  /* acentos */
  --accent:        #c9973c;   /* dourado âmbar */
  --accent-bright: #e9b85c;
  --accent-dim:    #8a6526;
  --accent-glow:   rgba(214, 164, 74, 0.35);
  --blood:         #7e1d1d;
  --blood-bright:  #a83232;
  --blood-deep:    #4a1010;

  /* estado das barras */
  --vigor-ok:      #4e7d3a;
  --vigor-ok-2:    #79a44f;
  --vigor-warn:    #b3812f;
  --vigor-warn-2:  #d4a94a;
  --vigor-danger:  #8c2323;
  --vigor-danger-2:#c04a3a;

  /* linhas e ornamento */
  --line:          rgba(201, 151, 60, 0.22);
  --line-strong:   rgba(201, 151, 60, 0.45);
  --edge-dark:     rgba(0, 0, 0, 0.55);

  /* tipografia */
  --serif:   Georgia, "Palatino Linotype", Palatino, "Times New Roman", serif;
  --display: "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --mono:    Consolas, "Courier New", monospace;

  /* ritmo */
  --t-fast:  160ms;
  --t-med:   220ms;
  --t-slow:  400ms;
  --ease:    cubic-bezier(0.33, 1, 0.68, 1);

  /* sombras em camadas */
  --shadow-panel:
    0 1px 0 rgba(255, 235, 190, 0.04) inset,
    0 0 0 1px rgba(0, 0, 0, 0.6),
    0 6px 18px rgba(0, 0, 0, 0.55),
    0 22px 48px rgba(0, 0, 0, 0.45);
  --shadow-raise:
    0 1px 0 rgba(255, 235, 190, 0.06) inset,
    0 10px 26px rgba(0, 0, 0, 0.6),
    0 30px 60px rgba(0, 0, 0, 0.5);

  /* cantos levemente irregulares (feito à mão) */
  --r-organic: 7px 9px 8px 6px;
  --r-organic-lg: 12px 15px 13px 11px;
}

/* --------------------------------------------------------------------------
   2. BASE
   -------------------------------------------------------------------------- */
* { box-sizing: border-box; }

html { height: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 16px;
  line-height: 1.6;
  background-color: var(--bg);
  /* pedra úmida: vinheta + veios sutis, sem imagens */
  background-image:
    radial-gradient(ellipse 120% 80% at 50% -10%, rgba(201, 151, 60, 0.05), transparent 60%),
    radial-gradient(ellipse 100% 100% at 50% 115%, rgba(126, 29, 29, 0.07), transparent 55%),
    repeating-linear-gradient(115deg,
      transparent 0px, transparent 3px,
      rgba(255, 245, 220, 0.006) 3px, rgba(255, 245, 220, 0.006) 4px),
    repeating-linear-gradient(25deg,
      transparent 0px, transparent 5px,
      rgba(0, 0, 0, 0.06) 5px, rgba(0, 0, 0, 0.06) 6px),
    linear-gradient(180deg, var(--bg-deep) 0%, var(--bg) 30%, var(--bg) 70%, var(--bg-deep) 100%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  isolation: isolate;
  overflow-x: hidden;
}

/* Atmosfera da Biblioteca: cenário vetorial em CSS, discreto e offline.
   Representa a coleção como um todo — estante de tomos ao rodapé e um
   círculo arcano suspenso ao fundo — em vez da história de um único livro. */
.library-atmosphere {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
  opacity: .72;
}

/* fileira de lombadas de grimórios, em silhueta, ao rodapé */
.atmosphere-shelf {
  position: absolute;
  inset: auto -6vw 0;
  height: 15vh;
  min-height: 84px;
  background:
    repeating-linear-gradient(90deg,
      #0c0906 0, #0c0906 22px,
      #100c08 22px, #100c08 25px,
      #090705 25px, #090705 46px,
      #120d09 46px, #120d09 50px,
      #0a0705 50px, #0a0705 74px,
      #0e0a06 74px, #0e0a06 78px,
      #0b0806 78px, #0b0806 97px,
      #0f0b07 97px, #0f0b07 101px),
    linear-gradient(180deg, #0c0906, #050403);
  border-top: 2px solid rgba(201, 151, 60, .16);
  box-shadow:
    0 1px 0 rgba(255, 235, 190, .04) inset,
    0 -30px 50px rgba(0, 0, 0, .55);
}

/* lasca dourada no topo das lombadas, como relevo de folha de ouro */
.atmosphere-shelf::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 3px;
  background: repeating-linear-gradient(90deg,
    transparent 0, transparent 10px,
    rgba(201, 151, 60, .22) 10px, rgba(201, 151, 60, .22) 13px,
    transparent 13px, transparent 24px);
}

/* círculo arcano suspenso — remete a magia, sorte e destino, não a um livro só */
.atmosphere-circle {
  position: absolute;
  top: 7vh;
  right: 6vw;
  width: clamp(220px, 26vw, 420px);
  aspect-ratio: 1;
  border-radius: 50%;
  border: 1px solid rgba(201, 151, 60, .16);
  background: repeating-conic-gradient(
    rgba(201, 151, 60, .1) 0deg 1.1deg,
    transparent 1.1deg 15deg);
  opacity: .55;
  animation: circle-turn 160s linear infinite;
}

.atmosphere-circle::before,
.atmosphere-circle::after {
  content: "";
  position: absolute;
  inset: 9%;
  border-radius: 50%;
  border: 1px dashed rgba(201, 151, 60, .14);
}

.atmosphere-circle::after {
  inset: 19%;
  border-style: solid;
  border-color: rgba(233, 184, 92, .1);
}

@keyframes circle-turn {
  to { transform: rotate(360deg); }
}

/* poeira de motas douradas — como faíscas de um encantamento distante */
.atmosphere-motes {
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(2px 2px at 12% 22%, rgba(233, 184, 92, .5), transparent 60%),
    radial-gradient(1.5px 1.5px at 27% 68%, rgba(233, 184, 92, .35), transparent 60%),
    radial-gradient(2px 2px at 44% 15%, rgba(233, 184, 92, .4), transparent 60%),
    radial-gradient(1.5px 1.5px at 63% 78%, rgba(233, 184, 92, .3), transparent 60%),
    radial-gradient(2px 2px at 78% 30%, rgba(233, 184, 92, .45), transparent 60%),
    radial-gradient(1.5px 1.5px at 90% 60%, rgba(233, 184, 92, .3), transparent 60%),
    radial-gradient(2px 2px at 35% 42%, rgba(233, 184, 92, .35), transparent 60%),
    radial-gradient(1.5px 1.5px at 8% 82%, rgba(233, 184, 92, .3), transparent 60%);
  animation: motes-twinkle 7s ease-in-out infinite alternate;
}

@keyframes motes-twinkle {
  from { opacity: .35; }
  to   { opacity: .85; }
}

.skip-link {
  position: fixed;
  z-index: 999;
  top: .75rem;
  left: 50%;
  padding: .65rem 1rem;
  color: #130f09;
  background: var(--accent-bright);
  border-radius: 4px;
  transform: translate(-50%, -180%);
  transition: transform var(--t-fast);
}

.skip-link:focus { transform: translate(-50%, 0); }

h1, h2, h3, h4 {
  font-family: var(--display);
  font-weight: 600;
  line-height: 1.2;
  color: var(--ink);
  margin: 0 0 0.6em;
}

p { margin: 0 0 1em; }

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

::selection {
  background: rgba(201, 151, 60, 0.35);
  color: #fff6e0;
}

/* foco visível — acessibilidade */
:focus-visible {
  outline: 2px solid var(--accent-bright);
  outline-offset: 2px;
  border-radius: 2px;
}
:focus:not(:focus-visible) { outline: none; }

/* --------------------------------------------------------------------------
   3. UTILITÁRIOS
   -------------------------------------------------------------------------- */
.hidden { display: none !important; }

.muted {
  color: var(--ink-faint);
  font-size: 0.9em;
  font-style: italic;
}

.only-mobile { display: none; }

.screen {
  min-height: 100vh;
  width: 100%;
  animation: screen-in var(--t-slow) var(--ease) both;
}

@keyframes screen-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

/* --------------------------------------------------------------------------
   4. BOTÕES (base)
   -------------------------------------------------------------------------- */
.btn {
  font-family: var(--display);
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  color: var(--ink);
  background:
    linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line-strong);
  border-radius: var(--r-organic);
  padding: 0.55em 1.3em;
  cursor: pointer;
  position: relative;
  transition:
    transform var(--t-fast) var(--ease),
    box-shadow var(--t-fast) var(--ease),
    border-color var(--t-fast) var(--ease),
    background-color var(--t-fast) var(--ease),
    color var(--t-fast) var(--ease);
  box-shadow:
    0 1px 0 rgba(255, 235, 190, 0.07) inset,
    0 -6px 12px rgba(0, 0, 0, 0.25) inset,
    0 2px 6px rgba(0, 0, 0, 0.45);
}

.btn:hover {
  border-color: var(--accent);
  color: var(--accent-bright);
  box-shadow:
    0 1px 0 rgba(255, 235, 190, 0.1) inset,
    0 -6px 12px rgba(0, 0, 0, 0.2) inset,
    0 3px 10px rgba(0, 0, 0, 0.5),
    0 0 14px var(--accent-glow);
}

.btn:active {
  transform: translateY(1px);
  box-shadow:
    0 2px 8px rgba(0, 0, 0, 0.5) inset;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: grayscale(0.6);
  transform: none;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.btn-primary {
  color: #f5e8c8;
  background: linear-gradient(180deg, #3d2f1a, #2a2012 55%, #221a0e);
  border: 1px solid var(--accent-dim);
  box-shadow:
    0 1px 0 rgba(233, 184, 92, 0.25) inset,
    0 0 0 1px rgba(0, 0, 0, 0.5),
    0 -8px 14px rgba(0, 0, 0, 0.3) inset,
    0 3px 8px rgba(0, 0, 0, 0.5);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
}

.btn-primary:hover {
  border-color: var(--accent-bright);
  color: #fff2d2;
  box-shadow:
    0 1px 0 rgba(233, 184, 92, 0.35) inset,
    0 0 0 1px rgba(0, 0, 0, 0.5),
    0 3px 10px rgba(0, 0, 0, 0.55),
    0 0 18px var(--accent-glow);
}

.btn-ghost {
  background: transparent;
  border-color: rgba(201, 151, 60, 0.18);
  color: var(--ink-dim);
  box-shadow: none;
}

.btn-ghost:hover {
  color: var(--accent-bright);
  border-color: var(--line-strong);
  background: rgba(201, 151, 60, 0.06);
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
}

.btn-lg {
  font-size: 1.1rem;
  padding: 0.75em 1.8em;
  letter-spacing: 0.06em;
}

.btn-sm {
  font-size: 0.85rem;
  padding: 0.3em 0.75em;
}

.btn-icon {
  font-size: 1.1rem;
  padding: 0.35em 0.6em;
  line-height: 1;
  min-width: 2.4em;
}

.btn-file { display: inline-block; }
.btn-file input[type="file"] { display: none; }

/* --------------------------------------------------------------------------
   5. BIBLIOTECA
   -------------------------------------------------------------------------- */
#screen-library {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: clamp(2rem, 6vh, 4.5rem) 1.5rem 2rem;
}

.library-header {
  text-align: center;
  margin-bottom: clamp(2rem, 5vh, 3.5rem);
}

.brand-kicker {
  margin: 0 0 .8rem;
  color: var(--accent);
  font-size: .76rem;
  font-weight: 700;
  letter-spacing: .28em;
  text-transform: uppercase;
}

.brand-title {
  font-size: clamp(2.4rem, 6vw, 4.2rem);
  font-variant: small-caps;
  letter-spacing: 0.12em;
  font-weight: 700;
  margin: 0 0 0.25em;
  color: transparent;
  background: linear-gradient(180deg,
    #f4e3b2 0%, var(--accent-bright) 38%, var(--accent) 60%, #7d5a1e 100%);
  -webkit-background-clip: text;
  background-clip: text;
  text-shadow: 0 3px 24px rgba(201, 151, 60, 0.25);
  position: relative;
  padding-bottom: 0.35em;
}

/* filete ornamental sob o título */
.brand-title::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(420px, 70%);
  height: 2px;
  background: linear-gradient(90deg,
    transparent, var(--accent-dim) 20%, var(--accent-bright) 50%,
    var(--accent-dim) 80%, transparent);
}

.brand-subtitle {
  color: var(--ink-dim);
  font-style: italic;
  font-size: clamp(1rem, 2vw, 1.15rem);
  letter-spacing: 0.05em;
  margin: 0.5em 0 0;
}

.book-list {
  display: grid;
  grid-template-columns: 1fr;
  justify-content: center;
  gap: 2rem;
  width: 100%;
  max-width: 1200px;
}

@media (min-width: 640px) {
  .book-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 1000px) {
  .book-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.book-card {
  /* tom por cartão (variado via :nth-child abaixo), sempre dentro da
     paleta âmbar/sangue/pergaminho do tema */
  --tint-wash:   rgba(201, 151, 60, .15);
  --tint-ring:   rgba(233, 184, 92, .34);
  --tint-glyph:  rgba(233, 184, 92, .74);
  --tint-medal:  rgba(201, 151, 60, .13);
  --tint-glow:   rgba(201, 151, 60, .12);
  --tint-ink:    var(--accent-bright);
  --tint-number: rgba(233, 184, 92, .65);
  --tint-edge:   var(--line-strong);

  display: flex;
  flex-direction: column;
  background:
    linear-gradient(160deg, var(--parchment-2) 0%, var(--parchment) 45%, #221a10 100%);
  border: 1px solid var(--line);
  border-radius: var(--r-organic-lg);
  overflow: hidden;
  box-shadow: var(--shadow-panel);
  transition:
    transform var(--t-med) var(--ease),
    box-shadow var(--t-med) var(--ease),
    border-color var(--t-med) var(--ease);
  position: relative;
  isolation: isolate;
}

.book-card::before {
  content: "";
  position: absolute;
  z-index: 2;
  inset: 6px;
  border: 1px solid rgba(233, 184, 92, .12);
  border-radius: 8px 11px 9px 7px;
  pointer-events: none;
}

.book-card:hover {
  transform: translateY(-6px);
  border-color: var(--tint-edge);
  box-shadow:
    var(--shadow-raise),
    0 0 28px var(--tint-glow);
}

/* variação sutil de tom por posição no grid — mesma paleta, ênfases
   diferentes, para diferenciar os tomos da coleção a olho */
.book-card:nth-child(6n+2) {
  --tint-wash:   rgba(168, 50, 50, .18);
  --tint-ring:   rgba(216, 120, 110, .34);
  --tint-glyph:  rgba(216, 120, 110, .78);
  --tint-medal:  rgba(168, 50, 50, .16);
  --tint-glow:   rgba(168, 50, 50, .16);
  --tint-ink:    #d68f7a;
  --tint-number: rgba(216, 140, 120, .7);
  --tint-edge:   rgba(168, 50, 50, .45);
}

.book-card:nth-child(6n+3) {
  --tint-wash:   rgba(179, 129, 47, .18);
  --tint-ring:   rgba(212, 169, 74, .34);
  --tint-glyph:  rgba(212, 169, 74, .78);
  --tint-medal:  rgba(179, 129, 47, .14);
  --tint-glow:   rgba(179, 129, 47, .14);
  --tint-ink:    #d4a94a;
  --tint-number: rgba(212, 169, 74, .65);
  --tint-edge:   rgba(179, 129, 47, .4);
}

.book-card:nth-child(6n+4) {
  --tint-wash:   rgba(154, 140, 96, .16);
  --tint-ring:   rgba(197, 184, 140, .3);
  --tint-glyph:  rgba(197, 184, 140, .72);
  --tint-medal:  rgba(154, 140, 96, .14);
  --tint-glow:   rgba(154, 140, 96, .12);
  --tint-ink:    #c7ba97;
  --tint-number: rgba(197, 184, 140, .6);
  --tint-edge:   rgba(154, 140, 96, .4);
}

.book-card:nth-child(6n+5) {
  --tint-wash:   rgba(126, 29, 29, .22);
  --tint-ring:   rgba(190, 90, 80, .3);
  --tint-glyph:  rgba(190, 90, 80, .72);
  --tint-medal:  rgba(126, 29, 29, .18);
  --tint-glow:   rgba(126, 29, 29, .16);
  --tint-ink:    #c77b6e;
  --tint-number: rgba(190, 110, 100, .62);
  --tint-edge:   rgba(126, 29, 29, .5);
}

.book-card:nth-child(6n) {
  --tint-wash:   rgba(192, 74, 58, .18);
  --tint-ring:   rgba(224, 140, 90, .34);
  --tint-glyph:  rgba(224, 140, 90, .78);
  --tint-medal:  rgba(192, 74, 58, .15);
  --tint-glow:   rgba(192, 74, 58, .14);
  --tint-ink:    #e0a173;
  --tint-number: rgba(224, 150, 110, .65);
  --tint-edge:   rgba(192, 74, 58, .42);
}

.book-cover {
  min-height: 260px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .65rem;
  padding: 2.4rem 2rem 2rem;
  overflow: hidden;
  text-align: center;
  font-family: var(--display);
  font-variant: small-caps;
  font-weight: 700;
  color: rgba(233, 184, 92, 0.85);
  text-shadow:
    0 2px 4px rgba(0, 0, 0, 0.8),
    0 0 30px rgba(201, 151, 60, 0.4);
  background:
    radial-gradient(ellipse 90% 70% at 50% 30%, var(--tint-wash), transparent 65%),
    repeating-linear-gradient(45deg,
      transparent 0, transparent 6px,
      rgba(0, 0, 0, 0.12) 6px, rgba(0, 0, 0, 0.12) 7px),
    linear-gradient(155deg, #3a2517 0%, #241408 55%, #150c05 100%);
  border-bottom: 1px solid var(--tint-edge);
  position: relative;
}

.book-cover::before {
  content: "⚔";
  display: grid;
  place-items: center;
  position: absolute;
  width: 88px;
  aspect-ratio: 1;
  border: 1px solid var(--tint-ring);
  border-radius: 50%;
  color: var(--tint-glyph);
  font-size: 2.4rem;
  background: radial-gradient(circle, var(--tint-medal), transparent 70%);
  box-shadow: 0 0 0 5px rgba(0,0,0,.15), 0 0 30px var(--tint-glow);
}

.book-cover > * { position: relative; z-index: 1; }

.book-cover .cover-rune {
  display: grid;
  place-items: center;
  width: 76px;
  aspect-ratio: 1;
  margin-bottom: .35rem;
  border: 1px solid var(--tint-ring);
  border-radius: 50%;
  background: rgba(10, 6, 3, .3);
  color: var(--tint-ink);
  font-size: 2rem;
  line-height: 1;
}

.book-cover .cover-number {
  position: absolute;
  top: 1.15rem;
  right: 1.35rem;
  color: var(--tint-number);
  font: 700 .8rem/1 var(--display);
  letter-spacing: .12em;
}

.book-cover .cover-title {
  display: block;
  max-width: 100%;
  color: var(--tint-ink);
  font-size: clamp(1.65rem, 3vw, 2.2rem);
  line-height: 1.08;
  letter-spacing: .07em;
  overflow-wrap: anywhere;
  text-wrap: balance;
}

/* moldura interna da capa, como couro trabalhado */
.book-cover::after {
  content: "";
  position: absolute;
  inset: 10px;
  border: 1px solid rgba(201, 151, 60, 0.28);
  border-radius: 4px 6px 5px 4px;
  pointer-events: none;
}

.book-info {
  padding: 1.25rem 1.4rem 1.5rem;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.book-title {
  font-size: 1.35rem;
  font-variant: small-caps;
  letter-spacing: 0.06em;
  color: var(--accent-bright);
  margin-bottom: 0.2em;
}

.book-series {
  color: var(--ink-faint);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  margin-bottom: 0.9em;
}

.book-blurb {
  color: var(--ink-dim);
  font-size: 0.95rem;
  line-height: 1.6;
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.book-actions {
  margin-top: 1.1rem;
  display: flex;
  gap: 0.6rem;
}

.book-actions .btn { flex: 1; }

.library-footer {
  margin-top: auto;
  padding-top: 3rem;
  text-align: center;
}

/* --------------------------------------------------------------------------
   6. CRIAÇÃO DE PERSONAGEM
   -------------------------------------------------------------------------- */
#screen-create {
  display: flex;
  justify-content: center;
  padding: clamp(1.5rem, 4vh, 3rem) 1rem;
}

.create-panel {
  width: min(760px, 100%);
  background: linear-gradient(170deg, var(--parchment-2), var(--parchment) 40%, #211a11);
  border: 1px solid var(--line);
  border-radius: var(--r-organic-lg);
  box-shadow: var(--shadow-panel);
  padding: clamp(1.5rem, 4vw, 2.75rem);
}

.create-title {
  font-variant: small-caps;
  letter-spacing: 0.1em;
  font-size: clamp(1.6rem, 4vw, 2.2rem);
  color: var(--accent-bright);
  text-align: center;
  border-bottom: 1px solid var(--line);
  padding-bottom: 0.6em;
  margin-bottom: 1em;
  text-shadow: 0 2px 12px rgba(201, 151, 60, 0.2);
}

.create-background {
  max-height: 300px;
  overflow-y: auto;
  padding: 1rem 1.25rem;
  margin-bottom: 1.75rem;
  font-size: 1.02rem;
  line-height: 1.7;
  color: var(--ink-dim);
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(201, 151, 60, 0.12);
  border-radius: var(--r-organic);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35) inset;
}

.panel-heading {
  font-variant: small-caps;
  letter-spacing: 0.1em;
  font-size: 1.15rem;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 0.75em;
}

.panel-heading::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--line-strong), transparent);
}

.create-stats { margin-bottom: 1.75rem; }

.stat-roll-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin: 1rem 0 1.4rem;
}

.stat-roll {
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--line);
  border-radius: var(--r-organic);
  padding: 0.9rem 1rem 1rem;
  text-align: center;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3) inset;
}

.stat-roll-name {
  display: block;
  font-variant: small-caps;
  letter-spacing: 0.16em;
  font-size: 0.85rem;
  color: var(--ink-dim);
  margin-bottom: 0.5em;
}

.dice-slot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 56px;
  min-width: 56px;
}

.stat-roll-value {
  display: block;
  font-family: var(--display);
  font-size: 1.9rem;
  font-weight: 700;
  color: var(--accent-bright);
  text-shadow: 0 0 14px rgba(201, 151, 60, 0.35);
  margin-top: 0.3em;
}

/* -------- escolha de encantos -------- */
.spell-picker {
  margin-bottom: 1.75rem;
  padding-top: 0.5rem;
  border-top: 1px dashed var(--line);
}

#spell-points-left {
  color: var(--accent-bright);
  font-weight: 700;
}

.spell-picker-hint { margin: 0.4em 0 1em; }

.spell-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 320px;
  overflow-y: auto;
  padding-right: 0.35rem;
}

.spell-item {
  display: grid;
  grid-template-columns: auto minmax(110px, auto) 1fr;
  gap: 0.4rem 1rem;
  align-items: center;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid rgba(201, 151, 60, 0.12);
  border-radius: var(--r-organic);
  padding: 0.55rem 0.9rem;
  transition: border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}

.spell-item:hover {
  border-color: var(--line-strong);
  background: rgba(201, 151, 60, 0.05);
}

/* seleção de poção (radio via clique) */
.potion-item { cursor: pointer; }
.potion-item.selected {
  border-color: var(--accent-bright);
  background: rgba(201, 151, 60, 0.12);
  box-shadow: inset 0 0 0 1px var(--accent-dim);
}
.potion-item.selected .spell-name { color: var(--accent-bright); }

/* botão de travessia entre mundos (sonho/realidade — Fantasmas do Medo) */
.choice-crossworld {
  border-style: dashed;
  border-color: var(--line-strong);
  font-style: italic;
}
.choice-crossworld .choice-label { color: var(--accent-bright); }

.spell-qty-controls {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.spell-minus,
.spell-plus {
  width: 1.7em;
  height: 1.7em;
  padding: 0;
  font-size: 0.95rem;
  line-height: 1;
  font-family: var(--mono);
  color: var(--ink-dim);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 50%;
  cursor: pointer;
  transition: color var(--t-fast), border-color var(--t-fast), box-shadow var(--t-fast);
}

.spell-minus:hover,
.spell-plus:hover {
  color: var(--accent-bright);
  border-color: var(--accent);
  box-shadow: 0 0 8px var(--accent-glow);
}

.spell-qty {
  font-family: var(--mono);
  font-size: 1rem;
  color: var(--accent-bright);
  min-width: 1.3em;
  text-align: center;
}

.spell-name {
  font-variant: small-caps;
  letter-spacing: 0.06em;
  color: var(--ink);
  font-weight: 600;
}

.spell-desc {
  grid-column: 1 / -1;
  color: var(--ink-faint);
  font-size: 0.88rem;
  font-style: italic;
  line-height: 1.5;
}

.create-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem;
  justify-content: center;
  padding-top: 0.75rem;
  border-top: 1px solid var(--line);
}

/* --------------------------------------------------------------------------
   7. TELA DE JOGO — cabeçalho e layout
   -------------------------------------------------------------------------- */
#screen-game {
  display: flex;
  flex-direction: column;
}

.game-header {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 0.55rem 1rem;
  background:
    linear-gradient(180deg, rgba(28, 23, 18, 0.97), rgba(20, 16, 12, 0.94));
  border-bottom: 1px solid var(--line);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
}

.game-book-title {
  flex: 1;
  font-variant: small-caps;
  letter-spacing: 0.1em;
  font-size: 1.05rem;
  color: var(--accent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.game-header-actions {
  display: flex;
  gap: 0.4rem;
}

.game-layout {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 0;
  align-items: start;
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
}

/* --------------------------------------------------------------------------
   8. NARRATIVA
   -------------------------------------------------------------------------- */
.narrative {
  padding: clamp(1.5rem, 4vw, 3rem) clamp(1.25rem, 4vw, 3rem) 7rem;
  min-width: 0;
}

.section-text {
  max-width: 65ch;
  margin: 0 auto 2rem;
  font-size: 1.15rem;
  line-height: 1.7;
  color: var(--ink);
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.4);
}

.section-text p { margin: 0 0 1.1em; }

/* capitular de grimório na primeira linha */
.section-text > p:first-of-type::first-letter,
.section-text::first-letter {
  font-family: var(--display);
  font-size: 3.4em;
  font-weight: 700;
  float: left;
  line-height: 0.82;
  padding: 0.08em 0.12em 0 0;
  color: var(--accent-bright);
  text-shadow:
    0 2px 3px rgba(0, 0, 0, 0.7),
    0 0 18px rgba(201, 151, 60, 0.35);
}

.section-text em { color: var(--accent-bright); font-style: italic; }
.section-text strong { color: #f2e6c6; }

/* --------------------------------------------------------------------------
   9. ESCOLHAS — botões de grimório
   -------------------------------------------------------------------------- */
.choices {
  max-width: 65ch;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.choice-btn {
  display: block;
  width: 100%;
  text-align: left;
  font-family: var(--serif);
  font-size: 1.05rem;
  line-height: 1.5;
  color: var(--ink);
  padding: 0.95em 1.4em 0.95em 3em;
  cursor: pointer;
  position: relative;
  background:
    linear-gradient(170deg, rgba(51, 40, 24, 0.75), rgba(36, 29, 21, 0.9) 55%, rgba(26, 20, 14, 0.95));
  border: 1px solid transparent;
  border-radius: var(--r-organic);
  /* borda ornamentada: gradiente por trás via box-shadow em camadas */
  box-shadow:
    0 0 0 1px var(--line),
    0 0 0 4px rgba(0, 0, 0, 0.45),
    0 0 0 5px rgba(201, 151, 60, 0.12),
    0 1px 0 rgba(255, 235, 190, 0.05) inset,
    0 4px 12px rgba(0, 0, 0, 0.45);
  transition:
    transform var(--t-fast) var(--ease),
    box-shadow var(--t-med) var(--ease),
    color var(--t-fast) var(--ease),
    background var(--t-med) var(--ease);
}

/* marcador de adaga/floreio antes do texto */
.choice-btn::before {
  content: "❧";
  position: absolute;
  left: 1.05em;
  top: 50%;
  transform: translateY(-50%);
  color: var(--accent-dim);
  font-size: 1.05em;
  transition: color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}

.choice-btn:hover,
.choice-btn:focus-visible {
  color: #f6ebcc;
  transform: translateX(4px);
  box-shadow:
    0 0 0 1px var(--accent),
    0 0 0 4px rgba(0, 0, 0, 0.45),
    0 0 0 5px rgba(201, 151, 60, 0.3),
    0 1px 0 rgba(255, 235, 190, 0.08) inset,
    0 4px 16px rgba(0, 0, 0, 0.5),
    0 0 24px var(--accent-glow);
}

.choice-btn:hover::before {
  color: var(--accent-bright);
  transform: translateY(-50%) translateX(2px);
}

.choice-btn:active { transform: translateX(4px) translateY(1px); }

.choice-label { pointer-events: none; }

/* escolha bloqueada por encanto esgotado */
.choice-btn.spell-gated,
.choice-btn.spell-gated:hover {
  cursor: not-allowed;
  color: var(--ink-faint);
  filter: grayscale(0.85);
  opacity: 0.55;
  transform: none;
  background: linear-gradient(170deg, rgba(30, 28, 25, 0.8), rgba(20, 18, 16, 0.9));
  box-shadow:
    0 0 0 1px rgba(140, 130, 110, 0.2),
    0 0 0 4px rgba(0, 0, 0, 0.35),
    0 2px 6px rgba(0, 0, 0, 0.4);
}

.choice-btn.spell-gated::before {
  content: "✕";
  color: var(--ink-faint);
}

/* --------------------------------------------------------------------------
   10. COMBATE
   -------------------------------------------------------------------------- */
.combat-panel {
  max-width: 65ch;
  margin: 0 auto 2rem;
  padding: 1.4rem 1.5rem 1.6rem;
  background:
    radial-gradient(ellipse 120% 90% at 50% 0%, rgba(126, 29, 29, 0.14), transparent 60%),
    linear-gradient(170deg, #241512, #1b100d 60%, #140b09);
  border: 1px solid var(--blood);
  border-radius: var(--r-organic-lg);
  box-shadow:
    0 0 0 4px rgba(0, 0, 0, 0.4),
    0 0 0 5px rgba(126, 29, 29, 0.35),
    0 1px 0 rgba(255, 200, 180, 0.05) inset,
    0 8px 24px rgba(0, 0, 0, 0.55),
    0 0 34px rgba(126, 29, 29, 0.18);
  animation: combat-pulse 3.2s ease-in-out infinite;
}

@keyframes combat-pulse {
  0%, 100% { box-shadow:
    0 0 0 4px rgba(0, 0, 0, 0.4),
    0 0 0 5px rgba(126, 29, 29, 0.35),
    0 8px 24px rgba(0, 0, 0, 0.55),
    0 0 26px rgba(126, 29, 29, 0.14); }
  50% { box-shadow:
    0 0 0 4px rgba(0, 0, 0, 0.4),
    0 0 0 5px rgba(168, 50, 50, 0.5),
    0 8px 24px rgba(0, 0, 0, 0.55),
    0 0 42px rgba(168, 50, 50, 0.26); }
}

.combat-title {
  font-variant: small-caps;
  letter-spacing: 0.14em;
  font-size: 1.3rem;
  color: var(--blood-bright);
  text-align: center;
  text-shadow: 0 0 16px rgba(168, 50, 50, 0.5), 0 2px 3px rgba(0, 0, 0, 0.8);
  border-bottom: 1px solid rgba(126, 29, 29, 0.5);
  padding-bottom: 0.5em;
  margin-bottom: 0.9em;
}

.combat-creature {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 1rem;
  margin-bottom: 1rem;
}

.creature-name {
  font-variant: small-caps;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #eecfae;
}

.creature-stats {
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--ink-dim);
  letter-spacing: 0.03em;
}

.hp-bar {
  flex-basis: 100%;
  height: 12px;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(126, 29, 29, 0.55);
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.6) inset;
}

.hp-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--blood-deep), var(--blood) 55%, var(--blood-bright));
  box-shadow: 0 0 8px rgba(168, 50, 50, 0.6), 0 1px 0 rgba(255, 180, 160, 0.25) inset;
  border-radius: 5px;
  transition: width var(--t-slow) var(--ease);
}

.combat-round {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2.5rem;
  min-height: 64px;
  margin-bottom: 1rem;
}

.combat-log {
  max-height: 180px;
  overflow-y: auto;
  padding: 0.6rem 0.9rem;
  margin-bottom: 1rem;
  font-size: 0.92rem;
  line-height: 1.55;
  color: var(--ink-dim);
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(126, 29, 29, 0.3);
  border-radius: var(--r-organic);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.4) inset;
  list-style: none;
}

.combat-log > * {
  padding: 0.3em 0;
  border-bottom: 1px dashed rgba(201, 151, 60, 0.12);
}
.combat-log > *:last-child { border-bottom: none; }

.combat-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  justify-content: center;
}

.combat-actions .btn,
.combat-actions button {
  flex: 1 1 auto;
  min-width: 130px;
}

.btn-attack {
  font-family: var(--display);
  font-variant: small-caps;
  letter-spacing: 0.1em;
  font-size: 1.05rem;
  color: #ffd9c9;
  padding: 0.65em 1.5em;
  cursor: pointer;
  background: linear-gradient(180deg, #6b1c1c, #4a1010 60%, #380c0c);
  border: 1px solid var(--blood-bright);
  border-radius: var(--r-organic);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
  box-shadow:
    0 1px 0 rgba(255, 180, 160, 0.2) inset,
    0 -6px 12px rgba(0, 0, 0, 0.35) inset,
    0 3px 8px rgba(0, 0, 0, 0.55);
  transition: transform var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease),
    border-color var(--t-fast) var(--ease);
}

.btn-attack:hover {
  border-color: #d05a4a;
  box-shadow:
    0 1px 0 rgba(255, 180, 160, 0.3) inset,
    0 3px 10px rgba(0, 0, 0, 0.6),
    0 0 20px rgba(168, 50, 50, 0.5);
}

.btn-attack:active { transform: translateY(1px); }

.btn-luck-yes,
.btn-luck-no,
.btn-luck {
  font-family: var(--display);
  font-variant: small-caps;
  letter-spacing: 0.08em;
  color: #f3e0b0;
  padding: 0.6em 1.3em;
  cursor: pointer;
  background: linear-gradient(180deg, #4d3a17, #33270f 60%, #271d0b);
  border: 1px solid var(--accent-dim);
  border-radius: var(--r-organic);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
  box-shadow:
    0 1px 0 rgba(233, 184, 92, 0.2) inset,
    0 3px 8px rgba(0, 0, 0, 0.5);
  transition: transform var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease),
    border-color var(--t-fast) var(--ease);
}

.btn-luck-yes:hover,
.btn-luck-no:hover,
.btn-luck:hover {
  border-color: var(--accent-bright);
  box-shadow:
    0 1px 0 rgba(233, 184, 92, 0.3) inset,
    0 3px 10px rgba(0, 0, 0, 0.55),
    0 0 18px var(--accent-glow);
}

.btn-luck-yes:active,
.btn-luck-no:active,
.btn-luck:active { transform: translateY(1px); }

.btn-luck-no {
  background: linear-gradient(180deg, #3a2e17, #241d10 60%, #1a150c);
  color: var(--ink-dim);
}

.btn-flee {
  font-family: var(--display);
  font-variant: small-caps;
  letter-spacing: 0.08em;
  color: #a9a294;
  padding: 0.6em 1.3em;
  cursor: pointer;
  background: linear-gradient(180deg, #2c2a26, #1e1c19 60%, #17150f);
  border: 1px solid rgba(160, 150, 130, 0.3);
  border-radius: var(--r-organic);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.45);
  transition: transform var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease),
    border-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}

.btn-flee:hover {
  color: #d8d0be;
  border-color: rgba(200, 190, 165, 0.5);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.55);
}

.btn-flee:active { transform: translateY(1px); }

/* --------------------------------------------------------------------------
   11. TESTE DE SORTE E NÚMERO SECRETO
   -------------------------------------------------------------------------- */
.luck-panel {
  max-width: 65ch;
  margin: 0 auto 2rem;
  padding: 1.1rem 1.3rem;
  text-align: center;
  background: linear-gradient(170deg, rgba(61, 47, 26, 0.5), rgba(34, 27, 16, 0.7));
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-organic-lg);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
}

.luck-result {
  display: block;
  margin-top: 0.8em;
  font-variant: small-caps;
  letter-spacing: 0.1em;
  font-size: 1.15rem;
  color: var(--accent-bright);
  text-shadow: 0 0 14px var(--accent-glow);
}

.number-input-panel {
  max-width: 65ch;
  margin: 0 auto 2rem;
  padding: 1.2rem 1.4rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.8rem;
  background: linear-gradient(170deg, var(--parchment), #1e1811);
  border: 1px solid var(--line);
  border-radius: var(--r-organic-lg);
  box-shadow: var(--shadow-panel);
}

.number-input-label {
  font-variant: small-caps;
  letter-spacing: 0.08em;
  color: var(--ink-dim);
}

.secret-number {
  width: 6.5em;
  font-family: var(--mono);
  font-size: 1.15rem;
  text-align: center;
  letter-spacing: 0.15em;
  color: var(--accent-bright);
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-organic);
  padding: 0.4em 0.5em;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5) inset;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}

.secret-number::placeholder { color: var(--ink-faint); }

.secret-number:focus {
  border-color: var(--accent);
  box-shadow:
    0 2px 8px rgba(0, 0, 0, 0.5) inset,
    0 0 12px var(--accent-glow);
}

/* remove spinners do input numérico */
.secret-number::-webkit-outer-spin-button,
.secret-number::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.secret-number { -moz-appearance: textfield; appearance: textfield; }

.number-feedback {
  flex-basis: 100%;
  margin: 0;
  min-height: 1.2em;
}

/* --------------------------------------------------------------------------
   12. FICHA DO PERSONAGEM (sheet)
   -------------------------------------------------------------------------- */
.sheet {
  position: sticky;
  top: 3.4rem;
  align-self: start;
  max-height: calc(100vh - 3.4rem);
  overflow-y: auto;
  padding: 1.4rem 1.3rem 2rem;
  background:
    repeating-linear-gradient(3deg,
      transparent 0, transparent 34px,
      rgba(201, 151, 60, 0.04) 34px, rgba(201, 151, 60, 0.04) 35px),
    linear-gradient(172deg, var(--parchment-2) 0%, var(--parchment) 45%, #201910 100%);
  border-left: 1px solid var(--line);
  box-shadow:
    -8px 0 24px rgba(0, 0, 0, 0.45),
    0 1px 0 rgba(255, 235, 190, 0.04) inset;
}

.sheet .panel-heading {
  font-size: 1.25rem;
  justify-content: center;
  text-align: center;
}

.sheet .panel-heading::after { display: none; }

.sheet > .panel-heading {
  border-bottom: 2px solid transparent;
  border-image: linear-gradient(90deg, transparent, var(--accent-dim), transparent) 1;
  padding-bottom: 0.5em;
  margin-bottom: 1em;
}

.stat-block {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  margin-bottom: 1.4rem;
}

.stat-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  grid-template-areas:
    "name value adjust"
    "bar  bar   bar";
  align-items: center;
  gap: 0.25rem 0.6rem;
  padding: 0.55rem 0.7rem 0.65rem;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid rgba(201, 151, 60, 0.1);
  border-radius: var(--r-organic);
  transition: border-color var(--t-med) var(--ease);
}

.stat-name {
  grid-area: name;
  font-variant: small-caps;
  letter-spacing: 0.14em;
  font-size: 0.88rem;
  color: var(--ink-dim);
}

.stat-value {
  grid-area: value;
  font-family: var(--display);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--ink);
  min-width: 2.2em;
  text-align: right;
}

.stat-bar {
  grid-area: bar;
  height: 9px;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(0, 0, 0, 0.7);
  border-radius: 5px;
  overflow: hidden;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.55) inset;
}

.stat-fill {
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--vigor-ok), var(--vigor-ok-2));
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.18) inset;
  transition: width var(--t-slow) var(--ease), background var(--t-slow) var(--ease);
}

/* o JS seta data-level na .stat-row conforme a ENERGIA esvazia */
.stat-row[data-level="ok"] .stat-fill {
  background: linear-gradient(90deg, var(--vigor-ok), var(--vigor-ok-2));
}

.stat-row[data-level="warn"] .stat-fill {
  background: linear-gradient(90deg, var(--vigor-warn), var(--vigor-warn-2));
}

.stat-row[data-level="warn"] { border-color: rgba(212, 169, 74, 0.3); }

.stat-row[data-level="danger"] .stat-fill {
  background: linear-gradient(90deg, var(--vigor-danger), var(--vigor-danger-2));
  box-shadow: 0 0 8px rgba(192, 74, 58, 0.6);
}

.stat-row[data-level="danger"] {
  border-color: rgba(168, 50, 50, 0.45);
  animation: danger-breath 1.8s ease-in-out infinite;
}

@keyframes danger-breath {
  0%, 100% { box-shadow: 0 0 0 rgba(168, 50, 50, 0); }
  50%      { box-shadow: 0 0 14px rgba(168, 50, 50, 0.25); }
}

.stat-adjust {
  grid-area: adjust;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.stat-minus,
.stat-plus {
  width: 1.55em;
  height: 1.55em;
  padding: 0;
  font-size: 0.9rem;
  line-height: 1;
  font-family: var(--mono);
  color: var(--ink-faint);
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(201, 151, 60, 0.2);
  border-radius: 50%;
  cursor: pointer;
  transition: color var(--t-fast), border-color var(--t-fast),
    background var(--t-fast), box-shadow var(--t-fast);
}

.stat-minus:hover,
.stat-plus:hover {
  color: var(--accent-bright);
  border-color: var(--accent);
  background: rgba(201, 151, 60, 0.1);
  box-shadow: 0 0 8px var(--accent-glow);
}

.stat-minus:active,
.stat-plus:active { transform: translateY(1px); }

/* -------- seções da ficha -------- */
.sheet-section {
  margin-bottom: 1.3rem;
  padding-top: 0.9rem;
  border-top: 1px dashed rgba(201, 151, 60, 0.18);
}

.sheet-heading {
  font-variant: small-caps;
  letter-spacing: 0.14em;
  font-size: 0.95rem;
  color: var(--accent);
  margin-bottom: 0.6em;
}

.sheet-spells,
.sheet-inventory {
  list-style: none;
  margin: 0 0 0.6rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.sheet-spell,
.sheet-inventory li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.92rem;
  color: var(--ink-dim);
  padding: 0.32em 0.55em;
  background: rgba(0, 0, 0, 0.18);
  border-radius: 4px 5px 4px 5px;
  border: 1px solid rgba(201, 151, 60, 0.07);
}

.sheet-spell .spell-name {
  flex: 1;
  font-size: 0.92rem;
  font-weight: 400;
  color: var(--ink-dim);
}

.spell-count {
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--accent-bright);
  background: rgba(201, 151, 60, 0.12);
  border: 1px solid rgba(201, 151, 60, 0.25);
  border-radius: 999px;
  padding: 0 0.55em;
  line-height: 1.5;
}

.btn-cast {
  font-family: var(--display);
  font-size: 0.78rem;
  font-variant: small-caps;
  letter-spacing: 0.08em;
  color: var(--accent-bright);
  background: rgba(201, 151, 60, 0.08);
  border: 1px solid rgba(201, 151, 60, 0.3);
  border-radius: 4px;
  padding: 0.15em 0.6em;
  cursor: pointer;
  transition: background var(--t-fast), box-shadow var(--t-fast), border-color var(--t-fast);
}

.btn-cast:hover {
  background: rgba(201, 151, 60, 0.18);
  border-color: var(--accent);
  box-shadow: 0 0 10px var(--accent-glow);
}

.btn-cast:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
}

.inventory-add {
  display: flex;
  gap: 0.45rem;
  margin-bottom: 0.8rem;
}

.inventory-input {
  flex: 1;
  min-width: 0;
  font-family: var(--serif);
  font-size: 0.9rem;
  color: var(--ink);
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(201, 151, 60, 0.18);
  border-radius: var(--r-organic);
  padding: 0.4em 0.7em;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}

.inventory-input::placeholder { color: var(--ink-faint); font-style: italic; }

.inventory-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 10px var(--accent-glow);
}

.gold-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.5rem 0.7rem;
  background:
    linear-gradient(170deg, rgba(201, 151, 60, 0.1), rgba(201, 151, 60, 0.03));
  border: 1px solid rgba(201, 151, 60, 0.25);
  border-radius: var(--r-organic);
}

.gold-label {
  font-variant: small-caps;
  letter-spacing: 0.08em;
  font-size: 0.9rem;
  color: var(--accent);
}

.gold-value {
  font-family: var(--display);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--accent-bright);
  min-width: 1.8em;
  text-align: center;
  text-shadow: 0 0 10px rgba(201, 151, 60, 0.35);
}

/* -------- diário -------- */
.event-log {
  max-height: 220px;
  overflow-y: auto;
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--ink-faint);
  padding: 0.5rem 0.7rem;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(201, 151, 60, 0.08);
  border-radius: var(--r-organic);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.35) inset;
}

.log-entry {
  padding: 0.35em 0;
  border-bottom: 1px solid rgba(201, 151, 60, 0.08);
}

.log-entry:last-child { border-bottom: none; }

.log-entry:first-child { color: var(--ink-dim); }

/* --------------------------------------------------------------------------
   13. DADOS
   -------------------------------------------------------------------------- */
.dice-tray {
  position: fixed;
  left: 50%;
  bottom: 1.6rem;
  transform: translateX(-50%);
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.2rem;
  padding: 1.1rem 1.8rem;
  background:
    radial-gradient(ellipse 110% 130% at 50% 0%, rgba(60, 90, 60, 0.1), transparent 55%),
    repeating-linear-gradient(50deg,
      transparent 0, transparent 3px,
      rgba(255, 255, 255, 0.012) 3px, rgba(255, 255, 255, 0.012) 4px),
    linear-gradient(180deg, #17140f, var(--felt) 60%, #0b0a08);
  border: 1px solid var(--line);
  border-radius: 16px 18px 15px 17px;
  box-shadow:
    0 0 0 4px rgba(0, 0, 0, 0.5),
    0 0 0 5px rgba(201, 151, 60, 0.22),
    0 6px 14px rgba(0, 0, 0, 0.45) inset,
    0 14px 40px rgba(0, 0, 0, 0.7);
  animation: tray-in var(--t-slow) var(--ease) both;
}

@keyframes tray-in {
  from { opacity: 0; transform: translateX(-50%) translateY(24px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.die {
  width: 56px;
  height: 56px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  padding: 7px;
  background:
    radial-gradient(circle at 30% 25%, #fffdf4, #f0e8d2 55%, #d8ccae 100%);
  border-radius: 11px 12px 10px 12px;
  border: 1px solid #b7a985;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.85) inset,
    0 -4px 8px rgba(120, 100, 60, 0.35) inset,
    0 4px 6px rgba(0, 0, 0, 0.5),
    0 10px 20px rgba(0, 0, 0, 0.55);
  transform: rotate(-2.5deg);
}

.die + .die { transform: rotate(3deg); }

.pip {
  width: 10px;
  height: 10px;
  align-self: center;
  justify-self: center;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #4a4137, #17130e 75%);
  box-shadow:
    0 1px 1px rgba(255, 255, 255, 0.55),
    0 1px 2px rgba(0, 0, 0, 0.4) inset;
}

/* posicionamento dos pips por face (o JS cria N divs .pip) */
.die[data-face="1"] .pip:nth-child(1) { grid-area: 2 / 2; }

.die[data-face="2"] .pip:nth-child(1) { grid-area: 1 / 1; }
.die[data-face="2"] .pip:nth-child(2) { grid-area: 3 / 3; }

.die[data-face="3"] .pip:nth-child(1) { grid-area: 1 / 1; }
.die[data-face="3"] .pip:nth-child(2) { grid-area: 2 / 2; }
.die[data-face="3"] .pip:nth-child(3) { grid-area: 3 / 3; }

.die[data-face="4"] .pip:nth-child(1) { grid-area: 1 / 1; }
.die[data-face="4"] .pip:nth-child(2) { grid-area: 1 / 3; }
.die[data-face="4"] .pip:nth-child(3) { grid-area: 3 / 1; }
.die[data-face="4"] .pip:nth-child(4) { grid-area: 3 / 3; }

.die[data-face="5"] .pip:nth-child(1) { grid-area: 1 / 1; }
.die[data-face="5"] .pip:nth-child(2) { grid-area: 1 / 3; }
.die[data-face="5"] .pip:nth-child(3) { grid-area: 2 / 2; }
.die[data-face="5"] .pip:nth-child(4) { grid-area: 3 / 1; }
.die[data-face="5"] .pip:nth-child(5) { grid-area: 3 / 3; }

.die[data-face="6"] .pip:nth-child(1) { grid-area: 1 / 1; }
.die[data-face="6"] .pip:nth-child(2) { grid-area: 1 / 3; }
.die[data-face="6"] .pip:nth-child(3) { grid-area: 2 / 1; }
.die[data-face="6"] .pip:nth-child(4) { grid-area: 2 / 3; }
.die[data-face="6"] .pip:nth-child(5) { grid-area: 3 / 1; }
.die[data-face="6"] .pip:nth-child(6) { grid-area: 3 / 3; }

/* animação de rolagem (o JS aplica/remova a classe .rolling) */
.die.rolling {
  animation: die-roll 0.6s cubic-bezier(0.2, 0.7, 0.35, 1) both;
}

.die.rolling .pip { opacity: 0; }

@keyframes die-roll {
  0%   { transform: translateY(-34px) rotate(-160deg) scale(0.82); }
  30%  { transform: translateY(6px)  rotate(-45deg)  scale(1.06); }
  55%  { transform: translateY(-10px) rotate(30deg)  scale(0.97); }
  75%  { transform: translateY(3px)  rotate(-8deg)   scale(1.02); }
  100% { transform: translateY(0)    rotate(-2.5deg) scale(1); }
}

/* dados menores dentro dos slots de criação/combate */
.dice-slot .die {
  width: 44px;
  height: 44px;
  padding: 6px;
}

.dice-slot .pip { width: 8px; height: 8px; }

/* --------------------------------------------------------------------------
   14. TOASTS
   -------------------------------------------------------------------------- */
.toast-zone {
  position: fixed;
  top: 4.2rem;
  right: 1.2rem;
  z-index: 90;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.55rem;
  pointer-events: none;
  max-width: min(340px, calc(100vw - 2rem));
}

.toast {
  font-family: var(--display);
  font-size: 0.95rem;
  letter-spacing: 0.03em;
  color: var(--ink);
  padding: 0.65em 1.1em;
  background: linear-gradient(170deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line-strong);
  border-left-width: 3px;
  border-radius: var(--r-organic);
  box-shadow:
    0 1px 0 rgba(255, 235, 190, 0.06) inset,
    0 6px 18px rgba(0, 0, 0, 0.6);
  animation: toast-life 3.4s var(--ease) forwards;
}

@keyframes toast-life {
  0%   { opacity: 0; transform: translateX(110%); }
  9%   { opacity: 1; transform: translateX(0); }
  84%  { opacity: 1; transform: translateX(0); }
  100% { opacity: 0; transform: translateX(30%); }
}

.toast-damage {
  border-left-color: var(--blood-bright);
  color: #f4c9bc;
  box-shadow:
    0 1px 0 rgba(255, 200, 180, 0.06) inset,
    0 6px 18px rgba(0, 0, 0, 0.6),
    0 0 16px rgba(126, 29, 29, 0.35);
}

.toast-heal {
  border-left-color: var(--vigor-ok-2);
  color: #cfe3b8;
  box-shadow:
    0 1px 0 rgba(220, 255, 190, 0.06) inset,
    0 6px 18px rgba(0, 0, 0, 0.6),
    0 0 16px rgba(78, 125, 58, 0.3);
}

.toast-info {
  border-left-color: var(--accent);
  color: var(--ink);
}

.toast-item {
  border-left-color: var(--accent-bright);
  color: #f0dfae;
  box-shadow:
    0 1px 0 rgba(233, 184, 92, 0.1) inset,
    0 6px 18px rgba(0, 0, 0, 0.6),
    0 0 16px var(--accent-glow);
}

/* --------------------------------------------------------------------------
   15. OVERLAYS — morte, vitória, saves
   -------------------------------------------------------------------------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background:
    radial-gradient(ellipse 90% 90% at 50% 50%, rgba(10, 8, 6, 0.82), rgba(5, 4, 3, 0.96));
  backdrop-filter: blur(3px);
  animation: overlay-in 500ms var(--ease) both;
}

@keyframes overlay-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.overlay-panel {
  width: min(560px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  text-align: center;
  padding: clamp(1.8rem, 5vw, 3rem);
  background: linear-gradient(168deg, var(--parchment-2), var(--parchment) 45%, #1d160e);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-organic-lg);
  box-shadow:
    0 0 0 5px rgba(0, 0, 0, 0.5),
    0 0 0 6px rgba(201, 151, 60, 0.2),
    var(--shadow-raise);
  animation: panel-in 550ms var(--ease) both;
}

@keyframes panel-in {
  from { opacity: 0; transform: translateY(20px) scale(0.97); }
  to   { opacity: 1; transform: none; }
}

.overlay-panel .btn { margin: 0.35rem 0.3rem 0; }

/* -------- morte: vinheta sangrenta -------- */
#screen-death {
  background:
    radial-gradient(ellipse 120% 120% at 50% 120%, rgba(126, 29, 29, 0.35), transparent 55%),
    radial-gradient(ellipse 90% 90% at 50% 50%, rgba(12, 6, 5, 0.85), rgba(6, 3, 2, 0.97));
}

.death-panel {
  border-color: var(--blood);
  box-shadow:
    0 0 0 5px rgba(0, 0, 0, 0.5),
    0 0 0 6px rgba(126, 29, 29, 0.4),
    0 0 60px rgba(126, 29, 29, 0.25),
    var(--shadow-raise);
}

.death-title {
  font-variant: small-caps;
  letter-spacing: 0.1em;
  font-size: clamp(1.7rem, 5vw, 2.4rem);
  color: var(--blood-bright);
  text-shadow:
    0 2px 4px rgba(0, 0, 0, 0.85),
    0 0 30px rgba(168, 50, 50, 0.55);
  margin-bottom: 0.7em;
}

.death-text {
  color: var(--ink-dim);
  font-style: italic;
  font-size: 1.05rem;
  line-height: 1.7;
  margin-bottom: 1.8em;
}

/* -------- vitória: dourado radiante -------- */
#screen-victory {
  background:
    radial-gradient(ellipse 100% 80% at 50% -20%, rgba(201, 151, 60, 0.22), transparent 55%),
    radial-gradient(ellipse 90% 90% at 50% 50%, rgba(10, 8, 5, 0.85), rgba(5, 4, 2, 0.96));
}

.victory-panel {
  border-color: var(--accent);
  box-shadow:
    0 0 0 5px rgba(0, 0, 0, 0.5),
    0 0 0 6px rgba(201, 151, 60, 0.45),
    0 0 70px rgba(201, 151, 60, 0.3),
    var(--shadow-raise);
}

.victory-title {
  font-variant: small-caps;
  letter-spacing: 0.1em;
  font-size: clamp(1.7rem, 5vw, 2.4rem);
  color: transparent;
  background: linear-gradient(180deg, #fdf0c8, var(--accent-bright) 55%, var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  text-shadow: 0 0 34px rgba(233, 184, 92, 0.4);
  margin-bottom: 0.7em;
}

.victory-text {
  color: var(--ink-dim);
  font-style: italic;
  font-size: 1.05rem;
  line-height: 1.7;
  margin-bottom: 1.8em;
}

/* -------- saves -------- */
.saves-panel { text-align: left; }

.saves-panel .panel-heading { justify-content: center; }
.saves-panel .panel-heading::after { display: none; }

.save-slots {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin: 1rem 0 1.2rem;
}

.save-slot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.7rem 0.9rem;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(201, 151, 60, 0.14);
  border-radius: var(--r-organic);
  transition: border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}

.save-slot:hover {
  border-color: var(--line-strong);
  background: rgba(201, 151, 60, 0.05);
}

.save-slot-info {
  font-size: 0.92rem;
  color: var(--ink-dim);
  line-height: 1.45;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.save-slot-actions {
  display: flex;
  gap: 0.4rem;
  flex-shrink: 0;
}

.btn-save,
.btn-load,
.btn-del {
  font-family: var(--display);
  font-size: 0.82rem;
  font-variant: small-caps;
  letter-spacing: 0.06em;
  padding: 0.3em 0.85em;
  cursor: pointer;
  border-radius: 4px 5px 4px 5px;
  border: 1px solid;
  background: rgba(0, 0, 0, 0.25);
  transition: background var(--t-fast), box-shadow var(--t-fast), color var(--t-fast);
}

.btn-save {
  color: var(--accent-bright);
  border-color: rgba(201, 151, 60, 0.4);
}

.btn-save:hover {
  background: rgba(201, 151, 60, 0.14);
  box-shadow: 0 0 10px var(--accent-glow);
}

.btn-load {
  color: #b7cf9a;
  border-color: rgba(121, 164, 79, 0.4);
}

.btn-load:hover {
  background: rgba(121, 164, 79, 0.12);
  box-shadow: 0 0 10px rgba(121, 164, 79, 0.3);
}

.btn-del {
  color: #d09585;
  border-color: rgba(168, 50, 50, 0.4);
}

.btn-del:hover {
  background: rgba(168, 50, 50, 0.14);
  box-shadow: 0 0 10px rgba(168, 50, 50, 0.3);
}

.saves-io {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  justify-content: center;
  margin-bottom: 1.1rem;
  padding-top: 0.9rem;
  border-top: 1px dashed var(--line);
}

#btn-saves-close { display: block; margin: 0 auto; min-width: 40%; }

/* --------------------------------------------------------------------------
   16. SCROLLBARS
   -------------------------------------------------------------------------- */
.scroll-box,
.combat-log,
.event-log,
.spell-list,
.sheet,
.overlay-panel {
  scrollbar-width: thin;
  scrollbar-color: var(--accent-dim) transparent;
}

.scroll-box::-webkit-scrollbar,
.combat-log::-webkit-scrollbar,
.event-log::-webkit-scrollbar,
.spell-list::-webkit-scrollbar,
.sheet::-webkit-scrollbar,
.overlay-panel::-webkit-scrollbar {
  width: 9px;
}

.scroll-box::-webkit-scrollbar-track,
.combat-log::-webkit-scrollbar-track,
.event-log::-webkit-scrollbar-track,
.spell-list::-webkit-scrollbar-track,
.sheet::-webkit-scrollbar-track,
.overlay-panel::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.25);
  border-radius: 6px;
}

.scroll-box::-webkit-scrollbar-thumb,
.combat-log::-webkit-scrollbar-thumb,
.event-log::-webkit-scrollbar-thumb,
.spell-list::-webkit-scrollbar-thumb,
.sheet::-webkit-scrollbar-thumb,
.overlay-panel::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--accent-dim), #5e451a);
  border-radius: 6px;
  border: 2px solid rgba(0, 0, 0, 0.4);
}

.scroll-box::-webkit-scrollbar-thumb:hover,
.combat-log::-webkit-scrollbar-thumb:hover,
.event-log::-webkit-scrollbar-thumb:hover,
.spell-list::-webkit-scrollbar-thumb:hover,
.sheet::-webkit-scrollbar-thumb:hover,
.overlay-panel::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}

/* --------------------------------------------------------------------------
   17. RESPONSIVO
   -------------------------------------------------------------------------- */
@media (max-width: 900px) {
  .only-mobile { display: inline-flex; }

  .game-layout {
    grid-template-columns: 1fr;
  }

  .narrative {
    padding-bottom: 9rem;
  }

  /* ficha vira drawer deslizante da direita (o JS alterna .open) */
  .sheet {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 80;
    width: min(340px, 88vw);
    max-height: none;
    height: 100%;
    border-left: 1px solid var(--line-strong);
    transform: translateX(105%);
    transition: transform var(--t-med) var(--ease);
    box-shadow:
      -14px 0 44px rgba(0, 0, 0, 0.7),
      0 1px 0 rgba(255, 235, 190, 0.04) inset;
  }

  .sheet.open {
    transform: translateX(0);
  }

  /* alvos de toque maiores */
  .btn { padding: 0.7em 1.4em; }
  .btn-icon { min-width: 2.7em; padding: 0.5em 0.65em; }

  .choice-btn {
    font-size: 1.08rem;
    padding: 1.1em 1.3em 1.1em 3em;
  }

  .stat-minus, .stat-plus { width: 2em; height: 2em; font-size: 1rem; }
  .spell-minus, .spell-plus { width: 2em; height: 2em; font-size: 1.05rem; }

  .section-text { font-size: 1.08rem; }

  .dice-tray {
    bottom: 1rem;
    padding: 0.9rem 1.3rem;
    gap: 0.9rem;
    max-width: calc(100vw - 1.5rem);
  }

  .toast-zone { top: 3.8rem; right: 0.75rem; }

  .combat-actions .btn,
  .combat-actions button {
    flex-basis: 100%;
  }

  .number-input-panel { flex-direction: column; align-items: stretch; text-align: center; }
  .secret-number { width: 100%; }
}

@media (max-width: 480px) {
  .create-panel { padding: 1.25rem 1rem; }
  .brand-title { letter-spacing: 0.08em; }
  .die { width: 50px; height: 50px; }
  /* menos ornamento de fundo atrás dos cartões em telas pequenas */
  .atmosphere-circle { opacity: .3; }
  .atmosphere-shelf { height: 10vh; min-height: 60px; }
}

/* --------------------------------------------------------------------------
   MAPA DA JORNADA (automapa)
   -------------------------------------------------------------------------- */
.map-panel {
  max-width: min(86vw, 900px);
  width: 100%;
}

.map-hint { margin-bottom: 0.8rem; }

.map-canvas {
  max-height: 62vh;
  overflow: auto;
  background:
    radial-gradient(ellipse at 30% 20%, rgba(201, 151, 60, 0.05), transparent 60%),
    var(--felt);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 18px;
  margin-bottom: 1rem;
}

.map-edge {
  stroke: var(--line-strong);
  stroke-width: 3;
  stroke-dasharray: 5 4;
}

.map-node rect {
  fill: var(--parchment);
  stroke: var(--line-strong);
  stroke-width: 1.5;
}

.map-node text {
  fill: var(--ink-dim);
  font-family: var(--serif);
  font-size: 11px;
  text-anchor: middle;
}

.map-node-current rect {
  fill: var(--accent-dim);
  stroke: var(--accent-bright);
  stroke-width: 2.5;
  filter: drop-shadow(0 0 8px var(--accent-glow));
}

.map-node-current circle {
  fill: var(--accent-bright);
}

.map-node-current text {
  fill: var(--accent-bright);
}

/* --------------------------------------------------------------------------
   18. MOVIMENTO REDUZIDO
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .toast {
    /* mantém visível; sem animação o estado final (opacity 0) apagaria o toast */
    animation: none;
    opacity: 1;
    transform: none;
  }

  .screen, .dice-tray, .overlay, .overlay-panel {
    animation: none;
    opacity: 1;
    transform: none;
  }

  .dice-tray { transform: translateX(-50%); }
  .sheet { transition: none; }
}
