:root {
  --text-color: #ffffff;
  --bg-color: #1a1a1a;
  --accent-color: #4CAF50;
  --border-color: #333333;
  --panel-bg: rgba(0, 0, 0, 0.8);
  --text-scale: 1.0;
  --transition-duration: 0.3s;
  --animation-duration: 0.3s;
  --bottom-tab-bar-height: 48px;
  --header-bar-height: 60px;
  --bottom-skill-hud-height: 86px;
}

body {
  margin: 0;
  padding: 0;
  font-family: 'Arial', sans-serif;
  background-color: var(--bg-color);
  color: var(--text-color);
  font-size: calc(14px * var(--text-scale));
  transition: all var(--transition-duration) ease;
}

#gameContainer {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

#uiOverlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 100;
}

#uiOverlay>* {
  pointer-events: auto;
}

/* Run progress: segment + wave (dungeon / field endless / boss) */
.battle-progress-hud {
  position: fixed;
  top: calc(var(--header-bar-height, 60px) + 6px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 190;
  pointer-events: none;
  text-align: center;
  max-width: min(92vw, 520px);
  padding: 8px 18px;
  border-radius: 999px;
  background: linear-gradient(145deg, rgba(24, 28, 36, 0.92), rgba(12, 14, 20, 0.88));
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.45);
}

.battle-progress-run {
  font-size: calc(11px * var(--text-scale, 1));
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.72);
}

.battle-progress-detail {
  margin-top: 3px;
  font-size: calc(14px * var(--text-scale, 1));
  font-weight: 600;
  color: #e8ecf4;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.65);
  line-height: 1.25;
}

.battle-progress-boss-hp-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.battle-progress-boss-label {
  font-size: calc(10px * var(--text-scale, 1));
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(200, 160, 255, 0.95);
  flex-shrink: 0;
}

.battle-progress-boss-bar {
  flex: 1;
  min-width: 96px;
  max-width: 220px;
  height: 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.45);
  overflow: hidden;
  border: 1px solid rgba(155, 77, 188, 0.35);
}

.battle-progress-boss-bar-fill {
  height: 100%;
  width: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #6b2a86 0%, #c56bff 55%, #ff8cf0 100%);
  box-shadow: 0 0 12px rgba(197, 107, 255, 0.45);
  transition: width 0.2s ease-out;
}

.battle-progress-boss-pct {
  font-size: calc(13px * var(--text-scale, 1));
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #f0e6ff;
  min-width: 2.75em;
  text-align: right;
  flex-shrink: 0;
}

#headerBar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 60px;
  box-sizing: border-box;
  background: var(--panel-bg);
  border-bottom: 2px solid var(--border-color);
  display: flex;
  flex-wrap: nowrap;
  justify-content: flex-start;
  align-items: center;
  gap: 10px 12px;
  padding: 0 12px;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  font-size: calc(15px * var(--text-scale));
  transition: all var(--transition-duration) ease;
  z-index: 200;
}

.header-section {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 0 1 auto;
}

.resource-icon {
  font-size: calc(18px * var(--text-scale));
  flex-shrink: 0;
}

.stat-value {
  font-size: calc(12px * var(--text-scale));
  font-weight: 600;
  white-space: nowrap;
}

.stat-value.level {
  font-size: calc(14px * var(--text-scale));
  font-weight: 700;
  color: var(--accent-color);
}

.stat-value.gold {
  color: #ffd700;
}

.stat-percent {
  font-size: calc(10px * var(--text-scale));
  color: #aaa;
  white-space: nowrap;
}

.resource-bar-container {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 80px;
  flex: 1;
}

.level-container {
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-items: center;
  min-width: 60px;
}

.resource-bar {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  overflow: hidden;
  position: relative;
}

.resource-bar.exp-bar {
  width: 80px;
  height: 4px;
}

.resource-bar-fill {
  height: 100%;
  background: var(--accent-color);
  border-radius: 3px;
  transition: width var(--transition-duration) ease;
}

#headerHealthBar .resource-bar-fill {
  background: #f44336;
}

#headerManaBar .resource-bar-fill {
  background: #2196f3;
}

#headerEnergyBar .resource-bar-fill {
  background: #ffeb3b;
}

#headerExpBar .resource-bar-fill {
  background: #9c27b0;
}

/* Panel stack: content grows upward from the bottom tab bar */
#mainPanelDock {
  position: fixed;
  left: 0;
  right: 0;
  top: 60px;
  bottom: 0;
  z-index: 200;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: stretch;
  pointer-events: none;
}

#bottomTabBar {
  flex-shrink: 0;
  display: flex;
  flex-direction: row;
  align-items: stretch;
  min-height: var(--bottom-tab-bar-height);
  background: var(--panel-bg);
  border-top: 2px solid var(--border-color);
  padding: 0;
  pointer-events: auto;
}

#bottomSkillHud {
  position: fixed;
  left: 50%;
  bottom: calc(var(--bottom-tab-bar-height) + 10px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 205;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 12px;
  pointer-events: none;
  width: min(96vw, 980px);
  box-sizing: border-box;
}

.bottom-resources {
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: linear-gradient(160deg, rgba(24, 24, 30, 0.94), rgba(12, 12, 16, 0.9));
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  min-width: 210px;
}

.bottom-resource-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.bottom-resource-icon {
  font-size: calc(14px * var(--text-scale));
  width: 1.4em;
  text-align: center;
  flex-shrink: 0;
}

.bottom-resource-bar-wrap {
  flex: 1;
  min-width: 0;
}

.bottom-resource-bar {
  height: 7px;
}

.bottom-resource-meta {
  margin-top: 2px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

.bottom-resource-value {
  font-size: calc(10px * var(--text-scale));
  font-weight: 600;
}

.bottom-resource-percent {
  font-size: calc(9px * var(--text-scale));
  opacity: 0.86;
}

#bottomHealthBar .resource-bar-fill {
  background: #f44336;
}

#bottomManaBar .resource-bar-fill {
  background: #2196f3;
}

#bottomEnergyBar .resource-bar-fill {
  background: #ffeb3b;
}

.bottom-skillbar {
  pointer-events: auto;
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 8px;
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: linear-gradient(160deg, rgba(30, 30, 38, 0.95), rgba(14, 14, 18, 0.9));
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.45);
  flex: 1;
  min-width: 0;
}

.skill-slot {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: radial-gradient(circle at 50% 35%, rgba(110, 110, 140, 0.45), rgba(20, 20, 24, 0.95));
  color: var(--text-color);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font: inherit;
  cursor: pointer;
  padding: 4px;
  box-sizing: border-box;
  transition: transform var(--transition-duration) ease,
    border-color var(--transition-duration) ease,
    opacity var(--transition-duration) ease;
}

.skill-slot--auto {
  box-shadow: inset 0 0 0 1px rgba(106, 191, 75, 0.35);
}

.skill-slot--manual {
  box-shadow: inset 0 0 0 1px rgba(255, 152, 0, 0.4);
}

.skill-slot-mode {
  position: absolute;
  top: 2px;
  right: 3px;
  font-size: calc(7px * var(--text-scale));
  line-height: 1;
  letter-spacing: 0.02em;
  font-weight: 700;
  opacity: 0.88;
  pointer-events: none;
}

.skill-slot--auto .skill-slot-mode {
  color: #9be870;
}

.skill-slot--manual .skill-slot-mode {
  color: #ffb74d;
}

.skill-slot:hover:not([disabled]) {
  transform: translateY(-1px);
  border-color: rgba(106, 191, 75, 0.86);
}

.skill-slot:disabled {
  opacity: 0.48;
  cursor: default;
}

.skill-slot.is-cooling {
  border-color: rgba(255, 193, 7, 0.75);
}

.skill-slot-key {
  font-size: calc(9px * var(--text-scale));
  opacity: 0.78;
}

.skill-slot-icon {
  font-size: calc(18px * var(--text-scale));
  line-height: 1;
}

.skill-slot-cd {
  font-size: calc(9px * var(--text-scale));
  min-height: 1em;
  opacity: 0.92;
}

body.main-panel-open #bottomSkillHud {
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, 8px);
}

.bottom-tab-btn {
  flex: 1;
  min-width: 0;
  margin: 0;
  border: none;
  border-right: 1px solid var(--border-color);
  background: rgba(0, 0, 0, 0.4);
  color: var(--text-color);
  font-size: calc(11px * var(--text-scale));
  font-weight: 600;
  cursor: pointer;
  padding: 10px 6px;
  transition: background var(--transition-duration) ease, color var(--transition-duration) ease;
}

.bottom-tab-btn:last-child {
  border-right: none;
}

.bottom-tab-btn:hover {
  background: rgba(255, 255, 255, 0.08);
}

.bottom-tab-btn.active {
  background: var(--accent-color);
  color: #1a1a1a;
}

/* Full-height overlay above the bottom tab bar (all tabs, not only gear) */
#mainPanel {
  position: relative;
  flex: 1 1 auto;
  max-height: none;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--panel-bg);
  border-top: none;
  box-shadow: inset 0 0 100px rgba(0, 0, 0, 0.4);
  padding: 20px;
  transition: transform var(--transition-duration) ease;
  font-size: calc(14px * var(--text-scale));
  pointer-events: auto;
  width: 100%;
  box-sizing: border-box;
}

/* Visible tab fills the panel; scroll inside the tab (inventory / skills / menu) */
#mainPanel > .tab-content {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
}

/* Equipment: scroll inside paper doll, not the outer tab strip */
#mainPanel.main-panel--equipment #tabContent-equipment:not([style*="display: none"]) {
  display: flex !important;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

#mainPanel.main-panel--equipment .panel-header {
  flex-shrink: 0;
  margin-bottom: 8px;
  padding-bottom: 8px;
  text-align: center;
  border-bottom: 1px solid var(--border-color);
}

#mainPanel.main-panel--equipment #equipmentPanelContent {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  overflow-y: auto;
}

.equipment-panel-stack {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  width: 100%;
  gap: 18px;
  padding-bottom: 16px;
  box-sizing: border-box;
}

.equipment-gear-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 0.85fr);
  gap: 16px;
  align-items: start;
}

.equipment-gear-left,
.equipment-gear-right {
  min-width: 0;
}

.equipment-stats-card {
  border-radius: 10px;
  background: rgba(28, 30, 38, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.12);
  overflow: hidden;
}

.equipment-stats-title {
  padding: 10px 12px;
  font-size: calc(12px * var(--text-scale));
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(8, 10, 16, 0.45);
}

.equipment-stats-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.equipment-stats-row:last-child {
  border-bottom: none;
}

.equipment-stats-row--primary {
  font-size: calc(16px * var(--text-scale));
  font-weight: 700;
}

.equipment-stats-key {
  color: #d5d8df;
}

.equipment-stats-value {
  color: #ffffff;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.equipment-sell-panel {
  flex-shrink: 0;
  width: 100%;
  max-width: min(480px, 100%);
  margin: 0 auto;
  padding: 14px 16px 18px;
  border-radius: 8px;
  background: rgba(35, 38, 48, 0.98);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-sizing: border-box;
}

.equipment-sell-panel__title {
  font-size: calc(13px * var(--text-scale));
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #c5c5c5;
  margin-bottom: 6px;
  text-align: center;
}

.equipment-sell-panel__hint {
  margin: 0 0 12px 0;
  font-size: calc(11px * var(--text-scale));
  line-height: 1.4;
  color: #888;
  text-align: center;
}

.equipment-sell-panel__empty {
  text-align: center;
  font-size: calc(12px * var(--text-scale));
  color: #666;
  padding: 12px 8px;
}

.equipment-sell-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.equipment-sell-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.equipment-sell-row__info {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.equipment-sell-row__icon {
  font-size: calc(20px * var(--text-scale));
  line-height: 1;
  flex-shrink: 0;
}

.equipment-sell-row__meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.equipment-sell-row__name {
  font-size: calc(12px * var(--text-scale));
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.equipment-sell-row__sub {
  font-size: calc(11px * var(--text-scale));
  color: #ffd93d;
  line-height: 1.35;
  word-break: break-word;
}

.equipment-sell-row__btn {
  flex-shrink: 0;
  padding: 6px 14px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(106, 191, 75, 0.25);
  color: var(--text-color, #e0e0e0);
  font-size: calc(12px * var(--text-scale));
  font-weight: 600;
  cursor: pointer;
}

.equipment-sell-row__btn:hover {
  background: rgba(106, 191, 75, 0.4);
}

.equipment-sell-row--unidentified {
  border-color: rgba(180, 160, 255, 0.45);
  background: rgba(40, 32, 58, 0.35);
}

.equipment-paper-doll {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr) minmax(0, 1fr);
  grid-template-rows: auto auto auto;
  grid-template-areas:
    ". head ."
    "weapon body offhand"
    ". feet .";
  gap: 14px 18px;
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
  padding: 12px 16px 28px;
  box-sizing: border-box;
  align-items: stretch;
  justify-items: stretch;
  background: radial-gradient(
    ellipse 60% 75% at 50% 42%,
    rgba(120, 120, 140, 0.09) 0%,
    transparent 62%
  );
}

.equipment-slot--head {
  grid-area: head;
}

.equipment-slot--weapon {
  grid-area: weapon;
}

.equipment-slot--body {
  grid-area: body;
}

.equipment-slot--offhand {
  grid-area: offhand;
}

.equipment-slot--gloves {
  grid-area: gloves;
}

.equipment-slot--feet {
  grid-area: feet;
}

#mainPanel.main-panel--equipment .equipment-slot {
  margin: 0;
  min-height: 0;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  padding: 12px;
  border-radius: 8px;
  background: rgba(40, 40, 45, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

#mainPanel.main-panel--equipment .equipment-slot.equipment-slot--head,
#mainPanel.main-panel--equipment .equipment-slot.equipment-slot--feet {
  justify-self: center;
  width: 100%;
  max-width: 220px;
}

.equipment-slot-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.equipment-slot-icon {
  font-size: calc(20px * var(--text-scale));
  line-height: 1;
}

.equipment-slot-title {
  font-size: calc(11px * var(--text-scale));
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #aaa;
}

.equipment-slot-inner--empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 8px;
  min-height: 104px;
  flex: 1;
}

.equipment-slot-inner--empty .equipment-slot-icon {
  font-size: calc(28px * var(--text-scale));
  opacity: 0.45;
}

.equipment-slot-sub {
  font-size: calc(12px * var(--text-scale));
  color: #666;
}

.equipment-unequip-hint {
  font-size: calc(10px * var(--text-scale));
  color: #666;
  margin-top: 6px;
}

#mainPanel.main-panel--equipment .equipment-item {
  cursor: pointer;
  flex: 1;
}

#mainPanel.main-panel--equipment .item-name {
  font-size: calc(13px * var(--text-scale));
}

@media (max-width: 520px) {
  .equipment-gear-layout,
  .skills-panel-layout {
    grid-template-columns: 1fr;
  }

  .skills-panel-stats {
    position: static;
  }

  .equipment-paper-doll {
    grid-template-columns: 1fr;
    grid-template-areas:
      "head"
      "weapon"
      "offhand"
      "body"
      "gloves"
      "feet";
    max-width: 100%;
    gap: 10px;
    padding: 8px 0 20px;
  }

  #mainPanel.main-panel--equipment .equipment-slot.equipment-slot--head,
  #mainPanel.main-panel--equipment .equipment-slot.equipment-slot--feet {
    max-width: none;
  }
}

.panel-header {
  margin-bottom: 15px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-color);
}

.panel-title {
  font-size: calc(18px * var(--text-scale));
  font-weight: 700;
  color: var(--text-color);
}

.tab-content {
  display: none;
}

.tab-content:not([style*="display: none"]) {
  display: block;
}

.equipment-slot {
  background: #333;
  border: 1px solid var(--border-color);
  padding: 15px;
  margin: 10px 0;
  border-radius: 5px;
  min-height: 60px;
  display: flex;
  align-items: center;
  transition: all var(--transition-duration) ease;
}

.equipment-slot:hover {
  background: #555;
  border-color: var(--accent-color);
}

.equipment-item {
  width: 100%;
  cursor: pointer;
}

.item-name {
  font-size: calc(14px * var(--text-scale));
  font-weight: 600;
  margin-bottom: 5px;
}

.item-stats {
  font-size: calc(12px * var(--text-scale));
  color: #aaa;
  margin-bottom: 5px;
}

.item-bag-hint {
  font-size: calc(11px * var(--text-scale));
  color: rgba(180, 210, 255, 0.95);
  margin: 6px 0 4px;
  line-height: 1.35;
}

.item-bag-hint__name {
  font-weight: 600;
}

.stat-delta {
  font-weight: 700;
  white-space: nowrap;
}

.stat-delta--up {
  color: #6abf4b;
}

.stat-delta--down {
  color: #e57575;
}

.item-level {
  font-size: calc(10px * var(--text-scale));
  color: #888;
}

.item-actions {
  display: flex;
  gap: 5px;
  margin-top: 8px;
}

.equip-btn {
  background: var(--accent-color);
}

.equip-btn:hover {
  background: #45a049;
}

.panel {
  display: none;
  animation: fadeIn var(--animation-duration) ease;
}

.panel.active {
  display: block;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.tab-button {
  background: #333;
  color: var(--text-color);
  border: none;
  padding: 10px 20px;
  margin: 0 5px;
  border-radius: 5px 5px 0 0;
  cursor: pointer;
  font-size: calc(14px * var(--text-scale));
  transition: all var(--transition-duration) ease;
}

.tab-button.active {
  background: var(--accent-color);
}

.tab-button:hover {
  background: #555;
}

.tab-button.active:hover {
  background: #45a049;
}

#controlsPanel {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-top: 20px;
  margin-bottom: 24px;
}

.skills-panel-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 0.85fr);
  gap: 16px;
  align-items: start;
}

.skills-panel-main {
  min-width: 0;
}

.skills-panel-stats {
  min-width: 0;
  position: sticky;
  top: 0;
}

.skills-section {
  margin-bottom: 14px;
}

.skills-section-title {
  font-size: calc(13px * var(--text-scale));
  font-weight: 700;
  letter-spacing: 0.02em;
  margin: 0 0 8px;
  color: #dcdce6;
}

.skills-section-summary {
  margin: 0 0 10px;
  line-height: 1.45;
  color: var(--text-color, #e0e0e0);
  font-size: calc(12px * var(--text-scale));
}

.weapon-skills-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
}

.weapon-skill-item {
  margin: 0;
}

.weapon-skill-slot {
  font-size: calc(11px * var(--text-scale));
  font-weight: 700;
  color: #b7c3ff;
  margin-bottom: 4px;
}

.weapon-skill-name {
  font-size: calc(13px * var(--text-scale));
  font-weight: 700;
  color: #f3f3ff;
  margin-bottom: 4px;
}

.weapon-skill-detail {
  font-size: calc(11px * var(--text-scale));
  color: #c9c9d6;
  line-height: 1.45;
}

.weapon-skill-tree-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.weapon-skill-tree-tab--equipped {
  border-color: #6a8cff;
  box-shadow: 0 0 0 1px rgba(106, 140, 255, 0.35);
}

.weapon-skill-tree-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.weapon-skill-tree-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.weapon-skill-tree-meta {
  font-size: calc(12px * var(--text-scale));
  font-weight: 700;
  color: #d8dcff;
  margin-bottom: 0;
}

.weapon-skill-tree-clear-btn {
  flex-shrink: 0;
  font-size: calc(11px * var(--text-scale));
  padding: 6px 10px;
}

.weapon-skill-tree-node {
  --wst-depth: 0;
  margin-left: calc(var(--wst-depth) * 18px);
  padding-left: 12px;
  border-left: 2px solid rgba(106, 140, 255, 0.45);
}

.weapon-skill-tree-node--locked {
  opacity: 0.55;
  border-left-color: rgba(120, 120, 140, 0.35);
}

.weapon-skill-tree-node-title {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
  font-weight: 700;
}

.weapon-skill-tree-tier-tag {
  font-size: calc(10px * var(--text-scale));
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #9aa8e8;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(106, 140, 255, 0.15);
}

.weapon-skill-tree-node--maxed .buy-btn {
  visibility: hidden;
}

.control-btn {
  background: #333;
  color: var(--text-color);
  border: 1px solid var(--border-color);
  padding: 10px;
  border-radius: 5px;
  cursor: pointer;
  font-size: calc(12px * var(--text-scale));
  transition: all var(--transition-duration) ease;
}

.control-btn:hover {
  background: #555;
  transform: scale(1.02);
}

/* Tall enough that the item detail / compare overlay (absolute, inset 0) has room when the grid is short */
#inventoryPanelContent {
  position: relative;
  min-height: clamp(320px, 52vh, 480px);
}

.inventory-grid-host {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
  gap: 8px;
  align-content: start;
}

.inventory-view-controls {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin: 0 0 10px;
  flex-wrap: wrap;
}

.inventory-filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.inventory-filter-chip {
  border: 1px solid var(--border-color);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-color);
  border-radius: 999px;
  padding: 4px 10px;
  font: inherit;
  font-size: calc(11px * var(--text-scale));
  cursor: pointer;
}

.inventory-filter-chip.is-active {
  border-color: var(--accent-color);
  background: rgba(76, 175, 80, 0.22);
}

.inventory-sort-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.inventory-sort-label {
  font-size: calc(11px * var(--text-scale));
  color: #bbb;
}

.inventory-sort-select {
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: #222;
  color: var(--text-color);
  font: inherit;
  font-size: calc(11px * var(--text-scale));
  padding: 4px 8px;
}

.inventory-grid-empty {
  grid-column: 1 / -1;
  color: rgba(255, 255, 255, 0.5);
  text-align: center;
  padding: 20px;
  font-size: calc(13px * var(--text-scale));
}

.inventory-grid-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 88px;
  padding: 8px 6px;
  border-radius: 8px;
  border: 2px solid var(--border-color);
  background: #333;
  cursor: pointer;
  font: inherit;
  color: var(--text-color);
  transition: background var(--transition-duration) ease,
    border-color var(--transition-duration) ease;
}

.inventory-grid-cell:hover,
.inventory-grid-cell:focus-visible {
  background: #444;
  outline: none;
  border-color: var(--accent-color);
}

.inventory-grid-cell-icon {
  font-size: 1.45rem;
  line-height: 1;
}

.inventory-grid-cell-name {
  font-size: calc(10px * var(--text-scale));
  text-align: center;
  line-height: 1.2;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.inventory-grid-cell-stats {
  font-size: calc(9px * var(--text-scale));
  line-height: 1.25;
  text-align: center;
  color: rgba(220, 220, 230, 0.92);
  max-width: 100%;
  word-break: break-word;
}

.inventory-grid-cell--common {
  border-color: #666;
}

.inventory-grid-cell--uncommon {
  border-color: #1eff00;
}

.inventory-grid-cell--rare {
  border-color: #0070dd;
}

.inventory-grid-cell--epic {
  border-color: #a335ee;
}

.inventory-grid-cell--legendary {
  border-color: #ff8000;
}

/* Mystery loot: name/stats hidden until the player taps to identify (client-only). */
.inventory-grid-cell--unidentified {
  border-color: rgba(160, 140, 220, 0.85);
  background: linear-gradient(160deg, #2a2538 0%, #1a1724 100%);
  box-shadow: 0 0 0 1px rgba(140, 120, 200, 0.35);
}

.inventory-grid-cell-stats--mystery {
  color: rgba(210, 200, 255, 0.92);
  font-style: italic;
}

/* Newly obtained gear: cleared when the player opens that item’s detail (in-memory only). */
.inventory-grid-cell--new {
  position: relative;
  box-shadow:
    0 0 0 2px rgba(255, 214, 120, 0.95),
    0 0 18px rgba(255, 190, 70, 0.55);
  animation: inventory-new-glow 1.5s ease-in-out infinite;
}

@keyframes inventory-new-glow {
  0%,
  100% {
    box-shadow:
      0 0 0 2px rgba(255, 214, 120, 0.85),
      0 0 14px rgba(255, 190, 70, 0.45);
  }
  50% {
    box-shadow:
      0 0 0 3px rgba(255, 236, 160, 1),
      0 0 26px rgba(255, 210, 100, 0.75);
  }
}

@media (prefers-reduced-motion: reduce) {
  .inventory-grid-cell--new {
    animation: none;
    box-shadow:
      0 0 0 3px rgba(255, 230, 140, 1),
      0 0 12px rgba(255, 200, 80, 0.5);
  }
}

.inventory-detail-overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
}

.inventory-detail-overlay[hidden] {
  display: none !important;
}

.inventory-detail-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.68);
  cursor: pointer;
}

.inventory-detail-card {
  position: relative;
  z-index: 1;
  max-width: 100%;
  width: min(320px, 100%);
  max-height: calc(100% - 24px);
  overflow: auto;
  background: #2a2a2a;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 12px 12px 10px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.55);
}

.inventory-detail-close {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-color);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.inventory-detail-close:hover,
.inventory-detail-close:focus-visible {
  background: rgba(255, 255, 255, 0.08);
  outline: none;
}

.inventory-detail-equip-zone {
  cursor: pointer;
  padding: 28px 8px 12px;
  border-radius: 8px;
  border: 1px solid transparent;
  transition: border-color var(--transition-duration) ease,
    background var(--transition-duration) ease;
}

.inventory-detail-equip-zone:hover,
.inventory-detail-equip-zone:focus-visible {
  border-color: var(--accent-color);
  background: rgba(255, 255, 255, 0.06);
  outline: none;
}

.inventory-detail-slot-line {
  text-align: center;
  margin-bottom: 10px;
  color: #ccc !important;
  font-weight: 600;
}

.inventory-detail-compare {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

.inventory-detail-compare-col {
  min-width: 0;
}

.inventory-detail-compare-label {
  font-size: calc(10px * var(--text-scale));
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #888;
  margin-bottom: 6px;
}

.inventory-detail-compare-divider {
  width: 1px;
  align-self: stretch;
  min-height: 48px;
  background: var(--border-color);
  margin-top: 22px;
}

.inventory-detail-title--compact {
  font-size: calc(13px * var(--text-scale));
}

.inventory-detail-empty-slot {
  font-size: calc(12px * var(--text-scale));
  color: #888;
  line-height: 1.4;
  padding: 4px 0;
}

@media (max-width: 360px) {
  .inventory-detail-compare {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .inventory-detail-compare-divider {
    width: 100%;
    height: 1px;
    min-height: 0;
    margin-top: 0;
  }
}

.inventory-detail-title {
  font-size: calc(15px * var(--text-scale));
  font-weight: 700;
  margin-bottom: 8px;
}

.inventory-detail-meta {
  font-size: calc(12px * var(--text-scale));
  color: #aaa;
  margin-bottom: 6px;
}

.inventory-detail-stats {
  font-size: calc(12px * var(--text-scale));
  color: #ccc;
  line-height: 1.35;
}

.inventory-detail-delete {
  width: 100%;
  margin-top: 8px;
  padding: 10px;
  border: none;
  border-radius: 6px;
  background: #f44336;
  color: #fff;
  font-size: calc(12px * var(--text-scale));
  cursor: pointer;
  transition: background var(--transition-duration) ease;
}

.inventory-detail-delete:hover,
.inventory-detail-delete:focus-visible {
  background: #d32f2f;
  outline: none;
}

.inventory-detail-equip-hint {
  font-size: calc(10px * var(--text-scale));
  color: #777;
  text-align: center;
  margin-top: 6px;
}

.action-btn {
  background: var(--accent-color);
  color: var(--text-color);
  border: none;
  padding: 5px 10px;
  border-radius: 3px;
  cursor: pointer;
  font-size: calc(10px * var(--text-scale));
  margin-left: 5px;
  transition: all var(--transition-duration) ease;
}

.action-btn:hover {
  background: #45a049;
  transform: scale(1.05);
}

.delete-btn {
  background: #f44336;
}

.delete-btn:hover {
  background: #d32f2f;
}

.upgrade-item {
  background: #333;
  border: 1px solid var(--border-color);
  padding: 15px;
  margin: 10px 0;
  border-radius: 5px;
  font-size: calc(12px * var(--text-scale));
  transition: all var(--transition-duration) ease;
}

.upgrade-item:hover {
  background: #555;
}

.upgrade-actions {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}

.buy-btn {
  background: var(--accent-color);
  color: var(--text-color);
  border: none;
  padding: 8px 15px;
  border-radius: 3px;
  cursor: pointer;
  font-size: calc(11px * var(--text-scale));
  transition: all var(--transition-duration) ease;
}

.buy-btn:hover {
  background: #45a049;
}

.refund-btn {
  background: #ff9800;
  color: var(--text-color);
  border: none;
  padding: 8px 15px;
  border-radius: 3px;
  cursor: pointer;
  font-size: calc(11px * var(--text-scale));
  transition: all var(--transition-duration) ease;
}

.refund-btn:hover {
  background: #f57c00;
}

.refund-btn:disabled {
  background: #666;
  cursor: not-allowed;
}

/* Mobile Controls */
#mobileControls {
  position: fixed;
  bottom: 20px;
  left: 20px;
  z-index: 200;
  display: none;
}

#virtualJoystick {
  width: 100px;
  height: 100px;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 50%;
  position: relative;
  border: 2px solid var(--accent-color);
}

#joystickHandle {
  width: 40px;
  height: 40px;
  background: var(--accent-color);
  border-radius: 50%;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  cursor: pointer;
}

#touchSkillButton {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 80px;
  height: 80px;
  background: var(--accent-color);
  border-radius: 50%;
  border: none;
  color: var(--text-color);
  font-size: calc(24px * var(--text-scale));
  cursor: pointer;
  z-index: 200;
  display: none;
  transition: all var(--transition-duration) ease;
}

#touchSkillButton:hover {
  background: #45a049;
  transform: scale(1.1);
}

#touchSkillButton:active {
  transform: scale(0.9);
}

/* Responsive Design */
@media (max-width: 768px) {
  #headerBar {
    padding: 0 10px;
    font-size: calc(14px * var(--text-scale));
  }

  #mainPanel {
    padding: 15px;
  }

  #controlsPanel {
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 8px;
  }

  .control-btn {
    padding: 8px;
    font-size: calc(10px * var(--text-scale));
  }

  #mobileControls {
    display: block;
  }

  #touchSkillButton {
    display: block;
  }

  #bottomSkillHud {
    gap: 8px;
    width: min(98vw, 760px);
  }

  .bottom-resources {
    min-width: 170px;
    padding: 7px 8px;
  }

  .bottom-skillbar {
    gap: 6px;
    padding: 7px 8px;
  }

  .skill-slot-icon {
    font-size: calc(15px * var(--text-scale));
  }

  .skill-slot-key,
  .skill-slot-cd {
    font-size: calc(8px * var(--text-scale));
  }
}

/* High Contrast Mode Adjustments */
[data-high-contrast="true"] {
  --text-color: #ffffff;
  --bg-color: #000000;
  --accent-color: #ffff00;
  --border-color: #ffffff;
  --panel-bg: rgba(0, 0, 0, 0.95);
}

/* Reduced Motion Adjustments */
[data-reduced-motion="true"] * {
  animation-duration: 0.1s !important;
  transition-duration: 0.1s !important;
}

/* Merchant Buttons */
.merchant-btn {
  background: #333;
  color: var(--text-color);
  border: 1px solid var(--border-color);
  padding: 8px 12px;
  border-radius: 5px;
  cursor: pointer;
  font-size: calc(12px * var(--text-scale));
  transition: all var(--transition-duration) ease;
  text-align: center;
}

.merchant-btn:hover {
  background: #555;
  transform: scale(1.02);
}

/* Home base: NPC proximity → sell / trainer prompt */
.home-base-npc-interact {
  position: fixed;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  z-index: 210;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
}

.home-base-npc-interact__npc {
  font-size: calc(13px * var(--text-scale));
  font-weight: 600;
  color: var(--text-color, #fff);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.85);
  pointer-events: none;
}

.home-base-npc-interact__btn {
  pointer-events: auto;
  padding: 10px 20px;
  border-radius: 8px;
  border: 2px solid var(--border-color, #444);
  background: var(--panel-bg, rgba(30, 30, 30, 0.95));
  color: var(--text-color, #fff);
  font-size: calc(14px * var(--text-scale));
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
  transition: transform var(--transition-duration, 0.15s) ease,
    background var(--transition-duration, 0.15s) ease;
}

.home-base-npc-interact__btn:hover {
  background: rgba(60, 60, 60, 0.98);
  transform: scale(1.03);
}

.home-base-npc-interact__btn:active {
  transform: scale(0.98);
}

/* Game Over Screen */
#gameOver {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--panel-bg);
  color: var(--text-color);
  padding: 30px;
  border-radius: 10px;
  border: 2px solid var(--border-color);
  text-align: center;
  z-index: 1000;
  display: none;
  min-width: 300px;
  font-size: calc(16px * var(--text-scale));
}

#gameOver h2 {
  color: #ff6b6b;
  margin-bottom: 20px;
  font-size: calc(24px * var(--text-scale));
}

#gameOver p {
  margin: 10px 0;
  font-size: calc(14px * var(--text-scale));
}

#gameOver .control-btn {
  margin-top: 20px;
  font-size: calc(14px * var(--text-scale));
}

/* Modal/Dialog Base Styles */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-dialog {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--panel-bg);
  color: var(--text-color);
  padding: 20px;
  border-radius: 10px;
  border: 2px solid var(--border-color);
  z-index: 1000;
  min-width: 300px;
  max-width: 90vw;
  max-height: 90vh;
  overflow-y: auto;
  font-size: calc(14px * var(--text-scale));
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.modal-header {
  font-weight: bold;
  margin-bottom: 15px;
  font-size: calc(18px * var(--text-scale));
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-color);
}

.modal-body {
  margin-bottom: 20px;
}

.modal-footer {
  text-align: center;
  display: flex;
  gap: 10px;
  justify-content: center;
}

.modal-btn {
  background: var(--accent-color);
  color: var(--text-color);
  border: none;
  padding: 10px 20px;
  border-radius: 5px;
  cursor: pointer;
  font-size: calc(14px * var(--text-scale));
  transition: all var(--transition-duration) ease;
}

.modal-btn:hover {
  background: #45a049;
  transform: scale(1.02);
}

.modal-btn-secondary {
  background: #666;
}

.modal-btn-secondary:hover {
  background: #777;
}

/* Season / battle pass stub UI */
.season-panel-overlay {
  position: fixed;
  inset: 0;
  z-index: 2500;
  background: rgba(0, 0, 0, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  box-sizing: border-box;
}

/* Author `display:flex` beats UA default for `[hidden]` unless forced (same idea as `.inventory-detail-overlay[hidden]`). */
.season-panel-overlay[hidden] {
  display: none !important;
  pointer-events: none;
}

.season-panel-dialog {
  max-width: 420px;
  width: 100%;
}

.season-panel-stub {
  margin-top: 0;
}

.season-panel-tracks {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 16px 0;
}

.season-panel-track {
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.25);
}

.season-panel-track-label {
  display: block;
  font-weight: 700;
  font-size: calc(13px * var(--text-scale));
  margin-bottom: 4px;
}

.season-panel-track-hint {
  font-size: calc(11px * var(--text-scale));
  color: #aaa;
}

.season-panel-progress-block {
  margin-bottom: 14px;
}

.season-panel-tier-line {
  font-size: 0.9rem;
  margin: 0.15rem 0 0.35rem;
  color: rgba(255, 255, 255, 0.85);
}

.season-panel-progress-label {
  font-size: calc(12px * var(--text-scale));
  margin-bottom: 6px;
  color: var(--text-color);
}

.season-panel-progress-bar .resource-bar-fill {
  background: #9c27b0;
}

.season-panel-progress-meta {
  margin-top: 6px;
  font-size: calc(11px * var(--text-scale));
  color: #aaa;
}

/* Cosmetic shop stub UI */
.cosmetic-shop-list-root {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 12px 0 16px;
}

.cosmetic-shop-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 12px;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.25);
}

.cosmetic-shop-row__meta {
  flex: 1 1 140px;
  min-width: 0;
}

.cosmetic-shop-row__name {
  font-weight: 700;
  font-size: calc(14px * var(--text-scale));
  color: var(--text-color);
}

.cosmetic-shop-row__price {
  margin-top: 4px;
  font-size: calc(12px * var(--text-scale));
  color: #aaa;
}

.cosmetic-shop-row__buy {
  flex-shrink: 0;
}

/* Dev-facing dungeon palette preview (Menu → Dungeon colours) */
.dungeon-palette-hint {
  margin-top: 0;
  margin-bottom: 14px;
  line-height: 1.45;
}

.dungeon-palette-table {
  width: 100%;
  border-collapse: collapse;
  font-size: calc(13px * var(--text-scale));
}

.dungeon-palette-table th,
.dungeon-palette-table td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
}

.dungeon-palette-table th {
  font-weight: 600;
  color: var(--text-color);
}

.dungeon-palette-cell {
  white-space: nowrap;
}

.dungeon-palette-swatch {
  display: inline-block;
  width: 36px;
  height: 36px;
  border-radius: 4px;
  border: 1px solid var(--border-color);
  vertical-align: middle;
  margin-right: 10px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.25);
}

.dungeon-palette-hex {
  font-size: calc(12px * var(--text-scale));
  vertical-align: middle;
}

/* Notification Styles */
.notification {
  position: fixed;
  top: 20px;
  right: 20px;
  background: var(--panel-bg);
  color: var(--text-color);
  padding: 12px 18px;
  border-radius: 5px;
  border: 1px solid var(--border-color);
  z-index: 1000;
  font-size: calc(14px * var(--text-scale));
  transition: opacity var(--transition-duration) ease, transform var(--transition-duration) ease;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
  max-width: 300px;
  opacity: 0;
  transform: translateY(-10px);
}

.notification.success {
  border-color: var(--accent-color);
}

.notification.error {
  border-color: #f44336;
}

.notification.info {
  border-color: #2196f3;
}

/* Upgrade Cost */
.upgrade-cost {
  font-size: calc(11px * var(--text-scale));
  color: #ffd700;
  margin: 5px 0;
}

/* Auth overlay + multiplayer HUD */
.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 5000;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.auth-card {
  background: var(--panel-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 24px;
  max-width: 360px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.auth-title {
  margin: 0 0 4px 0;
  font-size: 1.35rem;
}

.auth-hint {
  margin: 0 0 12px 0;
  font-size: calc(12px * var(--text-scale));
  opacity: 0.85;
  line-height: 1.4;
}

.auth-stale-lobby-hint {
  padding: 10px 12px;
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.4;
  color: #ffd4a8;
  background: rgba(180, 60, 40, 0.35);
  border: 1px solid #c86a4a;
  border-radius: 6px;
}

.auth-label {
  font-size: calc(12px * var(--text-scale));
  margin-top: 4px;
}

.auth-input {
  padding: 8px 10px;
  border-radius: 4px;
  border: 1px solid var(--border-color);
  background: #111;
  color: var(--text-color);
  font-size: calc(14px * var(--text-scale));
}

.auth-input-code {
  width: 4.5rem;
  text-transform: uppercase;
  text-align: center;
}

.auth-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.auth-btn {
  padding: 8px 14px;
  border-radius: 4px;
  border: 1px solid var(--border-color);
  background: #2a2a2a;
  color: var(--text-color);
  cursor: pointer;
  font-size: calc(13px * var(--text-scale));
}

.auth-btn-primary {
  background: #2e6b32;
  border-color: var(--accent-color);
}

.auth-btn-small {
  padding: 4px 8px;
  font-size: calc(11px * var(--text-scale));
}

.auth-error {
  color: #f88;
  font-size: calc(12px * var(--text-scale));
  margin: 4px 0 0 0;
}

.hub-bottom-left-actions {
  position: fixed;
  bottom: calc(var(--bottom-tab-bar-height) + 12px + env(safe-area-inset-bottom, 0px));
  left: 12px;
  z-index: 210;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  pointer-events: none;
}

.hub-bottom-left-actions > * {
  pointer-events: auto;
}

.multiplayer-hud {
  position: relative;
  pointer-events: none;
  font-size: calc(14px * var(--text-scale));
}

.multiplayer-hud .mp-party-fab,
.multiplayer-hud .multiplayer-hud-panel,
.multiplayer-hud .mp-connection-status {
  pointer-events: auto;
}

.mp-connection-status[hidden] {
  display: none !important;
}

.mp-connection-status {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  max-width: min(280px, calc(100vw - 24px));
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: rgba(24, 24, 28, 0.96);
  color: var(--text-color);
  font-size: calc(12px * var(--text-scale));
  line-height: 1.35;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
}

.mp-connection-status--reconnecting {
  border-color: rgba(230, 180, 60, 0.75);
  color: #f5e6a8;
}

.mp-connection-status--offline {
  border-color: rgba(220, 90, 90, 0.75);
  color: #ffc8c8;
}

.mp-offline-play-backdrop {
  position: fixed;
  inset: 0;
  z-index: 220;
  background: rgba(8, 8, 12, 0.72);
  pointer-events: auto;
}

.mp-offline-play-backdrop[hidden] {
  display: none !important;
}

.mp-connection-status--blocking {
  position: fixed;
  top: 50%;
  left: 50%;
  bottom: auto;
  transform: translate(-50%, -50%);
  z-index: 221;
  max-width: min(320px, calc(100vw - 32px));
  padding: 14px 16px;
  flex-direction: column;
  align-items: stretch;
  text-align: center;
  font-size: calc(14px * var(--text-scale));
}

.mp-connection-status--blocking .mp-connection-retry {
  width: 100%;
}

.mp-connection-retry {
  flex-shrink: 0;
  margin: 0;
}

.mp-party-fab {
  position: relative;
  z-index: 1;
  width: 48px;
  height: 48px;
  min-width: 48px;
  padding: 0;
  border-radius: 50%;
  border: 2px solid var(--border-color);
  background: var(--panel-bg);
  color: var(--text-color);
  font-size: calc(22px * var(--text-scale));
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
  transition: background var(--transition-duration) ease, transform var(--transition-duration) ease;
}

.mp-party-fab:hover {
  background: rgba(40, 40, 40, 0.95);
}

.hub-top-right-actions {
  position: fixed;
  top: calc(var(--header-bar-height) + 10px);
  right: 12px;
  z-index: 210;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  pointer-events: none;
}

.hub-top-right-actions > * {
  pointer-events: auto;
}

/* When any bottom tab panel (bag / gear / skills / menu) is open, hide fixed top-right hub actions. */
body.main-panel-open .hub-top-right-actions {
  display: none !important;
}

/* Same behavior for bottom-left dev/party action cluster. */
body.main-panel-open .hub-bottom-left-actions {
  display: none !important;
}

.auto-attack-fab {
  min-width: 88px;
  font-weight: 700;
}

.auto-attack-fab.is-off {
  background: rgba(65, 20, 20, 0.95);
  border-color: rgba(235, 95, 95, 0.92);
}

.auto-attack-fab.is-off:hover {
  background: rgba(85, 25, 25, 0.98);
}

.multiplayer-hud--open .mp-party-fab {
  background: var(--accent-color);
  color: #1a1a1a;
  border-color: var(--accent-color);
}

.multiplayer-hud-panel {
  position: fixed;
  top: var(--header-bar-height);
  left: 0;
  right: 0;
  bottom: var(--bottom-tab-bar-height);
  z-index: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-sizing: border-box;
  padding: 16px 18px 20px;
  background: var(--panel-bg);
  border-top: 1px solid var(--border-color);
  box-shadow: inset 0 0 80px rgba(0, 0, 0, 0.35);
}

.multiplayer-hud-panel[hidden] {
  display: none !important;
}

.mp-party-intro-hint {
  color: var(--text-muted, #a8a8b0);
  font-size: 0.85rem;
}

.multiplayer-hud-line {
  margin: 0 0 8px 0;
  line-height: 1.4;
  flex-shrink: 0;
}

.mp-stale-lobby-misconfig-banner {
  padding: 10px 12px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #ffd4a8;
  background: rgba(180, 60, 40, 0.35);
  border: 1px solid #c86a4a;
  border-radius: 6px;
}

.mp-open-parties-wrap.mp-stale-lobby-blocked .multiplayer-party-join-btn {
  pointer-events: none;
  opacity: 0.55;
}

.multiplayer-hud-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.multiplayer-hud-row-dungeon {
  margin-bottom: 8px;
}

.multiplayer-roster {
  margin: 0 0 10px 0;
  max-height: min(38vh, 320px);
  overflow-y: auto;
  font-size: calc(13px * var(--text-scale));
  line-height: 1.4;
  opacity: 0.95;
}

.multiplayer-roster-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 0;
}

.multiplayer-roster-name {
  min-width: 0;
  flex: 1 1 auto;
  word-break: break-word;
}

.multiplayer-roster-activity {
  flex: 0 0 auto;
  max-width: 42%;
  text-align: right;
  opacity: 0.82;
  font-size: calc(12px * var(--text-scale));
}

.multiplayer-roster-row[data-account-id] {
  cursor: context-menu;
}

.mp-open-parties-wrap {
  margin-bottom: 10px;
}

.mp-open-parties-title {
  margin-bottom: 6px;
  opacity: 0.9;
}

.mp-join-by-code-wrap {
  margin-bottom: 10px;
}

.mp-join-by-code-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.mp-join-input {
  flex: 1 1 120px;
  min-width: 0;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background: #1a1a1a;
  color: var(--text-color);
  font-size: calc(13px * var(--text-scale));
}

.multiplayer-party-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 8px;
  max-height: min(42vh, 360px);
  overflow-y: auto;
}

.multiplayer-party-list-empty {
  font-size: calc(13px * var(--text-scale));
  opacity: 0.8;
  padding: 8px 0;
}

.multiplayer-party-join-btn {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background: #252525;
  color: var(--text-color);
  cursor: pointer;
  font-size: calc(14px * var(--text-scale));
}

.multiplayer-party-list--blocked {
  opacity: 0.45;
  pointer-events: none;
}

.multiplayer-party-join-btn:hover {
  background: #333;
}

.multiplayer-party-join-btn .mp-pc {
  opacity: 0.75;
  font-weight: normal;
}

.multiplayer-hud .auth-error {
  margin-top: 10px;
  margin-bottom: 0;
  flex-shrink: 0;
}

/* Open field — server-scheduled respawn (non-blocking; under header + bottom dock) */
.respawn-soon-overlay {
  position: fixed;
  inset: 0;
  z-index: 195;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  /* Below header + typical battle-progress pill */
  padding: calc(var(--header-bar-height, 60px) + 44px) 12px 0;
  background: transparent;
  pointer-events: none;
}

.respawn-soon-overlay[hidden] {
  display: none;
}

.respawn-soon-card {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  min-width: 0;
  max-width: min(96vw, 420px);
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(12, 14, 18, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.1);
  text-align: center;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(6px);
}

.respawn-soon-title {
  margin: 0;
  font-size: calc(13px * var(--text-scale));
  font-weight: 600;
  letter-spacing: 0.02em;
  color: rgba(255, 255, 255, 0.85);
}

.respawn-soon-countdown {
  margin: 0;
  font-size: calc(18px * var(--text-scale));
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--accent-color);
}

/* Dev: quick low-stat weapon picker for iterating weapon behaviour */
.dev-weapon-menu {
  display: flex;
  flex-direction: column-reverse;
  align-items: flex-start;
  gap: 6px;
  font-size: calc(12px * var(--text-scale));
}

.dev-weapon-menu__toggle {
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid rgba(255, 200, 120, 0.45);
  background: rgba(40, 32, 20, 0.92);
  color: #f0e6d8;
  cursor: pointer;
}

.dev-weapon-menu__panel {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(22, 22, 26, 0.96);
  min-width: 132px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
}

.dev-weapon-menu__panel[hidden] {
  display: none;
}

.dev-weapon-menu__btn {
  padding: 5px 8px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(50, 50, 56, 0.95);
  color: var(--text-color);
  cursor: pointer;
  text-align: left;
}

.dev-weapon-menu__btn:hover {
  border-color: rgba(106, 191, 75, 0.55);
  background: rgba(60, 70, 58, 0.95);
}

/* Idle mode: body.idle-mode from UI.js (localStorage). Gameplay unchanged. */
body.idle-mode #performanceDisplay {
  opacity: 0.35;
}

body.idle-mode .battle-progress-hud {
  opacity: 0.72;
}

/* Idle: soften shop / build chrome — combat bars stay readable */
body.idle-mode #headerBar .header-section--meta {
  opacity: 0.48;
}

/* Meetup fresh lobby: hide premium / build meta in header + live-ops Camp lines (display only) */
body.event-mode #headerBar .header-section--meta {
  display: none !important;
}

body.event-mode #seasonPanelOpenBtn,
body.event-mode #cosmeticShopOpenBtn {
  display: none !important;
}

body.event-mode #campWeeklyResetCountdown,
body.event-mode #campLoginStreakLine,
body.event-mode #campWeeklyCadenceRewardRow {
  display: none !important;
}

body.event-mode #tabBtn-equipment,
body.event-mode #tabBtn-inventory,
body.event-mode #tabBtn-upgrades {
  display: none !important;
}
