/* ==========================================================================
   Verdant Quest — Retro 16-Bit RPG Stylesheet
   ========================================================================== */

:root {
  --bg-outer: #0d1117;
  --panel-bg: rgba(17, 25, 40, 0.92);
  --panel-border: #e2c792;
  --panel-border-dark: #6b4e27;
  --accent-gold: #ffd166;
  --accent-green: #6ede8a;
  --accent-green-dark: #2d6a4f;
  --text-main: #f8f4e3;
  --text-muted: #b8c2cc;
  --danger: #ff6b6b;
  --pixel-font: "Press Start 2P", "Courier New", monospace;
}

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

html,
body {
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at center, #1b2838 0%, #0b0f17 100%);
  color: var(--text-main);
  font-family: var(--pixel-font);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* Retro monitor frame around the game viewport */
.cabinet-frame {
  padding: 14px;
  background: linear-gradient(145deg, #2b2d42, #181a26);
  border: 4px solid #3d405b;
  box-shadow:
    0 0 0 4px #0b0d14,
    0 24px 60px rgba(0, 0, 0, 0.75);
  border-radius: 10px;
}

.game-container {
  position: relative;
  width: 800px;
  height: 540px;
  max-width: calc(100vw - 40px);
  max-height: calc(100vh - 40px);
  aspect-ratio: 800 / 540;
  background-color: #1d3527;
  border: 4px solid #0b0d14;
  overflow: hidden;
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* Subtle CRT scanline & vignette feel */
.scanlines {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    repeating-linear-gradient(
      to bottom,
      rgba(0, 0, 0, 0) 0px,
      rgba(0, 0, 0, 0) 2px,
      rgba(0, 0, 0, 0.11) 3px,
      rgba(0, 0, 0, 0.11) 4px
    ),
    radial-gradient(circle at center, transparent 60%, rgba(0, 0, 0, 0.35) 100%);
  z-index: 5;
}

/* ==================== OVERLAY SCREENS ==================== */
.overlay-screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 28px;
  z-index: 10;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
  background: rgba(9, 15, 22, 0.38);
}

.overlay-screen.active {
  opacity: 1;
  pointer-events: auto;
}

/* ==================== TITLE BLOCK ==================== */
.title-block {
  text-align: center;
  animation: floatTitle 3.2s ease-in-out infinite;
}

@keyframes floatTitle {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-6px);
  }
}

.subtitle-tag {
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--accent-green);
  text-shadow: 2px 2px 0 #091810;
  margin-bottom: 14px;
}

.game-title {
  font-size: 46px;
  line-height: 1.25;
  color: var(--accent-gold);
  text-shadow:
    0 4px 0 #9c5a13,
    0 8px 0 #261404,
    0 12px 22px rgba(0, 0, 0, 0.7);
  letter-spacing: 3px;
}

.title-divider {
  width: 240px;
  height: 4px;
  margin: 16px auto 0;
  background: linear-gradient(90deg, transparent, var(--accent-gold), transparent);
}

/* ==================== RPG DIALOG BOXES ==================== */
.rpg-box {
  background: var(--panel-bg);
  border: 4px solid var(--panel-border);
  box-shadow:
    inset 0 0 0 3px var(--panel-border-dark),
    0 10px 30px rgba(0, 0, 0, 0.65);
  padding: 20px 26px;
}

.menu-box {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 280px;
}

.menu-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  background: transparent;
  border: 2px solid transparent;
  color: var(--text-main);
  font-family: var(--pixel-font);
  font-size: 16px;
  padding: 12px 16px;
  cursor: pointer;
  text-align: left;
  transition: transform 0.1s ease, background 0.12s ease, border-color 0.12s ease;
}

.menu-btn .cursor-arrow {
  opacity: 0;
  color: var(--accent-gold);
  transform: translateX(-4px);
  transition: opacity 0.12s ease, transform 0.12s ease;
}

.menu-btn:hover,
.menu-btn.selected {
  background: rgba(255, 209, 102, 0.14);
  border-color: var(--accent-gold);
  color: var(--accent-gold);
}

.menu-btn:hover .cursor-arrow,
.menu-btn.selected .cursor-arrow {
  opacity: 1;
  transform: translateX(0);
}

.menu-btn:active {
  transform: scale(0.98);
}

.menu-hint {
  font-size: 10px;
  color: var(--text-main);
  background: rgba(10, 16, 24, 0.72);
  padding: 8px 14px;
  border: 2px solid rgba(226, 199, 146, 0.45);
  text-shadow: 1px 1px 0 #000;
}

/* ==================== SETTINGS PANEL ==================== */
.settings-box {
  width: 470px;
  max-width: 92%;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.panel-title {
  font-size: 18px;
  text-align: center;
  color: var(--accent-gold);
  text-shadow: 2px 2px 0 #1f1407;
  padding-bottom: 12px;
  border-bottom: 3px solid var(--panel-border-dark);
}

.setting-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.setting-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--text-main);
}

.setting-value {
  color: var(--accent-green);
}

/* Custom Pixel Slider */
.retro-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 12px;
  background: #0d1522;
  border: 2px solid var(--panel-border);
  outline: none;
  cursor: pointer;
}

.retro-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 22px;
  background: var(--accent-gold);
  border: 2px solid #2b1a06;
  cursor: pointer;
}

.retro-slider::-moz-range-thumb {
  width: 18px;
  height: 22px;
  background: var(--accent-gold);
  border: 2px solid #2b1a06;
  border-radius: 0;
  cursor: pointer;
}

.toggle-row {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  padding-top: 4px;
}

.retro-toggle {
  font-family: var(--pixel-font);
  font-size: 11px;
  padding: 8px 16px;
  min-width: 84px;
  border: 3px solid var(--panel-border);
  background: #1c2b3a;
  color: var(--accent-green);
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}

.retro-toggle.muted {
  background: #4a1c24;
  border-color: var(--danger);
  color: var(--danger);
}

.settings-actions {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  margin-top: 6px;
}

.action-btn {
  flex: 1;
  font-family: var(--pixel-font);
  font-size: 11px;
  padding: 12px 14px;
  border: 3px solid var(--panel-border);
  cursor: pointer;
  transition: transform 0.08s ease, filter 0.12s ease;
}

.action-btn:hover {
  filter: brightness(1.15);
}

.action-btn:active {
  transform: translateY(2px);
}

.primary-btn {
  background: var(--accent-green-dark);
  color: var(--text-main);
}

.secondary-btn {
  background: #27374d;
  color: var(--accent-gold);
}

/* ==================== IN-GAME HUD ==================== */
.game-hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 8;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.game-hud.active {
  opacity: 1;
}

.rpg-pill {
  background: rgba(15, 23, 35, 0.85);
  border: 3px solid var(--panel-border);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.45);
  padding: 8px 12px;
  font-size: 10px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.hud-top-left-stack {
  position: absolute;
  top: 12px;
  left: 12px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}

.hud-location {
  color: var(--accent-gold);
}

.hud-vitals {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 192px;
  padding: 7px 9px;
  background: rgba(15, 23, 35, 0.88);
  border: 3px solid var(--panel-border);
  box-shadow:
    inset 0 0 0 2px var(--panel-border-dark),
    0 4px 12px rgba(0, 0, 0, 0.45);
}

.vital-row {
  display: flex;
  align-items: center;
  gap: 7px;
}

.vital-icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.vital-bar-track {
  position: relative;
  flex: 1;
  height: 11px;
  background: #0b111c;
  border: 2px solid #5c4b32;
  overflow: hidden;
}

.vital-bar-fill {
  height: 100%;
  transition: width 0.16s ease;
}

.health-fill {
  background: linear-gradient(to bottom, #ff6b6b 0%, #d62828 55%, #9b1b1b 100%);
}

.hunger-fill {
  background: linear-gradient(to bottom, #ffd166 0%, #f48c06 55%, #b55404 100%);
}

.vital-divider {
  height: 2px;
  background: rgba(226, 199, 146, 0.25);
  margin: 1px 0;
}

.progress-row {
  gap: 6px;
}

.level-pill {
  font-size: 7px;
  color: var(--accent-gold);
  background: #23334c;
  border: 1px solid var(--panel-border);
  padding: 2px 4px;
  white-space: nowrap;
  flex-shrink: 0;
}

.xp-track {
  height: 8px;
}

.xp-fill {
  background: linear-gradient(to bottom, #72efdd 0%, #2ec4b6 55%, #168aad 100%);
}

.coins-readout {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
}

.coin-icon {
  width: 12px;
  height: 12px;
}

.coins-value {
  font-size: 8px;
  color: var(--accent-gold);
  text-shadow: 1px 1px 0 #090e17;
  min-width: 16px;
  text-align: right;
}

/* ==================== LEVEL-UP BANNER ==================== */
.level-up-banner {
  position: absolute;
  top: 60px;
  left: 50%;
  transform: translateX(-50%) translateY(-10px);
  background: rgba(15, 25, 40, 0.96);
  border: 3px solid var(--accent-gold);
  box-shadow:
    inset 0 0 0 2px #9c5a13,
    0 8px 24px rgba(0, 0, 0, 0.7);
  padding: 10px 18px;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.24s ease, transform 0.24s ease;
  z-index: 11;
}

.level-up-banner.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.level-up-title {
  font-size: 13px;
  color: var(--accent-gold);
  text-shadow: 2px 2px 0 #1f1407;
  margin-bottom: 5px;
}

.level-up-sub {
  font-size: 7.5px;
  color: var(--accent-green);
  line-height: 1.5;
}

/* ==================== NPC DIALOGUE MODAL ==================== */
.dialogue-overlay {
  justify-content: flex-end;
  padding-bottom: 26px;
}

.dialogue-box {
  width: 580px;
  max-width: 94%;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 20px;
}

.dialogue-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--panel-border-dark);
}

.dialogue-name {
  font-size: 13px;
  color: var(--accent-gold);
  margin-bottom: 4px;
}

.dialogue-role {
  font-size: 7.5px;
  color: var(--accent-green);
}

.dialogue-text {
  font-size: 9px;
  line-height: 1.75;
  color: var(--text-main);
  min-height: 44px;
}

.dialogue-reward-tag {
  display: none;
  font-size: 8px;
  color: var(--accent-gold);
  background: rgba(255, 209, 102, 0.12);
  border: 2px solid var(--accent-gold);
  padding: 8px 10px;
  line-height: 1.5;
}

.dialogue-reward-tag.visible {
  display: block;
}

.dialogue-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.dialogue-actions .action-btn {
  flex: 0 1 auto;
  padding: 10px 16px;
  font-size: 9px;
}

/* ==================== MERCHANT & SEED SHOP MODAL ==================== */
.shop-box {
  width: 540px;
  max-width: 94%;
  max-height: 90%;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 18px;
}

.shop-subtitle {
  font-size: 7px;
  color: var(--text-muted);
  margin-top: 4px;
}

.shop-wallet {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.shop-level-badge {
  font-size: 8px;
  color: #72efdd;
  background: #162638;
  border: 2px solid #2ec4b6;
  padding: 4px 6px;
}

.shop-coins-badge {
  font-size: 8.5px;
  color: var(--accent-gold);
  background: #2b2110;
  border: 2px solid var(--accent-gold);
  padding: 4px 8px;
}

.shop-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 310px;
  overflow-y: auto;
  padding: 6px;
  background: rgba(9, 14, 24, 0.78);
  border: 2px solid var(--panel-border-dark);
  scrollbar-width: thin;
  scrollbar-color: var(--panel-border-dark) #0b111c;
}

.shop-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: rgba(24, 35, 54, 0.92);
  border: 2px solid #5c4b32;
}

.shop-row.locked {
  opacity: 0.62;
  border-color: #3a3430;
}

.shop-row-icon {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.shop-row-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.shop-row-title {
  font-size: 9px;
  color: var(--text-main);
}

.shop-row-meta {
  font-size: 7px;
  color: var(--text-muted);
  line-height: 1.45;
}

.shop-row-meta .price-hl {
  color: var(--accent-gold);
}

.shop-row-meta .owned-hl {
  color: var(--accent-green);
}

.shop-row-meta .locked-hl {
  color: var(--danger);
}

.shop-row-btns {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.shop-tx-btn {
  font-family: var(--pixel-font);
  font-size: 7.5px;
  padding: 7px 9px;
  border: 2px solid var(--panel-border);
  background: var(--accent-green-dark);
  color: var(--text-main);
  cursor: pointer;
  white-space: nowrap;
}

.shop-tx-btn:hover:not(:disabled) {
  background: var(--accent-gold);
  color: #141923;
}

.shop-tx-btn:disabled {
  background: #1e2430;
  border-color: #495057;
  color: #6c757d;
  cursor: not-allowed;
}

.shop-tx-btn.sell-all-btn {
  background: #2b4560;
  border-color: var(--accent-gold);
  color: var(--accent-gold);
}

.shop-tx-btn.sell-all-btn:hover:not(:disabled) {
  background: var(--accent-gold);
  color: #141923;
}

.slot-water-bar {
  position: absolute;
  bottom: 2px;
  left: 4px;
  right: 4px;
  height: 3px;
  background: #0d1522;
  border: 1px solid #1971c2;
}

.slot-water-fill {
  height: 100%;
  background: #4dabf7;
}

.vital-value {
  width: 28px;
  text-align: right;
  font-size: 8px;
  color: var(--text-main);
  text-shadow: 1px 1px 0 #090e17;
}

.vital-row.low-warning .vital-bar-track {
  border-color: var(--accent-gold);
  animation: pulseLowBar 0.9s ease-in-out infinite;
}

.vital-row.critical-warning .vital-bar-track {
  border-color: var(--danger);
  animation: pulseCriticalBar 0.55s ease-in-out infinite;
}

.vital-row.critical-warning .vital-value {
  color: var(--danger);
}

@keyframes pulseLowBar {
  0%, 100% {
    box-shadow: 0 0 0 rgba(255, 209, 102, 0);
  }
  50% {
    box-shadow: 0 0 8px rgba(255, 209, 102, 0.75);
  }
}

@keyframes pulseCriticalBar {
  0%, 100% {
    box-shadow: 0 0 0 rgba(255, 107, 107, 0);
  }
  50% {
    box-shadow: 0 0 10px rgba(255, 107, 107, 0.9);
  }
}

.vital-status-tag {
  display: none;
  font-size: 7px;
  letter-spacing: 0.6px;
  text-align: center;
  padding-top: 2px;
}

.vital-status-tag.hungry {
  display: block;
  color: var(--accent-gold);
}

.vital-status-tag.starving {
  display: block;
  color: var(--danger);
  animation: pulseCriticalText 0.7s ease-in-out infinite;
}

@keyframes pulseCriticalText {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.45;
  }
}

/* Brief crimson vignette when taking damage */
.damage-vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at center, transparent 48%, rgba(214, 40, 40, 0.55) 100%);
  opacity: 0;
  transition: opacity 0.22s ease;
  z-index: 6;
}

.damage-vignette.flash {
  opacity: 1;
  transition: none;
}

/* ==================== DEATH / RESPAWN SCREEN ==================== */
.death-overlay {
  background: rgba(26, 6, 10, 0.74);
  z-index: 12;
}

.death-box {
  width: 420px;
  max-width: 90%;
  border-color: var(--danger);
  box-shadow:
    inset 0 0 0 3px #59161e,
    0 14px 36px rgba(0, 0, 0, 0.8);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 14px;
  padding: 26px 24px;
}

.death-emblem {
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #4a1c24;
  border: 3px solid var(--danger);
  color: var(--danger);
  font-size: 18px;
}

.death-title {
  font-size: 28px;
  color: var(--danger);
  text-shadow:
    0 3px 0 #59161e,
    0 6px 0 #1b0508;
  letter-spacing: 2px;
}

.death-reason {
  font-size: 9px;
  line-height: 1.6;
  color: var(--text-main);
}

.death-subnote {
  font-size: 7.5px;
  line-height: 1.5;
  color: var(--accent-green);
}

.death-actions {
  display: flex;
  width: 100%;
  gap: 12px;
  margin-top: 6px;
}

.respawn-btn {
  border-color: var(--accent-green);
}

.location-dot {
  width: 8px;
  height: 8px;
  background: var(--accent-green);
  display: inline-block;
  box-shadow: 0 0 6px var(--accent-green);
}

.hud-top-right {
  position: absolute;
  top: 14px;
  right: 14px;
  display: flex;
  gap: 8px;
  pointer-events: auto;
}

.hud-btn {
  font-family: var(--pixel-font);
  font-size: 10px;
  background: rgba(15, 23, 35, 0.88);
  color: var(--text-main);
  border: 3px solid var(--panel-border);
  padding: 8px 12px;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}

.hud-btn:hover {
  background: var(--accent-gold);
  color: #141923;
}

.bag-btn {
  border-color: var(--accent-gold);
  color: var(--accent-gold);
}

/* ==================== BACKPACK INVENTORY MODAL ==================== */
.inventory-box {
  width: 470px;
  max-width: 94%;
  max-height: 92%;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 20px;
}

.inventory-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 10px;
  border-bottom: 3px solid var(--panel-border-dark);
}

.inventory-title {
  padding-bottom: 0;
  border-bottom: none;
  font-size: 16px;
  text-align: left;
}

.inventory-capacity {
  margin-left: auto;
  font-size: 9px;
  color: var(--accent-green);
}

.inv-close-btn {
  font-family: var(--pixel-font);
  font-size: 10px;
  padding: 6px 9px;
  background: #4a1c24;
  color: var(--text-main);
  border: 2px solid var(--danger);
  cursor: pointer;
}

.inv-close-btn:hover {
  background: var(--danger);
  color: #141923;
}

.inventory-instructions {
  font-size: 7.5px;
  line-height: 1.55;
  color: var(--text-muted);
}

.backpack-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  max-height: 196px;
  overflow-y: auto;
  padding: 6px;
  background: rgba(9, 14, 24, 0.75);
  border: 2px solid var(--panel-border-dark);
  scrollbar-width: thin;
  scrollbar-color: var(--panel-border-dark) #0b111c;
}

.backpack-grid::-webkit-scrollbar {
  width: 8px;
}

.backpack-grid::-webkit-scrollbar-track {
  background: #0b111c;
  border-left: 1px solid var(--panel-border-dark);
}

.backpack-grid::-webkit-scrollbar-thumb {
  background: var(--panel-border-dark);
  border: 1px solid var(--panel-border);
}

.backpack-grid::-webkit-scrollbar-thumb:hover {
  background: var(--accent-gold);
}

.inv-slot {
  position: relative;
  height: 54px;
  background: rgba(24, 35, 54, 0.92);
  border: 2px solid #5c4b32;
  color: var(--text-main);
  font-family: var(--pixel-font);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
  padding-top: 4px;
  transition: border-color 0.1s ease, background 0.1s ease, transform 0.08s ease;
}

.inv-slot:hover {
  border-color: var(--panel-border);
  background: rgba(36, 52, 78, 0.96);
}

.inv-slot.empty {
  background: rgba(14, 21, 34, 0.72);
  border-color: #353028;
}

.inv-slot.empty:hover {
  border-color: #7c6745;
}

.inv-slot.transfer-selected {
  background: rgba(255, 209, 102, 0.25);
  border: 3px solid var(--accent-gold);
  box-shadow: 0 0 12px rgba(255, 209, 102, 0.55);
  transform: translateY(-2px);
}

.inv-slot.drag-over {
  border-color: var(--accent-green);
  box-shadow: inset 0 0 0 2px var(--accent-green);
}

.inventory-detail {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 52px;
  padding: 8px 10px;
  background: rgba(9, 14, 24, 0.78);
  border: 2px solid var(--panel-border-dark);
}

.detail-text {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.detail-name {
  font-size: 9px;
  color: var(--accent-gold);
}

.detail-desc {
  font-size: 7px;
  line-height: 1.5;
  color: var(--text-muted);
}

.detail-assign-bar {
  display: none;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

.detail-assign-bar.visible {
  display: flex;
}

.assign-label {
  font-size: 7px;
  color: var(--panel-border);
}

.assign-btn {
  font-family: var(--pixel-font);
  font-size: 8px;
  width: 24px;
  height: 24px;
  background: var(--accent-green-dark);
  color: var(--text-main);
  border: 2px solid var(--panel-border);
  cursor: pointer;
}

.assign-btn:hover {
  background: var(--accent-gold);
  color: #141923;
}

.inventory-hotbar-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.section-label {
  font-size: 8px;
  color: var(--panel-border);
  letter-spacing: 0.6px;
}

.inventory-hotbar-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 6px;
  background: rgba(9, 14, 24, 0.75);
  border: 2px solid var(--panel-border);
}

.inv-slot.active-equipped {
  box-shadow: inset 0 0 0 2px rgba(110, 222, 138, 0.6);
}

.hud-bottom-bar {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  color: var(--text-muted);
  white-space: nowrap;
  font-size: 8px;
  padding: 6px 10px;
}

.hud-sep {
  color: var(--accent-gold);
}

/* ==================== TOAST & CONTEXT PROMPT ==================== */
.hud-toast {
  position: absolute;
  top: 56px;
  left: 50%;
  transform: translateX(-50%) translateY(-6px);
  background: rgba(15, 23, 35, 0.92);
  border: 3px solid var(--accent-gold);
  color: var(--accent-gold);
  padding: 7px 14px;
  font-size: 9px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 9;
}

.hud-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.hud-prompt {
  position: absolute;
  bottom: 112px;
  left: 50%;
  transform: translateX(-50%);
  color: var(--accent-gold);
  border-color: var(--accent-gold);
  font-size: 10px;
  display: none;
  white-space: nowrap;
  z-index: 9;
  animation: pulsePrompt 1.4s ease-in-out infinite;
}

.hud-prompt.visible {
  display: inline-flex;
}

@keyframes pulsePrompt {
  0%, 100% {
    transform: translateX(-50%) translateY(0);
  }
  50% {
    transform: translateX(-50%) translateY(-3px);
  }
}

/* ==================== HOTBAR ==================== */
.hotbar {
  position: absolute;
  bottom: 42px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  padding: 6px;
  background: rgba(12, 19, 30, 0.88);
  border: 3px solid var(--panel-border);
  box-shadow:
    inset 0 0 0 2px var(--panel-border-dark),
    0 6px 18px rgba(0, 0, 0, 0.55);
  pointer-events: auto;
  z-index: 9;
}

.hotbar-slot {
  position: relative;
  width: 58px;
  height: 54px;
  background: rgba(24, 35, 54, 0.92);
  border: 2px solid #5c4b32;
  color: var(--text-main);
  font-family: var(--pixel-font);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
  padding-top: 4px;
  transition: border-color 0.1s ease, background 0.1s ease, transform 0.08s ease;
}

.hotbar-slot:hover {
  border-color: var(--panel-border);
}

.hotbar-slot.empty {
  background: rgba(14, 21, 34, 0.72);
  border-color: #353028;
}

.hotbar-slot.selected {
  background: rgba(255, 209, 102, 0.2);
  border: 3px solid var(--accent-gold);
  box-shadow: 0 0 10px rgba(255, 209, 102, 0.45);
  transform: translateY(-2px);
}

.slot-key {
  position: absolute;
  top: 3px;
  left: 4px;
  font-size: 7px;
  color: var(--text-muted);
}

.slot-count {
  position: absolute;
  top: 3px;
  right: 4px;
  font-size: 8px;
  color: var(--accent-green);
  text-shadow: 1px 1px 0 #090e17;
}

.slot-icon {
  width: 24px;
  height: 24px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.slot-name {
  font-size: 6px;
  color: var(--panel-border);
  letter-spacing: 0.4px;
}

.game-hud.mobile-controls-active .hotbar {
  bottom: 14px;
}

.game-hud.mobile-controls-active .hud-prompt {
  bottom: 84px;
}

/* ==================== MOBILE ACTION BUTTONS ==================== */
.mobile-actions {
  position: absolute;
  bottom: 24px;
  right: 22px;
  display: none;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
  pointer-events: auto;
  touch-action: none;
  z-index: 9;
}

.mobile-actions.visible {
  display: flex;
}

.mobile-action-btn {
  font-family: var(--pixel-font);
  font-size: 10px;
  padding: 13px 14px;
  min-width: 92px;
  border: 3px solid var(--panel-border);
  box-shadow:
    inset 0 0 0 2px var(--panel-border-dark),
    0 6px 14px rgba(0, 0, 0, 0.55);
  color: var(--text-main);
  cursor: pointer;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.08s ease, filter 0.1s ease;
}

.mobile-action-btn:active {
  transform: scale(0.94);
  filter: brightness(1.18);
}

.attack-btn {
  background: linear-gradient(145deg, #9c2b2b, #611818);
  border-color: #ffadad;
}

.context-btn {
  display: none;
  background: linear-gradient(145deg, #c97a16, #7d4509);
  border-color: var(--accent-gold);
  color: #fff8e7;
  box-shadow:
    inset 0 0 0 2px #5c2e04,
    0 0 14px rgba(255, 209, 102, 0.5);
}

.context-btn.visible {
  display: block;
}

/* ==================== MOBILE 4-DIAMOND D-PAD ==================== */
.mobile-dpad {
  position: absolute;
  bottom: 22px;
  left: 24px;
  width: 156px;
  height: 156px;
  display: none;
  pointer-events: auto;
  touch-action: none;
  -webkit-touch-callout: none;
  z-index: 9;
}

.mobile-dpad.visible {
  display: block;
}

/* Subtle golden centerpiece gem between the 4 diamonds */
.dpad-center-gem {
  position: absolute;
  top: 78px;
  left: 78px;
  width: 14px;
  height: 14px;
  transform: translate(-50%, -50%) rotate(45deg);
  background: linear-gradient(135deg, #ffd166 0%, #c98a1c 100%);
  border: 2px solid #2b1a06;
  box-shadow: 0 0 8px rgba(255, 209, 102, 0.55);
  pointer-events: none;
}

.dpad-diamond {
  position: absolute;
  width: 46px;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, rgba(26, 39, 61, 0.9), rgba(13, 20, 33, 0.92));
  border: 3px solid var(--panel-border);
  box-shadow:
    inset 0 0 0 2px var(--panel-border-dark),
    0 5px 14px rgba(0, 0, 0, 0.55);
  color: var(--text-main);
  font-family: var(--pixel-font);
  cursor: pointer;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  transition:
    background 0.08s ease,
    border-color 0.08s ease,
    box-shadow 0.08s ease,
    transform 0.08s ease;
}

.dpad-up {
  top: 34px;
  left: 78px;
  transform: translate(-50%, -50%) rotate(45deg);
}

.dpad-right {
  top: 78px;
  left: 122px;
  transform: translate(-50%, -50%) rotate(45deg);
}

.dpad-down {
  top: 122px;
  left: 78px;
  transform: translate(-50%, -50%) rotate(45deg);
}

.dpad-left {
  top: 78px;
  left: 34px;
  transform: translate(-50%, -50%) rotate(45deg);
}

/* Counter-rotate the arrow glyph so it points cleanly up/down/left/right */
.dpad-icon {
  display: inline-block;
  transform: rotate(-45deg);
  font-size: 13px;
  line-height: 1;
  color: var(--panel-border);
  text-shadow: 1px 1px 0 #090e17;
  pointer-events: none;
}

.dpad-diamond.pressed,
.dpad-diamond:active {
  background: linear-gradient(145deg, rgba(255, 209, 102, 0.36), rgba(196, 138, 34, 0.32));
  border-color: var(--accent-gold);
  box-shadow:
    inset 0 0 0 2px #9c5a13,
    0 0 14px rgba(255, 209, 102, 0.55);
  transform: translate(-50%, -50%) rotate(45deg) scale(0.93);
}

.dpad-diamond.pressed .dpad-icon,
.dpad-diamond:active .dpad-icon {
  color: var(--accent-gold);
}

/* Hide desktop keyboard hint when mobile D-pad is visible so it stays clean */
.game-hud.mobile-controls-active .hud-bottom-bar {
  display: none;
}

.game-hud.mobile-controls-active .slot-key {
  display: none;
}

@media (max-width: 780px) {
  .mobile-dpad {
    bottom: 14px;
    left: 14px;
    transform: scale(0.82);
    transform-origin: bottom left;
  }
  .mobile-actions {
    bottom: 16px;
    right: 14px;
    transform: scale(0.86);
    transform-origin: bottom right;
  }
  .game-hud.mobile-controls-active .hotbar {
    transform: translateX(-50%) scale(0.84);
    transform-origin: bottom center;
  }
}

@media (max-width: 640px) {
  .cabinet-frame {
    padding: 6px;
    border-width: 3px;
  }
  .game-container {
    max-width: calc(100vw - 16px);
    max-height: calc(100vh - 16px);
  }
  .game-title {
    font-size: 28px;
  }
  .menu-btn {
    font-size: 13px;
  }
  .hud-location,
  .hud-btn {
    font-size: 8px;
    padding: 6px 8px;
  }
  .hud-vitals {
    width: 158px;
    padding: 5px 7px;
    gap: 4px;
  }
  .vital-bar-track {
    height: 9px;
  }
  .vital-value {
    width: 24px;
    font-size: 7px;
  }
  .death-title {
    font-size: 22px;
  }
  .hud-bottom-bar {
    font-size: 8px;
  }
  .mobile-dpad {
    bottom: 10px;
    left: 10px;
    transform: scale(0.74);
    transform-origin: bottom left;
  }
  .mobile-actions {
    bottom: 12px;
    right: 10px;
    transform: scale(0.78);
    transform-origin: bottom right;
  }
  .hotbar {
    transform: translateX(-50%) scale(0.76);
    transform-origin: bottom center;
  }
  .inventory-box {
    padding: 12px;
    gap: 8px;
  }
  .inv-slot {
    height: 46px;
  }
  .inventory-detail {
    flex-direction: column;
    align-items: flex-start;
  }
  .shop-box,
  .dialogue-box {
    padding: 12px;
  }
  .shop-row {
    flex-wrap: wrap;
    gap: 6px;
  }
  .shop-wallet {
    gap: 4px;
  }
  .shop-level-badge,
  .shop-coins-badge {
    font-size: 7px;
    padding: 3px 5px;
  }
  .dialogue-text {
    font-size: 8px;
  }
}
