/* --- ESTILOS GERAIS --- */
:root {
  --bg-color: #070707;
  --panel-bg: rgba(12, 12, 12, 0.88);
  --accent: #c7a35a;
  --text-main: #c8c2b8;
  --border: #2a2620;
  --muted: #7b7266;
  --rare: #f1c40f;
  --magic: #9b59b6;
  --faith: #f1c40f;
  --pyro: #d35400;
  --container-max: 1000px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Times New Roman", "Georgia", serif;
  background: radial-gradient(circle at 50% 20%, #141414, #050505 60%);
  background-color: #050505;
  min-height: 100vh;
  min-height: 100dvh;
  min-height: calc(var(--vh, 1vh) * 100);
  width: 100%;
  min-width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: calc(10px + var(--safe-top)) calc(10px + var(--safe-right))
    calc(20px + var(--safe-bottom)) calc(10px + var(--safe-left));
  color: var(--text-main);
  overflow-x: hidden;
  user-select: none;
  transition: background 1s ease;
  letter-spacing: 0.2px;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  max-width: 100%;
  overflow-x: hidden;
  height: auto;
  min-height: 100%;
}

html {
  background-color: #050505;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

.container {
  width: 100%;
  max-width: var(--container-max);
  background: linear-gradient(
    180deg,
    rgba(12, 12, 12, 0.92),
    rgba(8, 8, 8, 0.92)
  );
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 24px;
  padding-bottom: calc(80px + var(--safe-bottom));
  box-shadow: 0 0 30px rgba(0, 0, 0, 0.8);
  position: relative;
  animation: fadeIn 0.75s ease;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

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

.hidden {
  display: none !important;
}

h1,
h2,
h3 {
  color: var(--accent);
  text-align: center;
  margin-bottom: 15px;
  text-transform: uppercase;
  letter-spacing: 3px;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.6);
  font-weight: 500;
}

/* --- BOTÕES --- */
.button {
  background: var(--btn-bg, transparent);
  color: var(--btn-text, var(--text-main));
  border: 1px solid var(--btn-border, var(--border));
  padding: 10px 12px;
  font-weight: 600;
  border-radius: 4px;
  font-family: "Times New Roman", "Georgia", serif;
  cursor: pointer;
  text-transform: uppercase;
  width: 100%;
  transition: all 0.2s ease;
  box-shadow: var(--btn-shadow, none);
  margin-top: 6px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  touch-action: manipulation;
}
.exit-btn {
  position: sticky;
  bottom: 0;
  width: 100%;
  max-width: 100%;
  align-self: stretch;
  transform: none;
  z-index: 30;
  margin-top: 18px;
  margin-bottom: 0;
  box-shadow:
    0 6px 16px rgba(0, 0, 0, 0.18),
    0 0 10px rgba(199, 163, 90, 0.12);
  backdrop-filter: blur(2px);
  transition: none;
}

@media (max-width: 600px) {
  .exit-btn {
    bottom: calc(10px + var(--safe-bottom));
  }
}
.button:hover:not(:disabled) {
  border-color: var(--btn-hover-border, var(--accent));
  color: var(--btn-hover-text, #f4e8cf);
  background: var(--btn-hover-bg, rgba(199, 163, 90, 0.08));
  transform: translateY(-1px);
  box-shadow: var(--btn-hover-shadow, none);
}
.button:active:not(:disabled) {
  transform: translateY(0);
  background: var(--btn-active-bg, rgba(199, 163, 90, 0.14));
}

.button:disabled,
.button.disabled {
  background: transparent;
  border-color: #1f1f1f;
  color: #555;
  box-shadow: none;
  cursor: not-allowed;
  transform: none;
  filter: grayscale(1);
}

.button.secondary {
  --btn-bg: rgba(20, 20, 20, 0.6);
  --btn-border: #2a2a2a;
  --btn-text: var(--muted);
  --btn-hover-bg: rgba(80, 80, 80, 0.18);
  --btn-hover-text: #e0d9cd;
  --btn-hover-border: #3a3a3a;
}
.button.bonfire {
  --btn-bg: rgba(118, 71, 174, 0.22);
  --btn-border: #6b43b5;
  --btn-text: #ead9ff;
  --btn-hover-bg: rgba(118, 71, 174, 0.32);
  --btn-hover-border: #8a5ddc;
  --btn-shadow: 0 0 10px rgba(118, 71, 174, 0.25);
}
.path-btn.path-bonfire {
  border-left: 0 !important;
  filter: none !important;
}

.button.shop {
  --btn-bg: rgba(20, 34, 20, 0.35);
  --btn-border: #2f3a2f;
  --btn-text: #b9c9b9;
  --btn-hover-bg: rgba(43, 68, 43, 0.25);
  --btn-hover-border: #3d5a3d;
  --btn-hover-text: #e6f0e6;
}
.button.farm {
  --btn-bg: rgba(14, 34, 32, 0.35);
  --btn-border: #2a3b38;
  --btn-text: #b2c7c4;
  --btn-hover-bg: rgba(35, 76, 72, 0.25);
  --btn-hover-border: #36605a;
}
.button.main-quest {
  --btn-bg: rgba(48, 32, 54, 0.35);
  --btn-border: #3a2b3e;
  --btn-text: #d0c0d6;
  --btn-hover-bg: rgba(80, 50, 90, 0.25);
  --btn-hover-border: #5a3e66;
}
.button.attune {
  --btn-bg: rgba(30, 44, 48, 0.35);
  --btn-border: #2b3a3f;
  --btn-text: #b8c7cf;
  --btn-hover-bg: rgba(52, 78, 86, 0.25);
  --btn-hover-border: #3d5c66;
}
.button.inline {
  width: auto;
  display: inline-flex;
  align-self: flex-end;
}

/* Combat Specific Buttons */
.btn-atk {
  --btn-bg: rgba(74, 42, 36, 0.35);
  --btn-border: #4a2a24;
  --btn-text: #e7c9c0;
  --btn-hover-bg: rgba(120, 60, 52, 0.35);
  --btn-hover-border: #7a3f35;
}
.btn-mag {
  --btn-bg: rgba(58, 43, 62, 0.35);
  --btn-border: #3a2b3e;
  --btn-text: #d7c5de;
  --btn-hover-bg: rgba(86, 60, 98, 0.35);
  --btn-hover-border: #5e4370;
}
.btn-def {
  --btn-bg: rgba(34, 52, 58, 0.35);
  --btn-border: #2b3a3f;
  --btn-text: #c2d3da;
  --btn-hover-bg: rgba(52, 80, 90, 0.35);
  --btn-hover-border: #3f5b66;
}
.btn-ddg {
  --btn-bg: rgba(34, 56, 47, 0.35);
  --btn-border: #2b3a2f;
  --btn-text: #c7d8cd;
  --btn-hover-bg: rgba(52, 86, 70, 0.35);
  --btn-hover-border: #3f5f4b;
}
.btn-item {
  --btn-bg: rgba(58, 47, 42, 0.35);
  --btn-border: #3a2f2a;
  --btn-text: #d6c9c0;
  --btn-hover-bg: rgba(92, 72, 62, 0.35);
  --btn-hover-border: #5a463c;
}
.btn-wait {
  --btn-bg: rgba(58, 43, 34, 0.35);
  --btn-border: #3a2b22;
  --btn-text: #e6d7c8;
  --btn-hover-bg: rgba(92, 66, 50, 0.35);
  --btn-hover-border: #5a3f2f;
}

/* --- UI ELEMENTS --- */
#gameScreen {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: start;
}
.battle-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-areas:
    "player enemy"
    "actions log";
  gap: 20px;
}

#playerPanel {
  grid-area: player;
}

#enemyPanel {
  grid-area: enemy;
}

#combatControls {
  grid-area: actions;
}

#combatLog {
  grid-area: log;
}

@media (min-width: 701px) {
  #battleScreen .battle-layout {
    grid-template-areas:
      "player enemy"
      "actions log";
  }
}
.panel {
  background: rgba(12, 12, 12, 0.7);
  padding: 14px;
  border-radius: 6px;
  border: 1px solid #2a2a2a;
  position: relative;
  transition: transform 0.2s;
}
.bar-frame {
  background: #0a0a0a;
  height: 18px;
  border-radius: 3px;
  margin: 6px 0;
  border: 1px solid #222;
  overflow: hidden;
  position: relative;
}
.bar-fill {
  height: 100%;
  transition: width 0.4s cubic-bezier(0.25, 1, 0.5, 1);
}
.hp {
  background: linear-gradient(90deg, #c0392b, #e74c3c);
}
.mana {
  background: linear-gradient(90deg, #154360, #3498db);
}
.stam {
  background: linear-gradient(90deg, #d35400, #f39c12);
}
.bar-text {
  position: absolute;
  width: 100%;
  text-align: center;
  font-size: 0.75em;
  line-height: 18px;
  color: #d6d1c7;
  text-shadow: 0 1px 2px #000;
  top: 0;
  left: 0;
  z-index: 2;
  font-weight: bold;
}
.log {
  height: 150px;
  overflow-y: auto;
  font-family: "Consolas", "Courier New", monospace;
  font-size: 0.82em;
  background: rgba(8, 8, 8, 0.7);
  padding: 10px;
  border: 1px solid #222;
  margin-top: 15px;
  border-radius: 3px;
  -webkit-overflow-scrolling: touch;
}
.log p {
  margin-bottom: 3px;
  padding-left: 5px;
  border-left: 2px solid transparent;
}
.log .p {
  border-color: #4b6f55;
  color: #c8d2c8;
}
.log .e {
  border-color: #6a3b34;
  color: #d6b7b0;
}
.log .sys {
  border-color: #666;
  color: #9a948c;
}
.log .crit {
  border-color: #c7a35a;
  color: #c7a35a;
  font-weight: bold;
  background: rgba(199, 163, 90, 0.1);
}
.log .parry {
  border-color: #5a6f77;
  color: #9fb0b6;
  text-transform: uppercase;
  font-weight: bold;
}

.filter-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0 15px;
}

.filter-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 6px 10px;
  border-radius: 4px;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  font-size: 0.75em;
  transition:
    border-color 0.2s ease,
    color 0.2s ease,
    background 0.2s ease;
  touch-action: manipulation;
}

.filter-btn:hover {
  border-color: var(--accent);
  color: var(--text-main);
  background: rgba(199, 163, 90, 0.08);
}

.filter-btn.active {
  border-color: var(--accent);
  color: #f4e8cf;
  background: rgba(199, 163, 90, 0.12);
}

.inv-weight {
  white-space: nowrap;
}

.tab-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 6px 10px;
  border-radius: 4px;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  font-size: 0.75em;
  transition:
    border-color 0.2s ease,
    color 0.2s ease,
    background 0.2s ease;
  touch-action: manipulation;
}

.tab-btn:hover:not(.active) {
  border-color: var(--accent);
  color: var(--text-main);
  background: rgba(199, 163, 90, 0.08);
}

.tab-btn.active {
  border-color: var(--accent);
  color: #f4e8cf;
  background: rgba(199, 163, 90, 0.12);
}

.combat-actions .button {
  position: relative;
  overflow: hidden;
  transition:
    transform 0.15s ease,
    box-shadow 0.2s ease,
    border-color 0.2s ease;
}
.combat-actions .button::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    120deg,
    transparent,
    rgba(199, 163, 90, 0.2),
    transparent
  );
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}
.combat-actions .button:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 12px rgba(199, 163, 90, 0.25);
}
.combat-actions .button:hover::after {
  opacity: 0.18;
}
.combat-actions .button:active {
  transform: translateY(0) scale(0.98);
  box-shadow: 0 0 6px rgba(199, 163, 90, 0.2);
}

.story-animate {
  animation: storyFade 0.9s ease;
}

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

/* Float Text & Anims */
.float-text {
  position: absolute;
  font-weight: 900;
  font-family: impact, sans-serif;
  pointer-events: none;
  animation: floatUp 1s ease-out forwards;
  z-index: 100;
  text-shadow: 2px 2px 0 #000;
  width: 150px;
  text-align: center;
  margin-left: -75px;
}
.ft-dmg {
  color: #e74c3c;
  font-size: 2em;
}
.ft-heal {
  color: #2ecc71;
  font-size: 1.5em;
}
.ft-crit {
  color: #f1c40f;
  font-size: 2.5em;
  text-transform: uppercase;
}
.ft-res {
  color: #95a5a6;
  font-size: 1.5em;
  border: 1px solid #fff;
  background: #000;
}

@keyframes floatUp {
  0% {
    transform: translateY(0) scale(0.8);
    opacity: 0;
  }
  20% {
    transform: translateY(-20px) scale(1.2);
    opacity: 1;
  }
  100% {
    transform: translateY(-80px) scale(1);
    opacity: 0;
  }
}

@keyframes actionPulse {
  0%,
  100% {
    box-shadow: 0 0 0 rgba(199, 163, 90, 0);
  }
  50% {
    box-shadow: 0 0 10px rgba(199, 163, 90, 0.35);
  }
}

.anim-atk-right {
  animation: lungeRight 0.2s ease-in-out;
}
@keyframes lungeRight {
  50% {
    transform: translateX(30px) rotate(2deg);
  }
}
.anim-atk-left {
  animation: lungeLeft 0.2s ease-in-out;
}
@keyframes lungeLeft {
  50% {
    transform: translateX(-30px) rotate(-2deg);
  }
}
.anim-hit {
  animation: shake 0.3s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}
@keyframes shake {
  10%,
  90% {
    transform: translate3d(-1px, 0, 0);
  }
  20%,
  80% {
    transform: translate3d(2px, 0, 0);
  }
  30%,
  50%,
  70% {
    transform: translate3d(-4px, 0, 0);
  }
  40%,
  60% {
    transform: translate3d(4px, 0, 0);
  }
}
.anim-defend {
  animation: shieldPulse 0.4s ease;
  border-color: #3498db;
  box-shadow: inset 0 0 20px rgba(52, 152, 219, 0.5);
}
.anim-dodge {
  opacity: 0.5;
  transform: scale(0.9);
  filter: blur(2px);
  transition: 0.2s;
}

.paper-doll {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  background: #111;
  padding: 15px;
  border-radius: 8px;
  border: 1px solid #333;
}
.equip-slot {
  background: #1a1a1a;
  border: 1px dashed #444;
  height: 50px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 0.7em;
  color: #555;
  cursor: pointer;
  transition: 0.2s;
  touch-action: manipulation;
}
.equip-slot:hover {
  border-color: #777;
  background: #222;
}
.equip-slot.filled {
  border: 1px solid #e67e22;
  color: #fff;
  background: #2d241b;
}
.equip-slot.two-hand-span {
  grid-column: span 2;
  height: 56px;
}

.grid-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 10px;
  margin-bottom: 10px;
  max-height: 450px;
  overflow-y: auto;
  padding-right: 5px;
}
::-webkit-scrollbar {
  width: 6px;
}
::-webkit-scrollbar-track {
  background: #111;
}
::-webkit-scrollbar-thumb {
  background: #444;
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: #555;
}

.card {
  background: rgba(12, 12, 12, 0.85);
  padding: 12px;
  border-radius: 4px;
  border: 1px solid #2a2a2a;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.card h4 {
  text-align: left;
  margin-bottom: 5px;
  color: #e0d9cd;
  font-size: 0.9em;
  letter-spacing: 0.5px;
}
.card-desc {
  font-size: 0.75em;
  color: var(--muted);
  margin-bottom: 8px;
}

.overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(4, 4, 4, 0.92);
  z-index: 200;
  display: flex;
  justify-content: center;
  align-items: center;
  backdrop-filter: blur(2px);
  overscroll-behavior: contain;
}

#combatItemList,
#combatSkillList,
#fieldSkillList {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

#combatItemList .button,
#combatSkillList .button,
#fieldSkillList .button {
  touch-action: pan-y;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  border-bottom: 1px solid #222;
  align-items: center;
  font-size: 0.9em;
}
.attr-btn {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background: #333;
  border: 1px solid #555;
  color: #fff;
  touch-action: manipulation;
}

.souls-display {
  color: var(--accent);
  font-weight: 600;
  font-size: 1.05em;
  text-shadow: 0 0 6px rgba(199, 163, 90, 0.2);
}

#menuScreen .menu-souls {
  top: calc(12px + var(--safe-top));
  right: calc(12px + var(--safe-right));
  pointer-events: none;
  z-index: 5;
}

#menuScreen,
#mapScreen,
#battleScreen {
  width: min(980px, 100%);
  margin: 0 auto;
}

#menuScreen .menu-grid,
#mapScreen .grid-list,
#battleScreen .battle-layout {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
}

#battleScreen .combat-actions {
  width: 100%;
  max-width: 720px;
  margin-left: auto;
  margin-right: auto;
}

.menu-grid {
  width: 100%;
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  align-items: stretch;
  grid-auto-rows: minmax(64px, auto);
}

.menu-grid .button {
  min-height: 52px;
  padding: 10px 14px;
  font-size: 0.95rem;
  letter-spacing: 0.4px;
  border-radius: 4px;
  background: rgba(14, 14, 14, 0.95);
  border-color: rgba(199, 163, 90, 0.38);
  color: var(--text-main);
  font-weight: 600;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.35);
  justify-content: center;
  text-align: center;
  animation: menuButtonPulse 12s ease-in-out infinite alternate;
}

.menu-grid .button:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: rgba(199, 163, 90, 0.72);
  box-shadow: 0 10px 18px rgba(199, 163, 90, 0.18);
  background: rgba(199, 163, 90, 0.05);
}

#menuScreen .menu-grid .button {
  animation: none !important;
}

#menuScreen .menu-grid .button:nth-child(1) {
  --btn-border: #d6b65a;
  --btn-hover-border: #f2d184;
  --btn-hover-bg: rgba(214, 182, 90, 0.14);
  --btn-text: #f3e6c8;
}
#menuScreen .menu-grid .button:nth-child(2) {
  --btn-border: #5fa06b;
  --btn-hover-border: #7cc28a;
  --btn-hover-bg: rgba(127, 176, 137, 0.16);
  --btn-text: #e6f3ea;
}
#menuScreen .menu-grid .button:nth-child(3) {
  --btn-border: #6fa5e4;
  --btn-hover-border: #8cb8ec;
  --btn-hover-bg: rgba(111, 165, 228, 0.15);
  --btn-text: #e5f0ff;
}
#menuScreen .menu-grid .button:nth-child(4) {
  --btn-border: #d7c34f;
  --btn-hover-border: #e7d36c;
  --btn-hover-bg: rgba(215, 195, 79, 0.16);
  --btn-text: #f9f2ce;
}
#menuScreen .menu-grid .button:nth-child(5) {
  --btn-border: #e67e3a;
  --btn-hover-border: #f29b63;
  --btn-hover-bg: rgba(230, 126, 58, 0.15);
  --btn-text: #ffe7d7;
}
#menuScreen .menu-grid .button:nth-child(6) {
  --btn-border: #b884f2;
  --btn-hover-border: #cda2ff;
  --btn-hover-bg: rgba(184, 132, 242, 0.16);
  --btn-text: #f4eaff;
}
#menuScreen .menu-grid .button:nth-child(7) {
  --btn-border: #7c95a1;
  --btn-hover-border: #9fb6c2;
  --btn-hover-bg: rgba(124, 149, 161, 0.16);
  --btn-text: #e3edf2;
}
#menuScreen .menu-grid .button:nth-child(8) {
  --btn-border: #b2744c;
  --btn-hover-border: #c88d63;
  --btn-hover-bg: rgba(178, 116, 76, 0.16);
  --btn-text: #f2e5da;
}
#menuScreen .menu-grid .button:nth-child(9) {
  --btn-border: #9aa7b5;
  --btn-hover-border: #b7c4d1;
  --btn-hover-bg: rgba(154, 167, 181, 0.15);
  --btn-text: #eef2f6;
}
#menuScreen .menu-grid .button:nth-child(10) {
  --btn-border: #6bb6b3;
  --btn-hover-border: #8ed1ce;
  --btn-hover-bg: rgba(107, 182, 179, 0.16);
  --btn-text: #e5f6f5;
}
#menuScreen .menu-grid .button:nth-child(11) {
  --btn-border: #c7a35a;
  --btn-hover-border: #e1c17b;
  --btn-hover-bg: rgba(199, 163, 90, 0.16);
  --btn-text: #f6edd7;
}
#menuScreen .menu-grid .button:nth-child(12) {
  --btn-border: #6ec1a3;
  --btn-hover-border: #8bdbbf;
  --btn-hover-bg: rgba(110, 193, 163, 0.16);
  --btn-text: #e6f7f1;
}
#menuScreen .menu-grid .button:nth-child(13) {
  --btn-border: #d16a9c;
  --btn-hover-border: #e68db7;
  --btn-hover-bg: rgba(209, 106, 156, 0.16);
  --btn-text: #ffe6f1;
}
#menuScreen .menu-grid .button:nth-child(14) {
  --btn-border: #c15656;
  --btn-hover-border: #d87474;
  --btn-hover-bg: rgba(193, 86, 86, 0.15);
  --btn-text: #ffe5e5;
}

.menu-grid .button:focus-visible {
  outline: 2px solid rgba(199, 163, 90, 0.6);
  outline-offset: 2px;
}

#menuScreen .menu-grid {
  position: relative;
  z-index: 1;
}

#menuScreen .menu-grid .button[onclick*="openNpcDialogue"] {
  z-index: 6;
}

.menu-grid .button.secondary,
.menu-grid .button.shop {
  background: rgba(10, 10, 10, 0.94);
  border-color: rgba(199, 163, 90, 0.35);
}

.menu-grid .button.menu-btn-shop-muted {
  background: transparent;
  border-color: #3a2b3e;
  color: #d7c8b2;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.45);
}

.menu-grid .button.menu-btn-bonfire {
  border: 2px solid var(--accent);
  color: var(--accent);
  font-weight: 700;
  background: rgba(12, 12, 12, 0.9);
  box-shadow: 0 0 16px rgba(199, 163, 90, 0.4);
}

.menu-grid .button.menu-btn-champion {
  border-color: #6f8a94;
  color: #6f8a94;
  box-shadow: 0 0 16px rgba(111, 138, 148, 0.25);
}

.menu-grid .button.menu-btn-reset {
  background: rgba(10, 10, 10, 0.92);
  border-color: rgba(0, 0, 0, 0.65);
  color: #c5c5c5;
}

#menuScreen .menu-grid {
  position: relative;
}

#menuScreen .menu-grid .button {
  position: relative;
  z-index: 2;
}

@keyframes menuButtonPulse {
  from {
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.35);
  }
  to {
    box-shadow: 0 8px 18px rgba(199, 163, 90, 0.18);
  }
}

#ageGateScreen {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  margin: 0;
  max-height: calc(100dvh - var(--safe-top) - var(--safe-bottom) - 24px);
  overflow-y: auto;
}
.stat-diff {
  color: var(--muted);
  font-size: 0.8em;
  font-weight: 600;
  margin-left: 5px;
}

.death-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #000;
  color: #e74c3c;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 300;
  font-family: serif;
  text-transform: uppercase;
  animation: fadeIn 2s;
}
.death-text {
  font-size: 3.5em;
  letter-spacing: 5px;
  text-shadow: 0 0 20px #e74c3c;
  margin-bottom: 20px;
  text-align: center;
}

.bonfire-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  max-width: 900px;
  margin: 0 auto;
}

.bonfire-panel {
  background: rgba(0, 0, 0, 0.5);
  padding: 20px;
  border-radius: 10px;
  border: 1px solid #2a2a2a;
}

.bonfire-summary {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

#bfStatsList {
  display: grid;
  gap: 10px;
}

.bonfire-stat-row {
  margin: 0;
}

/* --- NEW STATS UI --- */
.stat-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 6px;
}
.tag-group {
  align-items: center;
}
.tag-label {
  font-size: 0.65em;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--muted);
  margin-right: 6px;
}
.tag {
  font-size: 0.7em;
  padding: 2px 4px;
  border-radius: 3px;
  border: 1px solid #333;
  font-weight: bold;
  font-family: monospace;
}
.tag.scale {
  border-color: #3498db;
  color: #85c1e9;
  background: #0f1a20;
}
.tag.req {
  border-color: #666;
  color: #888;
  background: #111;
}
.tag.req.fail {
  border-color: #c0392b;
  color: #ff6b6b;
  background: #2a0a0a;
}
.tag.res {
  border-color: #e67e22;
  color: #f39c12;
  background: #1a1005;
}

.equipped-row {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.equipped-row:last-child {
  border-bottom: 0;
}
.equipped-name {
  font-weight: bold;
  color: var(--text-main);
}
.equipped-meta {
  font-size: 0.75em;
  color: var(--muted);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.path-btn.path-main {
  border-left: 3px solid var(--accent);
}
.path-btn.path-optional {
  border-left: 3px dashed var(--accent);
  filter: saturate(0.85);
}

.res-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 5px;
  font-size: 0.8em;
  margin-bottom: 10px;
  background: #111;
  padding: 5px;
  border-radius: 4px;
}
.res-item {
  text-align: center;
  color: #aaa;
}
.res-val {
  color: #fff;
  font-weight: bold;
}

.cat-sorc {
  border-color: var(--magic);
  color: #d2b4de;
}
.cat-mir {
  border-color: var(--faith);
  color: #f9e79f;
}
.cat-neu {
  border-color: #7f8c8d;
  color: #bdc3c7;
}

/* --- STORY ELEMENTS --- */
.story-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(4, 4, 4, 0.92);
  z-index: 1000;
  display: flex;
  justify-content: center;
  align-items: center;
  animation: fadeIn 1s ease;
}

.story-container {
  background: rgba(10, 10, 10, 0.95);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 26px;
  max-width: 700px;
  width: 90%;
  max-height: 80vh;
  max-height: 80dvh;
  max-height: calc(var(--vh, 1vh) * 80);
  overflow-y: auto;
  color: var(--text-main);
  line-height: 1.6;
  box-shadow: 0 0 30px rgba(0, 0, 0, 0.7);
  position: relative;
}

.story-container h1 {
  color: var(--accent);
  text-align: center;
  margin-bottom: 20px;
  font-family: "Times New Roman", serif;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.6);
}

.story-container h2 {
  color: var(--accent);
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
  margin: 25px 0 15px 0;
}

.story-container p {
  margin-bottom: 15px;
  text-align: justify;
}

.story-container strong {
  color: var(--accent);
  font-weight: bold;
}

.story-container em {
  color: var(--muted);
  font-style: italic;
}

.story-highlight {
  background: rgba(199, 163, 90, 0.08);
  border-left: 2px solid var(--accent);
  padding: 15px;
  margin: 20px 0;
  border-radius: 0 6px 6px 0;
}

.story-quote {
  font-style: italic;
  color: var(--muted);
  text-align: center;
  padding: 20px;
  border-top: 1px solid #222;
  border-bottom: 1px solid #222;
  margin: 25px 0;
}

@keyframes pulse-glow {
  0% {
    box-shadow: 0 0 50px rgba(255, 215, 0, 0.3);
  }
  50% {
    box-shadow: 0 0 80px rgba(255, 215, 0, 0.6);
  }
  100% {
    box-shadow: 0 0 50px rgba(255, 215, 0, 0.3);
  }
}

/* Scrollbar personalizada para história */
.story-container::-webkit-scrollbar {
  width: 8px;
}

.story-container::-webkit-scrollbar-track {
  background: #0e0e0e;
  border-radius: 5px;
}

.story-container::-webkit-scrollbar-thumb {
  background: #3a3226;
  border-radius: 5px;
}

.story-container::-webkit-scrollbar-thumb:hover {
  background: #5c4a2e;
}

/* --- CHARACTER IMAGES --- */
.character-img {
  width: 100px;
  height: 100px;
  font-size: 4.2em;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 10px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid #2a2a2a;
}

.enemy-img {
  width: 130px;
  height: 130px;
  font-size: 4.8em;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 15px;
  border-radius: 8px;
  background: rgba(20, 12, 10, 0.5);
  border: 1px solid #3a2b25;
}

.npc-img {
  width: 150px;
  height: 150px;
  font-size: 6em;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
  border-radius: 8px;
  background: rgba(12, 12, 14, 0.7);
  border: 1px solid #2a2a2a;
  background-position: center 20%;
  background-size: cover;
  background-repeat: no-repeat;
}

.boss-img {
  border-color: #7a5b2a;
  background: rgba(26, 16, 8, 0.7);
  box-shadow: 0 0 20px rgba(199, 163, 90, 0.2);
}

/* --- IMAGE CONTAINERS --- */
.image-container {
  text-align: center;
  margin-bottom: 15px;
}

.hud-character {
  display: flex;
  align-items: center;
  gap: 15px;
  margin-bottom: 10px;
}

.hud-avatar {
  width: 100px;
  height: 100px;
  font-size: 3.2em;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid var(--border);
}

.clickable-avatar {
  cursor: zoom-in;
}

.avatar-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 30px 20px;
  z-index: 6500;
}

.avatar-modal-wrapper {
  background: transparent;
  border-radius: 16px;
  padding: 0;
  box-shadow: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.avatar-modal-wrapper .clickable-avatar {
  cursor: default;
}

/* Combat character images */
#playerAvatar,
#enemyAvatar {
  width: 110px;
  height: 110px;
  font-size: 3.6em;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  margin: 0 auto 10px;
}

#playerAvatar {
  border: 1px solid #2b3a3f;
  background: rgba(10, 20, 24, 0.6);
}

#enemyAvatar {
  border: 1px solid #3a2b25;
  background: rgba(30, 12, 12, 0.6);
}

/* --- CREATE SCREEN IMPROVEMENTS --- */
#createScreen {
  max-width: 980px;
}

.create-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-top: 22px;
  align-self: stretch;
  position: static;
}

.create-actions .button {
  width: 100%;
  max-width: 320px;
}

.create-import-btn {
  padding: 12px;
  font-size: 0.95em;
}

@media (max-width: 900px) {
  .create-actions {
    margin-top: 32px;
    position: static !important;
  }
}

.create-layout {
  display: grid;
  grid-template-columns: 1fr 1.25fr;
  gap: 22px;
  margin: 10px 0 20px;
  /* Avoid shrinking when #createScreen is in a flex column; otherwise the grid
     can collapse and overlap the action buttons on small screens */
  flex-shrink: 0;
}

.create-panel {
  background: rgba(0, 0, 0, 0.2);
  border: none;
  border-radius: 4px;
  padding: 14px 12px;
}

.create-section + .create-section {
  margin-top: 18px;
}

.create-title {
  color: var(--accent);
  text-align: center;
  margin-bottom: 12px;
  font-size: 0.95em;
  letter-spacing: 1px;
}

.create-subtitle {
  text-align: center;
  color: var(--muted);
  font-size: 0.9em;
  margin-top: -8px;
  margin-bottom: 16px;
  letter-spacing: 1px;
}

.create-note {
  text-align: center;
  color: var(--muted);
  font-size: 0.8em;
  margin-top: -6px;
  margin-bottom: 18px;
  letter-spacing: 0.6px;
}

.create-hint {
  text-align: center;
  color: var(--muted);
  font-size: 0.85em;
  margin-bottom: 12px;
}

.gender-selection {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-bottom: 0;
}

.gender-btn {
  width: 100px;
  height: 96px;
  background: rgba(12, 12, 12, 0.8);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: all 0.3s;
  padding: 10px;
}

.gender-btn:hover {
  border-color: var(--accent);
  color: #f4e8cf;
  transform: translateY(-2px);
}

.gender-btn.selected {
  border-color: var(--accent);
  background: rgba(199, 163, 90, 0.08);
  box-shadow: 0 0 10px rgba(199, 163, 90, 0.2);
  transform: translateY(-2px);
}

.gender-btn .gender-emoji {
  font-size: 2.4em;
  margin-bottom: 8px;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
}

.gender-btn .gender-label {
  color: var(--text-main);
  font-weight: 600;
  font-size: 0.85em;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* --- RESPONSIVE ADJUSTMENTS --- */
@media (max-width: 768px) {
  .class-btn {
    width: 120px;
    height: 150px;
  }

  .character-img {
    width: 85px;
    height: 85px;
    font-size: 3em;
  }

  .gender-btn {
    width: 100px;
    height: 100px;
  }

  .gender-btn .gender-emoji {
    font-size: 2.5em;
  }

  .enemy-img {
    width: 110px;
    height: 110px;
    font-size: 4.2em;
  }

  .npc-img {
    width: 130px;
    height: 130px;
    font-size: 5.2em;
  }

  .hud-avatar {
    width: 90px;
    height: 90px;
    font-size: 2.9em;
  }

  #playerAvatar,
  #enemyAvatar {
    width: 95px;
    height: 95px;
    font-size: 3.2em;
  }

  .class-carousel-controls {
    display: none;
  }
}

@keyframes pulse-ring {
  0% {
    box-shadow: 0 0 0 0 rgba(230, 126, 34, 0.7);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(230, 126, 34, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(230, 126, 34, 0);
  }
}
/* --- CLASS SELECTION IMPROVED --- */
.class-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(135px, 1fr));
  gap: 12px;
  justify-content: center;
  margin: 20px 0;
}

.class-btn {
  background: rgba(12, 12, 12, 0.85);
  border: 1px solid #2a2a2a;
  border-radius: 6px;
  padding: 12px 8px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  text-align: center;
  min-height: 190px;
  position: relative;
  overflow: hidden;
}

.class-btn:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.45);
}

.class-btn.selected {
  border-color: var(--accent);
  background: rgba(199, 163, 90, 0.08);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(199, 163, 90, 0.18);
}

/* Character Image - MAIOR E MELHOR ENCAIXADA */
.character-img-container {
  width: 140px;
  height: 140px;
  border-radius: 6px;
  border: 1px solid;
  margin-bottom: 15px;
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.npc-portrait-container img {
  object-position: center 20%;
}

.character-img-background {
  width: 100%;
  height: 100%;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  transition: transform 0.3s;
}

.class-btn:hover .character-img-background {
  transform: scale(1.05);
}

.character-img-emoji {
  font-size: 4em;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

/* Texto das classes */
.class-name {
  color: #e0d9cd;
  font-size: 1.1em;
  font-weight: 600;
  margin-bottom: 8px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
  letter-spacing: 0.5px;
}

.class-desc {
  color: var(--muted);
  font-size: 0.85em;
  margin-bottom: 10px;
  line-height: 1.4;
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
}

/* --- CREATE SCREEN LAYOUT --- */
#createScreen h1 {
  font-size: 2.1em;
  margin-bottom: 18px;
  color: var(--accent);
  letter-spacing: 4px;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.7);
}

#playerName {
  width: 100%;
  padding: 12px;
  margin-bottom: 10px;
  background: rgba(10, 10, 10, 0.9);
  border: 2px solid rgba(199, 163, 90, 0.55);
  color: var(--text-main);
  text-align: center;
  border-radius: 6px;
  font-size: 1em;
  font-weight: 600;
  transition: all 0.3s;
  letter-spacing: 1px;
  box-shadow: 0 0 12px rgba(199, 163, 90, 0.18);
}

#playerName:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 16px rgba(199, 163, 90, 0.35);
  background: rgba(12, 12, 12, 0.95);
}

@media (max-width: 900px) {
  .create-layout {
    grid-template-columns: 1fr;
  }
}

.create-section {
  margin-bottom: 25px;
  padding: 15px;
  background: rgba(10, 10, 10, 0.7);
  border-radius: 6px;
  border: 1px solid #2a2a2a;
}

.section-title {
  color: var(--accent);
  text-align: center;
  margin-bottom: 15px;
  font-size: 1.3em;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 2px;
}

.section-subtitle {
  color: var(--muted);
  text-align: center;
  font-size: 0.9em;
  margin-bottom: 15px;
  font-style: italic;
}

/* Warning message */
.tactical-warning {
  background: rgba(20, 10, 8, 0.5);
  border: 1px solid #3a2b25;
  border-radius: 6px;
  padding: 12px;
  text-align: center;
  margin: 20px 0;
  font-size: 0.9em;
}

.warning-title {
  color: var(--accent);
  font-weight: bold;
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.warning-desc {
  color: var(--muted);
  font-size: 0.9em;
}

/* Start Button */
.start-journey-btn {
  margin: 30px auto 15px;
  max-width: 320px;
  padding: 18px;
  font-size: 1.2em;
  font-weight: bold;
  letter-spacing: 1px;
  background: rgba(12, 12, 12, 0.9);
  border: 1px solid var(--accent);
  position: relative;
  overflow: hidden;
}

.create-starter-grid {
  flex-wrap: wrap;
  gap: 8px;
}

.class-carousel-controls {
  display: none;
  justify-content: center;
  gap: 10px;
  margin: 8px 0 12px;
}

.class-carousel-controls .button {
  width: auto;
  min-width: 120px;
}

.starter-btn {
  width: auto;
  min-width: 150px;
  height: auto;
  padding: 8px 10px;
  background: rgba(12, 12, 12, 0.8);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.3s;
}

.starter-btn:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.starter-btn.selected {
  border-color: var(--accent);
  box-shadow: 0 0 10px rgba(199, 163, 90, 0.2);
}

.starter-label {
  color: var(--text-main);
  font-size: 0.82em;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  text-align: center;
}

.class-stats-panel {
  margin-top: 12px;
  padding: 12px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
}

.class-stats-title {
  text-align: center;
  color: var(--accent);
  font-size: 0.85em;
  letter-spacing: 1px;
  margin-bottom: 10px;
}

.class-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
  gap: 8px;
  text-align: center;
  font-size: 0.85em;
}

.save-note {
  color: #666;
  font-size: 0.8em;
  text-align: center;
  margin-top: 10px;
}

/* Estilo para display de poções */
.potion-display {
  display: flex;
  gap: 10px;
  font-size: 0.9em;
  margin: 5px 0;
}

.potion-hp {
  color: #e74c3c;
  font-weight: bold;
}

.potion-mp {
  color: #3498db;
  font-weight: bold;
}

.potion-low {
  color: #ff6b6b;
  animation: pulse-opacity 1s infinite;
}

@keyframes pulse-opacity {
  0% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
  100% {
    opacity: 1;
  }
}

/* Estilos para o mapa com sub-áreas */
.card.locked {
  opacity: 0.6;
  filter: grayscale(70%);
}

.card.filled {
  border: 1px solid var(--accent) !important;
  box-shadow: 0 0 12px rgba(199, 163, 90, 0.2);
}

.map-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 15px;
}

.button.main-quest {
  background: transparent;
  border-color: #3a2b22;
  font-weight: 600;
}

.button.farm {
  background: transparent;
  border-color: #2b3a2f;
}

.button.boss-fight {
  --btn-bg: rgba(199, 163, 90, 0.12);
  --btn-border: var(--accent);
  --btn-text: #f4e8cf;
  --btn-hover-bg: rgba(199, 163, 90, 0.18);
  --btn-hover-border: #e6c677;
  --btn-shadow: 0 0 12px rgba(199, 163, 90, 0.25);
  animation: pulse-scale 2s infinite;
}

@keyframes pulse-scale {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
  100% {
    transform: scale(1);
  }
}

/* Progress bars */
.progress-container {
  background: #333;
  border-radius: 5px;
  padding: 3px;
  margin: 10px 0;
}

.progress-bar {
  height: 10px;
  border-radius: 3px;
  transition: width 0.3s;
}

/* Sub-area indicators */
.sub-area-indicator {
  display: flex;
  justify-content: center;
  gap: 5px;
  margin: 10px 0;
}

.sub-area-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #444;
}

.sub-area-dot.completed {
  background: #2ecc71;
}

.sub-area-dot.current {
  background: #f1c40f;
  animation: blink 1s infinite;
}

@keyframes blink {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

/* Estilos para o mapa */
.map-location {
  background: rgba(20, 20, 20, 0.8);
  border: 2px solid;
  border-radius: 8px;
  padding: 15px;
  margin-bottom: 15px;
  transition: all 0.3s;
  word-break: break-word;
}

.map-location.unlocked {
  border-color: #2ecc71;
  box-shadow: 0 0 10px rgba(46, 204, 113, 0.3);
}

.map-location.locked {
  border-color: #7f8c8d;
  opacity: 0.7;
}

#mapGrid .map-card-collapsed {
  min-height: 200px;
  display: flex;
}

.map-location-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.map-icon {
  font-size: 1.5em;
}

.map-level {
  margin-left: auto;
  background: rgba(199, 163, 90, 0.12);
  color: var(--accent);
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 0.8em;
}

.map-progress {
  margin: 15px 0;
}

.area-stats {
  display: grid;
  gap: 5px;
  margin-top: 10px;
  font-size: 0.9em;
  color: var(--muted);
}

.map-actions {
  display: flex;
  gap: 10px;
  margin-top: 15px;
  flex-wrap: wrap;
}

.lock-reason {
  font-size: 0.8em;
  color: #a07a6f;
  margin-top: 5px;
}

.map-action-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px;
  margin-top: 10px;
}

#mapScreen .card {
  padding-left: 22px;
  padding-right: 22px;
}

#mapGrid {
  align-items: stretch;
  grid-auto-rows: minmax(220px, auto);
}

#mapGrid .card {
  height: 100%;
}

#mapGrid .map-card-collapsed,
#mapGrid .map-card-expanded,
#mapGrid .card.filled {
  align-self: stretch;
}

#mapScreen .card .button {
  width: calc(100% - 6px);
}

#mapScreen .card.filled {
  max-width: 520px;
  margin: 0 auto 18px;
}

/* Grid de áreas */
.grid-list {
  display: grid;
  gap: 15px;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

.card {
  background: rgba(12, 12, 12, 0.85);
  border: 1px solid #2a2a2a;
  border-radius: 6px;
  padding: 15px;
  transition: all 0.3s;
}

.card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.card.locked {
  opacity: 0.6;
  border-color: #4a4a4a;
}

.card.filled {
  border-color: var(--accent);
  box-shadow: 0 0 12px rgba(199, 163, 90, 0.2);
}

/* Botões do mapa */
.button.main-quest {
  background: transparent;
  border-color: #3a2b22;
}

.button.farm {
  background: transparent;
  border-color: #2b3a2f;
}

/* Estilos para o HUD */
.hud-character {
  display: flex;
  align-items: center;
  gap: 15px;
  margin-bottom: 15px;
}

.hud-avatar {
  width: 100px;
  height: 100px;
  border: 2px solid #e67e22;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3.2em;
  background: rgba(0, 0, 0, 0.3);
}

.souls-display {
  background: rgba(199, 163, 90, 0.08);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 8px 15px;
  color: var(--accent);
  font-weight: 600;
  display: inline-block;
}

/* Classes para o sistema de desbloqueio */
.unlocked {
  opacity: 1;
}

.locked {
  opacity: 0.5;
  pointer-events: none;
}

.hidden {
  display: none !important;
}

/* Animações */
.pulse {
  animation: pulse-opacity 2s infinite;
}

/* Responsividade */
@media (max-width: 768px) {
  .grid-list {
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  }

  .map-location-header {
    flex-direction: column;
    text-align: center;
  }

  .map-level {
    margin-left: 0;
    margin-top: 5px;
  }
}

/* Adicione estas regras ao seu arquivo styles.css existente */

.equipped {
  position: relative;
  border: 1px solid var(--accent) !important;
}

.equipped-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  background: rgba(199, 163, 90, 0.2);
  color: var(--accent);
  font-size: 0.6em;
  padding: 1px 3px;
  border-radius: 2px;
}

.item-count {
  background: rgba(199, 163, 90, 0.18);
  color: var(--accent);
  font-size: 0.8em;
  padding: 2px 6px;
  border-radius: 10px;
  font-weight: bold;
}

.tab-btn {
  background: #333;
  border: 1px solid #555;
  color: #aaa;
  padding: 10px;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.3s;
  text-align: center;
  touch-action: manipulation;
}

.tab-btn.active {
  background: #444;
  border-color: #e67e22;
  color: #fff;
  box-shadow: 0 0 10px rgba(230, 126, 34, 0.5);
}

.tab-btn:hover:not(.active) {
  background: #3a3a3a;
  border-color: #777;
}

/* --- RESPONSIVE LAYOUT --- */
@media (max-width: 900px) {
  body {
    align-items: flex-start;
  }

  .container {
    padding: 16px;
  }

  .hud-character {
    grid-template-columns: 1fr !important;
    padding-right: 120px !important;
    gap: 12px !important;
  }

  .menu-souls {
    position: absolute !important;
    top: 16px;
    right: 16px;
    text-align: right !important;
    margin-top: 0;
  }

  .menu-grid {
    grid-template-columns: 1fr 1fr;
  }

  .bonfire-stats-grid {
    grid-template-columns: 1fr;
  }

  .bonfire-panel {
    padding: 16px;
  }

  .map-potions-row {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .map-potions-row .button {
    width: 100%;
  }

  .battle-layout {
    grid-template-columns: 1fr !important;
  }

  .inv-layout {
    grid-template-columns: 1fr !important;
  }
}

@media (max-width: 900px) and (orientation: landscape) {
  .battle-layout {
    grid-template-columns: 1fr 1fr !important;
    gap: 12px !important;
  }

  #battleScreen .panel {
    padding: 10px;
  }

  #battleScreen .bar-frame {
    height: 16px;
  }

  #battleScreen .bar-text {
    font-size: 0.7em;
    line-height: 16px;
  }

  #battleScreen .log {
    height: 90px;
  }

  #battleScreen .combat-actions {
    gap: 6px !important;
    margin-top: 8px !important;
  }

  #battleScreen .button {
    padding: 6px 8px;
    font-size: 0.75em;
  }

  #playerAvatar,
  #enemyAvatar {
    width: 80px;
    height: 80px;
    font-size: 2.6em;
    margin-bottom: 6px;
  }

  .menu-souls {
    position: absolute !important;
    top: 12px;
    right: 12px;
    margin-top: 0 !important;
    text-align: right !important;
  }

  .hud-character {
    grid-template-columns: auto 1fr !important;
    padding-right: 140px !important;
    gap: 12px !important;
  }
}

@media (max-width: 700px) {
  h1 {
    font-size: 1.6em;
    letter-spacing: 2px;
  }

  h2 {
    font-size: 1.3em;
    letter-spacing: 2px;
  }

  .grid-list {
    grid-template-columns: 1fr;
  }

  .combat-actions {
    grid-template-columns: 1fr 1fr !important;
  }

  #battleScreen #combatControls {
    grid-template-columns: 1fr 1fr !important;
  }

  .hud-character {
    margin-bottom: 8px;
  }

  #menuScreen #hudPotionDisplay {
    flex-wrap: wrap;
    gap: 6px;
    font-size: 0.7em;
  }

  #menuScreen .bar-frame {
    height: 22px !important;
    min-height: 22px;
  }

  #menuScreen .bar-text {
    font-size: 0.8em;
    line-height: 22px;
  }

  #menuScreen .menu-bar-row .bar-frame {
    height: 22px !important;
    min-height: 22px;
    width: 100%;
    display: block;
  }

  #menuScreen .souls-display {
    padding: 6px 10px;
    font-size: 0.9em;
  }

  #battleScreen .battle-layout {
    grid-template-columns: 1fr 1fr !important;
    gap: 10px !important;
  }

  #battleScreen > div:first-child {
    margin-bottom: 6px !important;
  }

  #battleScreen h3 {
    font-size: 1em;
  }

  #battleScreen #btnFlee {
    padding: 4px 10px !important;
    font-size: 0.7em !important;
  }

  #battleScreen .panel {
    padding: 10px;
  }

  #battleScreen .bar-frame {
    height: 22px;
    margin: 4px 0;
  }

  #battleScreen .bar-text {
    font-size: 0.8em;
    line-height: 22px;
  }

  #battleScreen .log {
    height: 100px;
    margin-top: 6px;
    padding: 8px;
  }

  #battleScreen .combat-actions {
    gap: 6px !important;
    margin-top: 6px !important;
  }

  #battleScreen .button {
    padding: 6px 8px;
    font-size: 0.75em;
  }

  #battleScreen .combat-actions .button {
    min-height: 36px;
  }

  #battleScreen .btn-wait {
    font-size: 0.7em;
  }

  #playerAvatar,
  #enemyAvatar {
    width: 80px;
    height: 80px;
    font-size: 2.6em;
    margin-bottom: 6px;
  }

  #combatLog,
  #combatControls {
    grid-column: 1 / -1;
  }

  #battleScreen .battle-layout {
    grid-template-areas:
      "player enemy"
      "log log"
      "actions actions";
  }

  #createScreen {
    max-height: calc(100dvh - var(--safe-top) - var(--safe-bottom) - 12px);
    overflow-y: auto;
  }

  .create-layout {
    gap: 14px;
    margin: 8px 0 16px;
  }

  .create-panel {
    padding: 12px 10px;
  }

  .create-section {
    margin-bottom: 16px;
    padding: 12px;
  }

  .create-title {
    font-size: 0.9em;
  }

  .create-subtitle {
    font-size: 0.85em;
    margin-bottom: 12px;
  }

  .create-note {
    font-size: 0.75em;
    margin-bottom: 12px;
  }

  #playerName {
    padding: 10px;
    font-size: 0.95em;
  }

  .class-stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    gap: 6px;
    font-size: 0.8em;
  }

  .class-btn {
    min-height: 170px;
    padding: 10px 8px;
  }

  .character-img-container {
    width: 120px;
    height: 120px;
    margin-bottom: 10px;
  }

  .starter-btn {
    min-width: 130px;
  }

  .menu-grid {
    grid-template-columns: 1fr 1fr;
  }

  #combatItemList,
  #combatSkillList,
  #fieldSkillList {
    max-height: calc(var(--vh, 1vh) * 55) !important;
    max-height: 55dvh !important;
  }

  .button {
    padding: 8px 10px;
  }

  .filter-buttons {
    gap: 6px;
  }

  .menu-bar-row {
    grid-template-columns: minmax(140px, 1fr) auto !important;
    gap: 6px !important;
  }

  .menu-bar-row .potion-btn {
    width: auto !important;
    max-width: none !important;
    min-width: 84px;
    padding: 6px 8px;
    font-size: 0.7em;
  }

  .map-potions-row {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    align-items: stretch;
  }

  .map-potions-row .button {
    width: 100%;
  }

  #mapGrid .button {
    width: 100%;
    white-space: normal;
  }

  .map-actions .button {
    width: 100%;
  }

  .button {
    white-space: normal;
  }
}

@media (max-width: 520px) {
  body {
    padding: calc(6px + var(--safe-top)) calc(6px + var(--safe-right))
      calc(6px + var(--safe-bottom)) calc(6px + var(--safe-left));
  }

  .container {
    padding: 12px;
    border-radius: 4px;
    max-height: calc(
      (var(--vh, 1vh) * 100) - var(--safe-top) - var(--safe-bottom) - 12px
    );
    max-height: calc(100dvh - var(--safe-top) - var(--safe-bottom) - 12px);
    overflow-y: auto;
  }

  .souls-display {
    text-align: center;
  }

  .button.inline {
    width: 100%;
    justify-content: center;
  }

  #menuScreen .hud-character {
    padding-right: 110px !important;
  }

  #createScreen {
    max-height: calc(100dvh - var(--safe-top) - var(--safe-bottom) - 12px);
    min-height: calc(100dvh - var(--safe-top) - var(--safe-bottom) - 12px);
    overflow-y: auto;
  }

  #createScreen .create-actions {
    margin-top: 22px;
    padding-top: 14px;
  }
}

@media (max-height: 700px) {
  #createScreen {
    max-height: calc(100dvh - var(--safe-top) - var(--safe-bottom) - 12px);
    min-height: calc(100dvh - var(--safe-top) - var(--safe-bottom) - 12px);
    overflow-y: auto;
  }

  #createScreen .create-layout {
    margin-bottom: 12px;
  }

  #createScreen .create-section {
    padding: 10px;
    margin-bottom: 12px;
  }

  #createScreen .class-stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(76px, 1fr));
    font-size: 0.78em;
  }
}

@media (max-width: 400px) {
  .menu-grid {
    grid-template-columns: 1fr 1fr !important;
    gap: 8px;
  }

  .menu-grid .button {
    font-size: 0.8em;
    padding: 8px 10px;
  }
}

@media (max-width: 600px) {
  #classSelection {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }

  .class-carousel-controls {
    display: none;
  }

  #createScreen {
    max-height: calc(100dvh - var(--safe-top) - var(--safe-bottom) - 12px);
    overflow-y: auto;
  }

  #createScreen .create-layout {
    min-height: 0;
  }
}

@media (max-width: 600px) {
  #mapGrid,
  #shopGrid,
  #spellShopGrid {
    display: grid !important;
    grid-template-columns: 1fr;
    gap: 10px;
    overflow-x: hidden;
  }
}

.stat-diff {
  color: #2ecc71;
  font-weight: bold;
  font-size: 0.8em;
  margin-left: 5px;
}

/* Melhorias visuais para o inventário */
.card {
  position: relative;
  transition: transform 0.2s;
}

.card:hover {
  transform: translateY(-1px);
}

/* Estilo para itens equipados na mochila */
.card .equipped-indicator {
  position: absolute;
  top: 10px;
  right: 10px;
  color: var(--accent);
  font-size: 0.8em;
}

.death-screen.hidden {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
}

/* Garantir que overlay fique acima de tudo */
.death-screen {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: 100% !important;
  z-index: 9999 !important;
  background: rgba(0, 0, 0, 0.95) !important;
  display: flex !important;
  flex-direction: column !important;
  justify-content: center !important;
  align-items: center !important;
}

/* Estilos para caminhos opcionais */
.path-optional {
  border-left: 4px solid #e67e22 !important;
  background: rgba(230, 126, 34, 0.1) !important;
}

.path-dungeon {
  position: relative;
}

.path-dungeon::before {
  content: "\1F3F0";
  position: absolute;
  left: 10px;
  top: 10px;
  font-size: 1.2em;
}

/* Animação para indicar caminhos opcionais */
@keyframes optional-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(230, 126, 34, 0.4);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(230, 126, 34, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(230, 126, 34, 0);
  }
}

.optional-path {
  animation: optional-pulse 2s infinite;
}

/* Navegacao por teclado */
.kbd-focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (pointer: coarse) {
  .button,
  .filter-btn,
  .tab-btn {
    min-height: 44px;
    padding: 12px 14px;
  }

  .attr-btn {
    width: 28px;
    height: 28px;
  }

  .equip-slot {
    height: 60px;
  }
}

#mapScreen .button {
  padding: 14px 20px;
  font-size: 1rem;
}
