:root {
  --navy: #0A1018;
  --navy-2: #121A26;
  --navy-3: #1A2535;
  --gold: #C9A45C;
  --gold-dim: #8A7040;
  --cream: #E8DFC8;
  --danger: #C45C5C;
  --ok: #5CAD7A;
  --text: #E8DFC8;
  --muted: #8A9BB0;
  --radius: 12px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--navy);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  display: flex;
  justify-content: center;
  align-items: stretch;
}

.app {
  width: 100%;
  max-width: 430px;
  min-height: 100%;
  min-height: 100dvh;
  background: linear-gradient(180deg, var(--navy) 0%, #0D1520 100%);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow-x: hidden;
}

.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 12px 14px calc(16px + var(--safe-b));
  min-height: 100%;
  min-height: 100dvh;
}

.screen.hidden { display: none; }

/* Botões */
.btn {
  border: 1px solid var(--gold-dim);
  background: var(--navy-2);
  color: var(--cream);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn:not(:disabled):active { transform: scale(0.98); }
.btn.primary {
  background: linear-gradient(180deg, #D4B36A 0%, var(--gold) 100%);
  color: var(--navy);
  border-color: var(--gold);
}
.btn.ghost { background: transparent; }
.btn.evolve {
  background: var(--navy-3);
  border-color: var(--gold);
  color: var(--gold);
}
.btn.lg { padding: 14px 22px; font-size: 1.05rem; width: 100%; max-width: 280px; }
.btn.tiny { padding: 6px 10px; font-size: 0.85rem; }
.btn.danger { border-color: var(--danger); color: var(--danger); }
.btn.sell { border-color: var(--ok); color: var(--ok); font-size: 0.8rem; padding: 6px 10px; }

/* Título */
.title-hero {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 12px;
  padding: 24px 8px;
}
.title-hero h1 {
  font-size: 1.85rem;
  color: var(--gold);
  letter-spacing: 0.02em;
}
.proto {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
}
.subtitle { color: var(--muted); font-size: 0.95rem; }
.hint-title { margin-top: 8px; color: var(--gold-dim); font-size: 0.85rem; }

/* Top bar */
.top-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.top-title {
  flex: 1;
  font-size: 1.1rem;
  color: var(--gold);
  text-align: center;
}
.stat {
  font-size: 0.9rem;
  background: var(--navy-2);
  border: 1px solid var(--navy-3);
  border-radius: 8px;
  padding: 4px 10px;
  color: var(--cream);
}
.stat.gold { color: var(--gold); border-color: var(--gold-dim); }
.stat .ico { margin-right: 2px; }

/* Mapa */
.map-nodes {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  justify-content: center;
  padding: 8px 0 16px;
}
.map-node {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--navy-2);
  border: 2px solid var(--navy-3);
  border-radius: var(--radius);
  cursor: pointer;
  text-align: left;
  color: inherit;
  width: 100%;
}
.map-node .num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--navy-3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--muted);
  flex-shrink: 0;
}
.map-node .info { flex: 1; min-width: 0; }
.map-node .city { font-weight: 700; font-size: 1rem; }
.map-node .enemy { font-size: 0.8rem; color: var(--muted); }
.map-node.done {
  border-color: var(--ok);
  opacity: 0.7;
}
.map-node.done .num { background: var(--ok); color: var(--navy); }
.map-node.current {
  border-color: var(--gold);
  box-shadow: 0 0 0 1px var(--gold-dim);
}
.map-node.current .num { background: var(--gold); color: var(--navy); }
.map-node.locked { opacity: 0.45; cursor: default; }
.map-node.boss .city { color: var(--gold); }
.map-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
}
.map-actions .btn.primary { grid-column: 1 / -1; }
.map-hint { font-size: 0.8rem; color: var(--muted); text-align: center; }

/* Combate */
.combat-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.city-name { font-weight: 700; color: var(--gold); font-size: 0.95rem; }
.energy-bar {
  background: var(--navy-2);
  border: 1px solid var(--gold-dim);
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 0.85rem;
  color: var(--gold);
}
.energy-bar .label { color: var(--muted); margin-right: 6px; }

.enemy-panel {
  background: var(--navy-2);
  border: 1px solid var(--navy-3);
  border-radius: var(--radius);
  padding: 14px;
  text-align: center;
  position: relative;
  margin-bottom: 8px;
}
.intent {
  position: absolute;
  top: -10px;
  right: 12px;
  background: var(--navy);
  border: 1px solid var(--danger);
  color: #f0a0a0;
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 0.85rem;
  font-weight: 700;
}
.enemy-name { font-size: 1.15rem; font-weight: 700; margin-bottom: 8px; }
.hp-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.hp-bar {
  flex: 1;
  height: 12px;
  background: var(--navy);
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--navy-3);
}
.hp-fill { height: 100%; transition: width 0.25s; border-radius: 6px; }
.hp-fill.enemy { background: linear-gradient(90deg, #8B3A3A, var(--danger)); }
.hp-fill.player { background: linear-gradient(90deg, #2E6B4A, var(--ok)); }
.hp-text { font-size: 0.8rem; color: var(--muted); min-width: 52px; text-align: right; }
.block-badge {
  display: inline-block;
  margin-top: 6px;
  background: #1A3048;
  border: 1px solid #3A6080;
  color: #8EC0E8;
  border-radius: 8px;
  padding: 2px 8px;
  font-size: 0.8rem;
}
.block-badge.hidden { display: none; }

.combat-log {
  min-height: 36px;
  font-size: 0.8rem;
  color: var(--muted);
  text-align: center;
  padding: 4px 8px;
  margin-bottom: 4px;
}

.player-panel {
  background: var(--navy-2);
  border: 1px solid var(--navy-3);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 10px;
}
.you-label { font-size: 0.8rem; font-weight: 700; color: var(--gold); min-width: 36px; }

.hand {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  align-content: flex-start;
  flex: 1;
  overflow-y: auto;
  padding: 4px 0 8px;
  min-height: 140px;
}

.card {
  width: calc(50% - 4px);
  max-width: 160px;
  background: var(--navy-3);
  border: 2px solid var(--gold-dim);
  border-radius: 10px;
  padding: 8px 10px;
  cursor: pointer;
  text-align: left;
  color: inherit;
  position: relative;
  transition: border-color 0.15s, transform 0.1s;
}
.card:active:not(:disabled) { transform: scale(0.97); }
.card:disabled { opacity: 0.45; cursor: not-allowed; }
.card .cost {
  position: absolute;
  top: -8px;
  left: -6px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--gold);
  color: var(--navy);
  font-weight: 800;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--navy);
}
.card .ctype {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--gold-dim);
  margin-bottom: 2px;
}
.card .cname { font-weight: 700; font-size: 0.9rem; margin-bottom: 4px; line-height: 1.2; }
.card .ctext { font-size: 0.75rem; color: var(--muted); line-height: 1.3; }
.card.ataque { border-color: #8B5050; }
.card.bloqueio { border-color: #3A6080; }
.card.habilidade { border-color: var(--gold-dim); }
.card.reward-pick { max-width: none; width: 100%; }
.card.selected { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold); }

.combat-actions { padding-top: 4px; }
.combat-actions .btn { width: 100%; }

/* Recompensa */
.reward-intro {
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 12px;
}
.reward-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
  overflow-y: auto;
  margin-bottom: 12px;
}
.reward-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Baralho */
.deck-hint {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 12px;
  text-align: center;
}
.deck-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  flex: 1;
}
.deck-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--navy-2);
  border: 1px solid var(--navy-3);
  border-radius: 10px;
  padding: 10px 12px;
}
.deck-row .meta { flex: 1; min-width: 0; }
.deck-row .name { font-weight: 700; font-size: 0.9rem; }
.deck-row .desc { font-size: 0.75rem; color: var(--muted); }

/* Equipamento */
.section-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gold-dim);
  margin: 12px 0 8px;
}
.slots {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.slot-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--navy-2);
  border: 1px solid var(--navy-3);
  border-radius: 10px;
  padding: 10px 12px;
}
.slot-row .slot-label {
  width: 72px;
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  flex-shrink: 0;
}
.slot-row .piece { flex: 1; min-width: 0; }
.slot-row .piece-name { font-weight: 700; font-size: 0.9rem; }
.slot-row .piece-bonus { font-size: 0.75rem; color: var(--ok); }
.slot-row.empty .piece-name { color: var(--muted); font-weight: 500; font-style: italic; }

.inv-list, .shop-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 8px;
}
.item-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  background: var(--navy-2);
  border: 1px solid var(--navy-3);
  border-radius: 10px;
  padding: 10px 12px;
}
.item-row .piece { flex: 1; min-width: 120px; }
.item-row .actions { display: flex; gap: 6px; flex-wrap: wrap; }
.empty-hint { font-size: 0.85rem; color: var(--muted); text-align: center; padding: 8px; }
.empty-hint.hidden { display: none; }

.price { color: var(--gold); font-size: 0.85rem; font-weight: 700; }

@media (min-width: 400px) {
  .card { width: calc(33.33% - 6px); }
}
