:root {
  --cyan: #5df2ff;
  --mint: #14f195;
  --gold: #ffd166;
  --danger: #ff4d6d;
  --ink: #061116;
  --panel: rgba(5, 13, 20, 0.78);
  --line: rgba(140, 230, 255, 0.32);
}

* { box-sizing: border-box; }

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #061116;
  color: #eefcff;
  font-family: Inter, Arial, sans-serif;
}

button {
  border: 0;
  cursor: pointer;
  font: inherit;
}

#game-shell,
#game-canvas {
  position: fixed;
  inset: 0;
}

#game-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

#boot-screen {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 28% 20%, rgba(20, 241, 149, 0.16), transparent 32%),
    radial-gradient(circle at 68% 30%, rgba(93, 242, 255, 0.14), transparent 34%),
    linear-gradient(150deg, #061116 0%, #0b1920 48%, #15131b 100%);
}

.boot-panel {
  width: min(640px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  overflow: auto;
  padding: 28px;
  border: 1px solid var(--line);
  background: rgba(5, 13, 20, 0.84);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.42);
  border-radius: 8px;
}

.brand,
h1,
.panel-title,
#phase-name,
#wallet-btn,
#word-wallet-btn,
#start-game {
  font-family: Orbitron, Inter, sans-serif;
}

.brand {
  color: var(--mint);
  text-transform: uppercase;
  font-weight: 800;
}

h1 {
  margin: 8px 0 12px;
  font-size: clamp(2rem, 5vw, 4rem);
  line-height: 1;
  letter-spacing: 0;
}

.boot-panel p {
  max-width: 58ch;
  line-height: 1.55;
  color: #cce8ec;
}

.hero-select {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 22px 0;
}

.hero-card {
  min-height: 220px;
  padding: 10px;
  text-align: left;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.07);
  color: #eefcff;
  overflow: hidden;
}

.hero-card.selected {
  border-color: var(--mint);
  box-shadow: inset 0 0 0 1px rgba(20, 241, 149, 0.32);
}

.hero-card span,
.hero-card small {
  display: block;
}

.hero-card img {
  width: 100%;
  aspect-ratio: 4 / 5;
  display: block;
  object-fit: cover;
  object-position: center top;
  border-radius: 6px;
  margin-bottom: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.hero-card span {
  font-weight: 800;
  margin-bottom: 8px;
}

.hero-card small { color: #b9d7dc; }

.concept-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: -6px 0 18px;
}

.concept-strip figure {
  margin: 0;
  overflow: hidden;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
}

.concept-strip img {
  width: 100%;
  aspect-ratio: 1 / 1;
  display: block;
  object-fit: cover;
  object-position: center top;
}

.concept-strip figcaption {
  padding: 7px 8px;
  color: #d8eef2;
  font-size: 0.78rem;
  font-weight: 700;
}

#start-game {
  width: 100%;
  padding: 15px 18px;
  color: #061116;
  background: var(--mint);
  border-radius: 8px;
  font-weight: 800;
}

.boot-note {
  margin-top: 12px;
  color: #94b8be;
  font-size: 0.88rem;
}

#hud {
  position: fixed;
  top: 16px;
  left: 16px;
  width: min(620px, calc(100vw - 32px));
  z-index: 10;
  display: grid;
  gap: 10px;
  pointer-events: none;
}

.hud-row {
  display: grid;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
  backdrop-filter: blur(10px);
}

.vitals { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.combat { grid-template-columns: 1.4fr 0.8fr 0.7fr 0.7fr; }

.hud-row span {
  display: block;
  color: #9fc9cf;
  font-size: 0.72rem;
  text-transform: uppercase;
}

.hud-row b {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #fff;
}

.bar {
  position: relative;
  height: 8px;
  margin: 6px 0 4px;
  background: rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  overflow: hidden;
}

.bar i {
  position: absolute;
  inset: 0 auto 0 0;
  width: 100%;
  background: linear-gradient(90deg, #ff4d6d, #ffd166);
}

.bar.shield i { background: linear-gradient(90deg, #4ea8ff, #5df2ff); }
.bar.stamina i { background: linear-gradient(90deg, #14f195, #baff29); }

#wallet-panel {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 27;
  width: min(260px, calc(100vw - 32px));
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
  backdrop-filter: blur(10px);
}

#wallet-btn,
#word-wallet-btn,
#airdrop-sol,
#mint-selected,
#store-toggle,
#craft-toggle,
#market-toggle,
#leaderboard-toggle {
  min-height: 40px;
  padding: 9px 12px;
  border-radius: 8px;
  color: #061116;
  font-weight: 800;
  background: var(--mint);
}

.wallet-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

#word-wallet-btn {
  background: linear-gradient(135deg, #5df2ff, #14f195);
}

#word-wallet-btn.recommended {
  box-shadow: 0 0 0 2px rgba(93, 242, 255, 0.28), 0 0 22px rgba(20, 241, 149, 0.28);
}

#airdrop-sol,
#mint-selected,
#store-toggle,
#craft-toggle,
#market-toggle,
#leaderboard-toggle {
  background: rgba(255, 255, 255, 0.12);
  color: #eefcff;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

#store-toggle {
  background: linear-gradient(135deg, rgba(255, 209, 102, 0.92), rgba(20, 241, 149, 0.82));
  color: #061116;
}

#craft-toggle,
#market-toggle,
#leaderboard-toggle {
  min-height: 36px;
}

#wallet-address {
  color: #b8d6dc;
  font-size: 0.82rem;
  overflow-wrap: anywhere;
}

#store-panel {
  position: fixed;
  right: 292px;
  top: 16px;
  z-index: 35;
  width: min(460px, calc(100vw - 324px));
  max-height: calc(100vh - 32px);
  display: grid;
  gap: 10px;
  padding: 14px;
  overflow: auto;
  border: 1px solid rgba(255, 209, 102, 0.46);
  background: rgba(5, 13, 20, 0.9);
  border-radius: 8px;
  backdrop-filter: blur(12px);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.34);
}

.economy-panel {
  position: fixed;
  right: 292px;
  top: 16px;
  z-index: 35;
  width: min(620px, calc(100vw - 324px));
  max-height: calc(100vh - 32px);
  display: grid;
  gap: 12px;
  padding: 14px;
  overflow: auto;
  border: 1px solid rgba(93, 242, 255, 0.42);
  background: rgba(5, 13, 20, 0.92);
  border-radius: 8px;
  backdrop-filter: blur(12px);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.34);
}

.store-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

#store-balance,
.store-note {
  color: #a9c8cf;
  font-size: 0.82rem;
}

#store-close {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  color: #061116;
  background: var(--gold);
  font-weight: 900;
}

.panel-close {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  color: #061116;
  background: var(--cyan);
  font-weight: 900;
}

#store-list,
#craft-list,
#leaderboard-list {
  display: grid;
  gap: 8px;
}

.store-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.08);
  border-radius: 8px;
}

.store-item b,
.store-item span,
.store-buy strong {
  display: block;
}

.store-item span {
  margin-top: 4px;
  color: #bddce1;
  font-size: 0.82rem;
  line-height: 1.35;
}

.store-buy {
  display: grid;
  gap: 7px;
  min-width: 122px;
  text-align: right;
}

.store-buy strong {
  color: var(--gold);
  font-family: Orbitron, Inter, sans-serif;
  font-size: 0.82rem;
}

.store-buy button {
  min-height: 34px;
  padding: 7px 10px;
  border-radius: 8px;
  background: var(--mint);
  color: #061116;
  font-weight: 800;
}

.store-buy button:disabled {
  cursor: wait;
  opacity: 0.52;
}

.rarity-Lendario { border-color: rgba(255, 209, 102, 0.52); }
.rarity-Epico { border-color: rgba(255, 106, 193, 0.48); }
.rarity-Raro { border-color: rgba(123, 140, 255, 0.48); }

.market-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.subpanel-title {
  display: block;
  margin-bottom: 8px;
  color: var(--gold);
  font-family: Orbitron, Inter, sans-serif;
  font-size: 0.82rem;
}

#market-owned-list,
#market-listings {
  display: grid;
  gap: 8px;
}

.market-row,
.leader-row {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
}

.market-row span,
.leader-row span {
  display: block;
  margin-top: 3px;
  color: #bddce1;
  font-size: 0.8rem;
}

.market-actions {
  display: grid;
  grid-template-columns: minmax(72px, 1fr) auto;
  gap: 7px;
  align-items: center;
}

.market-actions input {
  min-height: 34px;
  min-width: 0;
  padding: 7px 8px;
  border: 1px solid rgba(93, 242, 255, 0.24);
  border-radius: 8px;
  color: #eefcff;
  background: rgba(0, 0, 0, 0.22);
}

.market-actions button {
  min-height: 34px;
  padding: 7px 10px;
  border-radius: 8px;
  background: var(--mint);
  color: #061116;
  font-weight: 800;
}

.market-actions strong {
  color: var(--gold);
  font-family: Orbitron, Inter, sans-serif;
  font-size: 0.78rem;
}

#gold-flash {
  position: fixed;
  inset: 0;
  z-index: 34;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(circle, rgba(255, 209, 102, 0.34), transparent 60%);
}

#gold-flash.pulse {
  animation: goldPulse 0.72s ease-out;
}

@keyframes goldPulse {
  0% { opacity: 0; }
  25% { opacity: 1; }
  100% { opacity: 0; }
}

#phase-complete {
  position: fixed;
  inset: 0;
  z-index: 33;
  display: grid;
  place-items: center;
  pointer-events: none;
  background: radial-gradient(circle, rgba(20, 241, 149, 0.14), rgba(0, 0, 0, 0.42));
}

.phase-complete-inner {
  display: grid;
  gap: 8px;
  min-width: min(560px, calc(100vw - 32px));
  padding: 24px;
  text-align: center;
  border: 1px solid rgba(255, 209, 102, 0.52);
  background: rgba(5, 13, 20, 0.84);
  border-radius: 8px;
  box-shadow: 0 0 60px rgba(255, 209, 102, 0.24);
}

.phase-complete-inner span,
.phase-complete-inner b {
  font-family: Orbitron, Inter, sans-serif;
  font-weight: 900;
}

.phase-complete-inner span {
  color: var(--gold);
  font-size: clamp(1.8rem, 5vw, 4.4rem);
}

.phase-complete-inner b {
  color: #fff;
}

.phase-complete-inner small {
  color: #bddce1;
}

#phase-complete.show .phase-complete-inner {
  animation: phasePop 2.2s ease-out;
}

@keyframes phasePop {
  0% { opacity: 0; transform: scale(0.86) translateY(20px); }
  18% { opacity: 1; transform: scale(1.03) translateY(0); }
  72% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.06); }
}

#radar-panel {
  position: fixed;
  left: 16px;
  top: 174px;
  z-index: 10;
  width: 126px;
  padding: 8px;
  border: 1px solid var(--line);
  background: rgba(5, 13, 20, 0.68);
  border-radius: 8px;
  backdrop-filter: blur(10px);
  pointer-events: none;
}

.radar-title {
  margin-bottom: 6px;
  color: var(--cyan);
  font-family: Orbitron, Inter, sans-serif;
  font-size: 0.68rem;
  font-weight: 800;
}

#radar-disc {
  position: relative;
  width: 108px;
  height: 108px;
  overflow: hidden;
  border-radius: 50%;
  border: 1px solid rgba(93, 242, 255, 0.34);
  background:
    linear-gradient(rgba(93, 242, 255, 0.1) 1px, transparent 1px),
    linear-gradient(90deg, rgba(93, 242, 255, 0.1) 1px, transparent 1px),
    rgba(6, 17, 22, 0.72);
  background-size: 18px 18px;
}

#radar-disc::before {
  content: "";
  position: absolute;
  inset: 8px;
  border: 1px dashed rgba(20, 241, 149, 0.28);
  border-radius: 50%;
  transform: rotate(var(--radar-rotation, 0rad));
}

.radar-player,
.radar-blip {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 8px;
  height: 8px;
  margin: -4px 0 0 -4px;
  border-radius: 50%;
}

.radar-player {
  background: var(--mint);
  box-shadow: 0 0 14px rgba(20, 241, 149, 0.8);
}

.radar-blip {
  background: var(--danger);
  box-shadow: 0 0 10px rgba(255, 77, 109, 0.76);
}

.radar-blip.boss {
  width: 11px;
  height: 11px;
  margin: -5px 0 0 -5px;
  background: var(--gold);
}

.radar-blip.loot {
  width: 7px;
  height: 7px;
  margin: -3px 0 0 -3px;
  background: var(--cyan);
}

#mission-panel {
  position: fixed;
  left: 50%;
  bottom: 22px;
  z-index: 12;
  transform: translateX(-50%);
  width: min(720px, calc(100vw - 32px));
  padding: 14px 16px;
  border: 1px solid rgba(255, 209, 102, 0.38);
  background: rgba(6, 17, 22, 0.82);
  border-radius: 8px;
  backdrop-filter: blur(10px);
}

#phase-name {
  color: var(--gold);
  font-weight: 800;
}

#mission-text {
  margin-top: 4px;
  color: #eefcff;
}

.mission-progress {
  position: relative;
  height: 6px;
  margin-top: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
}

.mission-progress i {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0%;
  background: linear-gradient(90deg, var(--gold), var(--mint));
}

#dialogue {
  position: fixed;
  left: 50%;
  bottom: 112px;
  z-index: 20;
  width: min(780px, calc(100vw - 32px));
  transform: translateX(-50%);
  padding: 16px;
  border: 1px solid rgba(93, 242, 255, 0.38);
  background: rgba(4, 9, 13, 0.88);
  border-radius: 8px;
  backdrop-filter: blur(10px);
}

#dialogue b {
  color: var(--mint);
  font-family: Orbitron, Inter, sans-serif;
}

#dialogue p {
  margin: 8px 0 0;
  line-height: 1.48;
}

.hidden { display: none !important; }

#inventory-panel,
#codex-panel {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 11;
  width: min(330px, calc(100vw - 32px));
  max-height: 38vh;
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
  backdrop-filter: blur(10px);
}

#codex-panel {
  left: 16px;
  right: auto;
  bottom: 112px;
}

.panel-title {
  margin-bottom: 8px;
  color: var(--cyan);
  font-weight: 800;
}

.inv-item,
.chain-item {
  display: grid;
  gap: 3px;
  padding: 9px;
  margin-top: 8px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 8px;
}

.inv-item span,
.chain-item span {
  color: #a9c8cf;
  font-size: 0.8rem;
}

#controls-panel {
  position: fixed;
  left: 16px;
  bottom: 16px;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-width: min(540px, calc(100vw - 32px));
  pointer-events: none;
}

#controls-panel span {
  padding: 6px 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(4, 9, 13, 0.58);
  border-radius: 6px;
  color: #bddce1;
  font-size: 0.76rem;
}

#mobile-controls {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 24;
  display: none;
  pointer-events: none;
  padding: 16px;
}

.touch-stick {
  position: absolute;
  left: 18px;
  bottom: 22px;
  width: 124px;
  height: 124px;
  border-radius: 50%;
  border: 1px solid rgba(93, 242, 255, 0.42);
  background: rgba(5, 13, 20, 0.48);
  box-shadow: inset 0 0 28px rgba(93, 242, 255, 0.12);
  pointer-events: auto;
  touch-action: none;
}

.touch-stick i {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 54px;
  height: 54px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: rgba(20, 241, 149, 0.78);
  box-shadow: 0 0 20px rgba(20, 241, 149, 0.4);
}

.touch-actions {
  position: absolute;
  right: 16px;
  bottom: 18px;
  display: grid;
  grid-template-columns: 54px 54px 54px;
  grid-template-rows: 54px 54px;
  gap: 10px;
  pointer-events: auto;
}

.touch-actions button {
  border-radius: 50%;
  color: #061116;
  background: rgba(238, 252, 255, 0.86);
  font-family: Orbitron, Inter, sans-serif;
  font-weight: 800;
  border: 1px solid rgba(93, 242, 255, 0.36);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.32);
  touch-action: none;
}

#touch-fire {
  grid-column: 2 / 4;
  grid-row: 1 / 3;
  width: 118px;
  height: 118px;
  background: radial-gradient(circle, #ffd166 0%, #ff4d6d 72%);
  color: #fff;
  font-size: 2rem;
}

#crosshair {
  position: fixed;
  left: 50%;
  top: 50%;
  z-index: 9;
  width: 18px;
  height: 18px;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

#crosshair::before,
#crosshair::after {
  content: "";
  position: absolute;
  background: rgba(255, 255, 255, 0.82);
}

#crosshair::before {
  left: 8px;
  top: 0;
  width: 2px;
  height: 18px;
}

#crosshair::after {
  left: 0;
  top: 8px;
  width: 18px;
  height: 2px;
}

#crosshair.hit::before,
#crosshair.hit::after {
  background: #ffd166;
  box-shadow: 0 0 12px rgba(255, 209, 102, 0.9);
}

.float-combat {
  position: fixed;
  z-index: 32;
  transform: translate(-50%, -50%);
  pointer-events: none;
  font-family: Orbitron, Inter, sans-serif;
  font-weight: 800;
  font-size: 1.05rem;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.85);
}

#damage-vignette {
  position: fixed;
  inset: 0;
  z-index: 8;
  pointer-events: none;
  background: radial-gradient(circle, transparent 52%, rgba(255, 0, 40, 0.34));
  opacity: 0;
  transition: opacity 0.18s ease;
}

#damage-vignette.hit { opacity: 1; }

#toast-stack {
  position: fixed;
  right: 16px;
  top: 190px;
  z-index: 30;
  display: grid;
  gap: 8px;
  width: min(340px, calc(100vw - 32px));
}

.toast {
  padding: 10px 12px;
  border: 1px solid rgba(93, 242, 255, 0.28);
  background: rgba(4, 9, 13, 0.88);
  border-radius: 8px;
  color: #eefcff;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.25);
}

@media (max-width: 860px) {
  .vitals,
  .combat { grid-template-columns: 1fr 1fr; }
  #wallet-panel {
    top: 10px;
    right: 10px;
    width: min(220px, calc(100vw - 20px));
  }
  #store-panel {
    right: 10px;
    top: 210px;
    width: min(430px, calc(100vw - 20px));
    max-height: calc(100vh - 240px);
  }
  .economy-panel {
    right: 10px;
    top: 210px;
    width: min(560px, calc(100vw - 20px));
    max-height: calc(100vh - 240px);
  }
  .market-columns {
    grid-template-columns: 1fr;
  }
  #radar-panel {
    top: 132px;
    left: 10px;
    width: 112px;
  }
  #radar-disc {
    width: 94px;
    height: 94px;
  }
  #inventory-panel { display: none; }
  #mission-panel {
    bottom: 154px;
    width: min(620px, calc(100vw - 176px));
  }
  #controls-panel { display: none; }
  #mobile-controls { display: block; }
  #hud {
    top: 10px;
    left: 10px;
    width: min(520px, calc(100vw - 250px));
  }
}

@media (max-width: 560px) {
  .hero-select,
  .concept-strip,
  .vitals,
  .combat { grid-template-columns: 1fr; }
  #hud {
    max-height: 42vh;
    overflow: auto;
    width: calc(100vw - 20px);
  }
  #wallet-panel {
    top: auto;
    bottom: 158px;
    right: 10px;
    width: min(210px, calc(100vw - 20px));
  }
  #store-panel {
    left: 10px;
    right: 10px;
    top: 10px;
    bottom: 286px;
    width: auto;
    max-height: none;
  }
  .economy-panel {
    left: 10px;
    right: 10px;
    top: 10px;
    bottom: 286px;
    width: auto;
    max-height: none;
  }
  .store-item {
    grid-template-columns: 1fr;
  }
  .store-buy {
    grid-template-columns: 1fr auto;
    align-items: center;
    min-width: 0;
    text-align: left;
  }
  #radar-panel {
    display: none;
  }
  #mission-panel {
    bottom: 150px;
    left: 10px;
    right: 10px;
    width: auto;
    transform: none;
  }
  #toast-stack {
    top: auto;
    bottom: 286px;
    right: 10px;
  }
}

/* ===== Campanha v4: dialogo cinematografico, tutorial e giveaway ===== */
#dialogue {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  cursor: pointer;
}

#dialogue-portrait {
  width: 76px;
  height: 76px;
  flex: 0 0 76px;
  object-fit: cover;
  object-position: top;
  border-radius: 8px;
  border: 1px solid rgba(93, 242, 255, 0.5);
  box-shadow: 0 0 18px rgba(20, 241, 149, 0.25);
}

#dialogue .dialogue-body { flex: 1; min-width: 0; }

#dialogue-next {
  display: block;
  margin-top: 6px;
  color: rgba(93, 242, 255, 0.66);
  font-size: 11px;
  text-align: right;
}

#tutorial-banner {
  position: fixed;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  width: min(640px, calc(100vw - 24px));
  padding: 12px 16px;
  border: 1px solid rgba(255, 209, 102, 0.55);
  background: rgba(10, 12, 6, 0.9);
  border-radius: 10px;
  backdrop-filter: blur(8px);
  text-align: center;
}

#tutorial-banner b {
  display: block;
  color: var(--gold, #ffd166);
  font-family: Orbitron, Inter, sans-serif;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

#tutorial-banner span {
  display: block;
  margin-top: 5px;
  font-size: 14px;
  line-height: 1.4;
  color: #f4fbf7;
}

.tutorial-actions {
  margin-top: 8px;
  display: flex;
  gap: 8px;
  justify-content: center;
}

.tutorial-actions button {
  min-height: 40px;
  padding: 8px 18px;
  border-radius: 8px;
  border: 1px solid rgba(20, 241, 149, 0.6);
  background: rgba(20, 241, 149, 0.14);
  color: #d8ffe9;
  font-family: Orbitron, Inter, sans-serif;
  font-size: 12px;
  cursor: pointer;
}

#tutorial-skip {
  border-color: rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.06);
  color: #9fb4ad;
}

#giveaway-panel {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 40;
  width: min(460px, calc(100vw - 24px));
  padding: 18px;
  border: 1px solid rgba(255, 209, 102, 0.6);
  background: rgba(6, 10, 8, 0.96);
  border-radius: 12px;
  backdrop-filter: blur(12px);
}

#giveaway-panel p {
  font-size: 13px;
  line-height: 1.5;
  color: #cfe8dc;
  margin: 10px 0;
}

#giveaway-panel input {
  width: 100%;
  box-sizing: border-box;
  margin: 6px 0;
  padding: 12px;
  min-height: 44px;
  border-radius: 8px;
  border: 1px solid rgba(93, 242, 255, 0.35);
  background: rgba(4, 9, 13, 0.85);
  color: #eafff5;
  font-size: 14px;
}

#giveaway-status {
  margin: 8px 0;
  font-size: 12px;
  line-height: 1.45;
  color: #ffd166;
  min-height: 16px;
}

.giveaway-actions {
  display: flex;
  gap: 10px;
}

.giveaway-actions button {
  flex: 1;
  min-height: 46px;
  border-radius: 8px;
  border: 1px solid rgba(20, 241, 149, 0.6);
  background: rgba(20, 241, 149, 0.16);
  color: #d8ffe9;
  font-family: Orbitron, Inter, sans-serif;
  font-size: 13px;
  cursor: pointer;
}

#giveaway-close {
  border-color: rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.06);
  color: #9fb4ad;
}

#giveaway-btn {
  border-color: rgba(255, 209, 102, 0.65) !important;
  color: #ffd166 !important;
}

@media (max-width: 860px) {
  #dialogue { bottom: 168px; }
  #dialogue-portrait { width: 58px; height: 58px; flex-basis: 58px; }
  #tutorial-banner span { font-size: 13px; }
}

/* ===== Crypto Legends v5: mobile viewport, HUD toggle, quality ===== */
#hud-toggle {
  display: none;
  position: fixed;
  top: calc(10px + env(safe-area-inset-top));
  right: 10px;
  z-index: 42;
  min-width: 52px;
  min-height: 42px;
  padding: 9px 11px;
  border-radius: 8px;
  border: 1px solid rgba(93, 242, 255, 0.42);
  color: #061116;
  background: linear-gradient(135deg, #5df2ff, #14f195);
  font-family: Orbitron, Inter, sans-serif;
  font-size: 0.72rem;
  font-weight: 900;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

#quality-toggle,
#sound-toggle {
  min-height: 36px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid rgba(93, 242, 255, 0.26);
  color: #eefcff;
  background: rgba(255, 255, 255, 0.08);
  font-weight: 800;
}

body[data-quality="low"] #game-canvas { image-rendering: auto; }

@media (max-width: 860px) {
  #hud-toggle { display: block; }

  body.mobile-hud #hud {
    top: calc(8px + env(safe-area-inset-top));
    left: 8px;
    right: 70px;
    width: auto;
    max-height: none;
    overflow: visible;
    gap: 6px;
    z-index: 28;
  }

  body.mobile-hud .hud-row {
    gap: 6px;
    padding: 7px;
    background: rgba(5, 13, 20, 0.66);
    backdrop-filter: blur(6px);
  }

  body.mobile-hud .vitals {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  body.mobile-hud .combat {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  body.mobile-hud .hud-row span { font-size: 0.56rem; }
  body.mobile-hud .hud-row b { font-size: 0.68rem; }
  body.mobile-hud .bar { height: 5px; margin: 4px 0 2px; }

  body.mobile-hud #wallet-panel {
    top: calc(58px + env(safe-area-inset-top));
    right: 8px;
    width: min(220px, calc(100vw - 16px));
    max-height: min(46vh, 330px);
    overflow: auto;
    transition: opacity 0.18s ease, transform 0.18s ease;
  }

  body.mobile-hud.hud-collapsed #wallet-panel {
    opacity: 0;
    pointer-events: none;
    transform: translateY(-10px);
  }

  body.mobile-hud #radar-panel {
    top: calc(86px + env(safe-area-inset-top));
    left: 8px;
    width: 108px;
  }

  body.mobile-hud #mission-panel {
    bottom: calc(16px + env(safe-area-inset-bottom));
    width: min(430px, calc(100vw - 330px));
    min-width: 210px;
    padding: 10px 12px;
  }

  body.mobile-hud #phase-name { font-size: 0.78rem; }
  body.mobile-hud #mission-text { font-size: 0.74rem; line-height: 1.28; }
  body.mobile-hud .mission-progress { margin-top: 7px; }

  body.mobile-hud #dialogue {
    bottom: calc(126px + env(safe-area-inset-bottom));
    max-height: 30vh;
    overflow: auto;
    padding: 10px;
  }

  body.mobile-hud #tutorial-banner {
    top: auto;
    bottom: calc(128px + env(safe-area-inset-bottom));
    width: min(560px, calc(100vw - 16px));
    padding: 9px 10px;
  }

  body.mobile-hud #mobile-controls {
    padding: 10px 12px calc(12px + env(safe-area-inset-bottom));
  }

  body.mobile-hud .touch-stick {
    left: 14px;
    bottom: calc(14px + env(safe-area-inset-bottom));
    width: 112px;
    height: 112px;
    background: rgba(5, 13, 20, 0.36);
  }

  body.mobile-hud .touch-stick i {
    width: 48px;
    height: 48px;
  }

  body.mobile-hud .touch-actions {
    right: 12px;
    bottom: calc(14px + env(safe-area-inset-bottom));
    grid-template-columns: 48px 48px 48px;
    grid-template-rows: 48px 48px;
    gap: 8px;
  }

  body.mobile-hud #touch-fire {
    width: 104px;
    height: 104px;
  }

  body.mobile-hud #toast-stack {
    top: calc(92px + env(safe-area-inset-top));
    right: 8px;
    width: min(280px, calc(100vw - 132px));
  }
}

@media (max-width: 560px) {
  body.mobile-hud #hud {
    right: 68px;
    max-width: none;
  }

  body.mobile-hud .combat { display: none; }
  body.mobile-hud.hud-expanded .combat {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  body.mobile-hud #wallet-panel {
    top: calc(70px + env(safe-area-inset-top));
    right: 8px;
    width: min(230px, calc(100vw - 16px));
    max-height: 40vh;
  }

  body.mobile-hud #mission-panel {
    left: 106px;
    right: 106px;
    bottom: calc(16px + env(safe-area-inset-bottom));
    width: auto;
    min-width: 0;
    transform: none;
    padding: 7px 8px;
    background: rgba(6, 17, 22, 0.68);
  }

  body.mobile-hud #phase-name {
    font-size: 0.62rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  body.mobile-hud #mission-text {
    max-height: 2.45em;
    overflow: hidden;
    font-size: 0.58rem;
  }

  body.mobile-hud .mission-progress { height: 4px; margin-top: 5px; }

  body.mobile-hud #dialogue {
    left: 8px;
    right: 8px;
    bottom: calc(112px + env(safe-area-inset-bottom));
    width: auto;
    transform: none;
    max-height: 28vh;
  }

  body.mobile-hud #dialogue-portrait {
    width: 44px;
    height: 44px;
    flex-basis: 44px;
  }

  body.mobile-hud #tutorial-banner {
    bottom: calc(112px + env(safe-area-inset-bottom));
  }

  body.mobile-hud #tutorial-banner span {
    font-size: 0.72rem;
    max-height: 2.8em;
    overflow: hidden;
  }

  body.mobile-hud .tutorial-actions button {
    min-height: 34px;
    padding: 6px 12px;
  }

  body.mobile-hud #store-panel,
  body.mobile-hud .economy-panel {
    top: calc(64px + env(safe-area-inset-top));
    left: 8px;
    right: 8px;
    bottom: calc(112px + env(safe-area-inset-bottom));
    width: auto;
    max-height: none;
  }

  body.mobile-hud #toast-stack {
    top: calc(72px + env(safe-area-inset-top));
    left: 8px;
    right: auto;
    bottom: auto;
    width: min(250px, calc(100vw - 124px));
  }

  body.mobile-hud #touch-q,
  body.mobile-hud #touch-e,
  body.mobile-hud #touch-reload,
  body.mobile-hud #touch-jump { font-size: 0.76rem; }
}
