/* Dígitos 0-9 em Tiny5 (OFL): a família só cobre os números, então qualquer
   texto com "Reliquary Digits" na frente mostra letras em Pixelify Sans e
   números em Tiny5 (cabeçalho, tooltips, descrições e canvas) */
@font-face {
  font-family: "Reliquary Digits";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url(https://fonts.gstatic.com/s/tiny5/v4/KFPmCnmCvdGT7gY17YjFsqU5P8HylYh0cHNgqfzNZyHYWuYMFEKbbJNjBFkz328200F85S8o1EvtViA7-Im-3J_pQp09C2aSrrZT8wI5Bw.woff2)
    format("woff2");
  unicode-range: U+0030-0039;
}

:root {
  /* Números (valores, barras, recargas, dano): Tiny5, pixel fino de licença OFL */
  --font-num: "Tiny5", "Pixelify Sans", monospace;
  --bg: #0a0806;
  --bg2: #120f0a;
  --bg3: #1c1710;
  --bg4: #261f15;
  --border: #3a2e1e;
  --border2: #5a4a2e;
  --gold: #c9a84c;
  --gold2: #e8c96a;
  --gold3: #f5e09a;
  --text: #d4c4a0;
  --text2: #a08860;
  --text3: #6a5840;
  --red: #c94444;
  --red2: #e86060;
  --green: #4caa6a;
  --green2: #72cc8a;
  --blue: #4488cc;
  --blue2: #66aaee;
  --purple: #8844cc;
  --purple2: #aa66ee;
  --orange: #cc6a22;
  --orange2: #ee8a44;
  --hp-bar: #cc3333;

  --slot-size: 72px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

/* Touch-friendly adjustments */
button,
.item-slot {
  touch-action: manipulation;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

html {
  overflow-x: hidden;
  scroll-behavior: smooth;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Reliquary Digits", "Pixelify Sans", sans-serif;
  font-size: 16px;
  min-height: 100vh;
  overflow-x: hidden;
  background-image:
    radial-gradient(
      ellipse at 20% 50%,
      rgba(201, 168, 76, 0.04) 0%,
      transparent 50%
    ),
    radial-gradient(
      ellipse at 80% 20%,
      rgba(136, 68, 204, 0.04) 0%,
      transparent 50%
    );
}

h1,
h2,
h3,
.label {
  font-family: "Reliquary Digits", "Pixelify Sans", sans-serif;
  letter-spacing: 0.05em;
}

#app {
  display: grid;
  grid-template-rows: auto auto 1fr;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas:
    "header"
    "inventory"
    "arena";
  min-height: 100vh;
  max-width: 1280px;
  margin: 0 auto;
  gap: 0;
}

/* ─── HEADER ─── */
#header {
  grid-area: header;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg2);
}
#header h1 {
  font-size: 22px;
  color: var(--gold2);
  letter-spacing: 0.12em;
}
#header .subtitle {
  font-size: 13px;
  color: var(--text3);
  font-style: normal;
}
#stats-header {
  display: flex;
  gap: 20px;
  align-items: center;
}
.stat-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg3);
  border: 1px solid var(--border);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 13px;
}
.stat-pill .val {
  font-family: var(--font-num);
  color: var(--gold2);
  font-size: 14px;
}

/* ─── BOTÃO DE IDIOMA (EN | PT): cabeçalho e tela inicial ─── */
.lang-toggle {
  display: inline-flex;
  flex: none;
  border: 1px solid var(--border2);
  border-radius: 20px;
  overflow: hidden;
  background: var(--bg3);
}
.lang-btn {
  font-family: "Reliquary Digits", "Pixelify Sans", sans-serif;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--text2);
  background: transparent;
  border: 0;
  padding: 5px 11px;
  min-width: 36px;
  cursor: pointer;
  transition:
    background 0.15s ease,
    color 0.15s ease;
}
.lang-btn + .lang-btn {
  border-left: 1px solid var(--border);
}
.lang-btn:hover {
  color: var(--gold2);
}
.lang-btn[aria-pressed="true"] {
  background: var(--gold);
  color: var(--bg);
  cursor: default;
}
.lang-btn:focus-visible {
  outline: 2px solid var(--gold2);
  outline-offset: -2px;
}
/* No cabeçalho o botão fica depois das estatísticas; no celular sobe para a
   linha do título, para as estatísticas manterem a largura toda */
#header > .lang-toggle {
  order: 3;
  margin-left: 16px;
}
/* Desktop: estatísticas coladas no botão, à direita (space-between as espalharia) */
@media (min-width: 1025px) {
  #stats-header {
    margin-left: auto;
  }
}

/* ─── ARENA ─── */
#arena {
  grid-area: arena;
  background: var(--bg2);
  position: relative;
  overflow: hidden;
  min-height: 480px;
}

/* Fora do fluxo: o tamanho do canvas segue a arena, nunca o contrário
   (senão abrir/fechar a barra de itens faria a arena crescer em loop) */
#combat-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* Camada de texto por cima do mundo pixelado: números, nomes e avisos */
#overlay-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* Vinheta de dano: acima dos canvas, abaixo da UI; não bloqueia toques */
#hurt-vignette {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(ellipse at center, transparent 45%, rgba(200, 20, 20, 0.75) 100%);
}

/* ─── GAME CONTROLS ─── */
#game-controls {
  position: absolute;
  top: 16px;
  right: 16px;
  display: flex;
  gap: 8px;
  z-index: 10;
}

.control-btn {
  background: linear-gradient(135deg, var(--bg3) 0%, var(--bg2) 100%);
  border: 2px solid var(--border2);
  border-radius: 8px;
  padding: 10px 18px;
  font-family: "Reliquary Digits", "Pixelify Sans", sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--gold);
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow:
    inset 0 1px 3px rgba(0, 0, 0, 0.5),
    0 2px 8px rgba(0, 0, 0, 0.4);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

.control-btn:hover {
  transform: translateY(-2px);
  border-color: var(--gold);
  box-shadow:
    inset 0 1px 3px rgba(0, 0, 0, 0.5),
    0 4px 12px rgba(201, 168, 76, 0.4);
  color: var(--gold2);
}

.control-btn:active {
  transform: translateY(0);
  box-shadow:
    inset 0 2px 4px rgba(0, 0, 0, 0.6),
    0 1px 4px rgba(0, 0, 0, 0.3);
}

.control-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.control-btn.active {
  background: linear-gradient(135deg, var(--bg4) 0%, var(--bg3) 100%);
  border-color: var(--gold2);
  color: var(--gold2);
  box-shadow:
    inset 0 1px 3px rgba(0, 0, 0, 0.5),
    0 0 12px rgba(201, 168, 76, 0.5);
}

.control-btn.reset-btn {
  background: linear-gradient(
    135deg,
    rgba(204, 68, 68, 0.2) 0%,
    var(--bg2) 100%
  );
  border-color: rgba(204, 68, 68, 0.5);
  color: var(--red2);
  margin-left: 8px;
}

.control-btn.reset-btn:hover {
  border-color: var(--red);
  color: var(--red2);
  box-shadow:
    inset 0 1px 3px rgba(0, 0, 0, 0.5),
    0 4px 12px rgba(204, 68, 68, 0.4);
}

.control-btn.reset-btn:active {
  background: linear-gradient(
    135deg,
    rgba(204, 68, 68, 0.3) 0%,
    var(--bg3) 100%
  );
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateX(-4px);
  }
  to {
    opacity: 1;
  }
}

/* ─── INVENTORY (barra no alto, recolhível) ─── */
#inventory {
  grid-area: inventory;
  background: var(--bg3);
  border-bottom: 1px solid var(--border);
  padding: 0;
}
.inv-bar {
  display: flex;
  align-items: stretch;
  border-bottom: 1px solid var(--border);
}
#inventory.collapsed .inv-bar {
  border-bottom: none;
}
.inv-bar .bars-container {
  flex: 1 1 320px;
  max-width: 460px;
  border-bottom: none;
  border-right: 1px solid var(--border);
}
.inv-bar .wave-info {
  flex: 1;
  gap: 16px;
  border-bottom: none;
}
.inv-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 18px;
  background: var(--bg3);
  border: none;
  border-left: 1px solid var(--border);
  color: var(--text2);
  font-family: "Reliquary Digits", "Pixelify Sans", sans-serif;
  font-size: 13px;
  letter-spacing: 0.05em;
  cursor: pointer;
  white-space: nowrap;
}
.inv-toggle:hover,
.inv-toggle:focus-visible {
  color: var(--gold2);
  background: var(--bg4);
}
.inv-toggle-arrow {
  display: inline-block;
  transition: transform 0.2s;
}
#inventory.collapsed .inv-toggle-arrow {
  transform: rotate(-90deg);
}
.inv-toggle-count {
  font-family: var(--font-num);
  min-width: 20px;
  padding: 1px 6px;
  border: 1px solid var(--border2);
  border-radius: 10px;
  color: var(--gold2);
  font-size: 11px;
  text-align: center;
}
.inv-items {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
#inventory.collapsed .inv-items {
  display: none;
}

.inv-section {
  padding: 10px 16px 12px;
  border-right: 1px solid var(--border);
}
.inv-section:last-child {
  border-right: none;
}
.inv-section-title {
  font-family: "Reliquary Digits", "Pixelify Sans", sans-serif;
  font-size: 11px;
  letter-spacing: 0.15em;
  color: var(--text3);
  text-transform: uppercase;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.inv-section-title::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* Item slot grid */
.slots-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, 56px);
  min-height: 56px;
  gap: 6px;
}

.item-slot {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  background: var(--bg4);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: default;
  transition:
    border-color 0.15s,
    transform 0.1s;
  overflow: visible;
}
.item-slot:hover {
  border-color: var(--border2);
  z-index: 100;
}
.item-slot.active {
  border-color: var(--gold);
  box-shadow:
    0 0 12px rgba(201, 168, 76, 0.3),
    inset 0 0 8px rgba(201, 168, 76, 0.1);
  animation: itemPulse 0.6s ease;
}
.item-slot.cooldown {
  border-color: var(--text3);
}

@keyframes itemPulse {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 rgba(201, 168, 76, 0);
  }
  40% {
    transform: scale(1.08);
    box-shadow: 0 0 20px rgba(201, 168, 76, 0.6);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 12px rgba(201, 168, 76, 0.3);
  }
}

.item-icon {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  border-radius: 5px;
  transition: filter 0.2s;
  position: relative;
  z-index: 1;
}
.item-slot.cooldown .item-icon {
  filter: grayscale(0.7) brightness(0.6);
}

.cooldown-overlay {
  font-family: var(--font-num);
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: var(--text2);
  border-radius: 0 0 5px 5px;
  z-index: 2;
  height: 0;
  overflow: hidden;
  transition: height 0.2s;
}
.item-slot.cooldown .cooldown-overlay {
  height: 16px;
}

.cd-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  background: var(--gold);
  border-radius: 0 0 0 5px;
  z-index: 3;
  transition: width 0.1s linear;
}

.rarity-gem {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  z-index: 4;
}
.rarity-common {
  background: #888;
}
.rarity-uncommon {
  background: var(--green);
}
.rarity-rare {
  background: var(--blue);
}
.rarity-epic {
  background: var(--purple);
}
.rarity-legendary {
  background: var(--gold);
  box-shadow: 0 0 6px var(--gold);
}
.rarity-mythic {
  background: #ff4d8d;
  box-shadow: 0 0 6px #ff4d8d;
}

/* Tooltip */
.tooltip {
  position: fixed;
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: 8px;
  padding: 12px 14px;
  min-width: 220px;
  max-width: 280px;
  pointer-events: none;
  z-index: 9999;
  opacity: 0;
  transform: translateY(4px);
  transition:
    opacity 0.15s,
    transform 0.15s;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.8);
}

.tooltip.mobile {
  left: 50% !important;
  top: 50% !important;
  transform: translate(-50%, -50%) translateY(4px);
  max-width: 90vw;
  max-height: 80vh;
  overflow-y: auto;
}

.tooltip.mobile.show {
  transform: translate(-50%, -50%) translateY(0);
}

.tooltip.show {
  opacity: 1;
  transform: translateY(0);
}
.tt-name {
  font-family: "Reliquary Digits", "Pixelify Sans", sans-serif;
  font-size: 14px;
  margin-bottom: 4px;
}
.tt-rarity {
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 8px;
  font-family: "Reliquary Digits", "Pixelify Sans", sans-serif;
}
.tt-desc {
  font-size: 13px;
  color: var(--text2);
  line-height: 1.5;
  margin-bottom: 8px;
  font-style: normal;
}
.tt-effect {
  font-size: 13px;
  color: var(--text);
  line-height: 1.6;
  margin-bottom: 6px;
}
.tt-enchant {
  font-size: 12px;
  color: var(--purple2);
  border-top: 1px solid var(--border);
  padding-top: 6px;
  margin-top: 4px;
  line-height: 1.5;
}
.tt-cd {
  font-size: 11px;
  color: var(--text3);
  margin-top: 4px;
  font-family: "Reliquary Digits", "Pixelify Sans", sans-serif;
}

/* Player bars */
.bars-container {
  padding: 10px 16px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
}
.bar-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.bar-label {
  font-family: "Reliquary Digits", "Pixelify Sans", sans-serif;
  font-size: 10px;
  color: var(--text3);
  width: 28px;
  text-align: right;
  letter-spacing: 0.05em;
}
.bar-track {
  flex: 1;
  height: 8px;
  background: var(--bg4);
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s ease;
}
.bar-fill.hp {
  background: linear-gradient(90deg, #882222, var(--hp-bar));
}

.bar-val {
  font-family: var(--font-num);
  font-size: 11px;
  color: var(--text2);
  min-width: 60px;
}

/* Wave info */
.wave-info {
  padding: 8px 16px;
  background: var(--bg4);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.wave-num {
  font-family: "Reliquary Digits", "Pixelify Sans", sans-serif;
  font-size: 13px;
  color: var(--gold2);
}
.enemy-count {
  font-size: 12px;
  color: var(--text3);
}
.gold-display {
  font-family: "Reliquary Digits", "Pixelify Sans", sans-serif;
  font-size: 13px;
  color: var(--gold);
}

/* ─── CANVAS STYLE ─── */
canvas {
  image-rendering: pixelated;
}

/* ═══════════════════════════════════════
   RESPONSIVE DESIGN
   ═══════════════════════════════════════ */

/* ─── TABLET (max-width: 1024px) ─── */
@media (max-width: 1024px) {
  #app {
    max-width: 100%;
  }

  #header {
    flex-wrap: wrap;
    gap: 12px;
  }

  #header > .lang-toggle {
    order: 0;
    margin-left: auto;
  }

  #stats-header {
    flex-wrap: wrap;
    gap: 8px;
  }

  .stat-pill {
    font-size: 11px;
    padding: 6px 10px;
  }

  #game-controls {
    top: 12px;
    right: 12px;
    gap: 6px;
  }

  .control-btn {
    padding: 8px 14px;
    font-size: 0.85rem;
  }
}

/* ─── MOBILE (max-width: 768px) ─── */
@media (max-width: 768px) {
  #header {
    padding: 10px 16px;
  }

  #header h1 {
    font-size: 18px;
  }

  #header .subtitle {
    font-size: 11px;
  }

  #stats-header {
    width: 100%;
    justify-content: space-between;
  }

  .stat-pill {
    font-size: 10px;
    padding: 5px 8px;
    flex: 1;
    min-width: 0;
    text-align: center;
  }

  .stat-pill span {
    display: block;
  }

  #arena {
    min-height: 400px;
  }

  #game-controls {
    top: 8px;
    right: 8px;
    gap: 4px;
  }

  .control-btn {
    padding: 6px 12px;
    font-size: 0.8rem;
  }

  .inv-bar {
    flex-wrap: wrap;
  }

  .inv-bar .bars-container {
    flex-basis: 100%;
    max-width: none;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .inv-toggle {
    padding: 8px 12px;
  }

  .inv-section {
    padding: 8px 10px 10px;
  }

  .bar-row {
    margin-bottom: 8px;
    gap: 6px;
  }

  .bar-label {
    font-size: 11px;
    min-width: 24px;
  }

  .bar-track {
    height: 16px;
  }

  .bar-val {
    font-size: 10px;
    min-width: 50px;
  }

  .wave-info {
    padding: 6px 12px;
  }

  .wave-num,
  .gold-display {
    font-size: 11px;
  }

  .enemy-count {
    font-size: 10px;
  }

  .inv-section {
    margin-bottom: 14px;
  }

  .inv-section-title {
    font-size: 12px;
    margin-bottom: 6px;
    padding-bottom: 4px;
  }

  .slots-grid {
    grid-template-columns: repeat(auto-fill, 44px);
    min-height: 44px;
    gap: 6px;
  }

  .item-icon {
    font-size: 1.5rem;
  }

  .rarity-gem {
    width: 6px;
    height: 6px;
    top: 3px;
    right: 3px;
  }

  .cooldown-overlay {
    font-size: 0.8rem;
  }

  .tooltip {
    max-width: 240px;
    padding: 10px;
    font-size: 0.85rem;
  }

  .tooltip .tt-name {
    font-size: 1rem;
  }

  .tooltip .tt-rarity {
    font-size: 0.75rem;
  }

  .tooltip .tt-enchant {
    font-size: 0.8rem;
    padding: 5px 6px;
  }

  .tooltip .tt-cd {
    font-size: 0.75rem;
  }
}

/* ─── MOBILE PEQUENO (max-width: 480px) ─── */
@media (max-width: 480px) {
  #header h1 {
    font-size: 16px;
  }

  #header .subtitle {
    display: none;
  }

  #stats-header {
    gap: 4px;
  }

  .stat-pill {
    font-size: 9px;
    padding: 4px 6px;
    border-radius: 4px;
  }

  .stat-pill .val {
    font-size: 10px;
  }

  #arena {
    min-height: 300px;
  }

  /* Em linha no alto: em coluna à direita os botões cobriam os inimigos que
     chegam pela borda direita */
  #game-controls {
    top: 6px;
    left: 6px;
    right: 6px;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 4px;
  }

  .control-btn {
    padding: 5px 8px;
    font-size: 0.72rem;
    white-space: nowrap;
  }

  .control-btn.reset-btn {
    margin-left: 0;
  }

  .inv-items {
    grid-template-columns: minmax(0, 1fr);
  }

  .inv-section {
    display: flex;
    align-items: center;
    gap: 10px;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .inv-section:last-child {
    border-bottom: none;
  }

  .inv-section .inv-section-title {
    flex: 0 0 72px;
    margin-bottom: 0;
  }

  .inv-section .inv-section-title::after {
    display: none;
  }

  .inv-section .slots-grid {
    flex: 1;
  }

  .bar-row {
    margin-bottom: 6px;
    gap: 4px;
  }

  .bar-label {
    font-size: 10px;
    min-width: 22px;
  }

  .bar-track {
    height: 14px;
  }

  .bar-val {
    font-size: 9px;
    min-width: 45px;
  }

  .wave-info {
    padding: 5px 8px;
    flex-wrap: wrap;
    gap: 4px;
  }

  .wave-num,
  .gold-display {
    font-size: 10px;
  }

  .enemy-count {
    font-size: 9px;
  }

  .inv-section {
    margin-bottom: 12px;
  }

  .inv-section-title {
    font-size: 11px;
    margin-bottom: 5px;
  }

  .slots-grid {
    grid-template-columns: repeat(auto-fill, 40px);
    min-height: 40px;
    gap: 5px;
  }

  .item-icon {
    font-size: 1.35rem;
  }

  .rarity-gem {
    width: 5px;
    height: 5px;
    top: 2px;
    right: 2px;
  }

  .cooldown-overlay {
    font-size: 0.7rem;
  }

  .cd-bar {
    height: 3px;
  }

  .tooltip {
    max-width: 85vw;
    padding: 10px;
    font-size: 0.85rem;
  }

  .tooltip.mobile {
    max-width: 90vw;
    min-width: 280px;
  }

  .tooltip .tt-name {
    font-size: 1rem;
    margin-bottom: 4px;
  }

  .tooltip .tt-rarity {
    font-size: 0.75rem;
    margin-bottom: 8px;
  }

  .tooltip .tt-desc {
    margin-bottom: 8px;
    font-size: 0.8rem;
    line-height: 1.3;
  }

  .tooltip .tt-effect {
    margin-bottom: 6px;
    font-size: 0.8rem;
    line-height: 1.3;
  }

  .tooltip .tt-enchant {
    font-size: 0.8rem;
    padding: 6px 8px;
    margin-bottom: 6px;
  }

  .tooltip .tt-cd {
    font-size: 0.75rem;
  }
}

/* ─── LANDSCAPE MOBILE ─── */
@media (max-width: 768px) and (orientation: landscape) {
  #arena {
    min-height: 70vh;
  }

}

/* ═══════════════════════════════════════════
   MODAL DE ESCOLHA DE ITEM
   ------------------------------------------- */

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(4px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.modal-content {
  background: var(--bg2);
  border: 2px solid var(--gold);
  border-radius: 12px;
  max-width: 800px;
  width: 100%;
  max-height: 90vh;
  max-height: 90dvh;
  overflow-y: auto;
  box-shadow:
    0 0 40px rgba(201, 168, 76, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  animation: slideUp 0.3s ease-out;
}

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

/* Escolha de item: coluna flex. O cabeçalho fica fixo, só a área dos cards rola
   e o botão (sticky) fica sempre visível. Escopo no id: game over e vitória
   seguem com o .modal-content genérico. */
#item-choice-modal .modal-content {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#item-choice-modal .modal-header {
  flex: none;
}

.modal-header {
  text-align: center;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, var(--bg3) 0%, var(--bg2) 100%);
}

.modal-header h2 {
  font-size: 1.5rem;
  color: var(--gold2);
  margin-bottom: 4px;
  text-shadow: 0 2px 8px rgba(201, 168, 76, 0.4);
}

.modal-subtitle {
  font-size: 1rem;
  color: var(--text2);
  font-style: normal;
}

.item-choices {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  padding: 14px 20px 12px;
  /* Ocupa o que sobra do modal e rola por dentro; min-height: 0 deixa encolher */
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}

/* Otimizar para 3 itens (recompensa de wave) */
.item-choices:has(.item-choice-card:nth-child(3):nth-last-child(-n + 2)) {
  grid-template-columns: repeat(3, 1fr);
  max-width: 900px;
  margin: 0 auto;
}

.item-choice-card {
  background: var(--bg3);
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 8px;
  touch-action: manipulation;
}

.item-choice-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    135deg,
    transparent 0%,
    rgba(255, 255, 255, 0.05) 100%
  );
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}

.item-choice-card:hover::before,
.item-choice-card:active::before {
  opacity: 1;
}

.item-choice-card:hover {
  transform: translateY(-4px);
  border-color: var(--gold);
  box-shadow:
    0 8px 24px rgba(0, 0, 0, 0.4),
    0 0 20px rgba(201, 168, 76, 0.3);
}

.item-choice-card:active {
  transform: translateY(-2px);
}

.item-choice-icon {
  font-size: 2.2rem;
  text-align: center;
  margin: 2px 0;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.5));
}

.item-choice-name {
  font-family: "Reliquary Digits", "Pixelify Sans", sans-serif;
  font-size: 1rem;
  font-weight: 600;
  text-align: center;
  color: var(--gold2);
  line-height: 1.3;
}

.item-choice-rarity {
  text-align: center;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 8px;
  border-radius: 12px;
  margin: 0 auto;
  display: inline-block;
}

.item-choice-desc {
  font-size: 0.85rem;
  color: var(--text2);
  text-align: center;
  line-height: 1.35;
  font-style: normal;
  min-height: 0;
}

.item-choice-effect {
  font-size: 0.85rem;
  color: var(--text);
  background: var(--bg4);
  padding: 8px;
  border-radius: 6px;
  border-left: 3px solid var(--gold);
  line-height: 1.4;
}

.item-choice-enchant {
  font-size: 0.8rem;
  color: var(--purple2);
  background: rgba(136, 68, 204, 0.15);
  padding: 6px;
  border-radius: 6px;
  border: 1px solid rgba(136, 68, 204, 0.3);
  line-height: 1.4;
}

.item-choice-type {
  position: absolute;
  top: 8px;
  right: 8px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 4px 8px;
  background: var(--bg4);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text3);
  font-weight: 600;
}

.rarity-common {
  background: rgba(136, 136, 136, 0.2);
  color: #888888;
  border: 1px solid rgba(136, 136, 136, 0.4);
}
.rarity-uncommon {
  background: rgba(76, 170, 106, 0.2);
  color: #4caa6a;
  border: 1px solid rgba(76, 170, 106, 0.4);
}
.rarity-rare {
  background: rgba(68, 136, 204, 0.2);
  color: #4488cc;
  border: 1px solid rgba(68, 136, 204, 0.4);
}
.rarity-epic {
  background: rgba(136, 68, 204, 0.2);
  color: #8844cc;
  border: 1px solid rgba(136, 68, 204, 0.4);
}
.rarity-legendary {
  background: rgba(201, 168, 76, 0.2);
  color: #c9a84c;
  border: 1px solid rgba(201, 168, 76, 0.4);
}
.rarity-mythic {
  background: rgba(255, 77, 141, 0.2);
  color: #ff4d8d;
  border: 1px solid rgba(255, 77, 141, 0.5);
}

/* ═══════════════════════════════════════════
   MODAL DE GAME OVER
   ------------------------------------------- */

.game-over-content {
  max-width: 520px;
  text-align: center;
  border-color: var(--red);
  box-shadow:
    0 0 40px rgba(204, 68, 68, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.game-over-content .modal-header h2 {
  color: var(--red2);
  text-shadow: 0 2px 8px rgba(204, 68, 68, 0.4);
}

.go-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  padding: 20px;
}

.go-stat {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 8px;
}

.go-stat.wide {
  grid-column: 1 / -1;
}

.go-stat-label {
  font-family: "Reliquary Digits", "Pixelify Sans", sans-serif;
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text3);
  margin-bottom: 4px;
}

.go-stat-value {
  font-family: "Reliquary Digits", "Pixelify Sans", sans-serif;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--gold2);
}

.go-restart-btn {
  display: block;
  width: calc(100% - 40px);
  margin: 0 auto 20px;
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold2) 100%);
  border: 2px solid var(--gold2);
  border-radius: 12px;
  padding: 14px 28px;
  font-family: "Reliquary Digits", "Pixelify Sans", sans-serif;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--bg);
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  transition: all 0.2s ease;
  box-shadow:
    0 4px 16px rgba(201, 168, 76, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.go-restart-btn:hover {
  transform: translateY(-2px);
  box-shadow:
    0 6px 20px rgba(201, 168, 76, 0.6),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.go-restart-btn:active {
  transform: translateY(0);
}

@media (max-width: 480px) {
  .go-stats {
    padding: 12px;
    gap: 6px;
  }
  .go-stat-value {
    font-size: 1rem;
  }
  .go-restart-btn {
    font-size: 0.95rem;
    padding: 12px 20px;
  }
}

/* Arma favorita e botão de compartilhar das telas de fim (share.js) */
.go-stat.wide .go-stat-value {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 4px 8px;
}

.go-fav-dmg {
  color: var(--text);
}

.go-fav-dmg::before {
  content: "· ";
}

.share-controls {
  padding: 0 20px 14px;
}

.share-btn {
  width: 100%;
  background: var(--bg3);
  border: 2px solid var(--border2);
  border-radius: 12px;
  padding: 12px 24px;
  font-family: "Reliquary Digits", "Pixelify Sans", sans-serif;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s ease;
}

.share-btn:hover:not(:disabled) {
  border-color: var(--gold);
  color: var(--gold2);
  transform: translateY(-2px);
}

.share-btn:active:not(:disabled) {
  transform: translateY(0);
}

.share-btn:disabled {
  opacity: 0.6;
  cursor: progress;
}

.share-status {
  min-height: 1.4em;
  margin-top: 8px;
  font-family: "Reliquary Digits", "Pixelify Sans", sans-serif;
  font-size: 0.85rem;
  color: var(--green2);
}

@media (max-width: 480px) {
  .share-btn {
    font-size: 0.95rem;
    padding: 12px 14px;
  }
}

/* ─── SELEÇÃO MÚLTIPLA ─── */
.selection-counter {
  margin-top: 12px;
  padding: 8px 16px;
  background: var(--bg4);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: inline-block;
  font-family: "Reliquary Digits", "Pixelify Sans", sans-serif;
  font-size: 1rem;
  color: var(--text);
}

.selection-counter #selection-count {
  color: var(--gold2);
  font-weight: 700;
  font-size: 1.2rem;
}

.selection-indicator {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 32px;
  height: 32px;
  background: var(--green);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1.2rem;
  font-weight: bold;
  opacity: 0;
  transform: scale(0);
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(76, 170, 106, 0.5);
  z-index: 10;
}

.item-choice-card.selected {
  border-color: var(--green);
  background: var(--bg4);
  box-shadow:
    0 0 20px rgba(76, 170, 106, 0.4),
    inset 0 0 20px rgba(76, 170, 106, 0.1);
}

.item-choice-card.selected .selection-indicator {
  opacity: 1;
  transform: scale(1);
}

.confirm-selection-btn {
  grid-column: 1 / -1;
  background: linear-gradient(135deg, var(--bg3) 0%, var(--bg4) 100%);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 12px 32px;
  margin: 0;
  /* Sticky: fica colado no fim da área rolável, sempre à vista */
  position: sticky;
  bottom: 12px;
  z-index: 20;
  box-shadow: 0 -10px 12px -2px var(--bg2);
  font-family: "Reliquary Digits", "Pixelify Sans", sans-serif;
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text2);
  text-align: center;
  cursor: not-allowed;
  transition: all 0.3s ease;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  opacity: 0.5;
}

.confirm-selection-btn.active {
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold2) 100%);
  border-color: var(--gold2);
  color: var(--bg);
  cursor: pointer;
  opacity: 1;
  /* Mantém a sombra que mascara o conteúdo rolando atrás do botão sticky */
  box-shadow:
    0 -10px 12px -2px var(--bg2),
    0 4px 16px rgba(201, 168, 76, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.confirm-selection-btn.active:hover {
  transform: translateY(-2px);
  box-shadow:
    0 -10px 12px -2px var(--bg2),
    0 6px 20px rgba(201, 168, 76, 0.6),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.confirm-selection-btn.active:active {
  transform: translateY(0);
}

@media (max-width: 768px) {
  .item-choices {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    padding: 12px;
  }

  /* Para 3 itens (recompensa), mostrar em coluna única em mobile */
  .item-choices:has(.item-choice-card:nth-child(3):nth-last-child(-n + 2)) {
    grid-template-columns: 1fr;
    max-width: 400px;
  }

  .modal-header h2 {
    font-size: 1.3rem;
  }
  .modal-subtitle {
    font-size: 0.9rem;
  }
  .selection-counter {
    font-size: 0.9rem;
    padding: 6px 12px;
  }
  .selection-counter #selection-count {
    font-size: 1.1rem;
  }
  .item-choice-card {
    padding: 12px;
    gap: 8px;
  }
  .item-choice-icon {
    font-size: 2.2rem;
  }
  .item-choice-name {
    font-size: 0.95rem;
  }
  .item-choice-desc {
    font-size: 0.8rem;
    min-height: 30px;
  }
  .item-choice-effect {
    font-size: 0.8rem;
    padding: 8px;
  }
  .item-choice-enchant {
    font-size: 0.75rem;
    padding: 6px;
  }
  .selection-indicator {
    width: 28px;
    height: 28px;
    font-size: 1rem;
  }
  .confirm-selection-btn {
    font-size: 1rem;
    padding: 14px 24px;
  }
}

@media (max-width: 480px) {
  .modal-overlay {
    padding: 4px;
  }
  .modal-content {
    border-radius: 8px;
    max-height: 98vh;
    max-height: 98dvh;
  }
  .modal-header {
    padding: 12px 10px 10px;
  }
  .modal-header h2 {
    font-size: 1.1rem;
    margin-bottom: 6px;
  }
  .modal-subtitle {
    font-size: 0.8rem;
  }
  .selection-counter {
    font-size: 0.85rem;
    padding: 5px 10px;
    margin-top: 8px;
  }
  .selection-counter #selection-count {
    font-size: 1rem;
  }
  .item-choices {
    padding: 8px;
    gap: 8px;
    grid-template-columns: repeat(2, 1fr);
  }
  .item-choice-card {
    padding: 10px;
    gap: 6px;
  }
  .item-choice-icon {
    font-size: 2rem;
    margin: 4px 0;
  }
  .item-choice-name {
    font-size: 0.85rem;
  }
  .item-choice-rarity {
    font-size: 0.7rem;
    padding: 3px 6px;
  }
  .item-choice-desc {
    font-size: 0.75rem;
    min-height: 28px;
  }
  .item-choice-effect {
    font-size: 0.75rem;
    padding: 6px;
  }
  .item-choice-enchant {
    font-size: 0.7rem;
    padding: 5px;
  }
  .item-choice-type {
    font-size: 0.65rem;
    padding: 2px 5px;
  }
  .selection-indicator {
    width: 24px;
    height: 24px;
    font-size: 0.9rem;
  }
  .confirm-selection-btn {
    font-size: 0.9rem;
    padding: 12px 20px;
    margin-top: 6px;
  }
}

/* ─── Níveis dos itens ─── */
.level-badge {
  font-family: var(--font-num);
  position: absolute;
  bottom: 2px;
  right: 3px;
  z-index: 4;
  padding: 0 3px;
  font-size: 9px;
  font-weight: 700;
  line-height: 12px;
  color: #fff;
  background: rgba(0, 0, 0, 0.7);
  border: 1px solid var(--border);
  border-radius: 3px;
  pointer-events: none;
}
.item-slot.max-level {
  border-color: #e6b800;
  box-shadow: 0 0 8px rgba(230, 184, 0, 0.55);
}
.item-slot.max-level .level-badge {
  color: #2a1d00;
  background: #e6b800;
  border-color: #ffd84d;
}
.tt-level {
  font-size: 11px;
  color: #e6b800;
  margin-bottom: 4px;
}
.item-choice-tag {
  align-self: center;
  margin-bottom: 4px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 700;
  border-radius: 10px;
}
.item-choice-tag.new {
  color: var(--green);
  border: 1px solid var(--green);
}
.item-choice-tag.upgrade {
  color: #2a1d00;
  background: #e6b800;
}
.item-choice-card.upgrade {
  border-color: #e6b800;
}
.item-choice-card.upgrade.selected {
  border-color: var(--green);
}

/* ═══════════════════════════════════════════
   FASE 6: CELULAR (retrato e paisagem)
   ------------------------------------------- */

/* ─── Celular em pé: arena no máximo quadrada, o resto fica de fundo da página ─── */
@media (orientation: portrait) {
  /* A arena pega o que sobra da altura depois do cabeçalho e da barra de itens
     (mínimo 260 px) e nunca passa de quadrada: acima de 1:1 o chão acabaria
     antes da borda do quadro. align-content: start: as linhas auto não esticam
     e a arena fica logo abaixo dos itens; o que sobra vira fundo da página. */
  #app {
    height: 100vh; /* sem dvh (navegadores antigos) */
    height: 100dvh;
    min-height: 0;
    grid-template-rows: auto auto minmax(260px, 1fr);
    align-content: start;
  }
  #arena {
    min-height: 260px;
    max-height: min(100vw, 1280px);
  }
}

/* ─── Celular deitado (pouca altura): modo compacto, a batalha cabe sem rolar ─── */
@media (orientation: landscape) and (max-height: 500px) {
  :root {
    --hdr-h: 34px;
    --invbar-h: 38px;
  }
  #app {
    min-height: 0;
    grid-template-rows: auto auto auto;
  }
  #header {
    box-sizing: border-box;
    height: var(--hdr-h);
    flex-wrap: nowrap;
    gap: 8px;
    padding: 0 12px;
  }
  #header h1 {
    font-size: 14px;
    white-space: nowrap;
  }
  #header .subtitle {
    display: none;
  }
  #header > .lang-toggle {
    order: 3;
    margin-left: 0;
  }
  .lang-btn {
    padding: 2px 8px;
    min-width: 30px;
    font-size: 11px;
  }
  /* Os indicadores encolhem (e cortam) antes de empurrar o EN|PT para fora */
  #header > div:first-child {
    flex: none;
  }
  #stats-header {
    flex: 0 1 auto;
    min-width: 0;
    overflow: hidden;
    width: auto;
    margin-left: auto;
    flex-wrap: nowrap;
    gap: 6px;
  }
  .stat-pill {
    flex: 0 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    gap: 4px;
    padding: 1px 8px;
    border-radius: 4px;
    font-size: 10px;
    white-space: nowrap;
  }
  .stat-pill span {
    display: inline;
  }
  .stat-pill .val {
    font-size: 11px;
  }
  /* Barra do inventário em uma linha: HP e MP lado a lado, sem a faixa de onda
     (a onda já está nos indicadores do alto) */
  .inv-bar {
    box-sizing: border-box;
    flex-wrap: nowrap;
    height: var(--invbar-h);
  }
  .inv-bar .bars-container {
    display: flex;
    flex: 1 1 auto;
    align-items: center;
    gap: 14px;
    max-width: none;
    padding: 0 12px;
    border-right: 1px solid var(--border);
    border-bottom: none;
  }
  .inv-bar .bar-row {
    flex: 1;
    margin: 0;
  }
  .inv-bar .bar-track {
    height: 10px;
  }
  .inv-bar .wave-info {
    display: none;
  }
  .inv-toggle {
    padding: 0 12px;
  }
  /* A arena ocupa o que sobra da altura da tela; nada rola */
  #arena {
    height: calc(100vh - var(--hdr-h) - var(--invbar-h) - 2px); /* sem dvh */
    height: calc(100dvh - var(--hdr-h) - var(--invbar-h) - 2px);
    max-height: none;
    min-height: 0;
  }
  #game-controls {
    top: 6px;
    right: 6px;
  }
  .control-btn {
    padding: 4px 8px;
    font-size: 0.72rem;
  }
}

/* Aviso se o items.json não carregar (não há mais log na tela) */
.load-error {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 10000;
  max-width: 90vw;
  padding: 14px 20px;
  background: var(--bg2);
  border: 1px solid var(--red2);
  border-radius: 8px;
  color: var(--red2);
  text-align: center;
}

/* ═══════════════════════════════════════════
   FASE 8: ARTE DOS ITENS (sprites 16×16 e selo de elemento 7×7)
   ------------------------------------------- */
/* Pixel art nítida: sem suavização e em escala inteira (3× / 2×) */
.item-sprite,
.element-badge {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
}
.item-sprite {
  width: 48px;
  height: 48px;
}
/* Selo do elemento no canto superior esquerdo: a gema de raridade fica no
   direito e o nível/recarga embaixo, então nada se sobrepõe */
.element-badge {
  position: absolute;
  top: 1px;
  left: 1px;
  width: 14px;
  height: 14px;
  z-index: 3;
}
.inline-icon {
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
  position: relative;
}
.inline-icon .item-sprite {
  width: 32px;
  height: 32px;
}
.tt-name {
  display: flex;
  align-items: center;
  gap: 6px;
}
.tt-icon .item-sprite {
  width: 32px;
  height: 32px;
}
/* O ícone do cartão vira uma caixa do tamanho do sprite, para o selo ancorar no canto dele */
.item-choice-icon {
  position: relative;
  align-self: center;
}
.item-choice-icon .item-sprite {
  width: 64px;
  height: 64px;
}
.item-choice-icon .element-badge {
  top: -3px;
  left: -5px;
  width: 21px;
  height: 21px;
}
@media (max-width: 768px) {
  .item-sprite {
    width: 32px;
    height: 32px;
  }
}
@media (max-width: 480px) {
  .item-choice-icon .item-sprite {
    width: 48px;
    height: 48px;
  }
  .item-choice-icon .element-badge {
    width: 14px;
    height: 14px;
    top: -2px;
    left: -4px;
  }
}

/* ───── Fase 14: itens no celular ───── */
.item-panel[hidden] {
  display: none;
}
.item-panel {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 900; /* abaixo dos modais (1100) */
  max-height: 60vh;
  max-height: 60dvh;
  overflow-y: auto;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom, 0px));
  background: var(--bg2);
  border-top: 2px solid var(--border2);
  box-shadow: 0 -8px 28px rgba(0, 0, 0, 0.75);
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
  animation: itemPanelIn 0.18s ease-out;
}
@keyframes itemPanelIn {
  from {
    transform: translateY(24px);
    opacity: 0;
  }
}
.item-panel-close {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 44px;
  height: 44px;
  background: var(--bg4);
  border: 1px solid var(--border2);
  border-radius: 8px;
  color: var(--gold3);
  font-size: 18px;
  cursor: pointer;
}
.item-panel-close:focus-visible {
  outline: 2px solid var(--gold2);
  outline-offset: 2px;
}
.item-panel-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-right: 48px; /* espaço do X */
  margin-bottom: 12px;
}
.item-panel-icon {
  position: relative;
  flex: none;
  font-size: 48px;
  line-height: 1;
}
.item-panel-icon .item-sprite {
  width: 64px;
  height: 64px;
}
.item-panel-icon .element-badge {
  top: -3px;
  left: -5px;
  width: 21px;
  height: 21px;
}
.item-panel-name {
  font-family: "Reliquary Digits", "Pixelify Sans", sans-serif;
  font-size: 20px;
  line-height: 1.2;
  margin-bottom: 2px;
}
.item-panel-meta {
  font-size: 15px;
  color: var(--text);
  line-height: 1.4;
}
.item-panel-effect {
  padding: 10px 12px;
  background: var(--bg4);
  border-left: 3px solid var(--gold);
  border-radius: 6px;
  font-size: 16px;
  line-height: 1.5;
  color: var(--gold3);
}
.item-panel-enchant {
  margin-top: 8px;
  padding: 10px 12px;
  background: rgba(136, 68, 204, 0.18);
  border: 1px solid rgba(136, 68, 204, 0.4);
  border-radius: 6px;
  font-size: 16px;
  line-height: 1.5;
  color: #d3a6ff;
}
.item-slot.selected {
  border-color: var(--gold2);
  box-shadow: 0 0 8px rgba(232, 201, 106, 0.5);
}

/* Celular: com mais de 6 itens a caixa rola por dentro e a arena não desce */
@media (max-width: 768px), (hover: none) {
  .inv-items.inv-scroll {
    max-height: var(--inv-scroll-h, 168px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: var(--gold) var(--bg3);
  }
  .inv-items.inv-scroll::-webkit-scrollbar {
    width: 6px;
  }
  .inv-items.inv-scroll::-webkit-scrollbar-thumb {
    background: var(--gold);
    border-radius: 3px;
  }
  .inv-items.inv-scroll::-webkit-scrollbar-track {
    background: var(--bg3);
  }
}

/* Cartas de recompensa e escolha inicial no celular: texto maior e com mais contraste */
@media (max-width: 768px) {
  /* Linhas do tamanho do conteúdo: sem isso o grid espreme os cartões em vez de rolar */
  .item-choices {
    grid-auto-rows: max-content;
  }
  .item-choice-desc {
    font-size: 14px;
    color: var(--text);
  }
  .item-choice-effect {
    font-size: 15px;
    line-height: 1.45;
    color: var(--gold3);
  }
  .item-choice-enchant {
    font-size: 14px;
    line-height: 1.45;
    color: #d3a6ff;
  }
}

/* Fase 11a: encantamento ainda trancado (o nível do item não chegou lá) */
.tt-enchant.locked,
.item-choice-enchant.locked,
.item-panel-enchant.locked {
  opacity: 0.6;
  filter: grayscale(0.5);
}
.enchant-lock {
  display: block;
  font-weight: bold;
  color: var(--text2);
  margin-bottom: 2px;
}

/* Botão de rerrolar da tela de recompensa */
.reroll-btn {
  margin-top: 10px;
  min-height: 44px;
  padding: 8px 18px;
  font-family: inherit;
  font-size: 1rem;
  color: var(--gold2);
  background: var(--bg3);
  border: 2px solid var(--gold);
  border-radius: 8px;
  cursor: pointer;
}
.reroll-btn:hover:not(:disabled),
.reroll-btn:focus-visible {
  background: var(--gold);
  color: #1a1408;
  outline: none;
}
.reroll-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* O modal tem max-width de 800px: com 4 cartas ele alarga */
#item-choice-modal .modal-content:has(.item-choice-card:nth-child(4):last-child) {
  max-width: 1100px;
}

/* Mais uma opção: 4 cartas lado a lado no desktop, 2×2 no celular */
.item-choices:has(.item-choice-card:nth-child(4):last-child) {
  grid-template-columns: repeat(4, 1fr);
  max-width: 1100px;
  margin: 0 auto;
}
@media (max-width: 768px) {
  .item-choices:has(.item-choice-card:nth-child(4):last-child) {
    grid-template-columns: repeat(2, 1fr);
    max-width: none;
  }
}

/* Fase 11b: evolução dos itens comuns */
.evo-note {
  font-size: 12px;
  color: #7ad6a0;
  border-top: 1px solid var(--border);
  padding-top: 6px;
  margin-top: 4px;
  line-height: 1.5;
}
.item-panel-evo {
  margin-top: 8px;
  font-size: 16px;
}
.item-choice-evo {
  margin-top: 6px;
  font-size: 0.8rem;
}
.item-slot.evolved {
  border-color: var(--frame);
}

/* Fase 11c: itens míticos (clique na arena) */
.item-slot.mythic {
  border-color: var(--frame);
  box-shadow: 0 0 8px rgba(255, 77, 141, 0.55);
}
.item-choice-card.mythic {
  border-color: #ff4d8d;
  box-shadow: 0 0 14px rgba(255, 77, 141, 0.45);
}
#arena {
  touch-action: manipulation; /* toques rápidos não viram zoom de duplo toque */
}
.click-counter {
  position: absolute;
  right: 10px;
  bottom: 10px;
  z-index: 5;
  padding: 4px 10px;
  border-radius: 12px;
  background: rgba(10, 8, 6, 0.7);
  border: 1px solid rgba(255, 77, 141, 0.5);
  color: #ff4d8d;
  font-size: 14px;
  pointer-events: none;
  user-select: none;
}
.click-counter[hidden] {
  display: none;
}
.click-counter.at-limit {
  color: #fff;
  background: rgba(255, 77, 141, 0.6);
}
