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

body {
  background: #0f0f1a;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  font-family: 'Segoe UI', system-ui, sans-serif;
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

#canvas {
  display: block;
  border-radius: 8px;
  background: #12122a;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  touch-action: none;
}

#ui {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 2rem;
}

#top-bar {
  align-self: flex-start;
  margin-left: 1rem;
  display: none;
  align-items: center;
  gap: 5px;
  pointer-events: auto;
}

#pos, .top-bar-info, #debug-sprite-select {
  padding: 0.25rem 0.5rem;
  background: #0a0a12;
  border: 1px solid #2a2a4a;
  border-radius: 4px;
  color: #4ade80;
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  cursor: pointer;
  min-width: 60px;
  text-align: center;
}

#server-url {
  color: #94a3b8;
}

.toggle-btn {
  padding: 0.2rem 0.5rem;
  background: #0a0a12;
  border: 1px solid #2a2a4a;
  border-radius: 4px;
  color: #64748b;
  font-size: 0.55rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  white-space: nowrap;
}

.toggle-btn:hover {
  border-color: #4a4a7a;
  color: #94a3b8;
}

.toggle-btn.active {
  color: #4ade80;
  border-color: #22c55e55;
  background: #0a1a12;
}

#label-you {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -80px);
  /* left/top/transform updated by app.js from cube top-center */
  color: #4ade80;
  font-size: 0.9rem;
  font-weight: 600;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

#label-you .arrow {
  font-size: 0.6rem;
  opacity: 0.9;
}

#pvp-indicator {
  display: none;
  position: fixed;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(220, 38, 38, 0.85);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  padding: 3px 14px;
  border-radius: 3px;
  z-index: 200;
  pointer-events: none;
  text-shadow: 0 1px 2px rgba(0,0,0,0.4);
}

#boss-health-bar {
  position: fixed;
  top: 32px;
  left: 50%;
  transform: translateX(-50%);
  width: 320px;
  background: rgba(20, 10, 30, 0.9);
  border: 1px solid #7c3aed;
  border-radius: 4px;
  padding: 6px 10px;
  z-index: 250;
  pointer-events: none;
}
#boss-health-bar.hidden {
  display: none;
}
#boss-health-name {
  color: #c084fc;
  font-size: 0.7rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 3px;
  letter-spacing: 0.05em;
  text-shadow: 0 1px 3px rgba(0,0,0,0.6);
}
#boss-health-track {
  position: relative;
  width: 100%;
  height: 10px;
  background: #1e1b2e;
  border-radius: 2px;
  overflow: hidden;
}
#boss-health-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #7c3aed, #a855f7);
  transition: width 0.15s ease;
  border-radius: 2px;
}
.boss-phase-marker {
  position: absolute;
  top: 0;
  width: 2px;
  height: 100%;
  background: rgba(255,255,255,0.35);
  pointer-events: none;
}
#boss-health-text {
  color: #d4d4d8;
  font-size: 0.6rem;
  text-align: center;
  margin-top: 2px;
}

.pow-effect {
  position: absolute;
  color: #facc15;
  font-size: 0.55rem;
  font-weight: 900;
  font-family: 'Impact', 'Arial Black', sans-serif;
  letter-spacing: 0.08em;
  text-shadow:
    -2px -2px 0 #000,
     2px -2px 0 #000,
    -2px  2px 0 #000,
     2px  2px 0 #000,
     0    0   6px rgba(250, 204, 21, 0.5);
  pointer-events: none;
  white-space: nowrap;
  will-change: transform, opacity;
  z-index: 10;
}
.pow-effect-miss {
  color: #ef4444;
  font-size: 0.45rem;
  text-shadow:
    -2px -2px 0 #000,
     2px -2px 0 #000,
    -2px  2px 0 #000,
     2px  2px 0 #000,
     0    0   4px rgba(239, 68, 68, 0.4);
}
.pow-effect-crit {
  color: #ff6600;
  font-size: 0.8rem;
  text-shadow:
    -2px -2px 0 #000,
     2px -2px 0 #000,
    -2px  2px 0 #000,
     2px  2px 0 #000,
     0    0   8px rgba(255, 102, 0, 0.6);
}
.telegraph-indicator {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  z-index: 1;
}
.telegraph-red {
  border: 3px solid rgba(239, 68, 68, 0.95);
  background: radial-gradient(ellipse, rgba(239, 68, 68, 0.45), rgba(239, 68, 68, 0.15));
}
.telegraph-orange {
  border: 3px solid rgba(249, 115, 22, 0.95);
  background: radial-gradient(ellipse, rgba(249, 115, 22, 0.45), rgba(249, 115, 22, 0.15));
}
.tile-telegraph {
  position: absolute;
  pointer-events: none;
  z-index: 1;
  clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
}
.tile-telegraph.telegraph-red {
  background: rgba(239, 68, 68, 0.75);
  border: 2px solid rgba(255, 80, 80, 0.9);
}
.tile-telegraph.telegraph-orange {
  background: rgba(249, 115, 22, 0.5);
}
.tile-telegraph.telegraph-green {
  background: rgba(30, 220, 30, 0.85);
  border: 2px solid rgba(50, 255, 50, 0.9);
}
.tile-telegraph.telegraph-purple {
  background: rgba(147, 51, 234, 0.6);
}
.telegraph-explosion {
  background: rgba(255, 220, 80, 0.85);
}
.pow-effect-ability {
  color: #f59e0b;
  font-size: 0.7rem;
  text-shadow:
    -1px -1px 0 #000,
     1px -1px 0 #000,
    -1px  1px 0 #000,
     1px  1px 0 #000,
     0    0   6px rgba(245, 158, 11, 0.5);
}
.entity-debuff-row {
  display: flex;
  justify-content: center;
  gap: 2px;
  margin-top: 1px;
}
.entity-debuff-icon {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  border: 1px solid rgba(0,0,0,0.5);
}
.entity-debuff-slow { background: #3b82f6; }
.entity-debuff-bleed { background: #ef4444; }
.entity-debuff-armorBreak { background: #eab308; }
.entity-debuff-stun { background: #a855f7; }
.entity-debuff-damageDown { background: #f97316; }
.heal-effect {
  position: absolute;
  color: #4ade80;
  font-size: 0.55rem;
  font-weight: 900;
  font-family: 'Impact', 'Arial Black', sans-serif;
  letter-spacing: 0.08em;
  text-shadow:
    -2px -2px 0 #000,
     2px -2px 0 #000,
    -2px  2px 0 #000,
     2px  2px 0 #000,
     0    0   6px rgba(74, 222, 128, 0.5);
  pointer-events: none;
  white-space: nowrap;
  will-change: transform, opacity;
  z-index: 10;
}

/* ── Bottom HUD ── */
#hud {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 140px;
  display: none;
  align-items: stretch;
  z-index: 20;
  pointer-events: none;
  font-family: 'Segoe UI', system-ui, sans-serif;
  padding: 0 8px 8px;
  gap: 6px;
}

#hud > div {
  pointer-events: auto;
}

.hud-panel-inner {
  background: linear-gradient(180deg, rgba(15, 15, 30, 0.92) 0%, rgba(8, 8, 20, 0.96) 100%);
  border: 1px solid #2a2a4a;
  border-radius: 6px;
  height: 100%;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* ── Left panel: Character info ── */
#hud-left {
  width: 220px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

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

.char-name {
  color: #e2e8f0;
  font-size: 0.8rem;
  font-weight: 600;
}

.char-level {
  color: #facc15;
  font-size: 0.7rem;
  font-weight: 700;
}

.bar-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 6px;
}

.bar-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.bar-label {
  color: #94a3b8;
  font-size: 0.6rem;
  font-weight: 700;
  width: 18px;
  text-align: right;
}

.bar {
  flex: 1;
  height: 12px;
  background: #1a1a2e;
  border: 1px solid #333355;
  border-radius: 3px;
  overflow: hidden;
  position: relative;
}

.bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.3s ease;
}

.hp-fill {
  background: linear-gradient(180deg, #ef4444 0%, #b91c1c 100%);
  box-shadow: 0 0 6px rgba(239, 68, 68, 0.4);
}

.shield-fill {
  position: absolute;
  top: 0;
  height: 100%;
  background: linear-gradient(180deg, #9ca3af 0%, #6b7280 100%);
  box-shadow: 0 0 4px rgba(156, 163, 175, 0.4);
  border-radius: 2px;
  transition: width 0.3s ease, left 0.3s ease;
}

.mp-fill {
  background: linear-gradient(180deg, #3b82f6 0%, #1d4ed8 100%);
  box-shadow: 0 0 6px rgba(59, 130, 246, 0.4);
}

.xp-fill {
  background: linear-gradient(180deg, #fbbf24 0%, #ca8a04 100%);
  box-shadow: 0 0 6px rgba(251, 191, 36, 0.4);
}

.job-xp-fill {
  background: linear-gradient(180deg, #a78bfa 0%, #7c3aed 100%);
  box-shadow: 0 0 6px rgba(167, 139, 250, 0.4);
}

#hud-wt.wt-warning { color: #f59e0b; }
#hud-wt.wt-over { color: #f87171; font-weight: 700; }

.bar-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 0.5rem;
  font-weight: 600;
  white-space: nowrap;
  text-shadow: 0 0 3px rgba(0,0,0,0.8), 0 1px 1px rgba(0,0,0,0.6);
  pointer-events: none;
  z-index: 1;
}

.char-stats {
  display: flex;
  gap: 10px;
  color: #64748b;
  font-size: 0.55rem;
  font-weight: 600;
  margin-top: auto;
}

.charleft-collapse-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  background: none;
  border: 1px solid #333355;
  border-radius: 3px;
  color: #64748b;
  font-size: 0.5rem;
  line-height: 1;
  padding: 2px 4px;
  cursor: pointer;
  z-index: 2;
  transition: color 0.15s, border-color 0.15s;
}

.charleft-collapse-btn:hover {
  color: #e2e8f0;
  border-color: #6366f1;
}

#hud-left .hud-panel-inner.charleft-collapsed .char-header,
#hud-left .hud-panel-inner.charleft-collapsed .bar-group,
#hud-left .hud-panel-inner.charleft-collapsed .char-stats {
  display: none;
}

#hud-left .hud-panel-inner.charleft-collapsed .char-compact {
  display: flex;
}

.char-compact {
  display: none;
  gap: 10px;
  color: #94a3b8;
  font-size: 0.55rem;
  font-weight: 600;
  white-space: nowrap;
}

.char-compact span span {
  color: #e2e8f0;
}

#hud-left .hud-panel-inner.charleft-collapsed {
  height: auto;
  padding: 4px 10px;
  flex-direction: row;
  align-items: center;
}

#hud-left .hud-panel-inner.charleft-collapsed .charleft-collapse-btn {
  position: static;
  order: 1;
  margin-left: auto;
  flex-shrink: 0;
}

/* ── Center panel: Chat / game log ── */
#hud-center {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.chat-panel {
  gap: 0;
  position: relative;
}

.chat-collapse-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  background: none;
  border: 1px solid #333355;
  border-radius: 3px;
  color: #64748b;
  font-size: 0.5rem;
  line-height: 1;
  padding: 2px 4px;
  cursor: pointer;
  z-index: 2;
  transition: color 0.15s, border-color 0.15s;
}

.chat-collapse-btn:hover {
  color: #e2e8f0;
  border-color: #6366f1;
}

.chat-panel.chat-collapsed .chat-tabs,
.chat-panel.chat-collapsed .chat-log,
.chat-panel.chat-collapsed .custom-filter-popover {
  display: none;
}

.chat-panel.chat-collapsed {
  height: auto;
  padding: 4px 10px;
  flex-direction: row;
  align-items: center;
}

.chat-panel.chat-collapsed .chat-input-row {
  flex: 1;
  margin-top: 0;
}

.chat-panel.chat-collapsed .chat-collapse-btn {
  position: static;
  order: 1;
  margin-left: 6px;
  flex-shrink: 0;
}

.chat-tabs {
  display: flex;
  gap: 2px;
  margin-bottom: 4px;
  border-bottom: 1px solid #2a2a4a;
  padding-bottom: 3px;
}

.chat-tab {
  color: #64748b;
  font-size: 0.6rem;
  font-weight: 600;
  padding: 2px 8px;
  cursor: pointer;
  border-radius: 3px 3px 0 0;
  transition: color 0.15s;
}

.chat-tab:hover {
  color: #94a3b8;
}

.chat-tab.active {
  color: #e2e8f0;
  background: rgba(255, 255, 255, 0.05);
}

.chat-log {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1px;
  font-size: 0.6rem;
  color: #94a3b8;
  line-height: 1.4;
  scrollbar-width: thin;
  scrollbar-color: #333355 transparent;
}

.chat-log::-webkit-scrollbar {
  width: 4px;
}

.chat-log::-webkit-scrollbar-thumb {
  background: #333355;
  border-radius: 2px;
}

.chat-msg {
  padding: 1px 0;
}

.chat-msg .chat-time {
  color: #475569;
  margin-right: 4px;
}

.chat-msg.combat {
  color: #f87171;
}

.chat-msg.system {
  color: #facc15;
}

.chat-msg.levelup {
  color: #fbbf24;
  font-weight: 700;
  text-shadow: 0 0 8px rgba(251, 191, 36, 0.5);
}

.chat-msg.skill {
  color: #60a5fa;
  font-style: italic;
}

.chat-msg.player-chat {
  color: #93c5fd;
}

.chat-msg.loot {
  color: #fbbf24;
  font-weight: 700;
}

.chat-msg.xp {
  color: #facc15;
}

.chat-msg.inv-full {
  color: #facc15;
}

.chat-msg.npc {
  color: #a78bfa;
  font-style: italic;
}

.chat-msg.enchant {
  color: #c084fc;
  font-weight: 700;
}

.chat-msg.tip {
  color: #34d399;
  font-style: italic;
}

.chat-msg.filtered-out {
  display: none;
}

.chat-input-row {
  display: flex;
  margin-top: 3px;
}

#chat-input {
  flex: 1;
  background: #12122a;
  border: 1px solid #333355;
  border-radius: 3px;
  color: #e2e8f0;
  font-size: 0.6rem;
  font-family: inherit;
  padding: 3px 6px;
  outline: none;
  transition: border-color 0.15s;
}

#chat-input:focus {
  border-color: #6366f1;
}

#chat-input::placeholder {
  color: #475569;
}

/* ── Speech bubble above player head ── */
.speech-bubble {
  position: absolute;
  background: rgba(15, 15, 30, 0.88);
  border: 1px solid #4a4a7a;
  border-radius: 6px;
  color: #e2e8f0;
  font-size: 0.6rem;
  font-family: 'Segoe UI', system-ui, sans-serif;
  padding: 3px 8px;
  max-width: 160px;
  word-wrap: break-word;
  pointer-events: none;
  white-space: pre-wrap;
  z-index: 15;
  will-change: transform, opacity;
  text-align: center;
  line-height: 1.3;
}

.speech-bubble::after {
  content: '';
  position: absolute;
  bottom: -5px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 5px solid #4a4a7a;
}

.speech-bubble.npc-bubble {
  border-color: #7c3aed;
  color: #c4b5fd;
}

.speech-bubble.npc-bubble::after {
  border-top-color: #7c3aed;
}

.speech-bubble.companion-bubble {
  border-color: #a855f7;
  color: #e9d5ff;
  background: rgba(30, 10, 40, 0.9);
}

.speech-bubble.companion-bubble::after {
  border-top-color: #a855f7;
}

/* ── Floating entity HP bar ── */
.entity-hp-bar {
  position: absolute;
  width: 48px;
  transform: translate(-50%, -100%);
  pointer-events: none;
  z-index: 8;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
}

.entity-hp-name {
  color: #e2e8f0;
  font-size: 0.6rem;
  font-weight: 600;
  text-shadow: 0 0 3px #000, 0 0 3px #000;
  white-space: nowrap;
  text-align: center;
}

.entity-hp-track {
  position: relative;
  width: 100%;
  height: 4px;
  background: #1a1a2e;
  border: 1px solid #333355;
  border-radius: 2px;
  overflow: hidden;
}

.entity-hp-fill {
  height: 100%;
  background: linear-gradient(180deg, #ef4444 0%, #b91c1c 100%);
  transition: width 0.25s ease;
  border-radius: 1px;
}

.entity-shield-fill {
  position: absolute;
  top: 0;
  height: 100%;
  background: linear-gradient(180deg, #9ca3af 0%, #6b7280 100%);
  transition: width 0.25s ease, left 0.25s ease;
  border-radius: 1px;
}

.entity-mp-fill {
  height: 100%;
  background: linear-gradient(180deg, #3b82f6 0%, #1d4ed8 100%);
  transition: width 0.25s ease;
  border-radius: 1px;
}


/* ── Death chat message ── */
.chat-msg.death {
  color: #ef4444;
  font-weight: 600;
}

/* ── Custom filter popover ── */
.custom-filter-popover {
  position: absolute;
  bottom: 100%;
  left: 0;
  background: #1a1a2e;
  border: 1px solid #333355;
  border-radius: 4px;
  padding: 6px 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 2px 10px;
  z-index: 100;
  font-size: 0.6rem;
  color: #c8d0dc;
  max-width: 260px;
}

.custom-filter-popover.hidden {
  display: none;
}

.custom-filter-popover label {
  display: flex;
  align-items: center;
  gap: 3px;
  cursor: pointer;
  white-space: nowrap;
}

.custom-filter-popover input[type="checkbox"] {
  accent-color: #6366f1;
  width: 12px;
  height: 12px;
}

/* ── Right panel: Action bar ── */
#hud-right {
  width: 400px;
  flex-shrink: 0;
}

/* Menu row (above hotkey bar) */
.menu-row {
  display: flex;
  gap: 2px;
  justify-content: center;
  margin-bottom: 3px;
}
.menu-btn {
  width: 32px;
  height: 24px;
  background: #1a1a2e;
  border: 1px solid #333355;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.menu-btn:hover { border-color: #4a4a7a; background: #222244; }
.menu-btn.slot-active { border-color: #facc15; background: #2a2a40; }
.menu-btn.weight-warn-border { border-color: #facc15; }
.menu-btn.weight-over-border { border-color: #f87171; }
.menu-icon { font-size: 0.75rem; color: #94a3b8; opacity: 0.7; }

/* Hotkey bar */
.hotkey-bar {
  display: flex;
  gap: 3px;
  justify-content: center;
}
.hotkey-slot {
  width: 44px;
  height: 44px;
  background: #1a1a2e;
  border: 1px solid #333355;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.hotkey-slot:hover { border-color: #4a4a7a; background: #222244; }
.hotkey-slot.drag-over { border-color: #facc15; background: #2a2a40; }

.slot-key {
  position: absolute;
  top: 2px;
  left: 3px;
  font-size: 0.45rem;
  color: #475569;
  font-weight: 700;
}

.slot-icon {
  font-size: 1.1rem;
  color: #94a3b8;
  opacity: 0.7;
}

.cd-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.6);
  pointer-events: none;
  display: none;
}

/* Hotkey bar item quantity badge */
.hotkey-qty {
  position: absolute;
  bottom: 1px;
  right: 2px;
  color: #facc15;
  font-size: 0.45rem;
  font-weight: 700;
  text-shadow: 0 0 2px #000;
  pointer-events: none;
  z-index: 1;
}

/* Dimmed state when consumable has 0 quantity */
.hotkey-slot.hotkey-empty-item { opacity: 0.4; }
.hotkey-slot.hotkey-empty-item .slot-icon-img { filter: grayscale(1); }
.hotkey-slot.hotkey-locked { opacity: 0.35; }
.hotkey-slot.hotkey-locked .slot-icon-img { filter: grayscale(1); }
.hotkey-slot.hotkey-toggle-active { border-color: #f97316; box-shadow: 0 0 8px 2px rgba(249,115,22,0.6); background: #2a1a0e; }
.hotkey-slot.hotkey-targeting { border-color: #38bdf8; box-shadow: 0 0 8px 2px rgba(56,189,248,0.6); background: #0c1a2e; animation: targeting-pulse 1s ease-in-out infinite; }
@keyframes targeting-pulse { 0%, 100% { box-shadow: 0 0 8px 2px rgba(56,189,248,0.6); } 50% { box-shadow: 0 0 14px 4px rgba(56,189,248,0.9); } }
.hotkey-slot.hotkey-buffered { border-color: #facc15; box-shadow: 0 0 6px 1px rgba(250,204,21,0.5); animation: buffered-pulse 0.4s ease-in-out infinite; }
@keyframes buffered-pulse { 0%, 100% { box-shadow: 0 0 6px 1px rgba(250,204,21,0.5); } 50% { box-shadow: 0 0 10px 3px rgba(250,204,21,0.8); } }

.skill-tooltip {
  display: none;
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(10, 10, 20, 0.95);
  border: 1px solid #4a4a7a;
  border-radius: 4px;
  padding: 5px 8px;
  white-space: nowrap;
  z-index: 100;
  pointer-events: none;
  margin-bottom: 4px;
}

.hotkey-slot:hover .skill-tooltip {
  display: block;
}

.skill-tooltip-name {
  color: #facc15;
  font-size: 0.65rem;
  font-weight: 600;
}

.skill-tooltip-desc {
  color: #c4b5fd;
  font-size: 0.55rem;
}

.skill-tooltip-cost {
  color: #60a5fa;
  font-size: 0.5rem;
}

/* ── Inventory Window ── */
#inventory-window {
  position: fixed;
  bottom: 160px;
  right: 16px;
  width: 260px;
  z-index: 30;
  pointer-events: auto;
  animation: inv-slide-in 0.15s ease-out;
}

#inventory-window.hidden {
  display: none;
}

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

.inv-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(180deg, rgba(30, 30, 55, 0.96) 0%, rgba(15, 15, 30, 0.98) 100%);
  border: 1px solid #3a3a5a;
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  padding: 6px 10px;
}

.inv-title {
  color: #e2e8f0;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.inv-close {
  background: none;
  border: none;
  color: #64748b;
  font-size: 1rem;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
  transition: color 0.15s;
}

.inv-close:hover {
  color: #f87171;
}

#inv-weight {
  font-size: 0.65rem;
  letter-spacing: 0.03em;
  margin-left: auto;
  margin-right: 8px;
}

#inv-weight.weight-normal {
  color: #94a3b8;
}

#inv-weight.weight-warning {
  color: #fbbf24;
}

#inv-weight.weight-over {
  color: #f87171;
  font-weight: 700;
}

.inv-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 3px;
  padding: 8px;
  background: linear-gradient(180deg, rgba(15, 15, 30, 0.94) 0%, rgba(8, 8, 20, 0.97) 100%);
  border: 1px solid #2a2a4a;
  border-top: none;
}

.inv-trade-row {
  display: flex;
  padding: 5px 8px;
  background: linear-gradient(180deg, rgba(8, 8, 20, 0.97) 0%, rgba(10, 10, 22, 0.98) 100%);
  border: 1px solid #2a2a4a;
  border-top: none;
  border-radius: 0 0 6px 6px;
}
.inv-trade-btn {
  flex: 1;
  background: rgba(99, 102, 241, 0.12);
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: 3px;
  color: #a5b4fc;
  font-size: 0.55rem;
  font-family: inherit;
  padding: 4px 8px;
  cursor: pointer;
  transition: background 0.15s;
}
.inv-trade-btn:hover { background: rgba(99, 102, 241, 0.25); }
.inv-trade-btn.targeting {
  background: rgba(249, 115, 22, 0.2);
  border-color: rgba(249, 115, 22, 0.5);
  color: #fb923c;
}

.inv-slot {
  position: relative;
  aspect-ratio: 1;
  background: #1a1a2e;
  border: 1px solid #333355;
  border-radius: 4px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.inv-slot:hover {
  border-color: #4a4a7a;
  background: #222244;
}

.inv-slot.inv-slot-selected {
  border-color: #facc15;
  border-width: 2px;
  background: #2a2a40;
  animation: inv-select-pulse 1.2s ease-in-out infinite;
}

@keyframes inv-select-pulse {
  0%, 100% { box-shadow: 0 0 4px rgba(250, 204, 21, 0.3); }
  50% { box-shadow: 0 0 8px rgba(250, 204, 21, 0.7), 0 0 4px rgba(250, 204, 21, 0.4); }
}

.inv-slot.inv-slot-filled {
  background: #1e1e38;
  border-color: #4a4a6a;
  cursor: grab;
}

.inv-slot.inv-slot-drag-source {
  opacity: 0.4;
  border-color: #facc15;
}

.inv-slot.inv-slot-drag-over {
  border-color: #22d3ee;
  background: #1a2a3e;
  box-shadow: inset 0 0 6px rgba(34, 211, 238, 0.4);
}

/* ── Bag Window ── */
#bag-window {
  position: fixed;
  bottom: 160px;
  right: 290px;
  width: 260px;
  z-index: 31;
  pointer-events: auto;
  animation: inv-slide-in 0.15s ease-out;
}

#bag-window.hidden {
  display: none;
}

.bag-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(180deg, rgba(40, 25, 15, 0.96) 0%, rgba(25, 15, 8, 0.98) 100%);
  border: 1px solid #6b4a2a;
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  padding: 6px 10px;
}

#bag-title {
  color: #e8d5b0;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.bag-weight {
  font-size: 0.65rem;
  color: #8b7355;
  margin-left: auto;
  margin-right: 8px;
}

.bag-close {
  background: none;
  border: none;
  color: #8b7355;
  font-size: 1rem;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
  transition: color 0.15s;
}

.bag-close:hover {
  color: #f87171;
}

.bag-rename {
  background: none;
  border: none;
  color: #8b7355;
  font-size: 0.7rem;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  transition: color 0.15s;
  margin-left: 4px;
}

.bag-rename:hover {
  color: #e8d5b0;
}

#bag-rename-input {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid #6b4a2a;
  border-radius: 3px;
  color: #e8d5b0;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 1px 4px;
  outline: none;
  width: 100px;
  letter-spacing: 0.04em;
}

#bag-rename-input:focus {
  border-color: #a8824a;
}

.bag-label-suffix {
  color: #8b7355;
  font-size: 0.65rem;
  font-weight: 400;
  margin-left: 4px;
}

#bag-grid {
  border-color: #4a3520;
}

/* ── Minimap Overlay ── */
#minimap-overlay {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 50;
  pointer-events: auto;
  animation: inv-slide-in 0.15s ease-out;
  border: 2px solid #6b4a2a;
  border-radius: 6px;
  background: rgba(15, 10, 5, 0.96);
}
#minimap-overlay.hidden { display: none; }
.minimap-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(180deg, rgba(40, 25, 15, 0.96) 0%, rgba(25, 15, 8, 0.98) 100%);
  border-bottom: 1px solid #4a3520;
  border-radius: 4px 4px 0 0;
  padding: 6px 10px;
}
.minimap-title {
  color: #e8d5b0;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}
.minimap-close {
  background: none;
  border: none;
  color: #8b7355;
  font-size: 1rem;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
  transition: color 0.15s;
}
.minimap-close:hover { color: #f87171; }
#minimap-canvas {
  display: block;
  image-rendering: pixelated;
  width: 500px;
  height: 500px;
}

/* ── Chest Window ── */
#chest-window {
  position: fixed;
  bottom: 160px;
  right: 290px;
  width: 260px;
  z-index: 31;
  pointer-events: auto;
  animation: inv-slide-in 0.15s ease-out;
}

#chest-window.hidden {
  display: none;
}

#chest-grid {
  border-color: #4a3520;
}

.inv-slot.inv-slot-bag-indicator::after {
  content: '';
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 8px;
  height: 8px;
  background: #8b6914;
  border-radius: 2px;
  border: 1px solid #c4991a;
  pointer-events: none;
}
.inv-slot.inv-slot-bag-open {
  box-shadow: 0 0 6px 2px #c4991a, inset 0 0 4px rgba(196,153,26,0.3);
  border-color: #c4991a;
}

.inv-slot-name {
  font-size: 0.4rem;
  color: #e2e8f0;
  font-weight: 600;
  text-align: center;
  line-height: 1.1;
  word-break: break-word;
  padding: 2px;
  pointer-events: none;
}

.inv-slot-tooltip {
  display: none;
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(10, 10, 20, 0.95);
  border: 1px solid #4a4a7a;
  border-radius: 4px;
  padding: 4px 6px;
  white-space: nowrap;
  z-index: 50;
  pointer-events: none;
}

.inv-slot:hover .inv-slot-tooltip {
  display: block;
}

.inv-slot-tooltip-name {
  color: #facc15;
  font-size: 0.55rem;
  font-weight: 600;
}

.inv-slot-tooltip-stats {
  color: #94a3b8;
  font-size: 0.5rem;
}

/* (slot-active is now handled by .menu-btn.slot-active above) */

/* ── Equipment Window ── */
#equip-window {
  position: fixed;
  bottom: 160px;
  right: 545px;
  width: 280px;
  z-index: 30;
  pointer-events: auto;
  animation: inv-slide-in 0.15s ease-out;
}

#equip-window.hidden {
  display: none;
}

.equip-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(180deg, rgba(30, 30, 55, 0.96) 0%, rgba(15, 15, 30, 0.98) 100%);
  border: 1px solid #3a3a5a;
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  padding: 6px 10px;
}

.equip-title {
  color: #e2e8f0;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.equip-close {
  background: none;
  border: none;
  color: #64748b;
  font-size: 1rem;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
  transition: color 0.15s;
}

.equip-close:hover {
  color: #f87171;
}

.equip-body {
  background: linear-gradient(180deg, rgba(15, 15, 30, 0.94) 0%, rgba(8, 8, 20, 0.97) 100%);
  border: 1px solid #2a2a4a;
  border-top: none;
  border-radius: 0 0 6px 6px;
  padding: 6px 8px;
}

.equip-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.equip-row {
  display: flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 3px;
  cursor: pointer;
  transition: background 0.12s;
  position: relative;
  gap: 6px;
}

.equip-row:hover {
  background: #222244;
}

.equip-row-icon {
  width: 20px;
  flex-shrink: 0;
  font-size: 0.9rem;
  color: #94a3b8;
  opacity: 0.6;
  text-align: center;
}

.equip-row.equip-row-filled .equip-row-icon {
  opacity: 1;
}

.equip-row-icon-img {
  width: 24px;
  height: 24px;
  object-fit: contain;
  image-rendering: auto;
  vertical-align: middle;
}

.equip-row-label {
  width: 48px;
  flex-shrink: 0;
  text-transform: uppercase;
  color: #64748b;
  font-size: 0.55rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.equip-row-item {
  flex: 1;
  font-size: 0.6rem;
  color: #64748b;
  font-style: italic;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.equip-row.equip-row-filled .equip-row-item {
  color: #facc15;
  font-style: normal;
  font-weight: 600;
}

.equip-row-enchant {
  color: #c084fc;
}

.equip-row-stat {
  min-width: 40px;
  flex-shrink: 0;
  text-align: right;
  font-size: 0.5rem;
  color: #94a3b8;
}

.equip-row-tooltip {
  display: none;
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(10, 10, 20, 0.95);
  border: 1px solid #4a4a7a;
  border-radius: 4px;
  padding: 4px 6px;
  white-space: nowrap;
  z-index: 50;
  pointer-events: none;
}

.equip-row:hover .equip-row-tooltip {
  display: block;
}

.equip-row-tooltip-name {
  color: #facc15;
  font-size: 0.55rem;
  font-weight: 600;
}

.equip-row-tooltip-stats {
  color: #94a3b8;
  font-size: 0.5rem;
}

.equip-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-top: 6px;
  margin-top: 4px;
  border-top: 1px solid #2a2a4a;
}

.equip-summary:empty {
  display: none;
}

.equip-summary-chip {
  font-size: 0.5rem;
  color: #94a3b8;
  background: #1a1a2e;
  padding: 2px 5px;
  border-radius: 3px;
  border: 1px solid #333355;
}

/* ── Character Status Window ── */
#status-window {
  position: fixed;
  bottom: 160px;
  right: 290px;
  width: 240px;
  z-index: 30;
  pointer-events: auto;
  animation: inv-slide-in 0.15s ease-out;
}

#status-window.hidden {
  display: none;
}

.status-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(180deg, rgba(30, 30, 55, 0.96) 0%, rgba(15, 15, 30, 0.98) 100%);
  border: 1px solid #3a3a5a;
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  padding: 6px 10px;
}

.status-title {
  color: #e2e8f0;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.status-close {
  background: none;
  border: none;
  color: #64748b;
  font-size: 1rem;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
  transition: color 0.15s;
}

.status-close:hover {
  color: #f87171;
}

.status-body {
  background: linear-gradient(180deg, rgba(15, 15, 30, 0.94) 0%, rgba(8, 8, 20, 0.97) 100%);
  border: 1px solid #2a2a4a;
  border-top: none;
  border-radius: 0 0 6px 6px;
  padding: 10px;
}

.status-portrait {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 10px;
}

.portrait-frame {
  width: 48px;
  height: 48px;
  background: #1a1a2e;
  border: 2px solid #3a3a5a;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  color: #94a3b8;
  margin-bottom: 4px;
}

.status-player-name {
  color: #e2e8f0;
  font-size: 0.75rem;
  font-weight: 600;
}

.status-player-class {
  color: #64748b;
  font-size: 0.6rem;
}

.status-stats-grid {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 2px 6px;
  border-radius: 3px;
  background: rgba(26, 26, 46, 0.5);
}

.stat-label {
  color: #94a3b8;
  font-size: 0.65rem;
  font-weight: 500;
}

.stat-value {
  color: #e2e8f0;
  font-size: 0.65rem;
  font-weight: 600;
}

.stat-divider {
  height: 1px;
  background: #2a2a4a;
  margin: 3px 0;
}

/* ── Settings Window ── */
#settings-window {
  position: fixed;
  bottom: 160px;
  right: 1040px;
  width: 210px;
  z-index: 30;
  pointer-events: auto;
  animation: inv-slide-in 0.15s ease-out;
}

#settings-window.hidden {
  display: none;
}

.settings-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(180deg, rgba(30, 30, 55, 0.96) 0%, rgba(15, 15, 30, 0.98) 100%);
  border: 1px solid #3a3a5a;
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  padding: 6px 10px;
}

.settings-title {
  color: #e2e8f0;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.settings-close {
  background: none;
  border: none;
  color: #64748b;
  font-size: 1rem;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
  transition: color 0.15s;
}

.settings-close:hover {
  color: #f87171;
}

.settings-body {
  background: linear-gradient(180deg, rgba(15, 15, 30, 0.94) 0%, rgba(8, 8, 20, 0.97) 100%);
  border: 1px solid #2a2a4a;
  border-top: none;
  border-radius: 0 0 6px 6px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.settings-section-label {
  color: #64748b;
  font-size: 0.55rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 2px;
}

.settings-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 3px 4px;
  border-radius: 3px;
  cursor: pointer;
  transition: background 0.12s;
}

.settings-row:hover {
  background: rgba(34, 34, 68, 0.4);
}

.settings-label {
  color: #cbd5e1;
  font-size: 0.65rem;
  font-weight: 500;
}

.settings-value {
  color: #94a3b8;
  font-size: 0.6rem;
  font-family: 'Consolas', 'Monaco', monospace;
  word-break: break-all;
  text-align: right;
}

.settings-toggle {
  appearance: none;
  width: 28px;
  height: 14px;
  background: #1a1a2e;
  border: 1px solid #333355;
  border-radius: 7px;
  position: relative;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
  flex-shrink: 0;
}

.settings-toggle::after {
  content: '';
  position: absolute;
  top: 1px;
  left: 1px;
  width: 10px;
  height: 10px;
  background: #64748b;
  border-radius: 50%;
  transition: transform 0.2s, background 0.2s;
}

.settings-toggle:checked {
  background: #1e3a2e;
  border-color: #22c55e55;
}

.settings-toggle:checked::after {
  transform: translateX(14px);
  background: #4ade80;
}

.settings-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 90px;
  height: 6px;
  background: #1a1a2e;
  border: 1px solid #333355;
  border-radius: 3px;
  outline: none;
  cursor: pointer;
}

.settings-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  background: #94a3b8;
  border-radius: 50%;
  border: 1px solid #4a4a7a;
  cursor: pointer;
}

.settings-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  background: #94a3b8;
  border-radius: 50%;
  border: 1px solid #4a4a7a;
  cursor: pointer;
}

.settings-select {
  background: #1a1a2e;
  color: #e2e8f0;
  border: 1px solid #333355;
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 11px;
  outline: none;
}
.settings-select:focus {
  border-color: #22c55e55;
}

.settings-divider {
  height: 1px;
  background: #2a2a4a;
  margin: 4px 0;
}

/* ── Social / Friend List Window ── */
#social-window {
  position: fixed;
  bottom: 160px;
  right: 800px;
  width: 220px;
  z-index: 30;
  pointer-events: auto;
  animation: inv-slide-in 0.15s ease-out;
}

#social-window.hidden {
  display: none;
}

.social-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(180deg, rgba(30, 30, 55, 0.96) 0%, rgba(15, 15, 30, 0.98) 100%);
  border: 1px solid #3a3a5a;
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  padding: 6px 10px;
}

.social-title {
  color: #e2e8f0;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.social-close {
  background: none;
  border: none;
  color: #64748b;
  font-size: 1rem;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
  transition: color 0.15s;
}

.social-close:hover {
  color: #f87171;
}

.social-body {
  background: linear-gradient(180deg, rgba(15, 15, 30, 0.94) 0%, rgba(8, 8, 20, 0.97) 100%);
  border: 1px solid #2a2a4a;
  border-top: none;
  border-radius: 0 0 6px 6px;
  padding: 8px;
}

.social-list {
  max-height: 180px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 8px;
  scrollbar-width: thin;
  scrollbar-color: #333355 transparent;
}

.social-list::-webkit-scrollbar {
  width: 4px;
}

.social-list::-webkit-scrollbar-thumb {
  background: #333355;
  border-radius: 2px;
}

.social-empty {
  color: #475569;
  font-size: 0.6rem;
  text-align: center;
  padding: 12px 0;
}

.social-entry {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 6px;
  border-radius: 3px;
  background: rgba(26, 26, 46, 0.5);
}

.social-entry:hover {
  background: rgba(34, 34, 68, 0.6);
}

.social-entry-name {
  color: #e2e8f0;
  font-size: 0.65rem;
  font-weight: 500;
}

.social-entry-status {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #22c55e;
  flex-shrink: 0;
}

.social-entry-status.offline {
  background: #64748b;
}

.social-actions {
  display: flex;
  gap: 4px;
}

.social-input {
  flex: 1;
  background: #12122a;
  border: 1px solid #333355;
  border-radius: 3px;
  color: #e2e8f0;
  font-size: 0.6rem;
  font-family: inherit;
  padding: 3px 6px;
  outline: none;
  transition: border-color 0.15s;
}

.social-input:focus {
  border-color: #6366f1;
}

.social-input::placeholder {
  color: #475569;
}

.social-add-btn {
  background: #1a1a2e;
  border: 1px solid #333355;
  border-radius: 3px;
  color: #94a3b8;
  font-size: 0.6rem;
  font-family: inherit;
  padding: 3px 8px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.social-add-btn:hover {
  border-color: #4a4a7a;
  color: #e2e8f0;
}

/* ── Social tabs ── */
.social-tabs {
  display: flex;
  gap: 2px;
  margin-bottom: 6px;
}

.social-tab {
  flex: 1;
  background: rgba(26, 26, 46, 0.6);
  border: 1px solid #2a2a4a;
  border-radius: 3px;
  color: #64748b;
  font-size: 0.6rem;
  font-family: inherit;
  padding: 4px 0;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.social-tab:hover {
  color: #94a3b8;
  border-color: #3a3a5a;
}

.social-tab.active {
  color: #e2e8f0;
  border-color: #6366f1;
  background: rgba(99, 102, 241, 0.1);
}

#friend-search-input {
  flex: 1;
  background: #12122a;
  border: 1px solid #333355;
  border-radius: 3px;
  color: #e2e8f0;
  font-size: 0.6rem;
  font-family: inherit;
  padding: 3px 6px;
  outline: none;
  transition: border-color 0.15s;
}

#friend-search-input:focus {
  border-color: #6366f1;
}

#friend-search-input::placeholder {
  color: #475569;
}

#friend-search-results {
  margin-bottom: 4px;
}

.friend-search-entry {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 3px 6px;
  border-radius: 3px;
  background: rgba(26, 26, 46, 0.5);
  margin-bottom: 2px;
}

.friend-search-entry:hover {
  background: rgba(34, 34, 68, 0.6);
}

.friend-add-btn {
  background: rgba(34, 197, 94, 0.12);
  border: 1px solid rgba(34, 197, 94, 0.3);
  border-radius: 2px;
  color: #4ade80;
  font-size: 0.5rem;
  font-family: inherit;
  padding: 1px 6px;
  cursor: pointer;
  transition: background 0.15s;
}

.friend-add-btn:hover {
  background: rgba(34, 197, 94, 0.25);
}

.friend-remove-btn {
  background: rgba(248, 113, 113, 0.08);
  border: 1px solid rgba(248, 113, 113, 0.25);
  border-radius: 2px;
  color: #f87171;
  font-size: 0.5rem;
  font-family: inherit;
  padding: 1px 6px;
  cursor: pointer;
  transition: background 0.15s;
}

.friend-remove-btn:hover {
  background: rgba(248, 113, 113, 0.2);
}

#social-friends-panel.hidden,
#social-guild-panel.hidden,
#social-party-panel.hidden {
  display: none;
}
#guild-create-flow.hidden,
#guild-members-flow.hidden,
#party-create-flow.hidden,
#party-members-flow.hidden {
  display: none;
}

/* ── Guild styles ── */
.guild-name {
  color: #a78bfa;
  font-size: 0.75rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.guild-member-entry {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 6px;
  border-radius: 3px;
  background: rgba(26, 26, 46, 0.5);
}

.guild-member-entry:hover {
  background: rgba(34, 34, 68, 0.6);
}

.guild-member-name {
  color: #e2e8f0;
  font-size: 0.65rem;
  font-weight: 500;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.guild-member-role {
  font-size: 0.55rem;
  font-weight: 600;
  padding: 1px 4px;
  border-radius: 2px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.guild-member-role.leader {
  color: #facc15;
  background: rgba(250, 204, 21, 0.12);
}

.guild-member-role.officer {
  color: #60a5fa;
  background: rgba(96, 165, 250, 0.12);
}

.guild-member-role.member {
  color: #94a3b8;
  background: rgba(148, 163, 184, 0.08);
}

.guild-member-status {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #22c55e;
  flex-shrink: 0;
}

.guild-member-status.offline {
  background: #64748b;
}

.guild-member-actions {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}

.guild-member-action-btn {
  background: rgba(30, 30, 55, 0.8);
  border: 1px solid #333355;
  border-radius: 2px;
  color: #94a3b8;
  font-size: 0.5rem;
  font-family: inherit;
  padding: 1px 4px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.guild-member-action-btn:hover {
  border-color: #6366f1;
  color: #e2e8f0;
}

.guild-member-action-btn.kick:hover {
  border-color: #f87171;
  color: #f87171;
}

.guild-invite-banner {
  background: rgba(99, 102, 241, 0.12);
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: 4px;
  padding: 6px 8px;
  margin-bottom: 6px;
  font-size: 0.6rem;
  color: #c7d2fe;
}

.guild-invite-banner.hidden {
  display: none;
}

.guild-invite-buttons {
  display: flex;
  gap: 4px;
  margin-top: 4px;
}

.guild-invite-accept {
  background: rgba(34, 197, 94, 0.15);
  border: 1px solid rgba(34, 197, 94, 0.4);
  border-radius: 3px;
  color: #4ade80;
  font-size: 0.55rem;
  font-family: inherit;
  padding: 2px 8px;
  cursor: pointer;
}

.guild-invite-accept:hover {
  background: rgba(34, 197, 94, 0.25);
}

.guild-invite-decline {
  background: rgba(248, 113, 113, 0.1);
  border: 1px solid rgba(248, 113, 113, 0.3);
  border-radius: 3px;
  color: #f87171;
  font-size: 0.55rem;
  font-family: inherit;
  padding: 2px 8px;
  cursor: pointer;
}

.guild-invite-decline:hover {
  background: rgba(248, 113, 113, 0.2);
}

.guild-disband-btn {
  width: 100%;
  margin-top: 6px;
  padding: 4px 8px;
  background: rgba(248, 113, 113, 0.1);
  border: 1px solid rgba(248, 113, 113, 0.3);
  border-radius: 3px;
  color: #f87171;
  font-size: 0.6rem;
  cursor: pointer;
  transition: background 0.15s;
}

.guild-disband-btn:hover {
  background: rgba(248, 113, 113, 0.2);
}

.chat-msg.guild {
  color: #a78bfa;
}
.chat-msg.party {
  color: #4ade80;
}
.chat-msg.whisper {
  color: #f472b6;
}

/* ── Party panel ── */
.party-member-entry {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 6px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  font-size: 0.6rem;
}
.party-member-name {
  flex: 1;
  color: #e2e8f0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.party-member-name .leader-tag {
  color: #fbbf24;
  font-size: 0.5rem;
  margin-left: 3px;
}
.party-hp-track {
  width: 50px;
  height: 4px;
  background: rgba(255,255,255,0.08);
  border-radius: 2px;
  overflow: hidden;
}
.party-hp-fill {
  height: 100%;
  background: #ef4444;
  transition: width 0.2s;
}
.party-mp-track {
  width: 30px;
  height: 4px;
  background: rgba(255,255,255,0.08);
  border-radius: 2px;
  overflow: hidden;
}
.party-mp-fill {
  height: 100%;
  background: #3b82f6;
  transition: width 0.2s;
}
.party-kick-btn {
  background: rgba(248, 113, 113, 0.1);
  border: 1px solid rgba(248, 113, 113, 0.3);
  color: #f87171;
  font-size: 0.45rem;
  padding: 1px 4px;
  border-radius: 3px;
  cursor: pointer;
}
.party-kick-btn:hover {
  background: rgba(248, 113, 113, 0.2);
}
.party-leave-btn {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 4px 8px;
  background: rgba(248, 113, 113, 0.1);
  border: 1px solid rgba(248, 113, 113, 0.3);
  color: #f87171;
  font-size: 0.55rem;
  border-radius: 4px;
  cursor: pointer;
}
.party-leave-btn:hover {
  background: rgba(248, 113, 113, 0.2);
}
.party-leave-btn.hidden {
  display: none;
}
.entity-hp-fill.party-member {
  background: #22c55e;
}

/* ── Social panel enhancements ── */
.social-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
  padding: 0 2px;
}
.social-panel-count {
  color: #64748b;
  font-size: 0.55rem;
  font-weight: 500;
}
.social-panel-label {
  color: #a78bfa;
  font-size: 0.65rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 130px;
}
.social-panel-footer {
  display: flex;
  gap: 4px;
  margin-top: 6px;
}
.social-footer-btn {
  flex: 1;
  padding: 4px 8px;
  border-radius: 3px;
  font-size: 0.55rem;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
}
.social-footer-leave {
  background: rgba(248, 113, 113, 0.1);
  border: 1px solid rgba(248, 113, 113, 0.3);
  color: #f87171;
}
.social-footer-leave:hover {
  background: rgba(248, 113, 113, 0.2);
}
.social-footer-disband {
  background: rgba(248, 113, 113, 0.05);
  border: 1px solid rgba(248, 113, 113, 0.2);
  color: #fb923c;
}
.social-footer-disband:hover {
  background: rgba(248, 113, 113, 0.15);
}
.social-create-btn {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 5px 8px;
  background: rgba(34, 197, 94, 0.1);
  border: 1px solid rgba(34, 197, 94, 0.3);
  border-radius: 3px;
  color: #4ade80;
  font-size: 0.6rem;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
}
.social-create-btn:hover {
  background: rgba(34, 197, 94, 0.2);
}
.friend-actions {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}
.friend-action-btn {
  background: rgba(30, 30, 55, 0.8);
  border: 1px solid #333355;
  border-radius: 2px;
  color: #94a3b8;
  font-size: 0.45rem;
  font-family: inherit;
  padding: 1px 4px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.friend-action-btn:hover {
  border-color: #6366f1;
  color: #e2e8f0;
}
.friend-action-btn.remove:hover {
  border-color: #f87171;
  color: #f87171;
}

/* ── Housing Overview Panel ── */
#housing-overview {
  position: fixed;
  bottom: 160px;
  right: 600px;
  width: 230px;
  z-index: 30;
  pointer-events: auto;
  animation: inv-slide-in 0.15s ease-out;
}
#housing-overview.hidden { display: none; }
.housing-ov-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(180deg, rgba(30, 30, 55, 0.96) 0%, rgba(15, 15, 30, 0.98) 100%);
  border: 1px solid #3a3a5a;
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  padding: 6px 10px;
}
.housing-ov-header span {
  color: #e2e8f0;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}
.housing-ov-close {
  background: none;
  border: none;
  color: #64748b;
  font-size: 1rem;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
  transition: color 0.15s;
}
.housing-ov-close:hover { color: #f87171; }
.housing-ov-body {
  background: linear-gradient(180deg, rgba(15, 15, 30, 0.97) 0%, rgba(10, 10, 22, 0.98) 100%);
  border: 1px solid #3a3a5a;
  border-top: none;
  border-radius: 0 0 6px 6px;
  padding: 8px;
  max-height: 300px;
  overflow-y: auto;
}
.housing-ov-section {
  margin-bottom: 8px;
}
.housing-ov-section-label {
  color: #64748b;
  font-size: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 3px;
}
.housing-ov-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 2px 0;
  font-size: 0.6rem;
}
.housing-ov-row-label { color: #94a3b8; }
.housing-ov-row-value { color: #e2e8f0; }
.housing-ov-color-swatch {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 1px solid #555;
  border-radius: 2px;
  vertical-align: middle;
  margin-left: 4px;
}
.housing-ov-btn {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 5px 8px;
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.4);
  border-radius: 3px;
  color: #a5b4fc;
  font-size: 0.6rem;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
}
.housing-ov-btn:hover { background: rgba(99, 102, 241, 0.3); }
.housing-ov-btn-danger {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 4px 8px;
  background: rgba(248, 113, 113, 0.08);
  border: 1px solid rgba(248, 113, 113, 0.25);
  border-radius: 3px;
  color: #f87171;
  font-size: 0.55rem;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
}
.housing-ov-btn-danger:hover { background: rgba(248, 113, 113, 0.18); }
.housing-ov-name-row {
  display: flex;
  gap: 4px;
  margin-top: 4px;
}
.housing-ov-name-row input {
  flex: 1;
  background: #12122a;
  border: 1px solid #333355;
  border-radius: 3px;
  color: #e2e8f0;
  font-size: 0.55rem;
  font-family: inherit;
  padding: 2px 5px;
  outline: none;
}
.housing-ov-name-row input:focus { border-color: #6366f1; }
.housing-ov-name-row button {
  background: rgba(99, 102, 241, 0.12);
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: 3px;
  color: #a5b4fc;
  font-size: 0.5rem;
  font-family: inherit;
  padding: 2px 6px;
  cursor: pointer;
}
.housing-ov-policy-row {
  display: flex;
  gap: 3px;
  margin-top: 4px;
}
.housing-ov-policy-btn {
  flex: 1;
  padding: 3px 0;
  background: rgba(30, 30, 55, 0.6);
  border: 1px solid #333355;
  border-radius: 3px;
  color: #94a3b8;
  font-size: 0.45rem;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.housing-ov-policy-btn:hover { border-color: #6366f1; }
.housing-ov-policy-btn.active {
  background: rgba(99, 102, 241, 0.2);
  border-color: #6366f1;
  color: #a5b4fc;
}

/* ── Player Context Menu ── */
#player-context-menu {
  position: absolute;
  z-index: 35;
  pointer-events: auto;
  background: linear-gradient(135deg, rgba(20, 15, 40, 0.96), rgba(30, 22, 55, 0.96));
  border: 1px solid #6d28d9;
  border-radius: 6px;
  padding: 6px;
  min-width: 120px;
  box-shadow: 0 4px 16px rgba(109, 40, 217, 0.25);
  animation: inv-slide-in 0.1s ease-out;
}
#player-context-menu.hidden { display: none; }
.ctx-menu-name {
  color: #e2e8f0;
  font-size: 0.65rem;
  font-weight: 600;
  text-align: center;
  padding: 2px 4px;
}
.ctx-menu-guild {
  color: #a78bfa;
  font-size: 0.5rem;
  text-align: center;
  margin-top: -1px;
}
.ctx-menu-divider {
  height: 1px;
  background: rgba(109, 40, 217, 0.3);
  margin: 4px 0;
}
.ctx-menu-btn {
  display: block;
  width: 100%;
  padding: 4px 8px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 3px;
  color: #cbd5e1;
  font-size: 0.55rem;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  transition: background 0.1s, border-color 0.1s;
}
.ctx-menu-btn:hover {
  background: rgba(139, 92, 246, 0.15);
  border-color: rgba(139, 92, 246, 0.3);
}

.entity-guild-tag {
  color: #a78bfa;
  font-size: 0.5rem;
  font-weight: 500;
  margin-top: -2px;
}

/* ── Companion Mode Menu ── */
#companion-mode-menu {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 36;
  pointer-events: auto;
  background: linear-gradient(135deg, #1a0a2e, #2d1b4e);
  border: 2px solid #8b5cf6;
  border-radius: 8px;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 140px;
  box-shadow: 0 4px 20px rgba(139, 92, 246, 0.3);
  animation: inv-slide-in 0.15s ease-out;
}
#companion-mode-menu.hidden { display: none; }
.companion-mode-title {
  color: #c4b5fd;
  font-weight: bold;
  text-align: center;
  font-size: 14px;
  margin-bottom: 4px;
  text-shadow: 0 0 6px rgba(139, 92, 246, 0.5);
}
.companion-mode-btn {
  background: rgba(139, 92, 246, 0.15);
  color: #e2e8f0;
  border: 1px solid #6d28d9;
  border-radius: 4px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 13px;
  transition: background 0.1s, border-color 0.1s;
}
.companion-mode-btn:hover {
  background: rgba(139, 92, 246, 0.35);
  border-color: #8b5cf6;
}
.companion-mode-btn.active {
  background: rgba(139, 92, 246, 0.5);
  border-color: #a78bfa;
  color: #fff;
  font-weight: bold;
}

/* ── NPC Interaction Menu ── */
#npc-interact-menu {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 36;
  pointer-events: auto;
  background: linear-gradient(135deg, #0f0f1e, #1a1a2e);
  border: 2px solid #4a4a6a;
  border-radius: 8px;
  padding: 0;
  min-width: 160px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  animation: inv-slide-in 0.15s ease-out;
}
#npc-interact-menu.hidden { display: none; }
.npc-interact-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  border-bottom: 1px solid #2a2a4a;
}
.npc-interact-title {
  color: #c4b5fd;
  font-weight: bold;
  font-size: 13px;
  text-shadow: 0 0 6px rgba(139, 92, 246, 0.5);
}
.npc-interact-close {
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 16px;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
}
.npc-interact-close:hover { color: #e2e8f0; }
.npc-interact-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px;
}
.npc-interact-btn {
  background: rgba(100, 100, 160, 0.15);
  color: #e2e8f0;
  border: 1px solid #3a3a5a;
  border-radius: 4px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
  text-align: left;
  transition: background 0.1s, border-color 0.1s;
}
.npc-interact-btn:hover {
  background: rgba(100, 100, 160, 0.35);
  border-color: #6a6a9a;
}

/* ── Pocket Housing Dialog ── */
#pocket-housing-dialog {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 320px;
  max-width: 90vw;
  z-index: 35;
  pointer-events: auto;
  animation: inv-slide-in 0.15s ease-out;
}

#pocket-housing-dialog.hidden {
  display: none;
}

.pocket-housing-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(180deg, rgba(60, 20, 100, 0.96) 0%, rgba(30, 10, 60, 0.98) 100%);
  border: 1px solid #7c3aed;
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  padding: 6px 10px;
}

.pocket-housing-title {
  color: #c4b5fd;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.pocket-housing-close {
  background: none;
  border: none;
  color: #8b5cf6;
  font-size: 1rem;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
  transition: color 0.15s;
}

.pocket-housing-close:hover {
  color: #f87171;
}

.pocket-housing-body {
  background: linear-gradient(180deg, rgba(15, 15, 30, 0.94) 0%, rgba(8, 8, 20, 0.97) 100%);
  border: 1px solid #5b21b6;
  border-top: none;
  border-radius: 0 0 6px 6px;
  padding: 12px;
}

.pocket-housing-text {
  color: #e2e8f0;
  font-size: 0.7rem;
  line-height: 1.4;
  margin: 0 0 12px 0;
}

.pocket-housing-buttons {
  display: flex;
  gap: 8px;
}

.pocket-housing-enter {
  flex: 1;
  padding: 6px 0;
  border: none;
  border-radius: 4px;
  background: linear-gradient(180deg, #7c3aed 0%, #5b21b6 100%);
  color: #e2e8f0;
  font-size: 0.7rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: opacity 0.15s;
}

.pocket-housing-enter:hover {
  opacity: 0.85;
}

.pocket-housing-cancel {
  flex: 1;
  padding: 6px 0;
  border: 1px solid #3a3a5a;
  border-radius: 4px;
  background: rgba(15, 15, 30, 0.8);
  color: #94a3b8;
  font-size: 0.7rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: opacity 0.15s;
}

.pocket-housing-cancel:hover {
  opacity: 0.85;
}

/* ── Apartment Exit Button ── */
.apartment-exit-btn {
  position: fixed;
  top: 50px;
  right: 12px;
  z-index: 30;
  padding: 8px 16px;
  border: 1px solid #7c3aed;
  border-radius: 6px;
  background: linear-gradient(180deg, rgba(124, 58, 237, 0.4) 0%, rgba(88, 28, 180, 0.6) 100%);
  color: #e2d4ff;
  font-size: 0.75rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
  box-shadow: 0 0 8px rgba(124, 58, 237, 0.3);
}
.apartment-exit-btn.hidden { display: none; }
.apartment-exit-btn:hover {
  background: linear-gradient(180deg, rgba(124, 58, 237, 0.6) 0%, rgba(88, 28, 180, 0.8) 100%);
  box-shadow: 0 0 12px rgba(124, 58, 237, 0.5);
}

/* ── Crypt Exit Button ── */
.crypt-exit-btn {
  position: fixed;
  top: 50px;
  right: 12px;
  z-index: 30;
  padding: 8px 16px;
  border: 1px solid #dc2626;
  border-radius: 6px;
  background: linear-gradient(180deg, rgba(220, 38, 38, 0.4) 0%, rgba(153, 27, 27, 0.6) 100%);
  color: #fecaca;
  font-size: 0.75rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
  box-shadow: 0 0 8px rgba(220, 38, 38, 0.3);
}
.crypt-exit-btn.hidden { display: none; }
.crypt-exit-btn:hover {
  background: linear-gradient(180deg, rgba(220, 38, 38, 0.6) 0%, rgba(153, 27, 27, 0.8) 100%);
  box-shadow: 0 0 12px rgba(220, 38, 38, 0.5);
}

/* ── Drop Confirmation Dialog ── */
#drop-confirm {
  position: fixed;
  z-index: 40;
  background: linear-gradient(180deg, rgba(15, 15, 30, 0.96) 0%, rgba(8, 8, 20, 0.98) 100%);
  border: 1px solid #3a3a5a;
  border-radius: 6px;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
}

#drop-confirm.hidden {
  display: none;
}

#drop-confirm-text {
  color: #e2e8f0;
  font-size: 0.7rem;
  font-weight: 600;
  white-space: nowrap;
}

.drop-confirm-btns {
  display: flex;
  gap: 8px;
}

.drop-confirm-btns button {
  background: #1a1a2e;
  border: 1px solid #333355;
  border-radius: 4px;
  color: #94a3b8;
  font-size: 0.6rem;
  font-family: inherit;
  font-weight: 600;
  padding: 3px 12px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.drop-confirm-btns button:hover {
  border-color: #4a4a7a;
  color: #e2e8f0;
}

#drop-confirm-yes {
  color: #f87171;
  border-color: #7f1d1d;
}

#drop-confirm-yes:hover {
  background: #2a1a1a;
  border-color: #ef4444;
  color: #ef4444;
}

/* ── Equipped badge on inventory slot ── */
.inv-slot-equipped {
  border-color: #22c55e;
  box-shadow: inset 0 0 6px rgba(34, 197, 94, 0.25);
}

.inv-slot-eq-badge {
  position: absolute;
  top: 1px;
  left: 2px;
  color: #4ade80;
  font-size: 0.4rem;
  font-weight: 800;
  line-height: 1;
  text-shadow: 0 0 2px #000, 0 0 4px #000;
  pointer-events: none;
  z-index: 1;
}

/* ── Inventory Quantity Badge ── */
.inv-slot-qty {
  position: absolute;
  bottom: 1px;
  right: 2px;
  color: #facc15;
  font-size: 0.4rem;
  font-weight: 700;
  line-height: 1;
  text-shadow: 0 0 2px #000, 0 0 4px #000;
  pointer-events: none;
}

/* ── Enchant Badge ── */
.inv-slot-enchant-badge {
  position: absolute;
  top: 1px;
  right: 2px;
  color: #c084fc;
  font-size: 0.4rem;
  font-weight: 800;
  line-height: 1;
  text-shadow: 0 0 2px #000, 0 0 4px #000;
  pointer-events: none;
  z-index: 1;
}

/* ── Enchant Targeting Mode ── */
.enchant-targeting .inv-slot {
  opacity: 0.4;
  pointer-events: none;
}

.enchant-targeting .inv-slot.enchant-valid-target {
  opacity: 1;
  pointer-events: auto;
  animation: enchant-pulse 1s ease-in-out infinite;
}

@keyframes enchant-pulse {
  0%, 100% { box-shadow: inset 0 0 4px rgba(192, 132, 252, 0.3); }
  50% { box-shadow: inset 0 0 8px rgba(192, 132, 252, 0.7), 0 0 4px rgba(192, 132, 252, 0.4); }
}

/* ── Split Stack Dialog ── */
#split-dialog {
  position: fixed;
  z-index: 40;
  background: rgba(10, 10, 20, 0.92);
  border: 1px solid #333355;
  border-radius: 6px;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

#split-dialog.hidden {
  display: none;
}

#split-dialog-text {
  color: #e2e8f0;
  font-size: 0.7rem;
  white-space: nowrap;
}

#split-amount {
  width: 50px;
  background: #1a1a2e;
  border: 1px solid #333355;
  border-radius: 4px;
  color: #e2e8f0;
  font-size: 0.65rem;
  padding: 2px 4px;
  text-align: center;
}

.split-dialog-btns {
  display: flex;
  gap: 8px;
}

.split-dialog-btns button {
  background: #1a1a2e;
  border: 1px solid #333355;
  border-radius: 4px;
  color: #94a3b8;
  font-size: 0.6rem;
  padding: 2px 10px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.split-dialog-btns button:hover {
  border-color: #4a4a7a;
  color: #e2e8f0;
}

/* ── Ground Loot Label ── */
.ground-loot-label {
  position: absolute;
  color: #facc15;
  font-size: 0.5rem;
  font-weight: 700;
  font-family: 'Segoe UI', system-ui, sans-serif;
  text-shadow:
    -1px -1px 0 #000,
     1px -1px 0 #000,
    -1px  1px 0 #000,
     1px  1px 0 #000;
  pointer-events: none;
  white-space: nowrap;
  z-index: 9;
  transform: translate(-50%, -100%);
}

/* ── House Sign Labels ── */
.house-sign {
  position: absolute;
  font-size: 0.5rem;
  font-weight: 700;
  font-family: 'Segoe UI', system-ui, sans-serif;
  text-shadow:
    -1px -1px 0 #000,
     1px -1px 0 #000,
    -1px  1px 0 #000,
     1px  1px 0 #000;
  pointer-events: none;
  white-space: nowrap;
  z-index: 9;
  transform: translate(-50%, -100%);
  color: #a78bfa;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.house-sign span { display: block; }
.house-sign.vendor-open { color: #34d399; }
.house-sign.decay-neglected { color: #fbbf24; }
.house-sign.decay-abandoned { color: #f97316; }
.house-sign.decay-condemned { color: #ef4444; font-size: 0.6rem; }

/* ── Portal Labels ── */
.portal-label {
  position: absolute;
  color: #c4b5fd;
  font-size: 0.6rem;
  font-weight: 700;
  font-family: 'Segoe UI', system-ui, sans-serif;
  text-shadow:
    -1px -1px 0 #000,
     1px -1px 0 #000,
    -1px  1px 0 #000,
     1px  1px 0 #000,
     0 0 6px rgba(124, 58, 237, 0.5);
  pointer-events: none;
  white-space: nowrap;
  z-index: 9;
  transform: translate(-50%, -100%);
}

/* ── Gather Progress Bar ── */
.gather-progress {
  position: absolute;
  width: 60px;
  pointer-events: none;
  z-index: 12;
  transform: translate(0, 0);
}
.gather-progress-label {
  color: #fde68a;
  font-size: 0.6rem;
  font-weight: 700;
  font-family: 'Segoe UI', system-ui, sans-serif;
  text-align: center;
  text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000;
  margin-bottom: 2px;
}
.gather-progress-track {
  height: 6px;
  background: rgba(30, 30, 30, 0.8);
  border: 1px solid #a78bfa;
  border-radius: 3px;
  overflow: hidden;
}
.gather-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #a78bfa, #c4b5fd);
  width: 0%;
  border-radius: 2px;
}
/* ── Cast Progress Bar ── */
.cast-progress {
  position: absolute;
  width: 60px;
  pointer-events: none;
  z-index: 12;
  transform: translate(0, 0);
}
.cast-progress-label {
  color: #93c5fd;
  font-size: 0.6rem;
  font-weight: 700;
  font-family: 'Segoe UI', system-ui, sans-serif;
  text-align: center;
  text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000;
  margin-bottom: 2px;
}
.cast-progress-track {
  height: 6px;
  background: rgba(30, 30, 30, 0.8);
  border: 1px solid #3b82f6;
  border-radius: 3px;
  overflow: hidden;
}
.cast-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #3b82f6, #60a5fa);
  width: 0%;
  border-radius: 2px;
}

/* ── Garden Growth Hover Indicator ── */
.garden-hover-progress {
  position: absolute;
  width: 80px;
  pointer-events: none;
  z-index: 12;
  transform: translate(0, 0);
}
.garden-hover-label {
  color: #86efac;
  font-size: 0.55rem;
  font-weight: 700;
  font-family: 'Segoe UI', system-ui, sans-serif;
  text-align: center;
  text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000;
  margin-bottom: 2px;
  white-space: nowrap;
}
.garden-hover-track {
  height: 5px;
  background: rgba(30, 30, 30, 0.8);
  border: 1px solid #4ade80;
  border-radius: 3px;
  overflow: hidden;
}
.garden-hover-fill {
  height: 100%;
  background: linear-gradient(90deg, #22c55e, #4ade80);
  border-radius: 2px;
  transition: width 1s linear;
}
.garden-hover-fill-ready {
  background: linear-gradient(90deg, #fbbf24, #fde68a);
}
.garden-hover-timer {
  color: #86efac;
  font-size: 0.5rem;
  font-family: 'Segoe UI', system-ui, sans-serif;
  text-align: center;
  text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000;
  margin-top: 1px;
}

/* ── Shop Window ── */
#shop-window {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 320px;
  max-width: 90vw;
  z-index: 35;
  pointer-events: auto;
  animation: inv-slide-in 0.15s ease-out;
}

#shop-window.hidden {
  display: none;
}

.shop-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(180deg, rgba(80, 60, 10, 0.96) 0%, rgba(50, 35, 5, 0.98) 100%);
  border: 1px solid #b8860b;
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  padding: 6px 10px;
}

.shop-title {
  color: #ffd700;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.shop-close {
  background: none;
  border: none;
  color: #b8860b;
  font-size: 1rem;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
  transition: color 0.15s;
}

.shop-close:hover {
  color: #f87171;
}

.shop-body {
  background: linear-gradient(180deg, rgba(15, 15, 30, 0.94) 0%, rgba(8, 8, 20, 0.97) 100%);
  border: 1px solid #8b6914;
  border-top: none;
  border-radius: 0 0 6px 6px;
  padding: 8px;
}

.shop-gold-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  background: rgba(50, 40, 10, 0.5);
  border: 1px solid #6b5000;
  border-radius: 4px;
  margin-bottom: 8px;
}

.shop-gold-icon {
  color: #ffd700;
  font-size: 0.8rem;
}

.shop-gold-amount {
  color: #ffd700;
  font-size: 0.75rem;
  font-weight: 700;
}

.shop-gold-label {
  color: #b8860b;
  font-size: 0.6rem;
  font-weight: 600;
}

.shop-tabs {
  display: flex;
  gap: 2px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.shop-tab {
  background: rgba(26, 26, 46, 0.6);
  border: 1px solid #333355;
  border-radius: 3px;
  color: #94a3b8;
  font-size: 0.55rem;
  padding: 3px 8px;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}

.shop-tab:hover {
  background: rgba(34, 34, 68, 0.7);
  color: #e2e8f0;
}

.shop-tab.active {
  background: rgba(139, 105, 20, 0.4);
  border-color: #b8860b;
  color: #ffd700;
}

.shop-items-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 240px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #6b5000 transparent;
}

.shop-item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px;
  background: rgba(26, 26, 46, 0.5);
  border: 1px solid #333355;
  border-radius: 4px;
  transition: background 0.12s;
}

.shop-item-row:hover {
  background: rgba(34, 34, 68, 0.6);
}

.shop-item-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.shop-item-name {
  color: #e2e8f0;
  font-size: 0.65rem;
  font-weight: 600;
}

.shop-item-desc {
  color: #94a3b8;
  font-size: 0.5rem;
}

.shop-item-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.shop-item-price {
  color: #ffd700;
  font-size: 0.6rem;
  font-weight: 700;
  white-space: nowrap;
}

.shop-buy-btn {
  background: linear-gradient(180deg, #22c55e 0%, #16a34a 100%);
  border: none;
  border-radius: 3px;
  color: #fff;
  font-size: 0.55rem;
  font-weight: 700;
  font-family: inherit;
  padding: 3px 10px;
  cursor: pointer;
  transition: opacity 0.15s;
}

.shop-buy-btn:hover {
  opacity: 0.85;
}

.shop-sell-divider {
  color: #b8860b;
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-align: center;
  padding: 6px 0 4px;
  border-top: 1px solid #333355;
  margin-top: 6px;
}

.shop-sell-btn {
  background: linear-gradient(180deg, #f59e0b 0%, #d97706 100%);
  border: none;
  border-radius: 3px;
  color: #fff;
  font-size: 0.55rem;
  font-weight: 700;
  font-family: inherit;
  padding: 3px 10px;
  cursor: pointer;
  transition: opacity 0.15s;
}

.shop-sell-btn:hover {
  opacity: 0.85;
}

.shop-qty-wrap {
  display: flex;
  align-items: center;
  gap: 1px;
}

.shop-qty-btn {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 2px;
  color: #fff;
  font-size: 0.5rem;
  font-weight: 700;
  font-family: inherit;
  width: 18px;
  height: 18px;
  padding: 0;
  cursor: pointer;
  line-height: 1;
}

.shop-qty-btn:hover {
  background: rgba(255, 255, 255, 0.22);
}

.shop-qty-max {
  width: auto;
  padding: 0 4px;
  font-size: 0.45rem;
}

.shop-qty-input {
  width: 28px;
  height: 18px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 2px;
  color: #fff;
  font-size: 0.5rem;
  font-weight: 700;
  font-family: inherit;
  text-align: center;
  padding: 0;
  -moz-appearance: textfield;
}

.shop-qty-input::-webkit-outer-spin-button,
.shop-qty-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* ── Respec Window ── */
#respec-window {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 320px;
  max-width: 90vw;
  z-index: 35;
  pointer-events: auto;
  animation: inv-slide-in 0.15s ease-out;
}
#respec-window.hidden { display: none; }
.respec-body {
  background: linear-gradient(180deg, rgba(25, 20, 8, 0.97) 0%, rgba(15, 12, 5, 0.98) 100%);
  border: 1px solid #b8860b;
  border-top: none;
  border-radius: 0 0 6px 6px;
  padding: 10px;
}
.respec-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  margin-bottom: 6px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(184,134,11,0.25);
  border-radius: 4px;
}
.respec-option-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.respec-option-name {
  color: #f0e6d2;
  font-size: 13px;
  font-weight: 600;
}
.respec-option-desc {
  color: #a89070;
  font-size: 11px;
}
.respec-option-cost {
  color: #ffd700;
  font-size: 12px;
  white-space: nowrap;
}
.respec-btn {
  padding: 4px 12px;
  background: linear-gradient(180deg, #b8860b, #8b6508);
  color: #fff;
  border: 1px solid #daa520;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
}
.respec-btn:disabled {
  opacity: 0.4;
  cursor: default;
}
.respec-btn:not(:disabled):hover {
  opacity: 0.85;
}
.respec-empty {
  color: #a89070;
  font-size: 12px;
  text-align: center;
  padding: 16px 0;
}

/* ── Storage Window ── */
#storage-window {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 340px;
  max-width: 90vw;
  z-index: 35;
  pointer-events: auto;
  animation: inv-slide-in 0.15s ease-out;
}

#storage-window.hidden {
  display: none;
}

.storage-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(180deg, rgba(20, 40, 70, 0.96) 0%, rgba(10, 25, 50, 0.98) 100%);
  border: 1px solid #4682b4;
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  padding: 6px 10px;
}

.storage-title {
  color: #87ceeb;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.storage-close {
  background: none;
  border: none;
  color: #4682b4;
  font-size: 1rem;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
  transition: color 0.15s;
}

.storage-close:hover {
  color: #f87171;
}

.storage-body {
  background: linear-gradient(180deg, rgba(15, 15, 30, 0.94) 0%, rgba(8, 8, 20, 0.97) 100%);
  border: 1px solid #36648b;
  border-top: none;
  border-radius: 0 0 6px 6px;
  padding: 8px;
}

.storage-section-label {
  color: #4682b4;
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-align: center;
  padding: 2px 0 4px;
}

.storage-divider {
  color: #4682b4;
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-align: center;
  padding: 6px 0 4px;
  border-top: 1px solid #333355;
  margin-top: 6px;
}

.storage-items-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 200px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #36648b transparent;
}

.storage-item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px;
  background: rgba(26, 26, 46, 0.5);
  border: 1px solid #333355;
  border-radius: 4px;
  transition: background 0.12s;
}

.storage-item-row:hover {
  background: rgba(34, 34, 68, 0.6);
}

.storage-item-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.storage-item-name {
  color: #e2e8f0;
  font-size: 0.65rem;
  font-weight: 600;
}

.storage-item-qty {
  color: #94a3b8;
  font-size: 0.5rem;
}

.storage-item-icon {
  width: 24px;
  height: 24px;
  object-fit: contain;
  flex-shrink: 0;
  margin-right: 6px;
}

.storage-deposit-btn {
  background: linear-gradient(180deg, #3b82f6 0%, #2563eb 100%);
  border: none;
  border-radius: 3px;
  color: #fff;
  font-size: 0.55rem;
  font-weight: 700;
  font-family: inherit;
  padding: 3px 10px;
  cursor: pointer;
  transition: opacity 0.15s;
}

.storage-deposit-btn:hover {
  opacity: 0.85;
}

.storage-withdraw-btn {
  background: linear-gradient(180deg, #22c55e 0%, #16a34a 100%);
  border: none;
  border-radius: 3px;
  color: #fff;
  font-size: 0.55rem;
  font-weight: 700;
  font-family: inherit;
  padding: 3px 10px;
  cursor: pointer;
  transition: opacity 0.15s;
}

.storage-withdraw-btn:hover {
  opacity: 0.85;
}

/* ── Crafting Window ── */
#craft-window {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 380px;
  max-width: 90vw;
  z-index: 35;
  pointer-events: auto;
  animation: inv-slide-in 0.15s ease-out;
}

#craft-window.hidden {
  display: none;
}

.craft-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(180deg, rgba(80, 50, 20, 0.96) 0%, rgba(50, 30, 10, 0.98) 100%);
  border: 1px solid #cd7f32;
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  padding: 6px 10px;
}

.craft-title {
  color: #cd7f32;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.craft-close {
  background: none;
  border: none;
  color: #cd7f32;
  font-size: 1rem;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
  transition: color 0.15s;
}

.craft-close:hover {
  color: #f87171;
}

.craft-body {
  background: linear-gradient(180deg, rgba(15, 15, 30, 0.94) 0%, rgba(8, 8, 20, 0.97) 100%);
  border: 1px solid #8b5e3c;
  border-top: none;
  border-radius: 0 0 6px 6px;
  padding: 8px;
  max-height: 60vh;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #8b5e3c transparent;
}

.craft-gold-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 6px;
  font-size: 0.65rem;
  color: #ffd700;
  border-bottom: 1px solid #333355;
  margin-bottom: 6px;
}

.craft-gold-icon { font-size: 0.75rem; }
.craft-gold-amount { font-weight: 600; }
.craft-gold-label { color: #998866; }

.craft-category-header {
  color: #cd7f32;
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-align: center;
  padding: 6px 0 4px;
  border-top: 1px solid #333355;
  margin-top: 4px;
}

.craft-category-header:first-child {
  border-top: none;
  margin-top: 0;
}

.craft-recipe-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 6px;
  background: rgba(26, 26, 46, 0.5);
  border: 1px solid #333355;
  border-radius: 4px;
  margin-bottom: 3px;
  transition: background 0.12s;
}

.craft-recipe-row:hover {
  background: rgba(40, 30, 20, 0.6);
}

.craft-recipe-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.craft-recipe-name {
  color: #e8d8c0;
  font-size: 0.65rem;
  font-weight: 600;
}

.craft-recipe-stats {
  color: #94a3b8;
  font-size: 0.5rem;
  margin-bottom: 2px;
}

.craft-recipe-mats {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  font-size: 0.55rem;
}

.craft-mat {
  color: #aaa;
}

.craft-mat-have {
  color: #4ade80;
}

.craft-mat-need {
  color: #f87171;
}

.craft-recipe-right {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: 8px;
  flex-shrink: 0;
}

.craft-recipe-gold {
  color: #ffd700;
  font-size: 0.6rem;
  font-weight: 600;
}

.craft-btn {
  background: linear-gradient(180deg, #cd7f32, #a0622a);
  border: 1px solid #8b5e3c;
  border-radius: 3px;
  color: #fff;
  font-size: 0.55rem;
  font-weight: 600;
  padding: 3px 8px;
  cursor: pointer;
  transition: opacity 0.15s;
}

.craft-btn:hover {
  opacity: 0.85;
}

.craft-btn:disabled {
  background: #444;
  border-color: #555;
  color: #888;
  cursor: not-allowed;
  opacity: 0.6;
}

/* ── Garden Window ── */
#garden-window {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 320px;
  max-width: 90vw;
  z-index: 35;
  pointer-events: auto;
  animation: inv-slide-in 0.15s ease-out;
}

#garden-window.hidden {
  display: none;
}

.garden-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(180deg, rgba(20, 60, 20, 0.96) 0%, rgba(10, 40, 10, 0.98) 100%);
  border: 1px solid #4ade80;
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  padding: 6px 10px;
}

#garden-title {
  color: #4ade80;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}

#garden-close {
  background: none;
  border: none;
  color: #4ade80;
  font-size: 1rem;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
  transition: color 0.15s;
}

#garden-close:hover {
  color: #f87171;
}

#garden-body {
  background: linear-gradient(180deg, rgba(10, 20, 10, 0.94) 0%, rgba(5, 15, 5, 0.97) 100%);
  border: 1px solid #2d7a3f;
  border-top: none;
  border-radius: 0 0 6px 6px;
  padding: 8px;
  min-height: 60px;
}

.garden-seed-grid {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.garden-seed-btn {
  background: rgba(30, 60, 30, 0.7);
  border: 1px solid #4ade80;
  border-radius: 4px;
  color: #a3e635;
  font-size: 0.7rem;
  padding: 6px 10px;
  cursor: pointer;
  transition: background 0.12s;
  text-align: left;
}

.garden-seed-btn:hover {
  background: rgba(50, 90, 50, 0.8);
}

.garden-progress {
  height: 10px;
  background: rgba(30, 30, 30, 0.8);
  border: 1px solid #2d7a3f;
  border-radius: 5px;
  margin: 6px 0;
  overflow: hidden;
}

.garden-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #22c55e, #4ade80);
  border-radius: 5px;
  transition: width 1s linear;
}

.garden-timer {
  color: #a3e635;
  font-size: 0.65rem;
  text-align: center;
  padding: 2px 0 4px;
}

.garden-harvest-btn {
  display: block;
  width: 100%;
  background: linear-gradient(180deg, #22c55e, #16a34a);
  border: 1px solid #4ade80;
  border-radius: 4px;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 8px;
  cursor: pointer;
  margin-top: 6px;
  transition: background 0.12s;
}

.garden-harvest-btn:hover {
  background: linear-gradient(180deg, #4ade80, #22c55e);
}

/* ── Vendor Window ── */
#vendor-window {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 340px;
  max-width: 90vw;
  z-index: 35;
  pointer-events: auto;
  animation: inv-slide-in 0.15s ease-out;
}
#vendor-window.hidden { display: none; }

.vendor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(180deg, rgba(80, 50, 20, 0.96) 0%, rgba(50, 30, 10, 0.98) 100%);
  border: 1px solid #cd7f32;
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  padding: 6px 10px;
}
.vendor-title {
  color: #cd7f32;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}
.vendor-close {
  background: none;
  border: none;
  color: #cd7f32;
  font-size: 1rem;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
  transition: color 0.15s;
}
.vendor-close:hover { color: #f87171; }

.vendor-body {
  background: linear-gradient(180deg, rgba(15, 15, 30, 0.94) 0%, rgba(8, 8, 20, 0.97) 100%);
  border: 1px solid #8b5e3c;
  border-top: none;
  border-radius: 0 0 6px 6px;
  padding: 8px;
  max-height: 65vh;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #8b5e3c transparent;
}

#vendor-owner-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 6px;
  font-size: 0.65rem;
  color: #ffd700;
  border-bottom: 1px solid #333355;
  margin-bottom: 6px;
}
#vendor-owner-bar.hidden { display: none; }
.vendor-gold-icon { font-size: 0.75rem; }
#vendor-gold-amount { font-weight: 600; }
.vendor-gold-label { color: #998866; }
#vendor-collect-btn {
  margin-left: auto;
  background: linear-gradient(180deg, #ffd700, #b8860b);
  border: 1px solid #8b6914;
  border-radius: 3px;
  color: #1a1a2e;
  font-size: 0.6rem;
  font-weight: 600;
  padding: 2px 8px;
  cursor: pointer;
}
#vendor-collect-btn:hover {
  background: linear-gradient(180deg, #ffe44d, #daa520);
}

#vendor-slots {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin-bottom: 6px;
}

.vendor-slot {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 6px;
  background: rgba(26, 26, 46, 0.5);
  border: 1px solid #333355;
  border-radius: 4px;
  min-height: 40px;
  transition: background 0.12s;
}
.vendor-slot:hover { background: rgba(40, 30, 20, 0.6); }
.vendor-slot-empty {
  border-style: dashed;
  justify-content: center;
  color: #555577;
  font-size: 0.55rem;
}
.vendor-slot-icon {
  width: 24px;
  height: 24px;
  image-rendering: pixelated;
  flex-shrink: 0;
}
.vendor-slot-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.vendor-slot-name {
  font-size: 0.6rem;
  color: #c8c8e0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.vendor-slot-price {
  font-size: 0.55rem;
  font-weight: 600;
}
.vendor-slot-qty {
  font-size: 0.5rem;
  color: #888;
}
.vendor-slot-btn {
  background: linear-gradient(180deg, #3b82f6, #2563eb);
  border: 1px solid #1d4ed8;
  border-radius: 3px;
  color: #fff;
  font-size: 0.5rem;
  font-weight: 600;
  padding: 2px 6px;
  cursor: pointer;
  flex-shrink: 0;
}
.vendor-slot-btn:hover {
  background: linear-gradient(180deg, #60a5fa, #3b82f6);
}
.vendor-slot-btn.unstock {
  background: linear-gradient(180deg, #ef4444, #dc2626);
  border-color: #b91c1c;
}
.vendor-slot-btn.unstock:hover {
  background: linear-gradient(180deg, #f87171, #ef4444);
}

.vendor-stock-divider {
  color: #cd7f32;
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-align: center;
  padding: 6px 0 4px;
  border-top: 1px solid #333355;
  margin-top: 4px;
}

#vendor-stock-area.hidden { display: none; }

#vendor-inventory-list {
  max-height: 160px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #8b5e3c transparent;
}

.vendor-inv-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 6px;
  background: rgba(26, 26, 46, 0.3);
  border: 1px solid #222244;
  border-radius: 3px;
  margin-bottom: 2px;
}
.vendor-inv-row:hover { background: rgba(40, 30, 20, 0.4); }
.vendor-inv-icon {
  width: 20px;
  height: 20px;
  image-rendering: pixelated;
  flex-shrink: 0;
}
.vendor-inv-name {
  flex: 1;
  font-size: 0.55rem;
  color: #c8c8e0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.vendor-inv-qty {
  font-size: 0.5rem;
  color: #888;
}
.vendor-stock-btn {
  background: linear-gradient(180deg, #22c55e, #16a34a);
  border: 1px solid #15803d;
  border-radius: 3px;
  color: #fff;
  font-size: 0.5rem;
  font-weight: 600;
  padding: 2px 6px;
  cursor: pointer;
}
.vendor-stock-btn:hover {
  background: linear-gradient(180deg, #4ade80, #22c55e);
}

/* Vendor price input inline */
.vendor-price-input {
  width: 50px;
  background: rgba(15, 15, 30, 0.9);
  border: 1px solid #cd7f32;
  border-radius: 3px;
  color: #ffd700;
  font-size: 0.55rem;
  padding: 2px 4px;
  text-align: right;
}
.vendor-price-input:focus {
  outline: none;
  border-color: #ffd700;
}
.vendor-price-ok {
  background: linear-gradient(180deg, #22c55e, #16a34a);
  border: 1px solid #15803d;
  border-radius: 3px;
  color: #fff;
  font-size: 0.5rem;
  font-weight: 600;
  padding: 2px 5px;
  cursor: pointer;
}

/* Buy confirm popup */
#vendor-buy-confirm {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 45;
  background: linear-gradient(180deg, rgba(30, 20, 10, 0.98) 0%, rgba(15, 10, 5, 0.99) 100%);
  border: 1px solid #cd7f32;
  border-radius: 6px;
  padding: 12px 16px;
  text-align: center;
  pointer-events: auto;
}
#vendor-buy-confirm.hidden { display: none; }
#vendor-buy-confirm-text {
  display: block;
  color: #c8c8e0;
  font-size: 0.65rem;
  margin-bottom: 8px;
}
#vendor-buy-yes {
  background: linear-gradient(180deg, #22c55e, #16a34a);
  border: 1px solid #15803d;
  border-radius: 3px;
  color: #fff;
  font-size: 0.6rem;
  font-weight: 600;
  padding: 3px 12px;
  cursor: pointer;
  margin-right: 6px;
}
#vendor-buy-yes:hover {
  background: linear-gradient(180deg, #4ade80, #22c55e);
}
#vendor-buy-no {
  background: linear-gradient(180deg, #ef4444, #dc2626);
  border: 1px solid #b91c1c;
  border-radius: 3px;
  color: #fff;
  font-size: 0.6rem;
  font-weight: 600;
  padding: 3px 12px;
  cursor: pointer;
}
#vendor-buy-no:hover {
  background: linear-gradient(180deg, #f87171, #ef4444);
}

/* ── Community Board ── */
#board-window {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 380px;
  max-width: 90vw;
  z-index: 35;
  pointer-events: auto;
  animation: inv-slide-in 0.15s ease-out;
}
#board-window.hidden { display: none; }
.board-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(180deg, rgba(20, 50, 80, 0.96) 0%, rgba(10, 30, 50, 0.98) 100%);
  border: 1px solid #3b82f6;
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  padding: 6px 10px;
}
.board-title {
  color: #60a5fa;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}
.board-close {
  background: none;
  border: none;
  color: #60a5fa;
  font-size: 1rem;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
  transition: color 0.15s;
}
.board-close:hover { color: #f87171; }
.board-body {
  background: linear-gradient(180deg, rgba(15, 15, 30, 0.94) 0%, rgba(8, 8, 20, 0.97) 100%);
  border: 1px solid #1e40af;
  border-top: none;
  border-radius: 0 0 6px 6px;
  padding: 8px;
  max-height: 65vh;
  overflow-y: auto;
  scrollbar-width: thin;
}
#board-vendor-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 6px;
  border-bottom: 1px solid rgba(96, 165, 250, 0.2);
  padding-bottom: 6px;
}
.board-vendor-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 6px;
  border-radius: 3px;
  cursor: pointer;
  transition: background 0.15s;
}
.board-vendor-row:hover { background: rgba(59, 130, 246, 0.15); }
.board-vendor-row.selected { background: rgba(59, 130, 246, 0.25); border: 1px solid rgba(96, 165, 250, 0.4); }
.board-vendor-name { color: #93c5fd; font-size: 0.6rem; font-weight: 600; }
.board-vendor-count { color: #64748b; font-size: 0.55rem; }
.board-empty { color: #475569; font-size: 0.6rem; text-align: center; padding: 12px; }
#board-vendor-detail {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.board-item-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  background: rgba(20, 15, 30, 0.5);
  border-radius: 3px;
}
.board-item-icon { width: 24px; height: 24px; image-rendering: pixelated; }
.board-item-info { flex: 1; display: flex; flex-direction: column; }
.board-item-name { color: #c8c8e0; font-size: 0.6rem; }
.board-item-price { font-size: 0.55rem; font-weight: 600; }
.board-item-qty { color: #94a3b8; font-size: 0.5rem; }
.board-buy-btn {
  padding: 2px 10px; border: 1px solid #3b82f6; border-radius: 3px;
  background: rgba(59, 130, 246, 0.2); color: #93c5fd; cursor: pointer;
  font-size: 0.55rem; font-weight: 600;
}
.board-buy-btn:hover { background: rgba(59, 130, 246, 0.4); border-color: #60a5fa; }
#board-buy-confirm {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 45;
  background: linear-gradient(180deg, rgba(10, 20, 30, 0.98) 0%, rgba(5, 10, 20, 0.99) 100%);
  border: 1px solid #3b82f6;
  border-radius: 6px;
  padding: 12px 16px;
  text-align: center;
  pointer-events: auto;
}
#board-buy-confirm.hidden { display: none; }
#board-buy-confirm-text {
  display: block;
  color: #c8c8e0;
  font-size: 0.65rem;
  margin-bottom: 8px;
}
#board-buy-yes {
  background: linear-gradient(180deg, #22c55e, #16a34a);
  border: 1px solid #15803d;
  border-radius: 3px;
  color: #fff;
  font-size: 0.6rem;
  font-weight: 600;
  padding: 3px 12px;
  cursor: pointer;
  margin-right: 6px;
}
#board-buy-yes:hover { background: linear-gradient(180deg, #4ade80, #22c55e); }
#board-buy-no {
  background: linear-gradient(180deg, #ef4444, #dc2626);
  border: 1px solid #b91c1c;
  border-radius: 3px;
  color: #fff;
  font-size: 0.6rem;
  font-weight: 600;
  padding: 3px 12px;
  cursor: pointer;
}
#board-buy-no:hover { background: linear-gradient(180deg, #f87171, #ef4444); }

/* ── Trade Request Notification ── */
#trade-request {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 40;
  background: linear-gradient(180deg, rgba(20, 40, 30, 0.96) 0%, rgba(10, 25, 15, 0.98) 100%);
  border: 1px solid #2e8b57;
  border-radius: 6px;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: auto;
  animation: inv-slide-in 0.15s ease-out;
}
#trade-request.hidden { display: none; }
#trade-request-text {
  color: #90ee90;
  font-size: 0.72rem;
  font-weight: 500;
}
.trade-request-btns {
  display: flex;
  gap: 6px;
}
.trade-request-btns button {
  padding: 3px 10px;
  font-size: 0.65rem;
  border-radius: 4px;
  cursor: pointer;
  border: 1px solid #2e8b57;
  background: rgba(46, 139, 87, 0.3);
  color: #90ee90;
  transition: background 0.15s;
}
.trade-request-btns button:hover {
  background: rgba(46, 139, 87, 0.5);
}
#trade-decline-btn {
  border-color: #555;
  background: rgba(60, 60, 60, 0.3);
  color: #aaa;
}
#trade-decline-btn:hover {
  background: rgba(80, 80, 80, 0.5);
}

/* ── Trade Window ── */
#trade-window {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 440px;
  max-width: 95vw;
  z-index: 35;
  pointer-events: auto;
  animation: inv-slide-in 0.15s ease-out;
}
#trade-window.hidden { display: none; }

.trade-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(180deg, rgba(20, 60, 40, 0.96) 0%, rgba(10, 35, 20, 0.98) 100%);
  border: 1px solid #2e8b57;
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  padding: 6px 10px;
}
.trade-title {
  color: #90ee90;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}
.trade-close {
  background: none;
  border: none;
  color: #90ee90;
  font-size: 1rem;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
  transition: color 0.15s;
}
.trade-close:hover { color: #f87171; }

.trade-body {
  background: linear-gradient(180deg, rgba(15, 15, 30, 0.94) 0%, rgba(8, 8, 20, 0.97) 100%);
  border: 1px solid #2e8b57;
  border-top: none;
  border-radius: 0 0 6px 6px;
  padding: 8px;
  max-height: 65vh;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #2e8b57 transparent;
}

.trade-columns {
  display: flex;
  gap: 0;
  margin-bottom: 8px;
}
.trade-column {
  flex: 1;
  min-width: 0;
}
.trade-divider {
  width: 1px;
  background: #2e8b57;
  margin: 0 8px;
}
.trade-column-label {
  color: #2e8b57;
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-align: center;
  padding-bottom: 4px;
  margin-bottom: 4px;
  border-bottom: 1px solid #333355;
}
.trade-inv-label {
  color: #888;
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-align: center;
  padding: 6px 0 4px;
  border-top: 1px solid #333355;
}
.trade-items-list {
  min-height: 30px;
  max-height: 140px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #2e8b57 transparent;
}
.trade-empty {
  color: #555;
  font-size: 0.62rem;
  text-align: center;
  padding: 8px 0;
  font-style: italic;
}
.trade-item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 3px 6px;
  background: rgba(26, 26, 46, 0.5);
  border: 1px solid #333355;
  border-radius: 3px;
  margin-bottom: 2px;
}
.trade-item-name {
  color: #c8c8e0;
  font-size: 0.65rem;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.trade-add-btn,
.trade-remove-btn {
  padding: 2px 8px;
  font-size: 0.58rem;
  border-radius: 3px;
  cursor: pointer;
  border: 1px solid #2e8b57;
  background: rgba(46, 139, 87, 0.25);
  color: #90ee90;
  transition: background 0.15s;
  flex-shrink: 0;
  margin-left: 4px;
}
.trade-add-btn:hover,
.trade-remove-btn:hover {
  background: rgba(46, 139, 87, 0.45);
}
.trade-remove-btn {
  border-color: #c53030;
  background: rgba(197, 48, 48, 0.2);
  color: #fca5a5;
}
.trade-remove-btn:hover {
  background: rgba(197, 48, 48, 0.4);
}
.trade-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px solid #333355;
}
.trade-confirm-btn {
  padding: 4px 16px;
  font-size: 0.65rem;
  font-weight: 600;
  border-radius: 4px;
  cursor: pointer;
  border: 1px solid #2e8b57;
  background: rgba(46, 139, 87, 0.35);
  color: #90ee90;
  transition: background 0.15s;
}
.trade-confirm-btn:hover {
  background: rgba(46, 139, 87, 0.55);
}
.trade-confirm-btn.confirmed {
  border-color: #555;
  background: rgba(60, 60, 60, 0.3);
  color: #888;
  cursor: default;
}
.trade-partner-status {
  font-size: 0.62rem;
}
.trade-status-waiting {
  color: #888;
}
.trade-status-ready {
  color: #90ee90;
  font-weight: 600;
}

/* ── Sell Confirmation Dialog ── */
#sell-confirm {
  position: fixed;
  z-index: 40;
  background: linear-gradient(180deg, rgba(15, 15, 30, 0.96) 0%, rgba(8, 8, 20, 0.98) 100%);
  border: 1px solid #3a3a5a;
  border-radius: 6px;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
}

#sell-confirm.hidden {
  display: none;
}

#sell-confirm-text {
  color: #e2e8f0;
  font-size: 0.7rem;
  font-weight: 600;
  white-space: nowrap;
}

.sell-confirm-btns {
  display: flex;
  gap: 8px;
}

.sell-confirm-btns button {
  background: #1a1a2e;
  border: 1px solid #333355;
  border-radius: 4px;
  color: #94a3b8;
  font-size: 0.6rem;
  font-weight: 600;
  font-family: inherit;
  padding: 3px 10px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.sell-confirm-btns button:hover {
  border-color: #4a4a7a;
  color: #e2e8f0;
}

#sell-confirm-yes {
  color: #f59e0b;
  border-color: #92400e;
}

#sell-confirm-yes:hover {
  background: #2a2a1a;
  border-color: #f59e0b;
  color: #f59e0b;
}

/* ── Exchange Window ── */
#exchange-window.hidden {
  display: none;
}

#exchange-window {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 120;
  min-width: 300px;
  max-width: 340px;
}

.exchange-desc {
  color: #c4b98a;
  font-size: 0.78rem;
  margin: 0 0 12px 0;
  line-height: 1.45;
  text-align: center;
  font-style: italic;
}

.exchange-cards {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.exchange-card {
  flex: 1;
  background: rgba(20, 18, 12, 0.7);
  border: 1px solid #3a3018;
  border-radius: 5px;
  padding: 10px 8px;
  text-align: center;
  transition: border-color 0.2s, box-shadow 0.2s, opacity 0.2s;
}

.exchange-card-available {
  border-color: #b8860b;
  cursor: pointer;
  box-shadow: 0 0 6px rgba(184, 134, 11, 0.2);
}

.exchange-card-available:hover {
  border-color: #ffd700;
  box-shadow: 0 0 12px rgba(255, 215, 0, 0.3);
  background: rgba(40, 32, 12, 0.8);
}

.exchange-card-available:active {
  transform: scale(0.97);
}

.exchange-card-dim {
  opacity: 0.4;
}

.exchange-card-icon {
  font-size: 1.5rem;
  margin-bottom: 4px;
  display: block;
}

.exchange-card-name {
  color: #ffd700;
  font-size: 0.78rem;
  font-weight: 600;
  margin-bottom: 6px;
}

.exchange-card-stat {
  color: #8bc34a;
  font-size: 0.72rem;
  margin-bottom: 2px;
}

.exchange-card-detail {
  color: #9a8e6e;
  font-size: 0.68rem;
  line-height: 1.35;
  margin-top: 4px;
}

.exchange-no-items {
  color: #7a6e52;
  font-size: 0.78rem;
  text-align: center;
  padding: 8px 0;
  font-style: italic;
}

/* ── Build Toolbar ── */
#build-toolbar {
  position: fixed;
  top: 48px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(15, 15, 30, 0.92);
  border: 1px solid #475569;
  border-radius: 6px;
  padding: 4px 10px;
  z-index: 30;
}
#build-toolbar.hidden { display: none; }
.build-label {
  color: #94a3b8;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-right: 2px;
}
.build-color {
  width: 24px;
  height: 24px;
  border: 2px solid transparent;
  border-radius: 4px;
  cursor: pointer;
  padding: 0;
}
.build-color.active {
  border-color: #f1f5f9;
  box-shadow: 0 0 4px rgba(255,255,255,0.4);
}
.build-color:hover {
  border-color: #94a3b8;
}
.build-types { display: inline-flex; gap: 2px; margin-right: 4px; }
.build-type {
  width: 28px; height: 24px; border: 2px solid transparent;
  border-radius: 3px; cursor: pointer; padding: 0;
  background: rgba(255,255,255,0.1); color: #94a3b8; font-size: 14px;
}
.build-type.active { border-color: #f1f5f9; color: #f1f5f9; box-shadow: 0 0 4px rgba(255,255,255,0.4); }
.build-type[data-type="remove"].active { border-color: #f87171; color: #f87171; box-shadow: 0 0 4px rgba(248,113,113,0.4); }
.build-type:hover { border-color: #94a3b8; }
.build-separator { display: inline-block; width: 1px; height: 18px; background: rgba(255,255,255,0.15); margin: 0 4px; vertical-align: middle; }
.build-orient-label { color: #94a3b8; font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.5px; min-width: 30px; }
.build-hint {
  position: absolute; bottom: -18px; left: 50%; transform: translateX(-50%);
  white-space: nowrap; color: #64748b; font-size: 0.55rem; letter-spacing: 0.3px;
}

/* ── Housing Toolbar ── */
#housing-toolbar {
  position: fixed;
  top: 48px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(15, 15, 30, 0.92);
  border: 1px solid #475569;
  border-radius: 6px;
  padding: 4px 10px;
  z-index: 30;
  flex-wrap: wrap;
  max-width: 90vw;
}
#housing-toolbar.hidden { display: none; }
.housing-label { color: #a78bfa; font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
.housing-actions { display: inline-flex; gap: 2px; }
.housing-action {
  width: 28px; height: 24px; border: 2px solid transparent; border-radius: 3px;
  background: rgba(255,255,255,0.06); color: #94a3b8; cursor: pointer; font-size: 0.7rem;
  display: flex; align-items: center; justify-content: center;
}
.housing-action.active { border-color: #a78bfa; color: #f1f5f9; box-shadow: 0 0 4px rgba(167,139,250,0.4); }
.housing-action:hover { border-color: #94a3b8; }
.housing-separator { display: inline-block; width: 1px; height: 18px; background: rgba(255,255,255,0.15); margin: 0 4px; vertical-align: middle; }
#housing-house-config { display: flex; align-items: center; gap: 6px; }
#housing-house-config.hidden { display: none; }
.housing-dim-label { color: #94a3b8; font-size: 0.6rem; display: flex; align-items: center; gap: 2px; }
.housing-dim-label input[type="range"] { width: 50px; height: 4px; accent-color: #a78bfa; }
.housing-dim-label span { color: #e2e8f0; font-size: 0.65rem; min-width: 12px; text-align: center; }
.housing-color-label { color: #94a3b8; font-size: 0.55rem; display: flex; align-items: center; gap: 2px; }
.housing-color-label input[type="color"] { width: 20px; height: 18px; border: 1px solid #475569; border-radius: 3px; padding: 0; background: none; cursor: pointer; }
.housing-floor-select { font-size: 0.6rem; background: #1e293b; color: #e2e8f0; border: 1px solid #475569; border-radius: 3px; padding: 1px 2px; max-width: 90px; cursor: pointer; }
.housing-door-label { color: #94a3b8; font-size: 0.6rem; display: flex; align-items: center; gap: 1px; cursor: pointer; }
.housing-door-label input[type="checkbox"] { width: 12px; height: 12px; accent-color: #a78bfa; }
.housing-compass {
  color: #a78bfa; font-size: 0.6rem; padding: 2px 6px;
  background: rgba(167, 139, 250, 0.08); border-radius: 3px;
  white-space: nowrap;
}
.housing-compass.hidden { display: none; }
.housing-hint {
  position: absolute; bottom: -18px; left: 50%; transform: translateX(-50%);
  white-space: nowrap; color: #64748b; font-size: 0.55rem; letter-spacing: 0.3px;
}
/* Collapsed state on mobile — hide everything except the expand button */
#housing-toolbar.housing-collapsed > *:not(#housing-expand-btn):not(.housing-hint) { display: none !important; }
#housing-toolbar.housing-collapsed #housing-expand-btn { display: flex; }
.housing-expand-btn {
  background: rgba(167,139,250,0.15); color: #a78bfa; border: 1px solid #a78bfa;
  border-radius: 4px; padding: 4px 10px; font-size: 0.65rem; cursor: pointer;
  align-items: center; gap: 4px; white-space: nowrap;
}
.housing-expand-btn.hidden { display: none; }

#housing-prop-palette {
  display: flex; flex-direction: column; gap: 6px; max-width: 300px;
}
#housing-prop-palette.hidden { display: none; }
.housing-palette-tabs { display: flex; gap: 2px; margin-bottom: 2px; }
.housing-palette-content { display: flex; flex-direction: column; gap: 6px; }
.housing-palette-label {
  font-size: 0.6rem; color: #94a3b8; text-transform: uppercase; letter-spacing: 0.5px;
  border-bottom: 1px solid rgba(148,163,184,0.2); padding-bottom: 2px;
}
.housing-palette-group {
  display: flex; gap: 4px; flex-wrap: wrap;
}
.housing-prop-btn {
  width: 32px; height: 32px; border: 2px solid transparent; border-radius: 3px;
  background: rgba(255,255,255,0.06); cursor: pointer; padding: 2px;
  display: flex; align-items: center; justify-content: center;
}
.housing-prop-btn.active { border-color: #a78bfa; box-shadow: 0 0 4px rgba(167,139,250,0.4); }
.housing-prop-btn:hover { border-color: #94a3b8; }
.housing-prop-btn img { width: 24px; height: 24px; image-rendering: pixelated; }

/* ── Housing Manage Panel ── */
#housing-manage {
  display: flex; flex-direction: column; gap: 4px; width: 100%;
  border-top: 1px solid rgba(255,255,255,0.12); margin-top: 4px; padding-top: 4px;
}
#housing-manage.hidden { display: none; }
.housing-manage-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.housing-manage-label { color: #a78bfa; font-size: 0.6rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
.housing-manage-btn {
  padding: 2px 8px; border: 1px solid #475569; border-radius: 3px;
  background: rgba(167,139,250,0.15); color: #c4b5fd; cursor: pointer;
  font-size: 0.6rem; white-space: nowrap;
}
.housing-manage-btn:hover { background: rgba(167,139,250,0.3); border-color: #a78bfa; }
#manage-house-name {
  padding: 2px 6px; border: 1px solid #475569; border-radius: 3px;
  background: rgba(30,41,59,0.8); color: #e2e8f0; font-size: 0.6rem;
  width: 120px; outline: none;
}
#manage-house-name:focus { border-color: #a78bfa; }
.housing-policy-btn {
  padding: 2px 6px; border: 1px solid #475569; border-radius: 3px;
  background: rgba(255,255,255,0.06); color: #94a3b8; cursor: pointer;
  font-size: 0.6rem; white-space: nowrap;
}
.housing-policy-btn:hover { border-color: #94a3b8; }
.housing-policy-btn.active { border-color: #a78bfa; color: #c4b5fd; background: rgba(167,139,250,0.25); box-shadow: 0 0 4px rgba(167,139,250,0.4); }

/* ── Housing Panel ── */
.housing-abandon-btn {
  background: rgba(239, 68, 68, 0.15) !important;
  color: #f87171 !important;
  border-color: #7f1d1d !important;
  margin-left: auto;
}
.housing-abandon-btn:hover { background: rgba(239, 68, 68, 0.3) !important; border-color: #ef4444 !important; }
.housing-abandon-btn.hidden { display: none; }

/* ── Placement Cancel Button (mobile Escape alternative) ── */
#placement-cancel-btn {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 28px;
  font-size: 15px;
  font-family: 'Segoe UI', Tahoma, sans-serif;
  color: #f87171;
  background: linear-gradient(180deg, rgba(30,15,15,0.92), rgba(20,8,8,0.95));
  border: 1px solid #7f1d1d;
  border-radius: 6px;
  cursor: pointer;
  z-index: 51;
  pointer-events: auto;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
#placement-cancel-btn:hover,
#placement-cancel-btn:active {
  background: rgba(40,20,20,0.95);
  border-color: #ef4444;
  color: #ef4444;
}
#placement-cancel-btn.hidden { display: none; }

/* ── Claim / Abandon Confirm Dialogs ── */
#claim-confirm,
#abandon-confirm {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 50;
  background: linear-gradient(180deg, rgba(15, 15, 30, 0.96) 0%, rgba(8, 8, 20, 0.98) 100%);
  border: 1px solid #3a3a5a;
  border-radius: 6px;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  pointer-events: auto;
}
#claim-confirm.hidden,
#abandon-confirm.hidden { display: none; }

#claim-confirm-text,
#abandon-confirm-text {
  color: #e2e8f0;
  font-size: 0.7rem;
  font-weight: 600;
  white-space: nowrap;
}

.claim-confirm-btns {
  display: flex;
  gap: 8px;
}
.claim-confirm-btns button {
  padding: 3px 12px;
  border: 1px solid #3a3a5a;
  border-radius: 4px;
  background: rgba(15, 15, 30, 0.8);
  color: #94a3b8;
  cursor: pointer;
  font-size: 0.65rem;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.claim-confirm-btns button:hover {
  border-color: #4a4a7a;
  color: #e2e8f0;
}
#claim-confirm-yes { color: #4ade80; border-color: #166534; }
#claim-confirm-yes:hover { background: #1a2a1a; border-color: #22c55e; color: #22c55e; }
#abandon-confirm-yes { color: #f87171; border-color: #7f1d1d; }
#abandon-confirm-yes:hover { background: #2a1a1a; border-color: #ef4444; color: #ef4444; }

#resize-confirm,
#doors-confirm {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(10, 10, 25, 0.96);
  border: 1px solid #3a3a5a;
  border-radius: 6px;
  padding: 12px 18px;
  z-index: 120;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  pointer-events: auto;
}
#resize-confirm.hidden,
#doors-confirm.hidden { display: none; }
#resize-confirm-text,
#doors-confirm-text {
  color: #e2e8f0;
  font-size: 0.7rem;
  font-weight: 600;
  white-space: nowrap;
}
#resize-confirm-yes { color: #4ade80; border-color: #166534; }
#resize-confirm-yes:hover { background: #1a2a1a; border-color: #22c55e; color: #22c55e; }
#doors-confirm-yes { color: #4ade80; border-color: #166534; }
#doors-confirm-yes:hover { background: #1a2a1a; border-color: #22c55e; color: #22c55e; }

/* ── Housing Cost Display ── */
.housing-cost-inline {
  font-size: 0.55rem;
  color: #94a3b8;
  white-space: nowrap;
}
.housing-prop-btn {
  position: relative;
}
.housing-prop-tip {
  display: none;
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(10, 10, 25, 0.96);
  border: 1px solid #3a3a5a;
  border-radius: 4px;
  padding: 4px 8px;
  white-space: nowrap;
  font-size: 0.55rem;
  color: #e2e8f0;
  z-index: 30;
  pointer-events: none;
  margin-bottom: 4px;
}
.housing-prop-btn:hover .housing-prop-tip { display: block; }
.housing-prop-btn-locked { cursor: not-allowed; opacity: 0.5; border-color: #333; }
.housing-prop-btn-locked:hover { border-color: #555; }
.housing-prop-tip-visible { display: block !important; }

#housing-claim-cost {
  font-size: 0.6rem;
  color: #94a3b8;
  padding: 2px 0;
}

#cursor-cost-tip {
  display: none;
  position: fixed;
  pointer-events: none;
  z-index: 100;
  background: rgba(10, 10, 25, 0.92);
  border: 1px solid #3a3a5a;
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 0.55rem;
  color: #e2e8f0;
  white-space: nowrap;
}

/* ── Buff Display ── */
#buff-display {
  position: fixed;
  top: 60px;
  right: 16px;
  display: flex;
  gap: 4px;
  z-index: 25;
  pointer-events: none;
}

.buff-icon {
  width: 32px;
  height: 32px;
  border-radius: 4px;
  background: rgba(15, 15, 30, 0.9);
  border: 2px solid #64748b;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.buff-icon.buff-hpRegen {
  border-color: #ef4444;
}

.buff-icon.buff-mpRegen {
  border-color: #3b82f6;
}

.buff-icon.buff-evasionRating {
  background: #2e7d32;
  border-color: #4caf50;
}

.buff-icon.buff-bonusDamage {
  background: #c62828;
  border-color: #ef5350;
}

.buff-icon.buff-damageReduction {
  background: #1565c0;
  border-color: #42a5f5;
}

.buff-icon-symbol {
  font-size: 0.8rem;
  color: #e2e8f0;
  z-index: 1;
}

.buff-timer-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: #4ade80;
  transition: width 0.5s linear;
}

/* ── Skills Window ── */
#skills-window {
  position: fixed;
  bottom: 160px;
  right: 16px;
  width: 220px;
  z-index: 30;
  pointer-events: auto;
  animation: inv-slide-in 0.15s ease-out;
}

#skills-window.hidden {
  display: none;
}

.skills-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(180deg, rgba(30, 30, 55, 0.96) 0%, rgba(15, 15, 30, 0.98) 100%);
  border: 1px solid #3a3a5a;
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  padding: 6px 10px;
}

.skills-title {
  color: #e2e8f0;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.skills-close {
  background: none;
  border: none;
  color: #64748b;
  font-size: 1rem;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
  transition: color 0.15s;
}

.skills-close:hover {
  color: #f87171;
}

.skills-body {
  background: linear-gradient(180deg, rgba(15, 15, 30, 0.94) 0%, rgba(8, 8, 20, 0.97) 100%);
  border: 1px solid #2a2a4a;
  border-top: none;
  border-radius: 0 0 6px 6px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: calc(100vh - 200px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.skills-body::-webkit-scrollbar { width: 4px; }
.skills-body::-webkit-scrollbar-track { background: transparent; }
.skills-body::-webkit-scrollbar-thumb { background: #3a3a5a; border-radius: 2px; }

.skills-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  cursor: grab;
  border-bottom: 1px solid #1a1a2e;
  border-radius: 3px;
  transition: background 0.12s;
}

.skills-row:hover {
  background: #222244;
}

.skills-row.dragging {
  opacity: 0.4;
}

.skills-row-icon {
  font-size: 1rem;
  color: #94a3b8;
  flex-shrink: 0;
  width: 20px;
  text-align: center;
}

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

.skills-row-name {
  color: #e2e8f0;
  font-size: 0.65rem;
  font-weight: 600;
}

.skills-row-desc {
  color: #64748b;
  font-size: 0.5rem;
}

/* ── Skill Point System ── */
.skills-points-header {
  color: #facc15;
  font-size: 0.65rem;
  font-weight: 600;
  padding: 4px 8px 2px;
  text-align: center;
  letter-spacing: 0.04em;
}

.skills-row-pips-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
  margin-left: auto;
  flex-shrink: 0;
}

.skills-row-pips {
  display: flex;
  gap: 3px;
  align-items: center;
}

.skill-pip {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1px solid #4a4a6a;
  background: transparent;
}

.skill-pip.filled {
  background: #facc15;
  border-color: #facc15;
}

.skills-row-btns {
  display: flex;
  gap: 4px;
}

.skill-btn {
  width: 20px;
  height: 18px;
  border: 1px solid #4a4a6a;
  border-radius: 3px;
  background: #1a1a2e;
  color: #e2e8f0;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.1s, border-color 0.1s;
}

.skill-btn:hover:not(:disabled) {
  background: #2a2a4e;
  border-color: #6a6a9a;
}

.skill-btn:disabled {
  opacity: 0.3;
  cursor: default;
}

.skill-btn-plus:not(:disabled) {
  border-color: #4ade80;
  color: #4ade80;
}

.skill-btn-minus:not(:disabled) {
  border-color: #f87171;
  color: #f87171;
}

.skills-row.passive-skill {
  border-left: 2px solid #4a9eff;
}

.skills-row.passive-skill .skills-row-name {
  color: #93c5fd;
}

.skill-points-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #facc15;
  color: #000;
  font-size: 0.5rem;
  font-weight: 700;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  animation: badge-pulse 1.5s ease-in-out infinite;
}

@keyframes badge-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.2); }
}

/* Drag ghost */
.drag-ghost {
  position: fixed;
  width: 44px;
  height: 44px;
  background: rgba(26, 26, 46, 0.9);
  border: 1px solid #facc15;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 9999;
  font-size: 1.1rem;
  color: #94a3b8;
}

/* ── Item / Skill Icon Images ── */
.inv-slot-icon {
  width: 80%;
  height: 80%;
  object-fit: contain;
  image-rendering: auto;
  pointer-events: none;
}


.slot-icon-img {
  width: 80%;
  height: 80%;
  object-fit: contain;
  image-rendering: auto;
  pointer-events: none;
}

.skills-row-icon-img {
  width: 24px;
  height: 24px;
  object-fit: contain;
  flex-shrink: 0;
}

.skills-section-header {
  color: #94a3b8;
  font-size: 0.6rem;
  font-weight: 700;
  padding: 6px 8px 2px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid #334155;
}

.skills-lock-msg {
  color: #64748b;
  font-size: 0.55rem;
  padding: 4px 8px;
  text-align: center;
  font-style: italic;
}

.skills-row.locked {
  opacity: 0.4;
  pointer-events: none;
}

.skills-row.skill-detail-active {
  background: #2a2a55;
}

/* ── Skill Cooldown in Row ── */
.skills-row-cd {
  color: #60a5fa;
  font-size: 0.5rem;
  white-space: nowrap;
}

/* ── Skill Detail Panel ── */
#skill-detail-panel {
  position: fixed;
  bottom: 160px;
  right: 242px;
  width: 200px;
  z-index: 31;
  pointer-events: auto;
  animation: inv-slide-in 0.1s ease-out;
}

#skill-detail-panel.hidden {
  display: none;
}

.skill-detail-header {
  display: flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(180deg, rgba(30, 30, 55, 0.97) 0%, rgba(20, 20, 40, 0.98) 100%);
  border: 1px solid #4a4a7a;
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  padding: 8px 10px;
}

.skill-detail-icon-img {
  width: 28px;
  height: 28px;
  image-rendering: pixelated;
  flex-shrink: 0;
}

.skill-detail-name {
  color: #facc15;
  font-size: 0.75rem;
  font-weight: 700;
}

.skill-detail-level {
  color: #94a3b8;
  font-size: 0.6rem;
  font-weight: 400;
}

.skill-detail-body {
  background: linear-gradient(180deg, rgba(15, 15, 30, 0.96) 0%, rgba(8, 8, 20, 0.98) 100%);
  border: 1px solid #3a3a5a;
  border-top: none;
  border-radius: 0 0 6px 6px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: calc(100vh - 240px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.skill-detail-body::-webkit-scrollbar { width: 4px; }
.skill-detail-body::-webkit-scrollbar-track { background: transparent; }
.skill-detail-body::-webkit-scrollbar-thumb { background: #3a3a5a; border-radius: 2px; }

.skill-detail-type-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 0.55rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.skill-detail-type-badge.type-melee { background: #7c2d12; color: #fb923c; border: 1px solid #9a3412; }
.skill-detail-type-badge.type-ranged { background: #1e3a5f; color: #60a5fa; border: 1px solid #2563eb; }
.skill-detail-type-badge.type-self { background: #14532d; color: #4ade80; border: 1px solid #16a34a; }
.skill-detail-type-badge.type-passive { background: #1e1b4b; color: #a5b4fc; border: 1px solid #4338ca; }
.skill-detail-type-badge.type-toggle { background: #4a1d96; color: #c084fc; border: 1px solid #7c3aed; }
.skill-detail-type-badge.type-charge { background: #78350f; color: #fbbf24; border: 1px solid #b45309; }
.skill-detail-type-badge.type-aoe { background: #7f1d1d; color: #fca5a5; border: 1px solid #b91c1c; }

.skill-detail-meta {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.skill-detail-meta-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.skill-detail-meta-label {
  color: #64748b;
  font-size: 0.55rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.skill-detail-meta-value {
  color: #e2e8f0;
  font-size: 0.6rem;
  font-weight: 600;
}

.skill-detail-meta-value.mp-cost { color: #60a5fa; }
.skill-detail-meta-value.cooldown { color: #facc15; }

.skill-detail-divider {
  border: none;
  border-top: 1px solid #2a2a4a;
  margin: 2px 0;
}

.skill-detail-section-title {
  color: #94a3b8;
  font-size: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 2px;
}

.skill-detail-stat {
  color: #c4b5fd;
  font-size: 0.6rem;
  padding-left: 4px;
}

.skill-detail-stat.next-level {
  color: #4ade80;
}

.skill-detail-special {
  color: #fbbf24;
  font-size: 0.55rem;
  font-style: italic;
  padding-left: 4px;
}

/* ── Job Advance Dialog ── */
.job-advance-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.job-advance-dialog {
  background: #1e293b;
  border: 1px solid #475569;
  border-radius: 8px;
  padding: 20px;
  min-width: 360px;
  max-width: 480px;
  color: #e2e8f0;
  font-family: monospace;
}

.job-advance-dialog h2 {
  text-align: center;
  color: #facc15;
  font-size: 1rem;
  margin-bottom: 12px;
}

.job-advance-cost {
  text-align: center;
  color: #fbbf24;
  font-size: 0.75rem;
  margin-bottom: 10px;
}

.job-advance-section-label {
  color: #94a3b8;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}

.job-advance-app-btns {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.job-advance-app-btn {
  flex: 1;
  padding: 6px;
  background: #0f172a;
  border: 1px solid #475569;
  border-radius: 4px;
  color: #e2e8f0;
  cursor: pointer;
  font-family: monospace;
  font-size: 0.7rem;
}

.job-advance-app-btn.selected {
  border-color: #38bdf8;
  background: #0c4a6e;
}

.job-advance-cards {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.job-advance-card {
  flex: 1;
  background: #0f172a;
  border: 1px solid #475569;
  border-radius: 6px;
  padding: 10px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s;
}

.job-advance-card:hover {
  border-color: #94a3b8;
}

.job-advance-card.selected {
  border-color: #facc15;
  box-shadow: 0 0 8px rgba(250,204,21,0.3);
}

.job-card-sprite {
  width: 48px;
  height: 48px;
  image-rendering: pixelated;
  margin: 0 auto 6px;
  background-size: 192px 48px;
  background-repeat: no-repeat;
  animation: job-sprite-idle 0.667s steps(4) infinite;
}
@keyframes job-sprite-idle {
  from { background-position: 0 0; }
  to { background-position: -192px 0; }
}

.job-card-name {
  color: #f8fafc;
  font-weight: 700;
  font-size: 0.75rem;
  margin-bottom: 4px;
}

.job-card-flavor {
  color: #94a3b8;
  font-size: 0.5rem;
  line-height: 1.3;
}

.job-advance-btns {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.job-advance-confirm, .job-advance-cancel {
  padding: 6px 16px;
  border-radius: 4px;
  border: 1px solid #475569;
  cursor: pointer;
  font-family: monospace;
  font-size: 0.7rem;
}

.job-advance-confirm {
  background: #166534;
  color: #f0fdf4;
  border-color: #22c55e;
}

.job-advance-confirm:disabled {
  opacity: 0.4;
  cursor: default;
}

.job-advance-cancel {
  background: #1e293b;
  color: #94a3b8;
}

/* ── Character Creation Dialog ── */
.char-create-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}
.char-create-dialog {
  background: #1e293b;
  border: 1px solid #475569;
  border-radius: 8px;
  padding: 24px;
  min-width: 340px;
  max-width: 420px;
  color: #e2e8f0;
  font-family: monospace;
}
.char-create-dialog h2 {
  text-align: center;
  color: #facc15;
  font-size: 1.1rem;
  margin: 0 0 16px;
}
.char-create-section-label {
  color: #94a3b8;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}
.char-create-sprite-preview {
  width: 64px;
  height: 64px;
  image-rendering: pixelated;
  margin: 0 auto 8px;
  background-size: 256px 64px;
  background-repeat: no-repeat;
  animation: char-create-idle 0.667s steps(4) infinite;
}
@keyframes char-create-idle {
  from { background-position: 0 0; }
  to { background-position: -256px 0; }
}
.char-create-app-btns {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}
.char-create-app-btn {
  flex: 1;
  padding: 8px;
  background: #0f172a;
  border: 1px solid #475569;
  border-radius: 4px;
  color: #e2e8f0;
  cursor: pointer;
  font-family: monospace;
  font-size: 0.75rem;
}
.char-create-app-btn.selected {
  border-color: #38bdf8;
  background: #0c4a6e;
}
.char-create-job-info {
  margin-bottom: 16px;
  padding: 8px;
  background: #0f172a;
  border-radius: 4px;
}
.char-create-job-text {
  color: #e2e8f0;
  font-size: 0.75rem;
}
.char-create-name-section {
  margin-bottom: 16px;
}
.char-create-name-input {
  width: 100%;
  padding: 8px;
  background: #0f172a;
  border: 1px solid #475569;
  border-radius: 4px;
  color: #e2e8f0;
  font-family: monospace;
  font-size: 0.8rem;
  box-sizing: border-box;
  margin-bottom: 4px;
}
.char-create-name-input:focus {
  outline: none;
  border-color: #38bdf8;
}
.char-create-name-hint {
  color: #64748b;
  font-size: 0.55rem;
  line-height: 1.4;
}
.char-create-name-error {
  color: #f87171;
  font-size: 0.65rem;
  margin-top: 4px;
}
.char-create-btns {
  display: flex;
  justify-content: center;
}
.char-create-confirm {
  padding: 8px 24px;
  background: #166534;
  color: #f0fdf4;
  border: 1px solid #22c55e;
  border-radius: 4px;
  cursor: pointer;
  font-family: monospace;
  font-size: 0.75rem;
}
.char-create-confirm:disabled {
  opacity: 0.4;
  cursor: default;
}

.char-create-tos {
  margin: 12px 0 4px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.char-create-tos-label {
  font-size: 12px;
  color: #ccc;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 2px;
}
.char-create-tos-check {
  cursor: pointer;
  accent-color: #f0c040;
}
.char-create-tos-link {
  color: #f0c040;
  text-decoration: underline;
  cursor: pointer;
}
.char-create-tos-link:hover {
  color: #ffe080;
}

/* ── Welcome Dialog ── */
.welcome-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.welcome-dialog {
  background: #1a1a2e;
  border: 1px solid #555;
  border-radius: 8px;
  padding: 28px 32px 20px;
  width: min(460px, 88vw);
  max-height: 85vh;
  overflow-y: auto;
  color: #ddd;
  text-align: center;
}
.welcome-dialog h2 {
  color: #f0c040;
  font-size: 20px;
  margin: 0 0 16px;
}
.welcome-body {
  text-align: left;
  font-size: 13px;
  line-height: 1.6;
}
.welcome-body p {
  margin: 10px 0;
}
.welcome-tip {
  background: rgba(240,192,64,0.1);
  border-left: 3px solid #f0c040;
  padding: 8px 12px;
  border-radius: 0 4px 4px 0;
}
.welcome-tip kbd {
  background: #333;
  border: 1px solid #666;
  border-radius: 3px;
  padding: 1px 6px;
  font-family: monospace;
  font-size: 13px;
  color: #f0c040;
}
.welcome-list {
  margin: 6px 0 10px;
  padding-left: 20px;
  font-size: 12px;
  color: #ccc;
}
.welcome-list li {
  margin: 4px 0;
}
.welcome-roadmap {
  color: #999;
  font-style: italic;
}
.welcome-patreon {
  text-align: center;
  color: #94a3b8;
  font-size: 0.85rem;
  margin-top: 8px;
}
.welcome-patreon a {
  color: #f97316;
  text-decoration: underline;
}
.welcome-footer {
  text-align: center;
  color: #aaa;
  font-style: italic;
}
.welcome-btns {
  margin-top: 18px;
}
.welcome-ok {
  background: #f0c040;
  color: #1a1a2e;
  border: none;
  padding: 8px 32px;
  border-radius: 4px;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
}
.welcome-ok:hover {
  background: #ffe080;
}

/* ── EULA Modal ── */
.eula-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 10001;
  display: flex;
  align-items: center;
  justify-content: center;
}
.eula-modal {
  background: #1a1a2e;
  border: 1px solid #444;
  border-radius: 8px;
  width: min(600px, 90vw);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  position: relative;
}
.eula-close {
  position: absolute;
  top: 8px;
  right: 12px;
  background: none;
  border: none;
  color: #aaa;
  font-size: 22px;
  cursor: pointer;
  z-index: 1;
}
.eula-close:hover {
  color: #fff;
}
.eula-content {
  padding: 24px 28px;
  overflow-y: auto;
  color: #ddd;
  font-size: 13px;
  line-height: 1.5;
}
.eula-content h2 {
  color: #f0c040;
  font-size: 18px;
  margin: 0 0 12px;
}
.eula-content h3 {
  color: #e0b030;
  font-size: 14px;
  margin: 16px 0 6px;
}
.eula-content p {
  margin: 6px 0;
}
.eula-content ul {
  margin: 6px 0;
  padding-left: 20px;
}
.eula-content li {
  margin: 4px 0;
}
.eula-content strong {
  color: #f08080;
}

.shop-item-icon {
  width: 24px;
  height: 24px;
  object-fit: contain;
  flex-shrink: 0;
  margin-right: 6px;
}

/* ── Guide Window ── */
#guide-window {
  position: fixed;
  bottom: 160px;
  right: 250px;
  width: 320px;
  z-index: 30;
  pointer-events: auto;
  animation: inv-slide-in 0.15s ease-out;
}
#guide-window.hidden { display: none; }
.guide-header {
  display: flex;
  align-items: center;
  background: linear-gradient(180deg, rgba(30, 30, 55, 0.96) 0%, rgba(15, 15, 30, 0.98) 100%);
  border: 1px solid #3a3a5a;
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  padding: 6px 10px;
  gap: 6px;
}
.guide-title {
  color: #e2e8f0;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  flex: 1;
}
.guide-fullpage {
  color: #64748b;
  font-size: 0.85rem;
  text-decoration: none;
  transition: color 0.15s;
}
.guide-fullpage:hover { color: #4ade80; }
.guide-close {
  background: none;
  border: none;
  color: #64748b;
  font-size: 1rem;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
  transition: color 0.15s;
}
.guide-close:hover { color: #f87171; }
.guide-body {
  background: linear-gradient(180deg, rgba(15, 15, 30, 0.94) 0%, rgba(8, 8, 20, 0.97) 100%);
  border: 1px solid #2a2a4a;
  border-top: none;
  border-radius: 0 0 6px 6px;
  padding: 0;
}
.guide-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 6px 6px 4px;
  border-bottom: 1px solid #1a1a2e;
}
.guide-nav-btn {
  background: rgba(255,255,255,0.04);
  border: 1px solid transparent;
  border-radius: 3px;
  color: #94a3b8;
  font-size: 0.55rem;
  font-weight: 600;
  font-family: inherit;
  padding: 3px 6px;
  cursor: pointer;
  transition: color 0.12s, border-color 0.12s, background 0.12s;
}
.guide-nav-btn:hover { color: #e2e8f0; background: rgba(255,255,255,0.08); }
.guide-nav-btn.active {
  color: #4ade80;
  border-color: #22c55e55;
  background: rgba(74, 222, 128, 0.08);
}
.guide-content {
  padding: 8px 10px;
  max-height: 350px;
  overflow-y: auto;
}
.guide-content::-webkit-scrollbar { width: 4px; }
.guide-content::-webkit-scrollbar-track { background: transparent; }
.guide-content::-webkit-scrollbar-thumb { background: #2a2a4a; border-radius: 2px; }
#guide-window .guide-section { display: block; }
#guide-window .guide-section.hidden { display: none; }
#guide-window .guide-section h3 {
  color: #e2e8f0;
  font-size: 0.8rem;
  font-weight: 700;
  margin-bottom: 6px;
}
#guide-window .guide-section p {
  color: #94a3b8;
  font-size: 0.68rem;
  line-height: 1.55;
  margin-bottom: 5px;
}
#guide-window .guide-section b { color: #e2e8f0; }
#guide-window .guide-tip {
  color: #a7f3d0;
  background: rgba(74, 222, 128, 0.06);
  border-radius: 4px;
  padding: 4px 8px;
  margin-top: 4px;
  font-size: 0.62rem;
}

/* ── Quest Dialog (NPC-bound) ── */
#quest-dialog-window {
  position: fixed;
  bottom: 160px;
  left: 50%;
  transform: translateX(-50%);
  width: 320px;
  max-height: 400px;
  z-index: 35;
  pointer-events: auto;
  animation: inv-slide-in 0.15s ease-out;
}
#quest-dialog-window.hidden { display: none; }
.quest-dialog-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(180deg, rgba(30, 30, 55, 0.96) 0%, rgba(15, 15, 30, 0.98) 100%);
  border: 1px solid #3a3a5a;
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  padding: 6px 10px;
}
.quest-dialog-title {
  color: #e2e8f0;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}
.quest-dialog-close {
  background: none;
  border: none;
  color: #64748b;
  font-size: 1rem;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
  transition: color 0.15s;
}
.quest-dialog-close:hover { color: #f87171; }
.quest-dialog-body {
  background: linear-gradient(180deg, rgba(15, 15, 30, 0.94) 0%, rgba(8, 8, 20, 0.97) 100%);
  border: 1px solid #2a2a4a;
  border-radius: 0 0 6px 6px;
  padding: 8px;
  max-height: 340px;
  overflow-y: auto;
}
.quest-dialog-section {
  margin-bottom: 8px;
}
.quest-dialog-section-title {
  color: #94a3b8;
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}
.quest-entry {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid #2a2a4a;
  border-radius: 4px;
  padding: 6px 8px;
  margin-bottom: 4px;
  transition: background 0.15s, border-color 0.15s;
}
.quest-entry:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: #4a4a7a;
}
.quest-entry-name {
  color: #e2e8f0;
  font-size: 0.7rem;
  font-weight: 600;
}
.quest-entry-desc {
  color: #94a3b8;
  font-size: 0.6rem;
  margin-top: 2px;
}
.quest-entry-objectives {
  margin-top: 4px;
}
.quest-objective {
  color: #cbd5e1;
  font-size: 0.6rem;
  padding: 1px 0;
}
.quest-objective-done {
  color: #4ade80;
}
.quest-objective-bar {
  height: 3px;
  background: #1e1e3e;
  border-radius: 2px;
  margin-top: 2px;
  overflow: hidden;
}
.quest-objective-fill {
  height: 100%;
  background: #f59e0b;
  border-radius: 2px;
  transition: width 0.2s;
}
.quest-objective-fill.complete {
  background: #4ade80;
}
.quest-rewards {
  margin-top: 4px;
  color: #fbbf24;
  font-size: 0.58rem;
}
.quest-accept-btn, .quest-turnin-btn {
  background: linear-gradient(180deg, #2a2a4a 0%, #1a1a3a 100%);
  border: 1px solid #3a3a5a;
  color: #e2e8f0;
  font-size: 0.6rem;
  padding: 3px 10px;
  border-radius: 3px;
  cursor: pointer;
  margin-top: 4px;
  transition: background 0.15s, border-color 0.15s;
}
.quest-accept-btn:hover { border-color: #4ade80; color: #4ade80; }
.quest-turnin-btn:hover { border-color: #fbbf24; color: #fbbf24; }

/* ── Quest Log (J key toggle) ── */
#quest-log-window {
  position: fixed;
  bottom: 160px;
  right: 16px;
  width: 260px;
  max-height: 350px;
  z-index: 30;
  pointer-events: auto;
  animation: inv-slide-in 0.15s ease-out;
}
#quest-log-window.hidden { display: none; }
.quest-log-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(180deg, rgba(30, 30, 55, 0.96) 0%, rgba(15, 15, 30, 0.98) 100%);
  border: 1px solid #3a3a5a;
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  padding: 6px 10px;
}
.quest-log-title {
  color: #e2e8f0;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}
.quest-log-close {
  background: none;
  border: none;
  color: #64748b;
  font-size: 1rem;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
  transition: color 0.15s;
}
.quest-log-close:hover { color: #f87171; }
.quest-log-body {
  background: linear-gradient(180deg, rgba(15, 15, 30, 0.94) 0%, rgba(8, 8, 20, 0.97) 100%);
  border: 1px solid #2a2a4a;
  border-radius: 0 0 6px 6px;
  padding: 8px;
  max-height: 300px;
  overflow-y: auto;
}
.quest-log-empty {
  color: #64748b;
  font-size: 0.65rem;
  text-align: center;
  padding: 16px 0;
}
.quest-abandon-btn {
  background: none;
  border: 1px solid #64748b;
  color: #94a3b8;
  font-size: 0.55rem;
  padding: 2px 6px;
  border-radius: 3px;
  cursor: pointer;
  margin-top: 4px;
  transition: color 0.15s, border-color 0.15s;
}
.quest-abandon-btn:hover { border-color: #f87171; color: #f87171; }

/* ── Quest chat type ── */
.chat-msg.quest {
  color: #f59e0b;
}

/* ── Mobile landscape (iPhone etc.) ── */
@media (max-height: 500px) and (orientation: landscape) {
  #top-bar {
    margin-left: max(0.5rem, env(safe-area-inset-left));
    gap: 3px;
  }

  #pos {
    padding: 0.15rem 0.35rem;
    font-size: 0.55rem;
    min-width: 45px;
  }

  .toggle-btn {
    padding: 0.15rem 0.35rem;
    font-size: 0.45rem;
  }

  #hud {
    height: 90px;
    padding: 0 4px 4px;
    padding-left: max(4px, env(safe-area-inset-left));
    padding-right: max(4px, env(safe-area-inset-right));
    gap: 4px;
  }

  .hud-panel-inner {
    padding: 5px 7px;
    border-radius: 4px;
  }

  /* Left panel */
  #hud-left {
    width: 160px;
  }

  .char-header {
    margin-bottom: 3px;
  }

  .char-name {
    font-size: 0.65rem;
  }

  .char-level {
    font-size: 0.55rem;
  }

  .bar-group {
    gap: 2px;
    margin-bottom: 3px;
  }

  .bar-row {
    gap: 4px;
  }

  .bar-label {
    font-size: 0.5rem;
    width: 15px;
  }

  .bar {
    height: 9px;
  }

  .bar-text {
    font-size: 0.4rem;
  }

  .char-stats {
    font-size: 0.45rem;
    gap: 6px;
  }

  /* Center panel */
  .chat-tabs {
    margin-bottom: 2px;
    padding-bottom: 2px;
  }

  .chat-tab {
    font-size: 0.5rem;
    padding: 1px 5px;
  }

  .chat-log {
    font-size: 0.5rem;
    line-height: 1.3;
  }

  /* Right panel */
  #hud-right {
    width: 320px;
  }

  .menu-row { gap: 1px; margin-bottom: 2px; }
  .menu-btn { width: 26px; height: 20px; }
  .menu-icon { font-size: 0.6rem; }

  .hotkey-bar { gap: 2px; }
  .hotkey-slot {
    width: 32px;
    height: 32px;
    border-radius: 3px;
  }

  .slot-key {
    font-size: 0.35rem;
    top: 1px;
    left: 2px;
  }

  .slot-icon {
    font-size: 0.8rem;
  }

  #skills-window {
    bottom: 100px;
    right: 8px;
    width: 190px;
  }

  .skills-body {
    max-height: calc(100vh - 140px);
  }

  #skill-detail-panel {
    bottom: 100px;
    right: 204px;
    width: 170px;
  }

  .skill-detail-body {
    max-height: calc(100vh - 170px);
  }

  #inventory-window {
    bottom: 100px;
    right: 8px;
    width: 220px;
  }

  #bag-window {
    bottom: 100px;
    right: 240px;
    width: 220px;
  }

  #chest-window {
    bottom: 100px;
    right: 240px;
    width: 220px;
  }

  .inv-header {
    padding: 4px 8px;
  }

  .inv-title {
    font-size: 0.65rem;
  }

  .inv-grid {
    padding: 6px;
    gap: 2px;
  }

  #status-window {
    bottom: 100px;
    right: 236px;
    width: 200px;
  }

  .status-header {
    padding: 4px 8px;
  }

  .status-title {
    font-size: 0.65rem;
  }

  .portrait-frame {
    width: 36px;
    height: 36px;
    font-size: 1.2rem;
  }

  .stat-label, .stat-value {
    font-size: 0.55rem;
  }

  #equip-window {
    bottom: 100px;
    right: 446px;
    width: 190px;
  }

  #social-window {
    bottom: 100px;
    right: 644px;
    width: 180px;
  }

  #settings-window {
    bottom: 100px;
    right: 832px;
    width: 170px;
  }

  #guide-window {
    bottom: 100px;
    right: 8px;
    width: 260px;
  }
}

/* Very small landscape (iPhone SE, older models) */
@media (max-height: 400px) and (orientation: landscape) {
  #hud {
    height: 76px;
    padding: 0 3px 3px;
    padding-left: max(3px, env(safe-area-inset-left));
    padding-right: max(3px, env(safe-area-inset-right));
  }

  .hud-panel-inner {
    padding: 4px 5px;
  }

  #hud-left {
    width: 140px;
  }

  .char-stats {
    display: none;
  }

  .bar {
    height: 7px;
  }

  .bar-text {
    display: none;
  }

  .chat-tabs {
    display: none;
  }

  #hud-right {
    width: 280px;
  }

  .menu-row { gap: 1px; }
  .menu-btn { width: 22px; height: 18px; }
  .menu-icon { font-size: 0.5rem; }

  .hotkey-bar { gap: 1px; }
  .hotkey-slot {
    width: 27px;
    height: 27px;
  }

  .slot-key {
    display: none;
  }

  #skills-window {
    bottom: 86px;
    right: 8px;
    width: 170px;
  }

  .skills-body {
    max-height: calc(100vh - 120px);
  }

  #skill-detail-panel {
    bottom: 86px;
    right: 184px;
    width: 155px;
  }

  .skill-detail-body {
    max-height: calc(100vh - 140px);
  }

  .skill-detail-name { font-size: 0.65rem; }
  .skill-detail-level { font-size: 0.5rem; }
  .skill-detail-stat { font-size: 0.5rem; }
  .skill-detail-special { font-size: 0.45rem; }
  .skill-detail-meta-label { font-size: 0.45rem; }
  .skill-detail-meta-value { font-size: 0.5rem; }
  .skill-detail-type-badge { font-size: 0.45rem; }
  .skill-detail-icon-img { width: 22px; height: 22px; }

  #inventory-window {
    bottom: 96px;
    right: 8px;
    width: 200px;
  }

  #bag-window {
    bottom: 96px;
    right: 220px;
    width: 200px;
  }

  #chest-window {
    bottom: 96px;
    right: 220px;
    width: 200px;
  }

  .inv-header {
    padding: 4px 8px;
  }

  .inv-title {
    font-size: 0.65rem;
  }

  .inv-grid {
    padding: 5px;
    gap: 2px;
  }

  #status-window {
    bottom: 86px;
    right: 216px;
    width: 180px;
  }

  .portrait-frame {
    width: 32px;
    height: 32px;
    font-size: 1rem;
  }

  .status-portrait {
    margin-bottom: 6px;
  }

  .stat-label, .stat-value {
    font-size: 0.5rem;
  }

  #equip-window {
    bottom: 86px;
    right: 404px;
    width: 170px;
  }

  #social-window {
    bottom: 86px;
    right: 582px;
    width: 160px;
  }

  #settings-window {
    bottom: 86px;
    right: 750px;
    width: 150px;
  }

  #guide-window {
    bottom: 86px;
    right: 8px;
    width: 240px;
  }
}

/* ── Portrait mode (phones held vertically) ── */
@media (max-width: 600px) and (orientation: portrait) {
  #top-bar {
    margin-left: 0.5rem;
    gap: 3px;
  }

  #pos {
    padding: 0.15rem 0.35rem;
    font-size: 0.55rem;
    min-width: 45px;
  }

  .toggle-btn {
    padding: 0.15rem 0.35rem;
    font-size: 0.45rem;
  }

  #hud {
    height: auto;
    flex-direction: column;
    padding: 0 6px 6px;
    padding-bottom: max(6px, env(safe-area-inset-bottom));
    gap: 4px;
  }

  .hud-panel-inner {
    padding: 5px 8px;
    border-radius: 5px;
  }

  /* ── Top row: character info — horizontal compact bar ── */
  #hud-left {
    width: 100%;
    order: 1;
  }

  #hud-left .hud-panel-inner {
    flex-direction: row;
    align-items: center;
    gap: 8px;
    padding: 4px 8px;
  }

  #hud-left .char-header {
    margin-bottom: 0;
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
    flex-shrink: 0;
    min-width: 60px;
  }

  #hud-left .char-name {
    font-size: 0.65rem;
  }

  #hud-left .char-level {
    font-size: 0.5rem;
  }

  #hud-left .bar-group {
    flex: 1;
    margin-bottom: 0;
    gap: 2px;
    min-width: 0;
  }

  #hud-left .bar {
    height: 8px;
  }

  #hud-left .bar-label {
    font-size: 0.5rem;
    width: 14px;
  }

  #hud-left .bar-row {
    gap: 4px;
  }

  #hud-left .bar-text {
    font-size: 0.4rem;
  }

  #hud-left .char-stats {
    display: none;
  }

  /* ── Middle: chat — short 3-line log ── */
  #hud-center {
    width: 100%;
    order: 2;
  }

  #hud-center .hud-panel-inner {
    padding: 3px 8px;
  }

  .chat-tabs {
    display: none;
  }

  .chat-log {
    max-height: 42px;
    font-size: 0.5rem;
    line-height: 1.25;
  }

  /* ── Bottom: action bar — single row across full width ── */
  #hud-right {
    width: 100%;
    order: 3;
  }

  #hud-right .hud-panel-inner {
    padding: 4px 6px;
  }

  .menu-row { gap: 2px; margin-bottom: 2px; }
  .menu-btn { width: 28px; height: 22px; }
  .menu-icon { font-size: 0.65rem; }

  .hotkey-bar {
    gap: 3px;
  }

  .hotkey-slot {
    flex: 1;
    width: auto;
    height: 36px;
    min-width: 0;
  }

  .slot-key {
    font-size: 0.35rem;
  }

  .slot-icon {
    font-size: 0.85rem;
  }

  #skills-window {
    bottom: auto;
    top: 50%;
    right: 8px;
    left: auto;
    transform: translateY(-50%);
    width: 180px;
  }

  .skills-body {
    max-height: calc(100vh - 180px);
  }

  #skill-detail-panel {
    bottom: auto;
    top: 50%;
    right: 194px;
    left: auto;
    transform: translateY(-50%);
    width: 155px;
  }

  .skill-detail-body {
    max-height: calc(100vh - 200px);
  }

  .skill-detail-name { font-size: 0.65rem; }
  .skill-detail-level { font-size: 0.5rem; }
  .skill-detail-stat { font-size: 0.55rem; }
  .skill-detail-special { font-size: 0.5rem; }
  .skill-detail-meta-label { font-size: 0.5rem; }
  .skill-detail-meta-value { font-size: 0.55rem; }
  .skill-detail-type-badge { font-size: 0.5rem; }
  .skill-detail-icon-img { width: 24px; height: 24px; }

  #inventory-window {
    bottom: auto;
    top: 50%;
    left: 50%;
    right: auto;
    transform: translate(-50%, -50%);
    width: 240px;
  }

  /* When bag or chest is open, shift inventory down so both fit vertically */
  #inventory-window.has-secondary {
    top: auto;
    bottom: 140px;
    transform: translateX(-50%);
  }

  #inventory-window.has-secondary .inv-grid {
    max-height: 35vh;
    overflow-y: auto;
  }

  #bag-window {
    bottom: auto;
    top: 80px;
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    width: 240px;
    max-height: 35vh;
    overflow-y: auto;
  }

  #chest-window {
    bottom: auto;
    top: 80px;
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    width: 240px;
    max-height: 35vh;
    overflow-y: auto;
  }

  #minimap-overlay {
    max-width: calc(100vw - 16px);
  }

  #minimap-canvas {
    width: calc(100vw - 24px);
    height: auto;
    aspect-ratio: 1;
  }

  #status-window {
    bottom: auto;
    top: 50%;
    left: 50%;
    right: auto;
    transform: translate(-50%, -50%);
    width: 220px;
  }

  #equip-window {
    bottom: auto;
    top: 50%;
    left: 50%;
    right: auto;
    transform: translate(-50%, -50%);
    width: 220px;
  }

  #social-window {
    bottom: auto;
    top: 50%;
    left: 50%;
    right: auto;
    transform: translate(-50%, -50%);
    width: 200px;
  }

  #settings-window {
    bottom: auto;
    top: 50%;
    left: 50%;
    right: auto;
    transform: translate(-50%, -50%);
    width: 200px;
  }

  #guide-window {
    bottom: auto;
    top: 50%;
    left: 50%;
    right: auto;
    transform: translate(-50%, -50%);
    width: 280px;
  }

  #housing-overview {
    bottom: auto;
    top: 50%;
    left: 50%;
    right: auto;
    transform: translate(-50%, -50%);
    width: 220px;
  }
}

/* ── Very narrow portrait (iPhone SE, small screens) ── */
@media (max-width: 380px) and (orientation: portrait) {
  #hud {
    padding: 0 4px 4px;
    gap: 3px;
  }

  #hud-left .hud-panel-inner {
    gap: 6px;
    padding: 3px 6px;
  }

  #hud-left .bar-text {
    display: none;
  }

  .chat-log {
    max-height: 32px;
    font-size: 0.45rem;
  }

  .hotkey-slot {
    height: 30px;
  }

  .menu-btn { width: 24px; height: 18px; }

  .slot-key {
    display: none;
  }

  #skill-detail-panel {
    display: none !important;
  }

  #skills-window {
    width: 160px;
  }
}

/* ── Login Modal ── */
#login-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}
#login-modal.hidden { display: none; }

.login-backdrop {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
}

.login-dialog {
  position: relative;
  background: linear-gradient(180deg, rgba(20, 20, 40, 0.98) 0%, rgba(10, 10, 25, 0.99) 100%);
  border: 1px solid #3a3a5a;
  border-radius: 10px;
  padding: 32px 40px;
  text-align: center;
  min-width: 280px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.login-title {
  color: #e2e8f0;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.login-subtitle {
  color: #64748b;
  font-size: 0.75rem;
  margin-bottom: 24px;
}

.login-error {
  color: #fca5a5;
  font-size: 0.7rem;
  background: rgba(220, 38, 38, 0.15);
  border: 1px solid rgba(220, 38, 38, 0.3);
  border-radius: 4px;
  padding: 6px 10px;
  margin-bottom: 16px;
}
.login-error.hidden { display: none; }

.login-invite-row {
  margin-bottom: 16px;
}
.login-invite-row.hidden { display: none; }
.login-invite-input {
  width: 100%;
  box-sizing: border-box;
  padding: 9px 12px;
  background: rgba(30, 30, 50, 0.8);
  border: 1px solid #475569;
  border-radius: 6px;
  color: #e2e8f0;
  font-size: 0.85rem;
  font-family: inherit;
  letter-spacing: 0.1em;
  text-align: center;
  text-transform: uppercase;
}
.login-invite-input::placeholder {
  color: #64748b;
  text-transform: none;
  letter-spacing: normal;
}
.login-invite-input:focus {
  outline: none;
  border-color: #6366f1;
}

.login-disclaimer {
  color: #fbbf24;
  font-size: 0.7rem;
  font-weight: 600;
  text-align: center;
  margin-top: 16px;
}
.login-disclaimer-minor {
  color: #94a3b8;
  font-size: 0.65rem;
  text-align: center;
  margin-top: 4px;
}

.login-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.login-btn {
  padding: 10px 20px;
  border: none;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}
.login-btn:hover { transform: translateY(-1px); }
.login-btn:active { transform: translateY(0); }

.login-btn-guest {
  background: rgba(51, 65, 85, 0.8);
  color: #cbd5e1;
  border: 1px solid #475569;
}
.login-btn-guest:hover { background: rgba(71, 85, 105, 0.9); }

.login-btn-google {
  background: #ffffff;
  color: #3c4043;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.login-btn-google:hover { background: #f8f9fa; }

.google-icon { flex-shrink: 0; }

/* ── Server Select Modal ── */
#server-select-modal {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
}
#server-select-modal.hidden { display: none; }

.server-select-dialog { min-width: 340px; }

.server-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 300px;
  overflow-y: auto;
  margin-bottom: 12px;
}

.server-entry {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid #334155;
  border-radius: 6px;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}
.server-entry:hover { background: rgba(30, 41, 59, 0.8); }
.server-entry.selected {
  border-color: #6366f1;
  background: rgba(99, 102, 241, 0.1);
}
.server-entry.offline {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

.server-name {
  color: #e2e8f0;
  font-size: 0.85rem;
  font-weight: 700;
}

.server-has-char {
  color: #4ade80;
  font-size: 0.65rem;
  margin-left: 6px;
}

.server-meta {
  text-align: right;
  color: #94a3b8;
  font-size: 0.7rem;
  white-space: nowrap;
}

.server-ping-green { color: #4ade80; }
.server-ping-yellow { color: #facc15; }
.server-ping-red { color: #f87171; }

/* Settings: Link Google button */
.settings-btn {
  background: rgba(51, 65, 85, 0.6);
  color: #cbd5e1;
  border: 1px solid #475569;
  border-radius: 4px;
  padding: 4px 12px;
  font-size: 0.6rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s;
  width: 100%;
}
.settings-btn:hover { background: rgba(71, 85, 105, 0.7); }
.settings-btn.hidden { display: none; }

.account-provider-badge {
  font-size: 0.55rem;
  font-weight: 700;
  color: #e2e8f0;
  background: rgba(66, 133, 244, 0.35);
  border: 1px solid rgba(66, 133, 244, 0.5);
  border-radius: 3px;
  padding: 1px 6px;
  letter-spacing: 0.03em;
}
.account-guest-label {
  color: #64748b;
  font-style: italic;
}

/* ── Google Account Conflict Dialog ── */
.google-conflict-overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 1001;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
}

.google-conflict-dialog {
  background: linear-gradient(180deg, rgba(20, 20, 40, 0.98) 0%, rgba(10, 10, 25, 0.99) 100%);
  border: 1px solid #3a3a5a;
  border-radius: 10px;
  padding: 24px 28px;
  max-width: 340px;
  width: 90%;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.google-conflict-title {
  color: #facc15;
  font-size: 0.9rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 10px;
}

.google-conflict-msg {
  color: #94a3b8;
  font-size: 0.65rem;
  text-align: center;
  margin-bottom: 16px;
  line-height: 1.5;
}

.google-conflict-option {
  background: rgba(30, 30, 55, 0.6);
  border: 1px solid #2a2a4a;
  border-radius: 6px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.google-conflict-option-label {
  color: #e2e8f0;
  font-size: 0.75rem;
  font-weight: 700;
}

.google-conflict-option-desc {
  color: #64748b;
  font-size: 0.55rem;
  line-height: 1.4;
}

.google-conflict-btn {
  padding: 8px 16px;
  border: none;
  border-radius: 5px;
  font-size: 0.65rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  width: 100%;
  margin-top: 4px;
}
.google-conflict-btn:hover:not(:disabled) { transform: translateY(-1px); }
.google-conflict-btn:active:not(:disabled) { transform: translateY(0); }
.google-conflict-btn:disabled { opacity: 0.5; cursor: default; }

.google-conflict-btn-keep {
  background: rgba(74, 222, 128, 0.2);
  color: #4ade80;
  border: 1px solid rgba(74, 222, 128, 0.4);
}
.google-conflict-btn-keep:hover:not(:disabled) {
  background: rgba(74, 222, 128, 0.3);
}

.google-conflict-btn-switch {
  background: rgba(96, 165, 250, 0.2);
  color: #60a5fa;
  border: 1px solid rgba(96, 165, 250, 0.4);
}
.google-conflict-btn-switch:hover:not(:disabled) {
  background: rgba(96, 165, 250, 0.3);
}

.google-conflict-divider {
  color: #475569;
  font-size: 0.6rem;
  text-align: center;
  margin: 10px 0;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.google-conflict-cancel {
  display: block;
  margin: 14px auto 0;
  background: none;
  border: none;
  color: #64748b;
  font-size: 0.6rem;
  cursor: pointer;
  padding: 4px 12px;
  transition: color 0.15s;
}
.google-conflict-cancel:hover { color: #94a3b8; }

.rename-warning {
  color: #f59e0b;
  font-size: 0.55rem;
  font-style: italic;
  padding: 2px 8px 4px;
}
.rename-input-row {
  display: flex;
  gap: 4px;
  padding: 0 8px 4px;
}
.rename-input {
  flex: 1;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid #475569;
  border-radius: 4px;
  color: #e2e8f0;
  font-size: 0.6rem;
  padding: 4px 8px;
  outline: none;
}
.rename-input:focus { border-color: #60a5fa; }
.rename-btn { width: auto; flex-shrink: 0; }
.rename-error {
  color: #f87171;
  font-size: 0.55rem;
  padding: 0 8px 4px;
}
.rename-error.hidden { display: none; }
