@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@600;700&display=swap');

:root {
  --bg: #120d0a;
  --panel: #1d1510;
  --panel-alt: #26190f;
  --border: #4a3524;
  --text: #ecdfc8;
  --muted: #a8927a;
  --blood: #8b1e1e;
  --blood-bright: #d4302f;
  --gold: #c9a227;
  --hp-good: #4a8f4a;
  --hp-bad: #b23a3a;
  --marked: #4ea8de;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at top, #1a120c 0%, var(--bg) 70%);
  color: var(--text);
  font-family: 'Georgia', 'Times New Roman', serif;
  display: flex;
  justify-content: center;
  position: relative;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at 50% 0%, rgba(201, 162, 39, 0.07), transparent 55%);
  animation: torch-flicker 5s ease-in-out infinite;
  z-index: 0;
}

@keyframes torch-flicker {
  0%, 100% { opacity: 1; }
  45% { opacity: 0.85; }
  50% { opacity: 1; }
  72% { opacity: 0.92; }
}

#app {
  width: 100%;
  max-width: 720px;
  padding: 24px 16px 60px;
  position: relative;
  z-index: 1;
}

#app.has-topbar {
  padding-top: 82px;
}

.top-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px 20px;
  flex-wrap: wrap;
  padding: 8px 16px;
  background: rgba(15, 11, 8, 0.96);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.top-bar.hidden {
  display: none;
}

.top-bar-resources {
  display: flex;
  gap: 16px;
  font-size: 0.95rem;
  flex-shrink: 0;
}

.top-bar-resources .gold,
.top-bar-resources .blood-currency {
  font-size: inherit;
}

.topbar-drink {
  font-size: inherit;
  padding: 2px 8px;
  border-radius: 20px;
  background: rgba(201, 162, 39, 0.12);
  border: 1px solid var(--gold);
  color: var(--gold);
}

.topbar-drink.debuff {
  background: rgba(212, 48, 47, 0.12);
  border-color: var(--blood-bright);
  color: var(--blood-bright);
}

.top-bar-nav,
.top-bar-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.top-bar button {
  padding: 6px 12px;
  font-size: 0.82rem;
}

.top-bar-actions button {
  border-color: var(--muted);
}

h1, h2, h3, h4 {
  font-family: 'Cinzel', 'Georgia', serif;
  color: var(--gold);
  letter-spacing: 0.5px;
  margin: 0 0 8px;
}

h1 {
  text-align: center;
  font-size: 2.2rem;
  text-shadow: 0 0 12px rgba(201, 162, 39, 0.4);
}

.subtitle {
  text-align: center;
  color: var(--muted);
  margin-bottom: 32px;
}

.screen {
  display: none;
}

.screen.active {
  display: block;
  animation: fadeIn 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px) scale(0.99); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

button {
  font-family: inherit;
  background: linear-gradient(180deg, #3a2417, #2a190e);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 10px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.95rem;
  position: relative;
  overflow: hidden;
  transition: border-color 0.15s, transform 0.1s, box-shadow 0.15s;
}

button::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(115deg, transparent 40%, rgba(201, 162, 39, 0.25) 50%, transparent 60%);
  transform: translateX(-100%);
  transition: transform 0.5s ease;
  pointer-events: none;
}

button:hover:not(:disabled)::before {
  transform: translateX(100%);
}

button:hover:not(:disabled) {
  border-color: var(--gold);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}

button:active:not(:disabled) {
  transform: translateY(0) scale(0.97);
}

button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.menu-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 300px;
  margin: 0 auto;
}

.load-form {
  max-width: 400px;
  margin: 24px auto 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.load-form.hidden,
.hidden {
  display: none !important;
}

textarea {
  font-family: monospace;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px;
  width: 100%;
  min-height: 70px;
  resize: vertical;
}

.error {
  color: var(--blood-bright);
  min-height: 1.2em;
  font-size: 0.9rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 16px;
}

.stats-grid.small {
  grid-template-columns: repeat(2, 1fr);
  font-size: 0.85rem;
}

.stat strong {
  color: var(--gold);
}

.muted {
  color: var(--muted);
}

.muted.small {
  font-size: 0.8rem;
  margin: 2px 0 0;
}

.gold {
  font-size: 1.1rem;
}

.blood-currency {
  font-size: 1.1rem;
  color: var(--blood-bright);
}

.currency-row {
  display: flex;
  gap: 24px;
  margin: 8px 0 18px;
}

.bonus-list {
  list-style: none;
  padding: 0;
  margin: 0 0 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.bonus-list li {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 0.9rem;
}

.weapon-name {
  text-align: center;
  color: var(--gold);
  margin: 0 0 4px;
}

.flee-button {
  display: block;
  margin: 16px auto 0;
  border-color: var(--blood-bright);
  color: var(--blood-bright);
}

.flee-button:hover {
  border-color: var(--blood-bright);
  background: rgba(212, 48, 47, 0.15);
}

.buff-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}

.buff-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.buff-card-icon {
  font-size: 1.6rem;
}

.buff-card-body p {
  margin: 2px 0 0;
}

.buff-card.equipped {
  border-color: var(--gold);
  box-shadow: 0 0 10px rgba(201, 162, 39, 0.3);
}

.buff-card.locked {
  opacity: 0.6;
}

.buff-card button {
  align-self: flex-start;
}

.dice-shop-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 8px 0 20px;
}

.dice-shop-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 12px;
  background: var(--panel);
  width: auto;
}

.dice-shop-card .die-face {
  width: 48px;
  height: 48px;
  pointer-events: none;
}

.dice-shop-cost {
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
}

/* --- Slots equipados + Armazém (loja): arrastar e soltar pra equipar --- */

.dice-section-title {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 18px 0 8px;
  color: var(--text);
}

.dice-section-count {
  font-size: 0.8rem;
  font-weight: normal;
  color: var(--muted);
}

.dice-slots-grid,
.dice-storage-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  min-height: 74px;
  transition: border-color 0.15s, background 0.15s;
}

.die-face {
  width: 54px;
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, #3a2417, #1c120a);
  border: 2px solid var(--die-color, var(--border));
  border-radius: 8px;
  font-weight: bold;
  color: var(--die-color, var(--gold));
  font-size: 0.95rem;
  position: relative;
}

.die-buff-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  font-size: 0.75rem;
  filter: drop-shadow(0 0 3px rgba(201, 162, 39, 0.9));
}

.die-tree-badge {
  position: absolute;
  top: -6px;
  left: -6px;
  font-size: 0.7rem;
  filter: drop-shadow(0 0 2px rgba(74, 143, 74, 0.8));
}

.dice-slot {
  border-radius: 8px;
  transition: transform 0.15s, filter 0.15s;
  position: relative;
}

.dice-slot.equipped,
.dice-storage-item {
  position: relative;
}

.die-detail-btn {
  position: absolute;
  bottom: -6px;
  right: -6px;
  width: 20px;
  height: 20px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  line-height: 1;
  border-radius: 50%;
  background: var(--panel-alt);
  opacity: 0;
  transition: opacity 0.15s, transform 0.15s;
}

.dice-slot.equipped:hover .die-detail-btn,
.dice-storage-item:hover .die-detail-btn {
  opacity: 1;
}

.die-detail-btn:hover {
  transform: scale(1.15);
}


.dice-slot.equipped,
.dice-storage-item {
  cursor: grab;
}

.dice-slot.equipped:hover .die-face,
.dice-storage-item:hover .die-face {
  border-color: var(--gold);
  box-shadow: 0 0 8px rgba(201, 162, 39, 0.4);
  transform: translateY(-2px);
}

.dice-slot.empty {
  width: 54px;
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px dashed var(--border);
  border-radius: 8px;
  color: var(--muted);
}

.dice-slot-plus {
  font-size: 1.3rem;
  opacity: 0.5;
}

.dice-storage-empty {
  padding: 6px 4px;
}

.dragging {
  opacity: 0.35;
}

[data-drop-zone].drag-over {
  border-color: var(--gold);
  background: rgba(201, 162, 39, 0.08);
}

.dice-slot.empty[data-drop-zone].drag-over,
.dice-slot.equipped[data-drop-zone].drag-over .die-face {
  border-color: var(--gold);
  box-shadow: 0 0 10px rgba(201, 162, 39, 0.55);
}

.hub-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.dungeon-map {
  overflow-x: auto;
  margin-bottom: 24px;
}

.dungeon-map-svg {
  display: block;
  width: 100%;
  min-width: 560px;
  max-width: 720px;
  height: auto;
  margin: 0 auto;
}

.map-path {
  stroke: var(--border);
  stroke-width: 3;
  stroke-dasharray: 7 9;
}

.map-node {
  cursor: pointer;
}

.map-node-circle {
  fill: var(--panel);
  stroke: var(--gold);
  stroke-width: 2;
  transform-box: fill-box;
  transform-origin: center;
  transition: transform 0.15s, stroke 0.15s;
}

.map-node:hover .map-node-circle {
  stroke: var(--blood-bright);
  transform: scale(1.12);
}

.map-node-icon {
  font-size: 22px;
  pointer-events: none;
}

.map-node-label {
  font-size: 10px;
  fill: var(--muted);
  pointer-events: none;
}

.dungeon-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 24px;
}

.dungeon-card {
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s;
}

.dungeon-card:hover {
  border-color: var(--gold);
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}

.dungeon-card p {
  margin: 4px 0;
}

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

.dungeon-card,
.forge-item,
.dice-shop-card,
.dice-slot,
.dice-storage-item,
.bonus-list li {
  animation: fadeInUp 0.35s ease both;
}

.dungeon-list .dungeon-card:nth-child(1) { animation-delay: 0.03s; }
.dungeon-list .dungeon-card:nth-child(2) { animation-delay: 0.09s; }
/* .forge-item e .dice-shop-card usam animation-delay inline (por índice), definido em ui.js */
.bonus-list li:nth-child(1) { animation-delay: 0.02s; }
.bonus-list li:nth-child(2) { animation-delay: 0.06s; }
.bonus-list li:nth-child(3) { animation-delay: 0.10s; }
.bonus-list li:nth-child(4) { animation-delay: 0.14s; }
.bonus-list li:nth-child(5) { animation-delay: 0.18s; }

.footer-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: flex-start;
}

#save-code-output {
  min-height: 60px;
}

.battle-top {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.combatant {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  text-align: center;
  position: relative;
  overflow: visible;
}

.combatant.hit {
  animation: hit-shake 0.35s ease;
}

.sprite {
  position: relative;
  width: 100px;
  height: 120px;
  margin: 4px auto 8px;
}

.sprite svg {
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
}

.char-layer {
  width: 100%;
  height: 100%;
}

.weapon-layer {
  position: absolute;
  width: 34px;
  height: 74px;
  right: 4%;
  top: 30%;
  transform: rotate(18deg);
  transform-origin: 50% 90%;
  pointer-events: none;
}

.monster-sprite {
  width: 110px;
}

.combatant.is-boss .monster-sprite {
  width: 132px;
}

.hub-portrait {
  display: flex;
  justify-content: center;
  margin-bottom: 4px;
}

.hub-portrait .sprite {
  width: 90px;
  height: 108px;
}

.sprite.attacking.player-attack {
  animation: lunge-right 0.45s ease;
}

.sprite.attacking.monster-attack {
  animation: lunge-left 0.45s ease;
}

@keyframes lunge-right {
  0% { transform: translateX(0); }
  40% { transform: translateX(16px); }
  100% { transform: translateX(0); }
}

@keyframes lunge-left {
  0% { transform: translateX(0); }
  40% { transform: translateX(-16px); }
  100% { transform: translateX(0); }
}

.weapon-layer.swing {
  animation: weapon-swing 0.45s ease;
}

@keyframes weapon-swing {
  0% { transform: rotate(18deg); }
  45% { transform: rotate(-55deg); }
  100% { transform: rotate(18deg); }
}

@keyframes hit-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(5px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(2px); }
}

.damage-popup {
  position: absolute;
  top: 38%;
  left: 50%;
  transform: translate(-50%, 0);
  font-family: 'Cinzel', 'Georgia', serif;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.7);
  pointer-events: none;
  animation: damage-float 0.9s ease-out forwards;
  z-index: 5;
}

.damage-popup.crit {
  color: var(--blood-bright);
  font-size: 2rem;
  text-shadow: 0 0 10px rgba(212, 48, 47, 0.8), 0 2px 6px rgba(0, 0, 0, 0.7);
}

@keyframes damage-float {
  0% { opacity: 0; transform: translate(-50%, 0) scale(0.6); }
  15% { opacity: 1; transform: translate(-50%, -14px) scale(1.15); }
  100% { opacity: 0; transform: translate(-50%, -60px) scale(1); }
}

.bar {
  width: 100%;
  height: 14px;
  background: #2a1c12;
  border: 1px solid var(--border);
  border-radius: 7px;
  overflow: hidden;
  margin: 6px 0;
}

.bar-fill {
  height: 100%;
  transition: width 0.25s ease-out;
  position: relative;
  overflow: hidden;
}

.bar-fill::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.25), transparent);
  transform: translateX(-100%);
  animation: bar-shimmer 2.4s ease-in-out infinite;
}

@keyframes bar-shimmer {
  0% { transform: translateX(-100%); }
  50%, 100% { transform: translateX(100%); }
}

.hp-bar .bar-fill {
  background: var(--hp-good);
}

.hp-bar.enemy .bar-fill {
  background: var(--hp-bad);
}

.blood-bar .bar-fill {
  background: var(--blood-bright);
}

.dice-tray {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin: 4px 0 16px;
  min-height: 52px;
}

.die {
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, #3a2417, #1c120a);
  border: 2px solid var(--border);
  border-radius: 10px;
  font-size: 1.3rem;
  font-weight: bold;
  color: var(--gold);
  position: relative;
}

.die::before {
  content: attr(data-type);
  position: absolute;
  top: 2px;
  left: 5px;
  font-size: 0.5rem;
  color: var(--muted);
  font-weight: normal;
}

.die.rolling {
  animation: dice-wobble 0.18s ease-in-out infinite;
  border-color: var(--gold);
}

@keyframes dice-wobble {
  0% { transform: rotate(0deg) scale(1); }
  50% { transform: rotate(10deg) scale(1.08); }
  100% { transform: rotate(-10deg) scale(1); }
}

.die.crit {
  border-color: var(--blood-bright);
  box-shadow: 0 0 12px rgba(212, 48, 47, 0.7);
  color: var(--blood-bright);
}

.die.advantage::after {
  content: '★';
  position: absolute;
  bottom: 1px;
  right: 5px;
  font-size: 0.6rem;
  color: var(--gold);
}

/* Borda sutil na bandeja de dados da masmorra — cada encantamento com uma
   cor própria, pra dar pra reconhecer de relance qual dado está encantado
   com o quê enquanto ele rola sozinho (ver DICE_BUFFS em data.js). */
.die[data-buff="sorte_do_um"] { border-color: #f4c542; box-shadow: 0 0 6px rgba(244, 197, 66, 0.5); }
.die[data-buff="furia_maxima"] { border-color: #e0502a; box-shadow: 0 0 6px rgba(224, 80, 42, 0.5); }
.die[data-buff="vento_par"] { border-color: #3ab5c9; box-shadow: 0 0 6px rgba(58, 181, 201, 0.5); }
.die[data-buff="sangue_impar"] { border-color: var(--blood-bright); box-shadow: 0 0 6px rgba(212, 48, 47, 0.5); }
.die[data-buff="eco_gemeo"] { border-color: #a866e0; box-shadow: 0 0 6px rgba(168, 102, 224, 0.5); }

.buff-bar {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
  margin: 0 0 10px;
}

.buff-button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 76px;
  padding: 6px 10px;
  border-color: var(--gold);
  color: var(--gold);
}

.buff-button:not(:disabled):hover {
  background: rgba(201, 162, 39, 0.15);
  box-shadow: 0 0 8px rgba(201, 162, 39, 0.35);
}

.buff-button .buff-icon {
  font-size: 1.2rem;
}

.buff-button .buff-name {
  font-size: 0.72rem;
  text-align: center;
}

.buff-button .buff-cooldown {
  font-size: 0.7rem;
  opacity: 0.8;
}

.buff-button:disabled {
  border-color: var(--border);
  color: var(--muted);
}

.buff-button.cooling .buff-cooldown {
  color: var(--blood-bright);
}

.active-effects {
  display: flex;
  gap: 6px;
  justify-content: center;
  flex-wrap: wrap;
  margin: 0 0 10px;
}

.active-effect-badge {
  font-size: 0.78rem;
  padding: 2px 8px;
  border-radius: 20px;
  background: rgba(201, 162, 39, 0.12);
  border: 1px solid var(--gold);
  color: var(--gold);
}

.blood-progress {
  margin-bottom: 12px;
}

.evolve-button {
  display: block;
  width: 100%;
  margin-top: 8px;
  border-color: var(--gold);
  color: var(--gold);
  font-weight: bold;
}

.evolve-button:not(:disabled):hover {
  background: rgba(201, 162, 39, 0.15);
  box-shadow: 0 0 10px rgba(201, 162, 39, 0.35);
}

.combatant.is-boss {
  border-color: var(--blood-bright);
  box-shadow: 0 0 14px rgba(212, 48, 47, 0.35);
}

.combatant.is-boss h3 {
  color: var(--blood-bright);
}

.dungeon-progress {
  color: var(--muted);
  margin: 12px 0 6px;
}

.battle-log {
  background: #0d0906;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  height: 220px;
  overflow-y: auto;
  display: flex;
  flex-direction: column-reverse;
  font-size: 0.88rem;
}

.log-entry {
  padding: 3px 0;
  border-bottom: 1px dashed #2a1c12;
  color: var(--muted);
}

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

.modal {
  position: fixed;
  inset: 0;
  background: rgba(5, 3, 2, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 10;
  animation: modal-backdrop-in 0.2s ease-out;
}

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

.modal-content {
  background: var(--panel);
  border: 1px solid var(--gold);
  border-radius: 10px;
  padding: 20px;
  max-width: 480px;
  width: 100%;
  box-shadow: 0 0 30px rgba(201, 162, 39, 0.25);
  animation: modal-pop-in 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-content textarea {
  margin: 10px 0;
}

.modal-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* Label vestindo o <input type=file> escondido pra parecer um botão normal
   (upload de save .txt — menu principal e modal do topbar). */
.file-upload-btn {
  font-family: inherit;
  background: linear-gradient(180deg, #3a2417, #2a190e);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 10px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.95rem;
  display: inline-flex;
  align-items: center;
  transition: border-color 0.15s, transform 0.1s, box-shadow 0.15s;
}

.file-upload-btn:hover {
  border-color: var(--gold);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}

@keyframes modal-pop-in {
  from { opacity: 0; transform: scale(0.85) translateY(12px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

/* --- Modal de dado: encantamento + skin --- */

.dice-modal-content h3 {
  display: flex;
  align-items: center;
  gap: 10px;
}

.dice-modal-subtitle {
  margin-top: 18px;
  font-size: 1rem;
}

.dice-buff-current {
  background: var(--panel-alt);
  border: 1px solid var(--gold);
  border-radius: 8px;
  padding: 10px 12px;
}

.dice-buff-current button,
.dice-buff-option button {
  margin-top: 8px;
}

.dice-buff-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.dice-buff-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
}

.dice-buff-option button {
  flex-shrink: 0;
  margin-top: 0;
}

.dice-skin-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.dice-skin-option {
  padding: 8px 12px;
  border-color: var(--die-color, var(--border));
}

.dice-skin-option.active {
  border-color: var(--die-color, var(--gold));
  box-shadow: 0 0 8px rgba(201, 162, 39, 0.4);
}

.evolution-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}

.evolution-option {
  display: flex;
  flex-direction: column;
  text-align: left;
  gap: 4px;
  padding: 12px;
}

.evolution-option .evolution-bonus {
  color: var(--gold);
  font-size: 0.88rem;
  font-weight: bold;
}

.evolution-option .evolution-flavor {
  color: var(--muted);
  font-size: 0.85rem;
}

.evolution-option.marked,
.forge-item.marked {
  border-color: var(--marked);
  box-shadow: 0 0 10px rgba(78, 168, 222, 0.35);
}

.evolution-marked-badge {
  align-self: flex-start;
  color: var(--marked);
  font-size: 0.78rem;
  font-weight: bold;
}

.evolution-known-badge {
  align-self: flex-start;
  color: var(--muted);
  font-size: 0.78rem;
}

.evolution-known-badge.full {
  color: var(--gold);
  font-weight: bold;
}

.forge-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}

.forge-item {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s;
}

.forge-item:hover {
  border-color: var(--gold);
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}

.forge-item.affordable {
  border-color: rgba(201, 162, 39, 0.35);
}

.forge-item-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--panel-alt);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.25s ease, border-color 0.2s, box-shadow 0.2s;
}

.forge-item-icon .weapon-icon {
  width: 22px;
  height: 42px;
}

.forge-item:hover .forge-item-icon {
  transform: scale(1.15) rotate(-6deg);
  border-color: var(--gold);
  box-shadow: 0 0 10px rgba(201, 162, 39, 0.45);
}

.forge-item-body {
  flex: 1;
  min-width: 0;
}

.forge-item-title {
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
}

.forge-item-tier {
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: normal;
}

.forge-item-desc {
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 3px;
}

.forge-item-btn {
  flex-shrink: 0;
  text-align: center;
  line-height: 1.35;
}

.forge-item-cost {
  font-size: 0.8rem;
  opacity: 0.85;
}

.tavern-item-icon {
  font-size: 1.6rem;
}

.tavern-active {
  background: var(--panel-alt);
  border: 1px solid var(--gold);
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 16px;
}

.tavern-active.debuff {
  border-color: var(--blood-bright);
}

/* --- Codex: árvore de armas inteira, unificada, num canvas SVG que arrasta e dá zoom (estilo Path of Exile) --- */

.weapon-icon {
  width: 30px;
  height: 56px;
  margin: 0 auto;
}

.weapon-icon svg {
  width: 100%;
  height: 100%;
  display: block;
  filter: var(--weapon-glow);
}

.tree-edge {
  stroke: var(--border);
  stroke-width: 1.5;
}

.tree-edge.crafted {
  stroke: var(--gold);
  stroke-width: 2.5;
}

.tree-edge.marked {
  stroke: var(--marked);
  stroke-width: 2.5;
}

.codex-node-wrap {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tree-node-box {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  box-sizing: border-box;
  position: relative;
  transition: border-color 0.15s, transform 0.15s;
}

.tree-node-box:hover {
  border-color: var(--gold);
  transform: scale(1.35);
  z-index: 3;
}

.tree-node-box.crafted {
  border-color: var(--gold);
  box-shadow: 0 0 6px rgba(201, 162, 39, 0.5);
}

.tree-node-box.unlocked {
  border-color: var(--blood-bright);
}

.tree-node-box.marked {
  box-shadow: 0 0 0 2px var(--marked), 0 0 8px rgba(78, 168, 222, 0.6);
}

.tree-node-box.locked {
  opacity: 0.45;
}

.tree-node-box .weapon-icon {
  width: 12px;
  height: 22px;
  pointer-events: none;
}

/* Barra de ferramentas acima do canvas */
.codex-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.codex-toolbar h2 {
  margin: 0;
}

.codex-controls {
  display: flex;
  gap: 6px;
}

.codex-controls button {
  padding: 6px 10px;
}

/* Viewport: janela fixa com overflow escondido; o canvas de dentro é que se move/escala */
.codex-viewport {
  position: relative;
  width: 100%;
  height: 64vh;
  min-height: 360px;
  overflow: hidden;
  background: radial-gradient(circle at center, #1a120c 0%, #0d0906 75%);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: grab;
  touch-action: none;
}

.codex-viewport.dragging {
  cursor: grabbing;
}

.codex-canvas {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
}

.codex-svg {
  display: block;
}

.codex-hint {
  color: var(--muted);
  font-size: 0.82rem;
  margin: 8px 0 0;
  text-align: center;
}

#screen-tree:fullscreen {
  background: var(--bg);
  padding: 16px;
  display: flex;
  flex-direction: column;
}

#screen-tree:fullscreen .codex-viewport {
  flex: 1;
  height: auto;
}

.weapon-tooltip {
  position: fixed;
  z-index: 50;
  display: flex;
  gap: 10px;
  max-width: 260px;
  background: var(--panel);
  border: 1px solid var(--gold);
  border-radius: 10px;
  padding: 12px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.55);
  pointer-events: none;
}

.weapon-tooltip.hidden {
  display: none;
}

.weapon-tooltip .tooltip-icon {
  flex-shrink: 0;
  width: 44px;
}

.weapon-tooltip .tooltip-icon .weapon-icon {
  width: 44px;
  height: 84px;
}

.weapon-tooltip h4 {
  margin: 0 0 4px;
  font-size: 0.92rem;
  color: var(--gold);
}

.weapon-tooltip .tooltip-desc {
  color: var(--muted);
  font-size: 0.78rem;
  margin: 0 0 6px;
}

.weapon-tooltip .tooltip-bonus {
  color: var(--gold);
  font-size: 0.8rem;
  font-weight: bold;
  margin: 0 0 4px;
}

.weapon-tooltip .tooltip-meta {
  color: var(--muted);
  font-size: 0.72rem;
  margin: 2px 0 0;
}

.weapon-tooltip .tooltip-mark-hint {
  color: var(--marked);
  font-weight: bold;
}

.result-panel {
  text-align: center;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px 20px;
  animation: fadeInUp 0.4s ease both;
}

.result-icon {
  font-size: 3.2rem;
  margin-bottom: 6px;
  animation: result-icon-in 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes result-icon-in {
  from { opacity: 0; transform: scale(0.4) rotate(-15deg); }
  to { opacity: 1; transform: scale(1) rotate(0deg); }
}

.result-panel.result-victory {
  border-color: var(--gold);
  box-shadow: 0 0 30px rgba(201, 162, 39, 0.2);
}

.result-panel.result-defeat {
  border-color: var(--blood-bright);
  box-shadow: 0 0 30px rgba(212, 48, 47, 0.2);
}

.result-panel.result-fled {
  border-color: var(--muted);
}

.result-panel button {
  margin-top: 10px;
}

@media (max-width: 480px) {
  .battle-top,
  .stats-grid {
    grid-template-columns: 1fr;
  }
}
