:root {
  --bg-void: #110e0c;
  --bg-iron: #1a1613;
  --bg-iron-elev: #231e19;
  --bg-panel: rgba(20, 17, 14, 0.92);
  --bg-panel-solid: #191512;
  --border-bronze: rgba(196, 154, 72, 0.34);
  --border-bronze-strong: rgba(218, 176, 88, 0.62);
  --border-subtle: rgba(235, 224, 204, 0.12);

  --text-parchment: #efe6d5;
  --text-muted: #b3a691;
  --text-dim: #7f7363;

  --accent-gold: #d4a448;
  --accent-gold-bright: #f2cf7e;
  --accent-forge: #d95b26;
  --accent-alchemy: #2f9e73;
  --accent-crimson: #c23934;
  --accent-steel: #5889a8;

  --rarity-common: #b6afa3;
  --rarity-rare: #59a5d8;
  --rarity-epic: #d9822b;
  --rarity-legendary: #f2be42;
  --rarity-mythic: #e64833;

  --font-display: "Cinzel", "Palatino Linotype", "Book Antiqua", Georgia, serif;
  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --shadow-panel: 0 18px 46px rgba(0, 0, 0, 0.65), inset 0 1px 0 rgba(255, 232, 185, 0.08);
}

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

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

#game-shell {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

#webgl-canvas,
#overlay-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

#overlay-canvas {
  pointer-events: none;
}

#ui-root {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 10;
}

.interactive {
  pointer-events: auto;
}

/* Typography helpers */
.font-display {
  font-family: var(--font-display);
  letter-spacing: 0.04em;
}

.font-mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

/* Reusable forged iron surface */
.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border-bronze);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-panel);
  backdrop-filter: blur(10px);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 15px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-bronze);
  background: linear-gradient(180deg, #2b241d 0%, #1d1813 100%);
  color: var(--text-parchment);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.btn:hover:not(:disabled) {
  border-color: var(--border-bronze-strong);
  background: linear-gradient(180deg, #382e24 0%, #261f18 100%);
  color: var(--accent-gold-bright);
  transform: translateY(-1px);
}

.btn:active:not(:disabled) {
  transform: translateY(0);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(180deg, #c69236 0%, #96681e 100%);
  border-color: #ebc574;
  color: #16110b;
  font-weight: 700;
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(180deg, #dba747 0%, #ab7926 100%);
  color: #110d08;
}

.btn-forge {
  background: linear-gradient(180deg, #c75322 0%, #8e3410 100%);
  border-color: #f08e5a;
  color: #fff6ec;
}

.btn-forge:hover:not(:disabled) {
  background: linear-gradient(180deg, #de612c 0%, #a53d15 100%);
  color: #ffffff;
}

.btn-alchemy {
  background: linear-gradient(180deg, #2b8c66 0%, #1d6448 100%);
  border-color: #5fd1a0;
  color: #f1fff8;
}

.btn-danger {
  background: linear-gradient(180deg, #a6332e 0%, #75201c 100%);
  border-color: #df6963;
  color: #fff2f2;
}

.btn-sm {
  padding: 6px 10px;
  font-size: 12px;
}

.input {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: rgba(12, 10, 8, 0.88);
  color: var(--text-parchment);
  font-family: var(--font-sans);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s ease;
}

.input:focus {
  border-color: var(--accent-gold);
}

/* ===========================
   ENTRY / AUTH SCREEN
   =========================== */
.auth-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(circle at 50% 35%, rgba(42, 30, 18, 0.42), rgba(11, 9, 7, 0.88) 72%);
}

.auth-card {
  width: 100%;
  max-width: 470px;
  padding: 32px 30px 26px;
  background: linear-gradient(180deg, rgba(28, 23, 18, 0.96) 0%, rgba(16, 13, 10, 0.98) 100%);
  border: 1px solid var(--border-bronze-strong);
  border-radius: var(--radius-lg);
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.82), inset 0 1px 0 rgba(242, 207, 126, 0.18);
}

.auth-crest {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.auth-emblem {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: linear-gradient(135deg, #d95b26 0%, #c89b3c 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #16110b;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 22px;
  box-shadow: 0 6px 18px rgba(217, 91, 38, 0.35);
}

.auth-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
  color: var(--accent-gold-bright);
  letter-spacing: 0.05em;
  line-height: 1.15;
}

.auth-subtitle {
  margin: 4px 0 20px;
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.45;
}

.auth-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 18px;
  padding: 4px;
  background: rgba(10, 8, 6, 0.65);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

.auth-tab {
  padding: 8px 6px;
  border: none;
  border-radius: 3px;
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.auth-tab.active {
  background: rgba(212, 164, 72, 0.18);
  color: var(--accent-gold-bright);
}

.form-group {
  margin-bottom: 13px;
}

.form-label {
  display: block;
  margin-bottom: 5px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.auth-error {
  margin: 10px 0;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  background: rgba(194, 57, 52, 0.18);
  border: 1px solid rgba(194, 57, 52, 0.55);
  color: #ffb8b5;
  font-size: 12px;
}

.auth-features {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border-subtle);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 12px;
  font-size: 11px;
  color: var(--text-muted);
}

/* ===========================
   TOP HUD BAR
   =========================== */
.hud-top-left {
  position: absolute;
  top: 14px;
  left: 14px;
  width: 310px;
  padding: 12px 14px;
}

.char-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.char-name {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  color: var(--text-parchment);
}

.char-gold {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-gold-bright);
}

.char-meta-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 9px;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-parchment);
}

.badge-gold {
  border-color: rgba(212, 164, 72, 0.55);
  background: rgba(212, 164, 72, 0.14);
  color: var(--accent-gold-bright);
}

.badge-legendary {
  border-color: rgba(232, 93, 36, 0.65);
  background: rgba(232, 93, 36, 0.2);
  color: #ffc28a;
}

.bar-wrap {
  margin-bottom: 6px;
}

.bar-labels {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 3px;
}

.bar-track {
  width: 100%;
  height: 9px;
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.bar-fill-hp {
  height: 100%;
  background: linear-gradient(90deg, #982522 0%, #d4433d 100%);
  transition: width 0.12s linear;
}

.bar-fill-xp {
  height: 100%;
  background: linear-gradient(90deg, #b88428 0%, #f0ca72 100%);
  transition: width 0.12s linear;
}

/* TOP CENTER (ZONE / DUNGEON TIMER & BOSS BAR) */
.hud-top-center {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.zone-pill {
  padding: 8px 18px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.zone-title {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  color: var(--accent-gold-bright);
}

.zone-stat {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-parchment);
}

.boss-bar-panel {
  width: 440px;
  padding: 9px 14px;
  border-color: rgba(201, 56, 43, 0.72);
}

.boss-bar-fill {
  height: 12px;
  background: linear-gradient(90deg, #8b1e1a 0%, #df4b37 100%);
  transition: width 0.1s linear;
}

/* TOP RIGHT (PERF TELEMETRY & QUICK CONTROLS) */
.hud-top-right {
  position: absolute;
  top: 14px;
  right: 14px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.perf-panel {
  padding: 9px 12px;
  min-width: 248px;
  font-family: var(--font-mono);
  font-size: 11px;
}

.perf-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px 10px;
  margin-bottom: 6px;
}

.perf-metric-label {
  color: var(--text-dim);
  font-size: 10px;
  text-transform: uppercase;
}

.perf-metric-val {
  color: var(--text-parchment);
  font-size: 13px;
  font-weight: 700;
}

.perf-ok {
  color: #6bd69b;
}

.perf-warn {
  color: #f0be5b;
}

/* BOTTOM ACTION DOCK */
.hud-bottom-center {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.interact-hint {
  padding: 7px 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-gold-bright);
  border-color: var(--border-bronze-strong);
  animation: gentlePulse 2s ease-in-out infinite;
}

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

.dock-bar {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 10px;
}

.skill-slot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 11px;
  border-radius: var(--radius-sm);
  background: rgba(10, 8, 6, 0.72);
  border: 1px solid var(--border-subtle);
  font-size: 12px;
}

.skill-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

/* BOTTOM LEFT CHAT (HUB) */
.hud-chat {
  position: absolute;
  bottom: 16px;
  left: 14px;
  width: 320px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.chat-messages {
  max-height: 130px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  line-height: 1.35;
}

.chat-sender {
  color: var(--accent-gold);
  font-weight: 700;
}

.chat-form {
  display: flex;
  gap: 6px;
}

/* ===========================
   MODALS & DRAWERS
   =========================== */
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(9, 7, 6, 0.74);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 30;
}

.modal-box {
  width: 100%;
  max-width: 820px;
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-color: var(--border-bronze-strong);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-bronze);
  background: rgba(28, 22, 16, 0.92);
}

.modal-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 20px;
  color: var(--accent-gold-bright);
}

.modal-body {
  padding: 18px 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(310px, 1fr));
  gap: 12px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.card-item {
  padding: 14px;
  border-radius: var(--radius-md);
  background: rgba(29, 24, 19, 0.88);
  border: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
}

.card-item-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.rarity-COMMON {
  color: var(--rarity-common);
}
.rarity-RARE {
  color: var(--rarity-rare);
}
.rarity-EPIC {
  color: var(--rarity-epic);
}
.rarity-LEGENDARY {
  color: var(--rarity-legendary);
}
.rarity-MYTHIC {
  color: var(--rarity-mythic);
}

/* ROGUELITE UPGRADE CARDS */
.upgrade-card {
  padding: 18px 16px;
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, #272019 0%, #17130f 100%);
  border: 1px solid var(--border-bronze);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
  text-align: left;
  color: var(--text-parchment);
  transition: transform 0.14s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.upgrade-card:hover {
  transform: translateY(-4px);
  border-color: var(--accent-gold-bright);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.6);
}

.hotkey-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 4px;
  background: rgba(212, 164, 72, 0.18);
  border: 1px solid var(--border-bronze);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-gold-bright);
}

/* SATISFY SYSTEM UNLOCK TOASTS */
.toast-stack {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  z-index: 60;
  pointer-events: none;
}

.satisfy-toast {
  min-width: 360px;
  max-width: 540px;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  background: linear-gradient(90deg, rgba(24, 18, 12, 0.96) 0%, rgba(44, 31, 16, 0.96) 50%, rgba(24, 18, 12, 0.96) 100%);
  border: 1px solid var(--accent-gold-bright);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.72);
  text-align: center;
  animation: toastSlide 0.25s ease-out;
}

.satisfy-toast-title {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  color: var(--accent-gold-bright);
}

.satisfy-toast-desc {
  margin-top: 3px;
  font-size: 12px;
  color: var(--text-parchment);
}

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

.req-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12px;
}

.req-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--text-muted);
}

.req-met {
  color: #6bd69b;
}

.controls-legend {
  position: absolute;
  bottom: 16px;
  right: 14px;
  padding: 8px 12px;
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 3px;
}
