:root {
  --bg-obsidian: #090b11;
  --stone-dark: #161923;
  --stone-mid: #222736;
  --stone-light: #353d52;
  --stone-highlight: #4c5672;
  --stone-shadow: #0c0e15;

  --gold-bright: #ffd970;
  --gold-mid: #e6a832;
  --gold-dark: #8a5b14;

  --emerald-bright: #42f58d;
  --emerald-mid: #1ec765;
  --emerald-dark: #0e6b35;

  --text-main: #f4f1ea;
  --text-muted: #adb5c7;

  --font-display: "Trebuchet MS", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-mono: "Consolas", "Courier New", monospace;

  --btn-radius: 4px;
  --panel-radius: 6px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-obsidian);
  color: var(--text-main);
  font-family: var(--font-display);
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

.game-shell {
  position: relative;
  width: 100%;
  height: 100dvh;
  overflow: hidden;
  background: #05070c;
}

.game-shell.is-splash-booting .game-canvas,
.game-shell.is-splash-booting .opening-screen,
.game-shell.is-splash-booting .vignette-layer {
  opacity: 0;
}

.game-canvas {
  position: absolute;
  inset: 0;
  z-index: 0;
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
}

.vignette-layer {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% 45%, transparent 32%, rgba(7, 9, 14, 0.58) 78%, rgba(5, 6, 10, 0.92) 100%),
    linear-gradient(to right, rgba(7, 9, 14, 0.72) 0%, rgba(7, 9, 14, 0.25) 45%, transparent 75%);
}

/* =========================================================
   Tela Splash + Loader do Herói com Tocha
   ========================================================= */
.splash-screen {
  position: absolute;
  inset: 0;
  z-index: 15;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(1rem, 3vw, 2.5rem);
  background:
    radial-gradient(circle at 50% 45%, #151b2b 0%, #0a0d15 58%, #05070c 100%);
  opacity: 0;
  transition: opacity 0.75s ease;
}

.splash-screen.is-visible {
  opacity: 1;
}

.splash-screen.is-fading {
  opacity: 0;
  pointer-events: none;
}

.splash-screen[hidden] {
  display: none;
}

.splash-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.splash-crest {
  margin-bottom: 1rem;
  animation: crestPulse 2s ease-in-out infinite;
}

.splash-title {
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 0.94;
  letter-spacing: 0.08em;
}

.splash-title .title-main {
  font-size: clamp(2rem, 5.2vw, 3.6rem);
}

.splash-title .title-sub {
  font-size: clamp(1.2rem, 3vw, 2.1rem);
}

.splash-subtitle {
  margin: 0.9rem 0 0;
  font-size: clamp(0.82rem, 1.25vw, 0.96rem);
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.splash-loader {
  position: absolute;
  right: clamp(1rem, 3vw, 2.4rem);
  bottom: clamp(0.9rem, 2.8vw, 2rem);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.85rem 0.35rem 0.45rem;
  background: rgba(14, 17, 26, 0.72);
  border: 1px solid rgba(230, 168, 50, 0.35);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.55);
}

.splash-loader-canvas {
  width: clamp(3.5rem, 6.5vw, 4.5rem);
  height: clamp(3.5rem, 6.5vw, 4.5rem);
  display: block;
}

.splash-loader-meta {
  display: flex;
  align-items: baseline;
  font-family: var(--font-mono);
  font-size: clamp(0.75rem, 1.15vw, 0.88rem);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold-bright);
}

.splash-dots span {
  display: inline-block;
  animation: dotBlink 1.2s infinite;
}

.splash-dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.splash-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes crestPulse {
  0%, 100% { transform: rotate(45deg) scale(1); }
  50% { transform: rotate(45deg) scale(1.07); }
}

@keyframes dotBlink {
  0%, 20% { opacity: 0.2; }
  50% { opacity: 1; }
  100% { opacity: 0.2; }
}

/* =========================================================
   Tela de Abertura (Mobile-first com clamp() fluido)
   ========================================================= */
.opening-screen {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  width: 100%;
  height: 100%;
  padding: clamp(1rem, 3.5vw, 3rem) clamp(1rem, 4.5vw, 4rem);
  pointer-events: none;
}

.opening-screen[hidden] {
  display: none;
}

.opening-header,
.opening-menu,
.opening-footer {
  pointer-events: auto;
}

.opening-header {
  max-width: min(100%, 34rem);
  margin-top: clamp(0.25rem, 2vh, 1.5rem);
}

.title-crest {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: clamp(2.2rem, 4vw, 3rem);
  height: clamp(2.2rem, 4vw, 3rem);
  margin-bottom: clamp(0.4rem, 1vw, 0.75rem);
  background: linear-gradient(145deg, var(--stone-light), var(--stone-dark));
  border: 2px solid var(--gold-mid);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.14),
    0 6px 18px rgba(0, 0, 0, 0.65);
  transform: rotate(45deg);
}

.crest-gem {
  display: block;
  width: 52%;
  height: 52%;
  background: linear-gradient(135deg, var(--emerald-bright), var(--emerald-dark));
  box-shadow: 0 0 14px rgba(66, 245, 141, 0.75);
}

.crest-gem--small {
  width: 1.1rem;
  height: 1.1rem;
  margin: 0 auto 0.75rem;
  transform: rotate(45deg);
}

.title-eyebrow {
  margin: 0 0 0.25rem;
  font-size: clamp(0.7rem, 1.1vw, 0.85rem);
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--gold-bright);
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.85);
}

.game-title {
  margin: 0;
  display: flex;
  flex-direction: column;
  line-height: 0.94;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.title-main {
  font-size: clamp(2.25rem, 6vw, 4.4rem);
  font-weight: 900;
  color: #fff6dc;
  text-shadow:
    0 3px 0 #5b4018,
    0 6px 0 #1f170c,
    0 12px 24px rgba(0, 0, 0, 0.85);
}

.title-sub {
  font-size: clamp(1.4rem, 3.6vw, 2.55rem);
  font-weight: 800;
  color: var(--emerald-bright);
  letter-spacing: 0.14em;
  text-shadow:
    0 2px 0 #0c4d26,
    0 5px 0 #072714,
    0 8px 20px rgba(30, 199, 101, 0.35);
}

.title-tagline {
  margin: clamp(0.6rem, 1.4vw, 1rem) 0 0;
  max-width: 30rem;
  font-size: clamp(0.88rem, 1.35vw, 1.05rem);
  line-height: 1.45;
  color: var(--text-muted);
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.95);
}

/* =========================================================
   Menu em blocos esculpidos (Estilo Minecraft Dungeons)
   ========================================================= */
.opening-menu {
  display: flex;
  flex-direction: column;
  gap: clamp(0.55rem, 1.2vh, 0.85rem);
  width: min(100%, clamp(15rem, 26vw, 20.5rem));
  margin: clamp(0.75rem, 2vh, 1.5rem) 0;
}

.dungeon-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.75rem;
  min-height: clamp(2.75rem, 5.2vh, 3.35rem);
  padding: clamp(0.6rem, 1.2vw, 0.85rem) clamp(1rem, 1.8vw, 1.35rem);
  font-family: var(--font-display);
  font-size: clamp(0.92rem, 1.35vw, 1.08rem);
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-main);
  background: linear-gradient(180deg, var(--stone-light) 0%, var(--stone-mid) 52%, var(--stone-dark) 100%);
  border: 2px solid var(--stone-shadow);
  border-radius: var(--btn-radius);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.14),
    inset 0 -3px 0 rgba(0, 0, 0, 0.45),
    0 6px 14px rgba(0, 0, 0, 0.55);
  cursor: pointer;
  transition: transform 0.14s ease, filter 0.14s ease, border-color 0.14s ease, box-shadow 0.14s ease;
}

.dungeon-btn:hover:not(:disabled),
.dungeon-btn.is-selected:not(:disabled) {
  transform: translateX(4px);
  border-color: var(--gold-mid);
  filter: brightness(1.1);
  box-shadow:
    inset 0 2px 0 rgba(255, 232, 160, 0.28),
    inset 0 -3px 0 rgba(0, 0, 0, 0.5),
    0 0 18px rgba(230, 168, 50, 0.3);
}

.dungeon-btn:active:not(:disabled) {
  transform: translateX(2px) translateY(1px);
}

.dungeon-btn:focus-visible,
.audio-pill:focus-visible,
.icon-close:focus-visible,
.stone-select:focus-visible,
input[type="range"]:focus-visible {
  outline: 3px solid var(--gold-bright);
  outline-offset: 2px;
}

.dungeon-btn:disabled {
  opacity: 0.42;
  cursor: not-allowed;
  filter: grayscale(0.4);
}

.dungeon-btn--primary {
  color: #091c10;
  background: linear-gradient(180deg, #5ef99e 0%, var(--emerald-mid) 58%, #107e3d 100%);
  border-color: #0a3c1f;
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.45),
    inset 0 -3px 0 rgba(5, 50, 22, 0.5),
    0 6px 20px rgba(30, 199, 101, 0.35);
}

.dungeon-btn--primary:hover:not(:disabled),
.dungeon-btn--primary.is-selected:not(:disabled) {
  border-color: var(--gold-bright);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.55),
    0 0 22px rgba(66, 245, 141, 0.52);
}

.btn-gem {
  width: 0.7rem;
  height: 0.7rem;
  background: #fff9d2;
  border: 1px solid #0e6b35;
  transform: rotate(45deg);
  flex-shrink: 0;
}

.btn-icon {
  font-size: 1rem;
  width: 1rem;
  text-align: center;
  color: var(--gold-bright);
  flex-shrink: 0;
}

/* =========================================================
   Rodapé da Abertura
   ========================================================= */
.opening-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.audio-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.45rem 0.9rem;
  font-family: var(--font-display);
  font-size: clamp(0.75rem, 1.1vw, 0.88rem);
  font-weight: 700;
  color: var(--text-main);
  background: rgba(16, 19, 28, 0.85);
  border: 1px solid var(--stone-highlight);
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.audio-pill:hover {
  border-color: var(--gold-mid);
  background: rgba(28, 33, 48, 0.92);
}

.audio-dot {
  width: 0.55rem;
  height: 0.55rem;
  background: #727b91;
  transform: rotate(45deg);
}

.audio-pill[aria-pressed="true"] .audio-dot {
  background: var(--emerald-bright);
  box-shadow: 0 0 8px var(--emerald-bright);
}

.version-badge {
  font-family: var(--font-mono);
  font-size: clamp(0.7rem, 1vw, 0.82rem);
  color: var(--text-muted);
  background: rgba(12, 14, 21, 0.75);
  padding: 0.35rem 0.7rem;
  border: 1px solid rgba(76, 86, 114, 0.45);
}

/* =========================================================
   Painéis em Pedra & Modais
   ========================================================= */
.stone-panel {
  background: linear-gradient(180deg, #272d3d 0%, #191d28 100%);
  border: 2px solid var(--gold-mid);
  border-radius: var(--panel-radius);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.12),
    inset 0 0 0 2px #10131b,
    0 24px 60px rgba(0, 0, 0, 0.82);
}

.modal-backdrop,
.prologue-overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(1rem, 3vw, 2rem);
  background: rgba(5, 7, 12, 0.76);
  backdrop-filter: blur(4px);
}

.modal-backdrop[hidden],
.prologue-overlay[hidden] {
  display: none;
}

.modal-card {
  width: min(100%, 31rem);
  padding: clamp(1rem, 2.5vw, 1.65rem);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 0.75rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid rgba(230, 168, 50, 0.35);
}

.modal-title {
  margin: 0;
  font-size: clamp(1.1rem, 2vw, 1.4rem);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--gold-bright);
}

.icon-close {
  width: 2.2rem;
  height: 2.2rem;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--text-main);
  background: var(--stone-dark);
  border: 1px solid var(--stone-highlight);
  cursor: pointer;
}

.icon-close:hover {
  border-color: var(--gold-mid);
  color: var(--gold-bright);
}

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  max-height: min(65dvh, 28rem);
  overflow-y: auto;
  padding-right: 0.25rem;
}

.setting-divider {
  width: 100%;
  border: 0;
  border-top: 1px solid rgba(230, 168, 50, 0.25);
  margin: 0.15rem 0;
}

.stone-checkbox {
  width: 1.25rem;
  height: 1.25rem;
  accent-color: var(--emerald-mid);
  cursor: pointer;
}

/* =========================================================
   Interface Em Jogo (Pausa + Sandbox de Teste da HUD)
   ========================================================= */
.ingame-shell {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: clamp(0.75rem, 2vw, 1.5rem);
  pointer-events: none;
}

.ingame-shell[hidden] {
  display: none;
}

.ingame-topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  pointer-events: none;
}

.hud-top-left,
.hud-top-right {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  pointer-events: auto;
}

.hud-top-right {
  align-items: flex-end;
}

.hud-top-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.5rem;
}

.hud-vitals-card {
  padding: clamp(0.5rem, 1.2vw, 0.75rem) clamp(0.65rem, 1.5vw, 0.95rem);
  min-width: clamp(12.5rem, 22vw, 17.5rem);
}

.hud-hearts {
  display: flex;
  align-items: center;
  gap: clamp(0.22rem, 0.5vw, 0.35rem);
  margin-bottom: 0.45rem;
}

.hud-heart {
  width: clamp(1.25rem, 2.2vw, 1.6rem);
  height: clamp(1.25rem, 2.2vw, 1.6rem);
  flex-shrink: 0;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.7));
  transition: transform 0.16s ease;
}

.hud-hearts.is-low .hud-heart--active {
  animation: heartPulse 0.85s ease-in-out infinite;
}

@keyframes heartPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.14); }
}

.hud-meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem;
}

.hud-emerald-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.18rem 0.5rem;
  font-family: var(--font-mono);
  font-size: clamp(0.75rem, 1.1vw, 0.88rem);
  color: var(--emerald-bright);
  background: rgba(10, 22, 16, 0.8);
  border: 1px solid var(--emerald-dark);
  border-radius: var(--btn-radius);
}

.emerald-icon {
  width: 0.55rem;
  height: 0.55rem;
  background: linear-gradient(135deg, var(--emerald-bright), var(--emerald-dark));
  transform: rotate(45deg);
  box-shadow: 0 0 6px rgba(66, 245, 141, 0.65);
}

.hud-objective {
  font-size: clamp(0.74rem, 1.05vw, 0.86rem);
  color: var(--text-muted);
}

.hud-minimap {
  position: relative;
  width: clamp(5.8rem, 10vw, 7.4rem);
  height: clamp(5.8rem, 10vw, 7.4rem);
  padding: 0.25rem;
  overflow: hidden;
}

.hud-minimap[hidden] {
  display: none;
}

.hud-minimap canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.hud-minimap-label {
  position: absolute;
  left: 0.35rem;
  bottom: 0.25rem;
  font-family: var(--font-mono);
  font-size: 0.64rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold-bright);
  text-shadow: 0 1px 3px #000;
  pointer-events: none;
}

/* Área inferior da HUD */
.hud-bottom-area {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: clamp(0.6rem, 2vw, 1.5rem);
  pointer-events: none;
}

.hud-action-bar {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding: clamp(0.45rem, 1vw, 0.65rem) clamp(0.55rem, 1.3vw, 0.85rem);
  pointer-events: auto;
}

.hud-slots-row {
  display: flex;
  align-items: center;
  gap: clamp(0.32rem, 0.7vw, 0.5rem);
}

.hud-slot-sep {
  width: 2px;
  height: 2.2rem;
  background: rgba(230, 168, 50, 0.3);
  margin: 0 0.1rem;
}

.hud-slot {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: clamp(2.7rem, 5.2vw, 3.45rem);
  height: clamp(2.7rem, 5.2vw, 3.45rem);
  padding: 0;
  background: linear-gradient(180deg, #2d3447 0%, #171b26 100%);
  border: 2px solid var(--stone-highlight);
  border-radius: var(--btn-radius);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.12),
    inset 0 -3px 0 rgba(0, 0, 0, 0.45);
  cursor: pointer;
  overflow: hidden;
  transition: transform 0.12s ease, border-color 0.12s ease;
}

.hud-slot:hover {
  border-color: var(--gold-mid);
  transform: translateY(-2px);
}

.hud-slot:active {
  transform: translateY(0);
}

.hud-slot--weapon.is-equipped {
  border-color: var(--gold-bright);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.25),
    0 0 12px rgba(255, 217, 112, 0.35);
}

.hud-slot--potion {
  border-color: #a83c4e;
}

.hud-slot--artifact {
  border-color: var(--emerald-dark);
}

.hud-slot--dash {
  border-color: var(--gold-dark);
}

.hud-svg-icon {
  position: relative;
  z-index: 1;
  width: 62%;
  height: 62%;
}

.hud-slot-cooldown {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 0%;
  z-index: 2;
  background: rgba(6, 9, 16, 0.72);
  pointer-events: none;
  transition: height 0.08s linear;
}

.hud-slot-timer {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 700;
  color: #fff6dc;
  text-shadow: 0 1px 4px #000;
  pointer-events: none;
}

.hud-count-badge {
  position: absolute;
  top: 0.14rem;
  right: 0.22rem;
  z-index: 3;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--gold-bright);
  text-shadow: 0 1px 3px #000;
}

.hud-key-hint {
  position: absolute;
  right: 0.15rem;
  bottom: 0.12rem;
  z-index: 3;
  padding: 0.04rem 0.24rem;
  font-family: var(--font-mono);
  font-size: 0.58rem;
  font-weight: 700;
  color: var(--text-main);
  background: rgba(8, 10, 16, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 2px;
  pointer-events: none;
}

.ingame-shell.hide-key-hints .hud-key-hint {
  display: none;
}

.hud-stamina-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.hud-stamina-label {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--gold-bright);
  white-space: nowrap;
}

.hud-key-hint--inline {
  position: static;
  font-size: 0.56rem;
}

.hud-stamina-track {
  flex: 1;
  height: 0.42rem;
  background: #0d1018;
  border: 1px solid var(--stone-highlight);
  border-radius: 3px;
  overflow: hidden;
}

.hud-stamina-fill {
  height: 100%;
  background: linear-gradient(90deg, #d98218, #ffd970);
  box-shadow: 0 0 8px rgba(255, 217, 112, 0.45);
  transition: width 0.08s linear;
}

.hud-stamina-fill.is-exhausted {
  background: linear-gradient(90deg, #8a2c2c, #d96b43);
  box-shadow: 0 0 6px rgba(217, 107, 67, 0.4);
}

.hud-xp-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.hud-level-badge {
  display: inline-flex;
  align-items: baseline;
  gap: 0.2rem;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--gold-bright);
  white-space: nowrap;
}

.hud-xp-track {
  flex: 1;
  height: 0.5rem;
  background: #0d1018;
  border: 1px solid var(--stone-highlight);
  border-radius: 3px;
  overflow: hidden;
}

.hud-xp-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--emerald-dark), var(--emerald-bright));
  box-shadow: 0 0 8px rgba(66, 245, 141, 0.55);
  transition: width 0.2s ease;
}

.hud-xp-text {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-muted);
  white-space: nowrap;
}

/* Controles Touch (Mobile / Tablet) */
.touch-joystick {
  position: absolute;
  left: clamp(0.85rem, 3vw, 2rem);
  bottom: clamp(0.85rem, 3vw, 2rem);
  pointer-events: auto;
  touch-action: none;
}

.touch-joystick[hidden],
.touch-actions[hidden] {
  display: none;
}

.touch-joystick-base {
  position: relative;
  width: clamp(5.8rem, 15vw, 7.2rem);
  height: clamp(5.8rem, 15vw, 7.2rem);
  border-radius: 50%;
  background: rgba(16, 20, 30, 0.62);
  border: 2px solid rgba(230, 168, 50, 0.45);
  box-shadow: inset 0 0 14px rgba(0, 0, 0, 0.65);
}

.touch-joystick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 44%;
  height: 44%;
  margin-left: -22%;
  margin-top: -22%;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, var(--gold-bright), var(--gold-dark));
  border: 2px solid #2b1b06;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.65);
  transition: transform 0.05s linear;
}

.touch-actions {
  position: absolute;
  right: clamp(0.85rem, 3vw, 2rem);
  bottom: clamp(0.85rem, 3vw, 2rem);
  display: grid;
  grid-template-columns: repeat(2, auto);
  gap: 0.5rem;
  pointer-events: auto;
  touch-action: manipulation;
}

.touch-btn {
  min-width: clamp(3.3rem, 9vw, 4.2rem);
  min-height: clamp(3.3rem, 9vw, 4.2rem);
  padding: 0.35rem;
  border-radius: 50%;
  font-family: var(--font-display);
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--text-main);
  background: rgba(24, 29, 42, 0.82);
  border: 2px solid var(--stone-highlight);
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.55);
  cursor: pointer;
}

.touch-btn--primary {
  background: linear-gradient(180deg, #42f58d, #128040);
  color: #07190d;
  border-color: var(--gold-bright);
}

.touch-btn:active {
  transform: scale(0.94);
}

/* Tremor de tela ao levar dano */
.game-shell.is-shaking .game-canvas {
  animation: screenShake 0.24s ease-out;
}

@keyframes screenShake {
  0% { transform: translate(0, 0); }
  25% { transform: translate(-5px, 3px); }
  50% { transform: translate(5px, -3px); }
  75% { transform: translate(-3px, -2px); }
  100% { transform: translate(0, 0); }
}

.hud-pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.48rem 0.85rem;
  font-family: var(--font-display);
  font-size: clamp(0.76rem, 1.1vw, 0.88rem);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-main);
  background: rgba(18, 22, 32, 0.88);
  border: 1px solid var(--stone-highlight);
  border-radius: var(--btn-radius);
  cursor: pointer;
}

.hud-pill-btn:hover {
  border-color: var(--gold-mid);
}

.hud-pill-btn--gold {
  border-color: var(--gold-mid);
  color: var(--gold-bright);
}

.sandbox-panel {
  align-self: flex-end;
  max-width: min(100%, 24rem);
  padding: 0.6rem 0.78rem;
  pointer-events: auto;
}

.sandbox-panel[hidden] {
  display: none;
}

.sandbox-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem 0.85rem;
  margin-bottom: 0.5rem;
}

.sandbox-title {
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold-bright);
}

.sandbox-readout {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--emerald-bright);
}

.sandbox-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.mini-stone-btn {
  padding: 0.32rem 0.58rem;
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-main);
  background: var(--stone-mid);
  border: 1px solid var(--stone-highlight);
  border-radius: var(--btn-radius);
  cursor: pointer;
}

.mini-stone-btn:hover {
  border-color: var(--gold-mid);
  filter: brightness(1.12);
}

.mini-stone-btn--danger {
  border-color: #a83c3c;
  color: #ffb4b4;
}

.mini-stone-btn--emerald {
  border-color: var(--emerald-dark);
  color: var(--emerald-bright);
}

.mini-stone-btn--gold {
  border-color: var(--gold-dark);
  color: var(--gold-bright);
}

.pause-card {
  width: min(100%, 24rem);
}

.pause-menu {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.setting-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  font-size: clamp(0.88rem, 1.25vw, 0.98rem);
}

.range-wrap {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.range-wrap input[type="range"] {
  width: clamp(7rem, 22vw, 10.5rem);
  accent-color: var(--emerald-mid);
  cursor: pointer;
}

.range-wrap output {
  min-width: 2.7rem;
  text-align: right;
  font-family: var(--font-mono);
  color: var(--gold-bright);
}

.stone-select {
  padding: 0.4rem 0.65rem;
  font-family: var(--font-display);
  font-size: 0.9rem;
  color: var(--text-main);
  background: var(--stone-dark);
  border: 1px solid var(--stone-highlight);
  cursor: pointer;
}

.controls-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.controls-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.45rem 0.65rem;
  background: rgba(12, 14, 21, 0.6);
  border: 1px solid rgba(76, 86, 114, 0.35);
  font-size: clamp(0.82rem, 1.2vw, 0.94rem);
}

.controls-list kbd {
  padding: 0.2rem 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.82em;
  font-weight: 700;
  color: var(--gold-bright);
  background: var(--stone-mid);
  border: 1px solid var(--gold-dark);
  white-space: nowrap;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  margin-top: 1.25rem;
}

.modal-footer .dungeon-btn {
  justify-content: center;
  min-width: 8.5rem;
}

/* =========================================================
   Tela de Transição de Prólogo
   ========================================================= */
.prologue-card {
  width: min(100%, 28rem);
  padding: clamp(1.25rem, 3vw, 2rem);
  text-align: center;
}

.prologue-chapter {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--emerald-bright);
}

.prologue-title {
  margin: 0.35rem 0 0.75rem;
  font-size: clamp(1.3rem, 2.5vw, 1.75rem);
  color: var(--gold-bright);
}

.prologue-text {
  margin: 0 0 1.4rem;
  font-size: clamp(0.88rem, 1.3vw, 1rem);
  line-height: 1.55;
  color: var(--text-muted);
}

.prologue-card .dungeon-btn {
  width: 100%;
  justify-content: center;
}

/* =========================================================
   Cortina de Fade Cinematográfico
   ========================================================= */
.fade-curtain {
  position: absolute;
  inset: 0;
  z-index: 20;
  background: #040509;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.45s ease;
}

.fade-curtain.is-active {
  opacity: 1;
  pointer-events: auto;
}

/* =========================================================
   Cursor de Tocha Isométrica (Desktop)
   ========================================================= */
.cursor-torch-canvas {
  position: fixed;
  inset: 0;
  z-index: 40;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

@media (pointer: fine) {
  body.has-torch-cursor,
  body.has-torch-cursor * {
    cursor: none !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  .dungeon-btn,
  .fade-curtain,
  .splash-screen,
  .splash-crest,
  .splash-dots span {
    transition: none;
    animation: none;
  }
}
