/* css/dungeon.css */

/* ── Dungeon Variables ── */
:root {
  --dungeon-bg: #080c14;
  --dungeon-surface: #0e1420;
  --dungeon-border: rgba(255,255,255,0.07);
  --dungeon-text: #c8d4e8;
  --dungeon-muted: rgba(200,212,232,0.4);
  --dungeon-accent: #7c3aed;
  --dungeon-gold: #f1c40f;
  --dungeon-danger: #e74c3c;
  --dungeon-success: #2ecc71;
  --dungeon-token: #f39c12;
}

/* ── Tower Entry ── */
.dungeon-tower-entry {
  background: var(--dungeon-surface);
  border: 1px solid var(--dtheme, #7c3aed);
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 0 30px var(--dglow, rgba(124,58,237,0.2));
  margin-bottom: 16px;
}
.dungeon-tower-top {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 16px;
}
.dungeon-tower-icon {
  font-size: 3rem;
}
.dungeon-tower-info {
  flex: 1;
}
.dungeon-tower-next {
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--dungeon-border);
  border-radius: 10px;
  padding: 14px;
  margin-top: 12px;
}

/* ── Floor Preview ── */
.dungeon-floor-history {
  margin-top: 8px;
}
.dungeon-floor-preview-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
}
.dungeon-floor-preview-card {
  flex: 0 0 auto;
  width: 150px;
  background: var(--dungeon-surface);
  border: 1px solid var(--card-accent, rgba(255,255,255,0.1));
  border-radius: 12px;
  overflow: hidden;
  transition: transform 0.15s;
}
.dungeon-floor-preview-card:hover {
  transform: translateY(-2px);
  border-color: var(--card-accent);
}
.fp-banner {
  position: relative;
  width: 100%;
  min-height: 80px;
  height: 80px;
  overflow: hidden;
  background: var(--dungeon-bg);
  border-bottom: 1px solid var(--dungeon-border);
}
.fp-banner img {
  position: absolute;
  top: 0;
  left: 0;
  width: 150px;
  height: 80px;
  object-fit: cover;
}
.fp-floor-badge {
  position: absolute;
  top: 4px;
  left: 4px;
  z-index: 2;
  background: rgba(0,0,0,0.7);
  color: var(--card-accent, #fff);
  font-size: 0.6rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.04em;
}
.fp-name {
  font-size: 0.7rem;
  font-weight: 700;
  color: #e2e8f0;
  text-align: center;
  padding: 6px 6px 2px;
  text-shadow: 0 0 10px var(--card-accent);
}
.fp-stats {
  display: flex;
  justify-content: center;
  gap: 6px;
  padding: 2px 6px 7px;
  font-size: 0.6rem;
  color: var(--dungeon-muted);
}

/* ── Wrapper ── */
.dungeon-wrapper {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-bottom: 32px;
}

/* ============================================================
   Game Window / HUD layout
   ============================================================ */
.dungeon-game {
  border-radius: 16px;
  overflow: hidden;
}

.dungeon-game-screen {
  position: relative;
  /*
    Keep this as a single "scene" block with no inner scrolling.
    Make it tall enough that the page (tab-content-area) scrolls instead of the room creating a nested scrollbox.
  */
  height: clamp(720px, 92vh, 980px);
  background: #05070c;
  border: 1px solid var(--dungeon-border);
  border-radius: 16px;
  overflow-x: hidden;
  /* Never allow this element to become a scroll container (mobile/iOS shows a separate scrollbar). */
  overflow-y: hidden;
  overflow-y: clip;
  box-shadow: 0 0 30px var(--dglow, rgba(124,58,237,0.2));
}

.dungeon-game-scene {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(1.02);
  filter: saturate(1.05) contrast(1.05);
  z-index: 0;
}

.dungeon-game-scene-fallback {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(1200px 600px at 50% 20%, rgba(124,58,237,0.15), transparent 60%),
    linear-gradient(180deg, rgba(0,0,0,0.2), rgba(0,0,0,0.75));
  z-index: 0;
}

.dungeon-game-vignette {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(900px 420px at 50% 40%, rgba(0,0,0,0.15), rgba(0,0,0,0.7)),
    linear-gradient(180deg, rgba(0,0,0,0.15), rgba(0,0,0,0.55));
  pointer-events: none;
  z-index: 1;
}

.dungeon-hud-top {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  min-height: 48px;
  border-radius: 12px;
  background: rgba(6, 10, 18, 0.85);
  border: 1px solid rgba(255,255,255,0.08);
  backdrop-filter: blur(10px);
  /* Keep HUD actions above the central room card on Safari/WebKit. */
  z-index: 60;
  box-sizing: border-box;
}

.dungeon-hud-title {
  font-family: 'Cinzel Decorative', serif;
  color: #e2e8f0;
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 55%;
}

.dungeon-hud-floor {
  color: var(--dungeon-muted);
  font-size: 0.8rem;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  padding: 4px 10px;
  border-radius: 999px;
}

.dungeon-hud-actions {
  display: inline-flex;
  gap: 8px;
  align-items: center;
}

.dungeon-btn-hud {
  padding: 6px 10px;
  font-size: 0.75rem;
  border-radius: 10px;
  background: rgba(255,255,255,0.04);
  border-color: rgba(255,255,255,0.12);
  color: #e2e8f0;
  cursor: pointer;
}

.dungeon-hud-log-inline {
  flex: 1;
  font-size: 0.75rem;
  color: rgba(200, 212, 232, 0.55);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 8px;
  min-width: 0; /* important for flex truncation to work */
}

.dungeon-hud-log-inline .dungeon-log-entry {
  display: none;
}

.dungeon-hud-log-inline .dungeon-log-entry:first-child {
  display: block;
  border: none;
  padding: 0;
}

.dungeon-hud-minimap {
  position: absolute;
  left: 12px;
  bottom: 12px;
  width: clamp(140px, 32vw, 240px);
  padding: 10px 10px;
  border-radius: 12px;
  background: rgba(6, 10, 18, 0.85);
  border: 1px solid rgba(255,255,255,0.08);
  backdrop-filter: blur(10px);
  /* Keep the minimap under the central room card (so it never covers boss buttons). */
  z-index: 30;
}

.dungeon-minimap {
  width: 100%;
}

.dungeon-minimap .dungeon-maze-svg {
  display: block;
  width: 100%;
  height: auto;
}

.dungeon-hud-minimap-title {
  font-size: 0.7rem;
  color: rgba(200,212,232,0.6);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
}

.dungeon-minimap .dungeon-grid-inner {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 4px;
  width: 100%;
}

.dungeon-minimap {
  /* Avoid nested scrollbars inside the dungeon room; scale content instead. */
  overflow: hidden;
}

.map-room-player {
  animation: player-pulse 1.5s ease-in-out infinite;
  box-shadow: 0 0 8px var(--dtheme, #7c3aed);
}

@keyframes player-pulse {
  0%, 100% {
    box-shadow: 0 0 4px var(--dtheme, #7c3aed);
  }
  50% {
    box-shadow: 0 0 12px var(--dtheme, #7c3aed);
  }
}

/* Warning text for multiple enemies */
.monster-warning {
  animation: warning-pulse 1s ease-in-out infinite;
}

@keyframes warning-pulse {
  0%, 100% {
    opacity: 0.7;
  }
  50% {
    opacity: 1;
  }
}

.dungeon-minimap .map-room,
.dungeon-minimap .map-void {
  width: 20px;
  height: 20px;
  border-radius: 999px;
  font-size: 0.72rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.dungeon-minimap .map-room-player {
  border-width: 2px;
}

.dungeon-hud-center {
  position: absolute;
  /* More robust than top/% transforms on Safari/WebKit: center within a fixed inset box. */
  left: 12px;
  right: 12px;
  top: 64px;
  bottom: 96px;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: none;
  width: auto;
  pointer-events: none;
  /* Central card should never cover the top HUD actions. */
  z-index: 50;
  max-height: none;
  overflow-x: clip;
}

.dungeon-hud-room {
  pointer-events: auto;
  padding: 14px 14px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.08);
  backdrop-filter: blur(10px);
  max-width: 100%;
  box-sizing: border-box;
  position: relative;
  z-index: 2;
}

.dungeon-hud-room-info {
  position: relative;
  z-index: 3;
}

.dungeon-hud-room-title {
  font-family: 'Cinzel', serif;
  color: #e2e8f0;
  font-size: 0.9rem;
  margin-bottom: 6px;
}

.dungeon-hud-room-id {
  color: var(--dungeon-muted);
  font-weight: 500;
  font-size: 0.82rem;
}

.dungeon-hud-room-desc {
  color: rgba(200,212,232,0.75);
  font-style: italic;
  line-height: 1.5;
  font-size: clamp(0.75rem, 2.2vw, 0.88rem);
  margin-bottom: 10px;
}

.dungeon-hud-room-progress {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 10px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(12, 20, 34, 0.82);
  border: 1px solid rgba(255,255,255,0.08);
  color: rgba(223, 235, 255, 0.88);
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.dungeon-hud-room-log {
  display: none;
  margin-bottom: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(8, 16, 28, 0.82);
  border: 1px solid rgba(125, 187, 255, 0.18);
  color: rgba(223, 235, 255, 0.88);
  font-size: 0.72rem;
  line-height: 1.35;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.dungeon-hud-room-log span {
  display: inline-block;
  padding-left: 100%;
  animation: dungeon-log-scroll 12s linear infinite;
}
@keyframes dungeon-log-scroll {
  0% { transform: translate(0, 0); }
  100% { transform: translate(-100%, 0); }
}

.dungeon-hud-room-info {
  position: relative;
  z-index: 1;
}
.dungeon-hud-room-info .dungeon-room-monster,
.dungeon-hud-room-info .dungeon-boss-room,
.dungeon-hud-room-info .dungeon-room-clear {
  background: transparent;
  border: none;
  padding: 0;
}

.dungeon-hud-bottom {
  position: absolute;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  width: min(760px, 96vw);
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
  pointer-events: none;
  /* Keep travel bar/buttons above the minimap when they overlap (mobile/WebKit). */
  z-index: 70;
}

.dungeon-travel-bar-wrap-hud {
  width: min(560px, 86vw);
  pointer-events: none;
}

.dungeon-path-options {
  pointer-events: auto;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  padding: 12px 12px;
  border-radius: 14px;
  background: rgba(6, 10, 18, 0.85);
  border: 1px solid rgba(255,255,255,0.08);
  backdrop-filter: blur(10px);
}

.dungeon-path-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 0;
  width: 60px;
  min-width: 60px;
  min-height: 52px;
  border-radius: 14px;
  background: transparent;
  border: none;
  box-shadow: none;
  color: #e2e8f0;
  cursor: pointer;
  transition: transform 0.15s, opacity 0.15s;
  font-size: 0;
  font-family: inherit;
}

.dungeon-path-btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  line-height: 1;
  font-size: 1rem;
}

.dungeon-path-btn-arrow-img {
  width: calc(100% - 2px);
  height: calc(100% - 2px);
  object-fit: cover;
  display: block;
  border-radius: 14px;
  border: 1px solid rgba(184, 201, 226, 0.18);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.05),
    0 8px 18px rgba(0,0,0,0.22);
  filter: saturate(1.02) contrast(1.04);
}

.dungeon-path-btn-text {
  display: none;
}

.dungeon-path-btn-roomno {
  display: none;
}

.dungeon-path-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  opacity: 0.9;
}

.dungeon-path-btn:hover:not(:disabled) .dungeon-path-btn-arrow-img {
  border-color: rgba(212, 224, 244, 0.28);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.08),
    0 10px 22px rgba(0,0,0,0.28);
}

.dungeon-path-btn.has-monster {
  filter: drop-shadow(0 0 8px rgba(231, 76, 60, 0.18));
}

.dungeon-path-btn.has-monster:hover {
  opacity: 1;
}

.dungeon-path-btn.is-boss {
  filter: drop-shadow(0 0 10px rgba(241,196,15,0.18));
}

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

.dungeon-overlay {
  position: fixed;
  /* Sit below the global topbar so it's not covered/cut off. */
  top: calc(var(--topbar-h, 64px) + env(safe-area-inset-top, 0px));
  left: 0;
  right: 0;
  bottom: env(safe-area-inset-bottom, 0px);
  display: none;
  align-items: flex-start;
  justify-content: center;
  /* Must sit above sidebar hubs (z-index: 9999), topbar (200), and chat widget (6000). */
  z-index: 20000;
  /* Single scroll surface for the whole overlay. */
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 28px 20px 20px;
  box-sizing: border-box;
}

.dungeon-overlay:has(.dungeon-overlay-card) {
  display: flex;
}

.dungeon-overlay-backdrop {
  /* Backdrop should stay fixed while the overlay content scrolls. */
  position: fixed;
  top: calc(var(--topbar-h, 64px) + env(safe-area-inset-top, 0px));
  left: 0;
  right: 0;
  bottom: env(safe-area-inset-bottom, 0px);
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(4px);
  z-index: 19999;
}

/* Full-screen overlays (combat, guild) — no topbar offset. */
.dungeon-overlay:has(.dungeon-combat-panel),
.dungeon-overlay.guild-active {
  top: 50px;
  bottom: 0;
  padding-top: max(12px, env(safe-area-inset-top, 0px));
  padding-bottom: max(12px, env(safe-area-inset-bottom, 0px));
  z-index: 400000;
}

.dungeon-overlay:has(.dungeon-combat-panel) .dungeon-overlay-backdrop,
.dungeon-overlay.guild-active .dungeon-overlay-backdrop {
  top: 0;
  bottom: 0;
}

.dungeon-overlay-card {
  position: relative;
  z-index: 20001;
  width: min(720px, 92vw);
  margin: auto;
}

.guild-overlay-card {
  position: relative;
  z-index: 20001;
  width: min(880px, 94vw);
  margin: auto;
}

.guild-container {
  /* Let the overlay itself scroll; avoid nested scroll containers. */
  max-height: none;
  overflow: visible;
  padding: 18px;
  background: var(--dungeon-surface);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 16px;
}

.guild-header {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: space-between;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--dungeon-border);
  margin-bottom: 14px;
}

.guild-icon {
  font-size: 1.8rem;
}

.guild-title {
  font-family: 'Cinzel Decorative', serif;
  color: #e2e8f0;
  font-size: 1.05rem;
}

.guild-subtitle {
  color: var(--dungeon-muted);
  font-size: 0.78rem;
  margin-top: 2px;
}

.guild-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.guild-stat-card {
  display: flex;
  gap: 10px;
  align-items: center;
  background: rgba(0,0,0,0.25);
  border: 1px solid var(--dungeon-border);
  border-radius: 12px;
  padding: 12px;
}

.guild-stat-icon {
  font-size: 1.6rem;
}

.guild-stat-label {
  color: var(--dungeon-muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.guild-stat-value {
  color: #e2e8f0;
  font-family: 'Cinzel', serif;
  font-size: 1.05rem;
  margin-top: 2px;
}

.guild-stat-rank {
  color: rgba(167,139,250,0.95);
  font-size: 0.78rem;
  margin-top: 2px;
}

.guild-reputation-bar {
  background: rgba(0,0,0,0.25);
  border: 1px solid var(--dungeon-border);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 14px;
}

.rep-bar-label {
  color: var(--dungeon-muted);
  font-size: 0.75rem;
  margin-bottom: 8px;
}

.rep-bar-track {
  height: 8px;
  background: rgba(255,255,255,0.06);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.07);
}

.rep-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--dtheme, #7c3aed), #a78bfa);
}

.rep-bar-text {
  color: var(--dungeon-muted);
  font-size: 0.72rem;
  margin-top: 8px;
}

.guild-section-title {
  color: rgba(200,212,232,0.7);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 8px 0 10px;
}

.exchanges-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 10px;
}

.exchange-card {
  background: rgba(0,0,0,0.22);
  border: 1px solid var(--dungeon-border);
  border-radius: 14px;
  padding: 12px;
  display: flex;
  gap: 12px;
}

.exchange-unavailable {
  opacity: 0.55;
}

.exchange-icon {
  font-size: 2rem;
  width: 44px;
  text-align: center;
}

.exchange-name {
  color: #e2e8f0;
  font-family: 'Cinzel', serif;
  font-size: 0.95rem;
}

.exchange-desc {
  color: var(--dungeon-muted);
  font-size: 0.78rem;
  margin-top: 4px;
}

.exchange-cost,
.exchange-reward {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
  font-size: 0.75rem;
}

.cost-item,
.reward-gold,
.reward-rep,
.reward-item,
.reward-discount {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 999px;
  padding: 3px 10px;
  color: #e2e8f0;
}

.reward-gold { color: var(--dungeon-gold); }
.reward-rep { color: #a78bfa; }
.reward-discount { color: rgba(200,212,232,0.8); }

.exchange-btn {
  margin-top: 12px;
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(124,58,237,0.15);
  border: 1px solid rgba(124,58,237,0.35);
  color: #e2e8f0;
  cursor: pointer;
  font-family: 'Cinzel', serif;
  font-weight: 600;
}

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

.raid-create-card,
.raid-card {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr);
  gap: 14px;
  align-items: stretch;
  padding: 14px;
  background:
    radial-gradient(circle at top left, rgba(124,58,237,0.16), transparent 42%),
    rgba(4, 8, 14, 0.88);
  border: 1px solid rgba(124,58,237,0.18);
  box-shadow: 0 14px 28px rgba(0,0,0,0.22);
}

.raids-grid {
  margin-top: 10px;
  grid-template-columns: 1fr;
}

.raid-card-icon {
  width: 84px;
  min-width: 84px;
  min-height: 84px;
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  align-self: start;
  background:
    linear-gradient(180deg, rgba(124,58,237,0.3), rgba(124,58,237,0.12)),
    rgba(7,12,20,0.92);
  border: 1px solid rgba(196,181,253,0.24);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.05),
    0 10px 22px rgba(0,0,0,0.24);
  color: #efe7ff;
  font-size: 1rem;
  font-family: 'Cinzel', serif;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.raid-card .exchange-info,
.raid-create-card .exchange-info {
  min-width: 0;
}

.raid-card .exchange-name,
.raid-create-card .exchange-name {
  font-size: 1rem;
  line-height: 1.35;
}

.raid-card .exchange-desc,
.raid-create-card .exchange-desc {
  line-height: 1.5;
}

.raid-card .exchange-cost,
.raid-card .exchange-reward,
.raid-create-card .exchange-cost,
.raid-create-card .exchange-reward {
  gap: 8px;
}

.raid-card .cost-item,
.raid-card .reward-item,
.raid-card .reward-gold,
.raid-card .reward-rep,
.raid-create-card .cost-item,
.raid-create-card .reward-item,
.raid-create-card .reward-gold,
.raid-create-card .reward-rep {
  padding: 5px 10px;
  background: rgba(255,255,255,0.06);
}

.dungeon-raid-hub-shell {
  margin-top: 16px;
  padding: 14px;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(8,12,20,0.96), rgba(6,10,18,0.92));
  border: 1px solid rgba(124,58,237,0.18);
  box-shadow: 0 14px 28px rgba(0,0,0,0.2);
}

.dungeon-raid-hub-head {
  margin-bottom: 12px;
}

.dungeon-raid-hub-title {
  font-size: 0.72rem;
  color: rgba(196,181,253,0.86);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.dungeon-raid-hub-subtitle {
  margin-top: 6px;
  color: rgba(200,212,232,0.74);
  font-size: 0.82rem;
}

.raid-create-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.raid-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.raid-field > span {
  font-size: 0.75rem;
  color: var(--text-dim, rgba(255,255,255,0.5));
  display: flex;
  justify-content: space-between;
}

.raid-field > span > span {
  color: var(--text-bright, #e2e8f0);
  font-weight: 600;
}

.raid-field-wide {
  grid-column: 1 / -1;
}

.raid-input {
  width: 100%;
  min-height: 40px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(5,8,14,0.9);
  color: #e2e8f0;
  padding: 8px 10px;
  font-size: 0.82rem;
}

.raid-input[type="range"] {
  appearance: auto;
  -webkit-appearance: auto;
  width: 100%;
  padding: 0;
  margin: 6px 0;
  border: none;
  background: transparent;
  min-height: 20px;
  cursor: default;
  accent-color: #6b7280;
}

/* Dark gray themed custom range slider */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
}

input[type="range"]::-webkit-slider-runnable-track {
  width: 100%;
  height: 6px;
  background: rgba(255,255,255,0.08);
  border-radius: 3px;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #4a4a4a;
  border: 2px solid rgba(255,255,255,0.2);
  cursor: pointer;
  margin-top: -6px;
}

input[type="range"]::-moz-range-track {
  width: 100%;
  height: 6px;
  background: rgba(255,255,255,0.08);
  border-radius: 3px;
}

input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #4a4a4a;
  border: 2px solid rgba(255,255,255,0.2);
  cursor: pointer;
}

input[type="range"]::-ms-track {
  width: 100%;
  height: 6px;
  background: transparent;
  border-color: transparent;
  color: transparent;
}

input[type="range"]::-ms-fill-lower {
  background: rgba(255,255,255,0.12);
  border-radius: 3px;
}

input[type="range"]::-ms-fill-upper {
  background: rgba(255,255,255,0.08);
  border-radius: 3px;
}

input[type="range"]::-ms-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #4a4a4a;
  border: 2px solid rgba(255,255,255,0.2);
  cursor: pointer;
}

.raid-member-leader {
  border-color: rgba(124,58,237,0.4);
  color: #c4b5fd;
}

.raid-summary {
  margin-top: 10px;
  color: rgba(226,232,240,0.92);
}

.raid-setting-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 10px;
}

.raid-inline-input {
  min-width: 140px;
  flex: 1 1 160px;
}

.raid-settings-btn,
.raid-mercenary-btn {
  min-width: 120px;
}

.raid-mercenary-board {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.raid-mercenary-head {
  margin-top: 12px;
  color: #e8eef9;
  font-family: 'Cinzel', serif;
  font-size: 0.84rem;
}

.raid-mercenary-sub {
  margin-top: 4px;
  color: rgba(207, 218, 235, 0.72);
  font-size: 0.72rem;
}

.raid-mercenary-card {
  padding: 10px;
  border-radius: 12px;
  background: rgba(9, 14, 24, 0.92);
  border: 1px solid rgba(255,255,255,0.08);
}

.raid-mercenary-card.is-recruited {
  opacity: 0.65;
  border-color: rgba(46, 204, 113, 0.24);
}

.raid-mercenary-name {
  font-family: 'Cinzel', serif;
  color: #e8eef9;
  font-size: 0.82rem;
  margin-bottom: 6px;
}

.raid-mercenary-stats,
.raid-mercenary-status {
  color: rgba(207, 218, 235, 0.76);
  font-size: 0.72rem;
  line-height: 1.45;
}

.raid-mercenary-status {
  margin-top: 8px;
  color: rgba(46, 204, 113, 0.9);
  font-weight: 700;
}

.raid-result-log {
  margin-top: 10px;
  padding: 10px;
  border-radius: 12px;
  background: rgba(4,7,12,0.72);
  border: 1px solid rgba(255,255,255,0.08);
  max-height: none;
  overflow: visible;
}

.raid-result-line {
  color: rgba(200,212,232,0.8);
  font-size: 0.76rem;
  line-height: 1.38;
}

.raid-status-completed {
  border-color: rgba(46,204,113,0.22);
}

.raid-status-forming {
  border-color: rgba(124,58,237,0.24);
}

@media (max-width: 640px) {
  .raid-create-card,
  .raid-card {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .raid-card-icon {
    width: 100%;
    min-width: 0;
    min-height: 56px;
    border-radius: 14px;
  }

  .raids-grid {
    grid-template-columns: 1fr;
  }

  .raid-create-grid {
    grid-template-columns: 1fr;
  }

  .raid-field-wide {
    grid-column: auto;
  }
}

/* ── Full-screen dungeon combat ─────────────────────────────── */
body.combat-lock #tab-content-area {
  padding-top: 0;
  padding-bottom: 0;
}

.dungeon-overlay:has(.dungeon-combat-panel) {
  top: 0 !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
}

.dungeon-combat-panel {
  height: var(--vph, 100dvh);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.dungeon-combat-panel .combat-header {
  flex-shrink: 0;
}

.dungeon-combat-panel .combat-fighters {
  flex: 0 1 auto;
  overflow-y: auto;
  min-height: 0;
  max-height: 45vh;
}

.dungeon-combat-panel .combat-log {
  flex: 0 0 auto !important;
  overflow-y: auto !important;
  height: 120px !important;
  max-height: 120px !important;
  min-height: 60px !important;
  margin-bottom: 0;
}

.dungeon-combat-panel .combat-actions {
  flex-shrink: 0;
  position: sticky;
  bottom: 0;
  background: var(--dungeon-surface);
  padding: 12px 0 0;
  margin-top: auto;
}

/* ── Topbar ── */
.dungeon-topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 16px 20px;
  background: var(--dungeon-surface);
  border: 1px solid var(--dungeon-border);
  border-radius: 14px;
}
.dungeon-title-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}
.dungeon-title-icon {
  font-size: 2rem;
}
.dungeon-title-text {
  font-family: 'Cinzel Decorative', serif;
  font-size: 1.25rem;
  color: #e2e8f0;
  letter-spacing: 0.05em;
}
.dungeon-title-sub {
  font-size: 0.75rem;
  color: var(--dungeon-muted);
  margin-top: 2px;
}
.dungeon-token-wrap {
    display: flex;
    flex-wrap: wrap;  /* This allows the pills to stack on mobile */
    gap: 12px;
    align-items: center;
}
.dungeon-token-pill {
    display: flex;  /* Changed from inline-flex */
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: rgba(243, 156, 18, 0.1);
    border: 1px solid rgba(243, 156, 18, 0.3);
    border-radius: 20px;
    padding: 6px 14px;
    font-size: 0.85rem;
    color: var(--dungeon-token);
    white-space: nowrap;  /* Prevent text wrapping inside pill */
}

/* Mobile fix */
@media (max-width: 768px) {
    .dungeon-token-pill {
        padding: 4px 10px;
        font-size: 0.75rem;
        gap: 4px;
    }
    
    .dungeon-token-wrap {
        flex-wrap: wrap;  /* Allow pills to wrap to next line */
        gap: 8px;
    }
}
.dungeon-token-num {
  font-weight: 700;
  font-size: 1.1rem;
}
.dungeon-token-hint {
  font-size: 0.7rem;
  color: var(--dungeon-muted);
  margin-top: 4px;
}

/* ── Dungeon List ── */
.dungeon-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.dungeon-card {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 18px 20px;
  background: var(--dungeon-surface);
  border: 1px solid var(--dungeon-border);
  border-radius: 14px;
  transition: border-color 0.2s, box-shadow 0.2s;
  position: relative;
  overflow: hidden;
}
.dungeon-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--dtheme, #7c3aed);
  box-shadow: 0 0 16px var(--dglow, rgba(124,58,237,0.4));
}
.dungeon-card:not(.dungeon-card-locked):hover {
  border-color: var(--dtheme, #7c3aed);
  box-shadow: 0 0 24px var(--dglow, rgba(124,58,237,0.2));
}
.dungeon-card-locked {
  opacity: 0.5;
  filter: grayscale(0.4);
}
.dungeon-card-icon {
  font-size: 2.5rem;
  min-width: 48px;
  text-align: center;
  margin-top: 4px;
}
.dungeon-card-info {
  flex: 1;
}
.dungeon-card-name {
  font-family: 'Cinzel', serif;
  font-size: 1.1rem;
  color: #e2e8f0;
  margin-bottom: 4px;
}
.dungeon-card-desc {
  font-size: 0.8rem;
  color: var(--dungeon-muted);
  margin-bottom: 8px;
}
.dungeon-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 0.75rem;
  color: var(--dungeon-muted);
  margin-bottom: 8px;
}
.dungeon-save-badge {
  color: var(--dungeon-token);
  background: rgba(243,156,18,0.1);
  border-radius: 10px;
  padding: 2px 8px;
}
.dungeon-boss-preview {
  font-size: 0.85rem;
  color: var(--dungeon-text);
  margin-bottom: 4px;
}
.dungeon-boss-icon {
  margin-right: 6px;
}
.dungeon-boss-name {
  font-weight: 600;
}
.dungeon-boss-drops {
  font-size: 0.72rem;
  color: var(--dungeon-muted);
}
.dungeon-card-action {
  display: flex;
  align-items: center;
  min-width: 140px;
  justify-content: flex-end;
}

/* ── Buttons ── */
.dungeon-btn {
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid;
  transition: all 0.15s;
  letter-spacing: 0.03em;
  font-family: 'Cinzel', serif;
}
.dungeon-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.dungeon-btn-enter {
  background: rgba(124,58,237,0.15);
  border-color: rgba(124,58,237,0.5);
  color: #a78bfa;
}
.dungeon-btn-enter:hover:not(:disabled) {
  background: rgba(124,58,237,0.3);
}
.dungeon-btn-locked {
  background: rgba(100,100,100,0.1);
  border-color: #555;
  color: #666;
}
.dungeon-btn-exit {
  background: rgba(231,76,60,0.1);
  border-color: rgba(231,76,60,0.3);
  color: #e74c3c;
  font-size: 0.75rem;
  padding: 6px 12px;
}
.dungeon-btn-fight {
  background: rgba(231,76,60,0.15);
  border-color: rgba(231,76,60,0.4);
  color: #e74c3c;
}
.dungeon-btn-fight:hover:not(:disabled) {
  background: rgba(231,76,60,0.3);
}
.dungeon-btn-run {
  background: rgba(52,152,219,0.1);
  border-color: rgba(52,152,219,0.3);
  color: #3498db;
}
.dungeon-btn-run:hover:not(:disabled) {
  background: rgba(52,152,219,0.25);
}
.boss-fight-btn {
  width: 100%;
  margin-top: 12px;
  padding: 10px;
  font-size: 0.9rem;
  border-color: rgba(241,196,15,0.5);
  background: rgba(241,196,15,0.08);
  color: var(--dungeon-gold);
}
.boss-fight-btn:hover:not(:disabled) {
  background: rgba(241,196,15,0.2);
  box-shadow: 0 0 20px rgba(241,196,15,0.15);
}

/* ── Active Dungeon ── */
.dungeon-active {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.dungeon-active-header {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 12px 16px;
  background: var(--dungeon-surface);
  border: 1px solid var(--dungeon-border);
  border-radius: 12px;
}
.dungeon-active-name {
  font-family: 'Cinzel Decorative', serif;
  font-size: 1.1rem;
  color: #e2e8f0;
  flex: 1;
}
.dungeon-active-floor {
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--dungeon-border);
  border-radius: 8px;
  padding: 4px 12px;
  font-size: 0.8rem;
  color: var(--dungeon-muted);
}

/* ── Travel bar ── */
.dungeon-travel-bar-wrap {
  height: 4px;
  background: rgba(255,255,255,0.05);
  border-radius: 2px;
  overflow: hidden;
}
.dungeon-travel-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--dtheme, #7c3aed), #a78bfa);
  border-radius: 2px;
}

/* ── Content row ── */
.dungeon-content-row {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}
.dungeon-map-wrap {
  flex: 0 0 auto;
}
.dungeon-map-label {
  font-size: 0.72rem;
  color: var(--dungeon-muted);
  margin-bottom: 8px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.dungeon-room-panel {
  flex: 1;
  min-width: 240px;
  background: var(--dungeon-surface);
  border: 1px solid var(--dungeon-border);
  border-radius: 12px;
  padding: 16px;
}

/* ── Map Grid ── */
.dungeon-map-grid {
  background: rgba(0,0,0,0.4);
  border: 1px solid var(--dungeon-border);
  border-radius: 10px;
  padding: 10px;
}
.dungeon-grid-inner {
  display: grid;
  gap: 5px;
}
.map-room, .map-void {
  width: 38px;
  height: 38px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  transition: all 0.2s;
}
.map-void {
  background: transparent;
}
.map-room-fog {
  background: transparent;
  border: none;
  box-shadow: none;
  color: transparent;
  opacity: 0;
}
.map-room-discovered {
  background: rgba(160, 174, 192, 0.22);
  border: 1px solid rgba(190, 205, 224, 0.55);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.05), 0 0 8px rgba(160, 174, 192, 0.18);
  opacity: 1;
}
.map-room-player {
  background: rgba(124,58,237,0.3);
  border: 2px solid var(--dtheme, #7c3aed);
  box-shadow: 0 0 10px var(--dglow);
}
.map-room-boss {
  background: rgba(231,76,60,0.2);
  border: 1px solid rgba(231,76,60,0.5);
  animation: boss-pulse 2s ease-in-out infinite;
}
.map-room-treasure {
  background: rgba(241,196,15,0.15);
  border: 1px solid rgba(241,196,15,0.4);
}
.map-room-miniboss {
  background: rgba(155,89,182,0.15);
  border: 1px solid rgba(155,89,182,0.4);
}
.map-room-area {
  background: rgba(52,152,219,0.1);
  border: 1px solid rgba(52,152,219,0.35);
}
.map-room-monster {
  background: rgba(192,57,43,0.15);
  border: 1px solid rgba(192,57,43,0.45);
}
.map-room-clear {
  background: rgba(39,174,96,0.12);
  border: 1px solid rgba(39,174,96,0.3);
}

/* SVG Maze Map Styles */
.dungeon-maze-svg {
  background: rgba(20, 25, 35, 0.95);
  border-radius: 8px;
}
.dungeon-maze-container {
  display: flex;
  align-items: center;
  justify-content: center;
}
.maze-player-pulse {
  animation: maze-pulse 1.2s ease-in-out infinite;
}
@keyframes maze-pulse {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 0.7; }
}
.map-room.wall-south {
  border-bottom: 2px solid rgba(80, 80, 100, 0.7);
}
.map-room.wall-west {
  border-left: 2px solid rgba(80, 80, 100, 0.7);
}
.map-room.wall-east {
  border-right: 2px solid rgba(80, 80, 100, 0.7);
}
.map-room-monster {
  background: rgba(231,76,60,0.1);
  border: 1px solid rgba(231,76,60,0.25);
}
.map-room-clear {
  background: rgba(46,204,113,0.08);
  border: 1px solid rgba(46,204,113,0.2);
}
.map-room-discovered {
  width: 4px;
  height: 4px;
  background: rgba(241,196,15,0.15);
  border: 1px solid rgba(241,196,15,0.4);
  border-radius: 1px;
}
@keyframes boss-pulse {
  0%, 100% {
    box-shadow: 0 0 4px rgba(231,76,60,0.3);
  }
  50% {
    box-shadow: 0 0 16px rgba(231,76,60,0.6);
  }
}

/* ── Room Panel ── */
.dungeon-room-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.dungeon-room-type {
  font-size: 0.78rem;
  color: var(--dungeon-muted);
}
.dungeon-room-id {
  font-size: 0.72rem;
  color: var(--dungeon-muted);
}
.boss-room-badge {
  color: #e74c3c;
  font-weight: 700;
  animation: boss-pulse 1.5s infinite;
}
.start-room-badge {
  color: #3498db;
}
.treasure-room-badge {
  color: var(--dungeon-gold);
}

/* ── Monster Info ── */
.dungeon-room-monster {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.monster-icon {
  font-size: 2.5rem;
  text-align: center;
}
.monster-name {
  font-family: 'Cinzel', serif;
  font-size: 1rem;
  color: #e2e8f0;
  text-align: center;
}
.monster-hp-bar-wrap {
  height: 6px;
  background: rgba(255,255,255,0.08);
  border-radius: 3px;
  margin: 4px 0;
}
.monster-hp-bar {
  height: 100%;
  background: #e74c3c;
  border-radius: 3px;
  transition: width 0.3s;
}
.monster-stats {
  font-size: 0.75rem;
  color: var(--dungeon-muted);
  text-align: center;
}
.monster-btns {
  display: flex;
  gap: 8px;
  justify-content: center;
}
.stolen-items-notice {
  background: rgba(231,76,60,0.1);
  border: 1px solid rgba(231,76,60,0.25);
  border-radius: 8px;
  padding: 8px;
  font-size: 0.75rem;
  color: #e74c3c;
  text-align: center;
}

/* ── Boss Room ── */
.dungeon-boss-room {
  text-align: center;
}
.boss-icon-big {
  font-size: 3rem;
  margin-bottom: 8px;
}
.boss-name-big {
  font-family: 'Cinzel Decorative', serif;
  font-size: 1.2rem;
  color: #e74c3c;
  margin-bottom: 8px;
}
.boss-stats {
  font-size: 0.8rem;
  color: var(--dungeon-muted);
  margin-bottom: 6px;
}
.boss-drop-preview {
  font-size: 0.75rem;
  color: var(--dungeon-gold);
}

/* ── Connections ── */
.dungeon-connections {
  margin-top: 14px;
  border-top: 1px solid var(--dungeon-border);
  padding-top: 12px;
}
.dungeon-conn-label {
  font-size: 0.7rem;
  color: var(--dungeon-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
}
.dungeon-conn-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 4px 4px 0 0;
  padding: 7px 14px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--dungeon-border);
  border-radius: 8px;
  color: var(--dungeon-text);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.15s;
}
.dungeon-conn-btn:hover:not(:disabled) {
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.15);
}
.dungeon-conn-btn.has-monster {
  border-color: rgba(231,76,60,0.35);
  color: #e74c3c;
}
.dungeon-conn-btn.is-boss {
  border-color: rgba(241,196,15,0.4);
  color: var(--dungeon-gold);
}
.dungeon-conn-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ── Combat Panel ── */
.dungeon-combat-panel {
  background: var(--dungeon-surface);
  border: 1px solid var(--dtheme, #7c3aed);
  border-radius: 0;
  padding: 16px;
  box-shadow: 0 0 30px var(--dglow, rgba(124,58,237,0.2));
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
}

.dungeon-combat-panel .combat-fighters {
  flex: 1;
  min-height: 0;
  overflow: visible;
}

.dungeon-combat-panel .combat-log {
  max-height: 32vh;
}

.dungeon-combat-panel .combat-actions {
  margin-top: auto;
  padding-top: 12px;
  display: flex;
  gap: 12px;
}

.dungeon-combat-panel .combat-actions .dungeon-btn {
  flex: 1;
}
.combat-boss-warning {
  text-align: center;
  color: #e74c3c;
  font-weight: 700;
  letter-spacing: 0.1em;
  font-size: 0.85rem;
  margin-bottom: 4px;
  animation: boss-pulse 1s infinite;
}
.combat-title {
  font-family: 'Cinzel', serif;
  font-size: 1.1rem;
  color: #e2e8f0;
  text-align: center;
  margin-bottom: 16px;
}
.combat-fighters {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 0;
  align-items: flex-start;
  margin-bottom: 12px;
}
.monster-side {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  position: relative;
  min-height: 200px;
}
.deck-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 3;
  background: rgba(0,0,0,0.2);
  border: none;
  color: rgba(201,146,42,0.7);
  font-size: 0.9rem;
  width: 24px;
  height: 80px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.deck-arrow:hover:not(:disabled) {
  background: rgba(0,0,0,0.35);
  color: #c9a64a;
}
.deck-arrow:hover:not(:disabled) {
  background: rgba(0,0,0,0.7);
  border-color: rgba(201,146,42,0.6);
}
.deck-arrow:disabled {
  opacity: 0.2;
  cursor: default;
}
.deck-arrow-left { left: 0; }
.deck-arrow-right { right: 0; }
.deck-counter {
  font-size: 0.7rem;
  color: var(--dungeon-muted, #8b9bb5);
  text-align: center;
}
.monster-combat-card {
  cursor: default;
  transition: all 0.15s ease;
  position: relative;
  overflow: visible;
  width: 130px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.combat-fighters > .fighter-card:first-child {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.combat-fighters .fighter-avatar-splash {
  width: 130px;
  height: 180px;
}
.monster-combat-card .fighter-avatar {
  width: 130px;
  height: 180px;
  border-radius: 10px;
  position: relative;
}
.monster-lore-popup {
  position: absolute;
  z-index: 100;
  top: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%);
  max-width: 220px;
  width: max-content;
  padding: 6px 10px;
  font-size: 0.65rem;
  line-height: 1.4;
  color: rgba(220,200,160,0.95);
  background: rgba(0,0,0,0.85);
  border: 1px solid rgba(200,170,80,0.4);
  border-radius: 6px;
  text-align: left;
  pointer-events: auto;
  cursor: pointer;
}


.fighter-name {
  font-size: 0.85rem;
  color: var(--dungeon-text);
  margin-bottom: 6px;
}
.fighter-hp-bar-wrap {
  height: 8px;
  background: rgba(255,255,255,0.08);
  border-radius: 4px;
  margin-bottom: 4px;
}
.fighter-hp-bar {
  height: 100%;
  border-radius: 4px;
  transition: width 0.4s ease;
}
.player-hp {
  background: linear-gradient(90deg, #2ecc71, #27ae60);
}
.monster-hp {
  background: linear-gradient(90deg, #e74c3c, #c0392b);
}
.fighter-stats {
  font-size: 0.72rem;
  color: var(--dungeon-muted);
}
.combat-log {
  max-height: none;
  overflow: visible;
  padding: 10px 12px;
  background: rgba(0,0,0,0.3);
  border-radius: 8px;
  border: 1px solid var(--dungeon-border);
  margin-bottom: 14px;
}
.combat-log-entry {
  font-size: 0.8rem;
  padding: 3px 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.combat-log-entry.player {
  color: #a78bfa;
}
.combat-log-entry.monster {
  color: #e74c3c;
}
.combat-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

/* ── Dungeon Log ── */
.dungeon-log-panel {
  background: var(--dungeon-surface);
  border: 1px solid var(--dungeon-border);
  border-radius: 12px;
  padding: 14px 16px;
}
.dungeon-log-title {
  font-size: 0.72rem;
  color: var(--dungeon-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 10px;
}
.dungeon-log-entries {
  max-height: none;
  overflow: visible;
}
.dungeon-log-entry {
  font-size: 0.78rem;
  padding: 4px 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  color: var(--dungeon-text);
}
.log-enter {
  color: #a78bfa;
}
.log-travel {
  color: var(--dungeon-muted);
}
.log-arrive {
  color: #3498db;
}
.log-loot {
  color: var(--dungeon-gold);
}
.log-success {
  color: var(--dungeon-success);
}
.log-danger {
  color: var(--dungeon-danger);
}
.log-token {
  color: var(--dungeon-token);
}
.log-boss {
  color: var(--dungeon-gold);
  font-weight: 700;
}
.log-info {
  color: var(--dungeon-muted);
}

/* ── Boss Victory Modal ── */
.dungeon-victory-box {
  text-align: center;
}
.victory-icon {
  font-size: 3.5rem;
  margin-bottom: 8px;
}
.victory-title {
  font-family: 'Cinzel Decorative', serif;
  font-size: 1.6rem;
  color: var(--dungeon-gold);
  text-shadow: 0 0 20px rgba(241,196,15,0.5);
  margin-bottom: 4px;
}
.victory-boss-name {
  font-size: 0.9rem;
  color: var(--dungeon-muted);
  margin-bottom: 16px;
}
.victory-loot {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}
.loot-row {
  font-size: 1rem;
  color: var(--dungeon-text);
}
.victory-next {
  font-size: 0.8rem;
  color: var(--dungeon-muted);
}

/* ── Room clear ── */
.dungeon-room-clear {
  padding: 12px;
  text-align: center;
}

/* ============================================================
   Dungeon Visual Redesign Styles
   ============================================================ */

/* ── Dungeon View Container ───────────────────────────────── */
.dungeon-view {
  background: var(--dungeon-surface);
  border: 1px solid var(--dungeon-border);
  border-radius: 16px;
  overflow: hidden;
  position: relative;
}

/* ── Header ───────────────────────────────────────────────── */
.dungeon-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background: rgba(0, 0, 0, 0.4);
  border-bottom: 1px solid var(--dungeon-border);
}

.dungeon-floor-info {
  display: flex;
  gap: 12px;
  align-items: baseline;
}

.dungeon-floor-badge {
  background: linear-gradient(135deg, var(--dungeon-accent), #a78bfa);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 700;
  color: white;
  letter-spacing: 0.05em;
}

.dungeon-room-type {
  font-size: 0.7rem;
  color: var(--dungeon-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* ── Image Container ──────────────────────────────────────── */
.dungeon-image-container {
  position: relative;
  height: 280px;
  overflow: hidden;
  background: #0a0e17;
}

.dungeon-scene-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.dungeon-scene-image:hover {
  transform: scale(1.02);
}

.dungeon-image-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 80px;
  background: linear-gradient(to top, rgba(8, 12, 20, 0.9), transparent);
  pointer-events: none;
}

/* ── Description ──────────────────────────────────────────── */
.dungeon-description {
  padding: 20px 24px;
  background: rgba(0, 0, 0, 0.3);
  border-bottom: 1px solid var(--dungeon-border);
}

.dungeon-description p {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--dungeon-text);
  font-style: italic;
}

.dungeon-lore-text {
  margin: 6px 0 10px;
  padding: 8px 12px;
  background: rgba(0,0,0,0.35);
  border-left: 3px solid rgba(200,170,80,0.4);
  border-radius: 0 6px 6px 0;
  font-size: 0.72rem;
  line-height: 1.5;
  color: rgba(220,200,160,0.85);
  font-style: italic;
}

/* ── Travel Bar ───────────────────────────────────────────── */
.dungeon-travel-bar-wrap {
  height: 3px;
  background: rgba(255, 255, 255, 0.05);
  overflow: hidden;
}

.dungeon-travel-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--dtheme, #7c3aed), #a78bfa);
  transition: width linear;
}

/* ── Actions Panel ────────────────────────────────────────── */
.dungeon-actions {
  padding: 24px;
}

/* ── Monster Preview ──────────────────────────────────────── */
.monster-preview {
  background: rgba(231, 76, 60, 0.08);
  border: 1px solid rgba(231, 76, 60, 0.3);
  border-radius: 12px;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.monster-preview-icon {
  font-size: 3rem;
  filter: drop-shadow(0 0 8px rgba(231, 76, 60, 0.5));
}

.monster-preview-info {
  flex: 1;
}

.monster-preview-name {
  font-size: 1.1rem;
  font-weight: 700;
  color: #e74c3c;
  font-family: 'Cinzel', serif;
}

.monster-preview-stats {
  font-size: 0.75rem;
  color: var(--dungeon-muted);
  margin-top: 4px;
}

.monster-preview-buttons {
  display: flex;
  gap: 10px;
}

/* ── Boss Preview ─────────────────────────────────────────── */
.boss-preview {
  background: linear-gradient(135deg, rgba(231, 76, 60, 0.15), rgba(155, 89, 182, 0.15));
  border: 2px solid rgba(231, 76, 60, 0.5);
  border-radius: 16px;
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 24px;
  animation: boss-pulse 2s ease-in-out infinite;
}

.boss-preview-icon {
  font-size: 4rem;
  filter: drop-shadow(0 0 12px rgba(231, 76, 60, 0.8));
}

.boss-preview-info {
  flex: 1;
}

.boss-preview-name {
  font-size: 1.3rem;
  font-weight: 800;
  color: #e74c3c;
  font-family: 'Cinzel Decorative', serif;
  text-shadow: 0 0 8px rgba(231, 76, 60, 0.5);
}

.boss-preview-stats {
  font-size: 0.8rem;
  color: var(--dungeon-text);
  margin: 8px 0;
}

.boss-preview-loot {
  font-size: 0.75rem;
  color: var(--dungeon-gold);
}

.dungeon-btn-boss {
  background: linear-gradient(135deg, rgba(231, 76, 60, 0.2), rgba(155, 89, 182, 0.2));
  border-color: rgba(231, 76, 60, 0.6);
  color: #e74c3c;
  padding: 12px 24px;
  font-size: 1rem;
}

.dungeon-btn-boss:hover:not(:disabled) {
  background: linear-gradient(135deg, rgba(231, 76, 60, 0.35), rgba(155, 89, 182, 0.35));
  box-shadow: 0 0 20px rgba(231, 76, 60, 0.3);
}

/* ── Cleared Preview ──────────────────────────────────────── */
.cleared-preview {
  background: rgba(46, 204, 113, 0.08);
  border: 1px solid rgba(46, 204, 113, 0.3);
  border-radius: 12px;
  padding: 20px;
  text-align: center;
  margin-bottom: 24px;
}

.cleared-icon {
  font-size: 3rem;
  margin-bottom: 8px;
}

.cleared-text {
  font-size: 0.9rem;
  color: var(--dungeon-text);
  margin-bottom: 16px;
}

/* ── Treasure Preview ─────────────────────────────────────── */
.treasure-preview {
  background: rgba(241, 196, 15, 0.08);
  border: 1px solid rgba(241, 196, 15, 0.3);
  border-radius: 12px;
  padding: 20px;
  text-align: center;
  margin-bottom: 24px;
}

.treasure-icon {
  font-size: 3rem;
  margin-bottom: 8px;
}

.treasure-text {
  font-size: 0.9rem;
  color: var(--dungeon-gold);
}

/* ── Direction Buttons ────────────────────────────────────── */
.dungeon-directions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
  margin-bottom: 24px;
}

.dungeon-direction-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--dungeon-border);
  border-radius: 40px;
  padding: 10px 20px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--dungeon-text);
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.dungeon-direction-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--dtheme, #7c3aed);
  transform: translateY(-2px);
}

.dungeon-direction-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ── Stairs Button ────────────────────────────────────────── */
.dungeon-btn-stairs {
  background: linear-gradient(135deg, rgba(52, 152, 219, 0.2), rgba(46, 204, 113, 0.2));
  border-color: rgba(52, 152, 219, 0.5);
  color: #3498db;
  width: 100%;
  padding: 14px;
  font-size: 1rem;
  margin-bottom: 24px;
}

.dungeon-btn-stairs:hover:not(:disabled) {
  background: linear-gradient(135deg, rgba(52, 152, 219, 0.35), rgba(46, 204, 113, 0.35));
  box-shadow: 0 0 20px rgba(52, 152, 219, 0.3);
}

/* ── Blacksmith Button ────────────────────────────────────── */
.dungeon-btn-blacksmith {
  background: rgba(241, 196, 15, 0.1);
  border-color: rgba(241, 196, 15, 0.4);
  color: var(--dungeon-gold);
  width: 100%;
  padding: 12px;
  margin-top: 16px;
}

.dungeon-btn-blacksmith:hover:not(:disabled) {
  background: rgba(241, 196, 15, 0.2);
  box-shadow: 0 0 20px rgba(241, 196, 15, 0.2);
}

/* ── Blacksmith Panel ─────────────────────────────────────── */
.dungeon-blacksmith {
  background: var(--dungeon-surface);
  border: 1px solid var(--dungeon-border);
  border-radius: 16px;
  padding: 20px;
}

.blacksmith-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--dungeon-border);
}

.blacksmith-icon {
  font-size: 3rem;
  filter: drop-shadow(0 0 8px var(--dungeon-gold));
}

.blacksmith-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--dungeon-text);
  font-family: 'Cinzel', serif;
}

.blacksmith-desc {
  font-size: 0.75rem;
  color: var(--dungeon-muted);
  margin-top: 4px;
}

/* ── Materials Grid ──────────────────────────────────────── */
.blacksmith-inventory {
  margin-bottom: 24px;
}

.inventory-title {
  font-size: 0.7rem;
  color: var(--dungeon-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 12px;
}

.materials-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 12px;
  padding: 12px;
}

.material-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--dungeon-border);
  border-radius: 10px;
  padding: 10px;
  transition: all 0.2s;
}

.material-card:hover {
  background: rgba(255, 255, 255, 0.06);
  transform: translateY(-2px);
}

.material-icon {
  font-size: 1.8rem;
}

.material-info {
  flex: 1;
}

.material-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--dungeon-text);
}

.material-desc {
  font-size: 0.6rem;
  color: var(--dungeon-muted);
  margin-top: 2px;
}

.material-qty {
  font-size: 0.7rem;
  color: var(--dungeon-gold);
  font-weight: 600;
  margin-top: 2px;
}

.empty-mats {
  text-align: center;
  padding: 20px;
  color: var(--dungeon-muted);
  font-size: 0.8rem;
}

/* ── Recipes Grid ────────────────────────────────────────── */
.blacksmith-recipes {
  margin-bottom: 24px;
}

.recipes-title {
  font-size: 0.7rem;
  color: var(--dungeon-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 12px;
}

.recipes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

.recipe-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--dungeon-border);
  border-radius: 12px;
  padding: 14px;
  transition: all 0.2s;
}

.recipe-card.craftable {
  border-color: rgba(46, 204, 113, 0.4);
  background: rgba(46, 204, 113, 0.05);
}

.recipe-card.uncraftable {
  opacity: 0.5;
}

.recipe-icon {
  font-size: 2rem;
}

.recipe-info {
  flex: 1;
}

.recipe-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--dungeon-text);
  margin-bottom: 6px;
}

.recipe-materials {
  font-size: 0.7rem;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.material-needed {
  background: rgba(255, 255, 255, 0.05);
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.65rem;
}

.material-needed.has {
  color: var(--dungeon-success);
  border: 1px solid rgba(46, 204, 113, 0.3);
}

.material-needed.needs {
  color: var(--dungeon-danger);
}

.craft-btn {
  background: rgba(46, 204, 113, 0.15);
  border: 1px solid rgba(46, 204, 113, 0.4);
  border-radius: 20px;
  padding: 6px 16px;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--dungeon-success);
  cursor: pointer;
  transition: all 0.2s;
  width: 100%;
}

.craft-btn:hover:not(:disabled) {
  background: rgba(46, 204, 113, 0.3);
  transform: translateY(-1px);
}

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

/* ── Animations ──────────────────────────────────────────── */
@keyframes boss-pulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(231, 76, 60, 0.4);
  }
  50% {
    box-shadow: 0 0 0 12px rgba(231, 76, 60, 0);
  }
}

@keyframes combat-player-lunge {
  0% { transform: translateX(0) rotate(0deg); }
  20% { transform: translateX(30px) rotate(-4deg); }
  40% { transform: translateX(40px) rotate(-6deg); }
  60% { transform: translateX(30px) rotate(-4deg); }
  100% { transform: translateX(0) rotate(0deg); }
}
@keyframes combat-monster-hit {
  0%, 100% { transform: translateX(0); }
  15% { transform: translateX(-8px); }
  30% { transform: translateX(8px); }
  45% { transform: translateX(-5px); }
  60% { transform: translateX(5px); }
  75% { transform: translateX(-2px); }
}
@keyframes combat-damage-float {
  0% { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(-60px) scale(1.3); }
}
@keyframes combat-monster-strike {
  0%, 100% { transform: translateX(0) rotate(0deg); }
  30% { transform: translateX(-45px) rotate(-6deg); }
  60% { transform: translateX(-50px) rotate(-8deg); }
}

.combat-anim-player-lunge { animation: combat-player-lunge 0.5s ease-out; }
.combat-anim-monster-hit { animation: combat-monster-hit 0.4s ease-out; }

@keyframes combat-monster-attack-from-deck {
  0% { transform: translateX(-50%) translateY(150px) scale(0.6); opacity: 0; }
  20% { transform: translateX(-50%) translateY(0) scale(1); opacity: 1; }
  50% { transform: translateX(-50%) translateX(-55px) rotate(-8deg); }
  100% { transform: translateX(-50%) translateX(0) rotate(0deg); }
}
@keyframes combat-monster-retreat {
  0% { transform: translateX(-50%) translateY(0) scale(1); opacity: 1; }
  100% { transform: translateX(-50%) translateY(150px) scale(0.6); opacity: 0; }
}

.combat-anim-monster-attack-from-deck { animation: combat-monster-attack-from-deck 0.7s ease-out forwards; }
.combat-anim-monster-strike { animation: combat-monster-strike 0.4s ease-out; }
.combat-anim-monster-retreat { animation: combat-monster-retreat 0.3s ease-in forwards; }

@keyframes combat-player-burst {
  0% { transform: translateX(0) rotate(0deg); }
  15% { transform: translateX(-12px) rotate(4deg) scale(1.05); }
  35% { transform: translateX(55px) rotate(-10deg) scale(1.1); }
  60% { transform: translateX(60px) rotate(-12deg) scale(1.08); }
  100% { transform: translateX(0) rotate(0deg) scale(1); }
}
@keyframes combat-player-ultimate {
  0% { transform: translateX(0) rotate(0deg) scale(1); }
  10% { transform: translateX(-20px) rotate(6deg) scale(0.9); }
  30% { transform: translateX(70px) rotate(-15deg) scale(1.2); }
  50% { transform: translateX(80px) rotate(-18deg) scale(1.25); }
  70% { transform: translateX(70px) rotate(-15deg) scale(1.2); }
  100% { transform: translateX(0) rotate(0deg) scale(1); }
}
@keyframes combat-screen-shake {
  0%, 100% { transform: translateX(0); }
  10% { transform: translateX(-6px); }
  20% { transform: translateX(6px); }
  30% { transform: translateX(-5px); }
  40% { transform: translateX(5px); }
  50% { transform: translateX(-4px); }
  60% { transform: translateX(4px); }
  70% { transform: translateX(-3px); }
  80% { transform: translateX(3px); }
  90% { transform: translateX(-2px); }
}

.combat-anim-player-burst { animation: combat-player-burst 0.6s ease-out; }
.combat-anim-player-ultimate { animation: combat-player-ultimate 0.8s ease-out; }
.combat-anim-screen-shake { animation: combat-screen-shake 0.4s ease-out; }

.combat-damage-float.burst {
  font-size: 1.8rem;
  text-shadow: 0 0 15px rgba(255,107,107,0.9), 0 0 30px rgba(255,50,50,0.4), 0 2px 4px rgba(0,0,0,0.5);
}
.combat-damage-float.ultimate {
  font-size: 2.2rem;
  text-shadow: 0 0 20px rgba(255,200,50,0.9), 0 0 40px rgba(255,150,0,0.5), 0 2px 4px rgba(0,0,0,0.5);
  color: #ffd700;
}

.combat-temp-monster-card {
  position: absolute;
  left: 50%;
  top: 0;
  transform: translateX(-50%);
  z-index: 1;
  width: 120px;
  pointer-events: none;
  opacity: 0;
}
.monster-combat-card {
  position: relative;
  z-index: 2;
}
@keyframes combat-dissolve {
  0% { clip-path: inset(0 0 0 0); opacity: 1; filter: blur(0) brightness(1); }
  25% { clip-path: inset(25% 0 0 0); opacity: 0.8; filter: blur(0.5px) brightness(1.15); }
  50% { clip-path: inset(50% 0 0 0); opacity: 0.5; filter: blur(1.5px) brightness(1.3); }
  75% { clip-path: inset(75% 0 0 0); opacity: 0.2; filter: blur(3px) brightness(1.6); }
  100% { clip-path: inset(100% 0 0 0); opacity: 0; filter: blur(6px) brightness(2); }
}
@keyframes combat-dissolve-glow {
  0% { opacity: 0; transform: scale(0.4); }
  25% { opacity: 0.8; transform: scale(0.8); }
  50% { opacity: 0.4; transform: scale(1.2); filter: blur(4px); }
  100% { opacity: 0; transform: scale(1.8); filter: blur(12px); }
}
.combat-anim-dissolve {
  animation: combat-dissolve 1.2s ease-in forwards;
}
.combat-anim-dissolve::before {
  content: '';
  position: absolute;
  inset: -30px;
  background: radial-gradient(circle, rgba(255,200,80,0.25) 0%, rgba(255,100,50,0.1) 40%, transparent 70%);
  pointer-events: none;
  z-index: -1;
  animation: combat-dissolve-glow 1.2s ease-out forwards;
}

@keyframes combat-particle-fly {
  0% { opacity: 1; transform: translate(0, 0) scale(1); }
  100% { opacity: 0; transform: translate(var(--px), var(--py)) scale(0); }
}
.combat-dissolve-particle {
  position: fixed;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 500000;
  background: radial-gradient(circle, #ffd700, #ff6a00);
  animation: combat-particle-fly 0.8s ease-out forwards;
}
.combat-damage-float {
  position: absolute;
  color: #ff6b6b;
  font-size: 1.3rem;
  font-weight: 800;
  text-shadow: 0 0 10px rgba(255,107,107,0.6), 0 2px 4px rgba(0,0,0,0.5);
  pointer-events: none;
  z-index: 500000;
  white-space: nowrap;
  left: 50%;
  top: 30%;
  transform: translateX(-50%);
  animation: combat-damage-float 0.8s ease-out forwards;
}
.combat-damage-float.heal {
  color: #51cf66;
  text-shadow: 0 0 10px rgba(81,207,102,0.6), 0 2px 4px rgba(0,0,0,0.5);
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 768px) {
  .dungeon-image-container {
    height: 200px;
  }
  
  .dungeon-description {
    padding: 16px;
  }
  
  .dungeon-description p {
    font-size: 0.85rem;
  }
  
  .dungeon-actions {
    padding: 16px;
  }
  
  .boss-preview-icon,
  .monster-preview-icon {
    font-size: 2.5rem;
  }
  
  .boss-preview-name {
    font-size: 1rem;
  }
  
  .dungeon-direction-btn {
    padding: 6px 14px;
    font-size: 0.75rem;
  }
  
  .materials-grid {
    grid-template-columns: 1fr;
  }
  
  .recipes-grid {
    grid-template-columns: 1fr;
  }
}

/* ── Responsive HUD (game-window style) ───────────────────────────── */
/* Mobile optimization for HUD elements */

@media (max-width: 768px) {
  .dungeon-game-screen {
    height: clamp(560px, 86svh, 760px);
  }

  .dungeon-hud-top {
    top: 8px;
    left: 8px;
    right: 8px;
    padding: 6px 10px;
    gap: 8px;
    min-height: 40px;
  }

  .dungeon-hud-title {
    font-size: 0.85rem;
    max-width: 40%;
  }

  .dungeon-hud-floor {
    font-size: 0.7rem;
    padding: 3px 8px;
  }

  .dungeon-hud-actions {
    gap: 6px;
  }

  .dungeon-btn-hud {
    padding: 5px 8px;
    font-size: 0.7rem;
  }
}

/* ── Elemental Panel & Modal ──────────────────────────────────── */
.dungeon-elem-panel {
  position: absolute;
  top: 60px;
  right: 12px;
  width: 180px;
  padding: 10px;
  border-radius: 12px;
  background: rgba(6, 10, 18, 0.88);
  border: 1px solid rgba(255,255,255,0.08);
  backdrop-filter: blur(10px);
  z-index: 75;
  font-size: 0.7rem;
  pointer-events: auto;
}
.dungeon-elem-header {
  font-size: 0.8rem;
  font-weight: 600;
  color: #e2e8f0;
  margin-bottom: 4px;
}
.dungeon-elem-body {
  color: #cbd5e1;
}
.dungeon-elem-bar {
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: rgba(255,255,255,0.08);
  overflow: hidden;
}
.dungeon-elem-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s;
}
.dungeon-elem-bar-fill.hp-fill { background: linear-gradient(90deg, #22c55e, #16a34a); }
.dungeon-elem-bar-fill.xp-fill { background: linear-gradient(90deg, #a855f7, #7c3aed); }
.dungeon-elem-feed-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border-radius: 8px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
  font-size: 0.75rem;
  color: #cbd5e1;
}
.dungeon-elem-feed-row:hover {
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.15);
}
.dungeon-modal {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 320px;
  max-width: 90vw;
  padding: 16px;
  border-radius: 14px;
  background: rgba(8, 12, 22, 0.96);
  border: 1px solid rgba(255,255,255,0.1);
  backdrop-filter: blur(12px);
  z-index: 100;
  box-shadow: 0 8px 40px rgba(0,0,0,0.5);
}
.dungeon-elem-name-input {
  width: 100%;
  padding: 8px 10px;
  margin-top: 4px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.15);
  background: rgba(0,0,0,0.4);
  color: #e2e8f0;
  font-size: 0.85rem;
  outline: none;
  box-sizing: border-box;
}
.dungeon-elem-name-input:focus {
  border-color: rgba(168,85,247,0.5);
  box-shadow: 0 0 12px rgba(168,85,247,0.2);
}
.dungeon-modal-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: #e2e8f0;
  margin-bottom: 8px;
}

@media (max-width: 768px) {

.dungeon-hud-log-inline {
    display: none;
  }

  .dungeon-hud-log {
    display: none;
  }

  .dungeon-hud-room-log {
    display: block;
    max-height: 2.7em;
    overflow: hidden;
    line-height: 1.35;
  }
  
  /* Adjust minimap position to avoid overlap */
  .dungeon-hud-minimap {
    left: 8px;
    bottom: 70px;
    width: 120px;
  }
  
  .dungeon-hud-minimap-title {
    font-size: 0.6rem;
    margin-bottom: 6px;
  }
  
  .dungeon-minimap .map-room,
  .dungeon-minimap .map-void {
    width: 16px;
    height: 16px;
    font-size: 0.65rem;
  }
  
  .dungeon-minimap .dungeon-grid-inner {
    gap: 3px;
  }
}

@media (max-width: 640px) {
  .dungeon-game-screen {
    height: clamp(520px, 84svh, 700px);
  }

  .dungeon-hud-minimap {
    width: 110px;
    bottom: 10px;
  }

  .dungeon-hud-center {
    left: 8px;
    right: 8px;
    top: 52px;
    bottom: 200px;
    transform: none;
    width: auto;
  }

  .dungeon-hud-room {
    padding: 10px;
    margin-top: 0;
  }

  .dungeon-hud-room-title {
    font-size: 0.8rem;
  }

  .dungeon-hud-room-id {
    font-size: 0.7rem;
  }

  .dungeon-hud-room.has-monster .dungeon-hud-room-desc,
  .dungeon-hud-room.has-monster .dungeon-hud-room-progress {
    display: none;
  }
  /* During encounters, the "running log" ticker is noisy and can overlap controls on WebKit. */
  .dungeon-hud-room.has-monster .dungeon-hud-room-log {
    display: none !important;
  }

  /* Encounter layout: give the enemy preview/actions the full vertical space instead of a tiny inner scrollbox. */
  .dungeon-game.dungeon-has-encounter .dungeon-hud-bottom {
    display: none;
  }
  .dungeon-game.dungeon-has-encounter .dungeon-hud-center {
    /* Leave space for the minimap; we want the preview higher, not covering the map. */
    bottom: 210px;
  }
  .dungeon-game.dungeon-has-encounter .dungeon-hud-minimap {
    /* Keep the minimap in its usual mobile region. */
    bottom: 65px;
    /* And ensure nothing can cover it (Safari/WebKit layering). */
    z-index: 55;
  }
  .dungeon-game.dungeon-has-encounter .dungeon-hud-room {
    max-height: none;
    overflow: visible;
  }
}

@media (max-width: 480px) {
  .dungeon-game-screen {
    height: clamp(480px, 82svh, 640px);
  }

  .dungeon-hud-top {
    top: 6px;
    left: 6px;
    right: 6px;
    padding: 5px 8px;
    min-height: 36px;
  }

  .dungeon-hud-title {
    font-size: 0.75rem;
    max-width: 35%;
  }

  .dungeon-hud-floor {
    font-size: 0.65rem;
    padding: 2px 6px;
  }

  .dungeon-hud-minimap {
    width: 95px;
    bottom: 85px;
    padding: 5px;
  }

  .dungeon-minimap .map-room,
  .dungeon-minimap .map-void {
    width: 12px;
    height: 12px;
    font-size: 0.55rem;
  }

  .dungeon-minimap .dungeon-grid-inner {
    gap: 2px;
  }

  .dungeon-hud-center {
    left: 6px;
    right: 6px;
    top: 176px;
    bottom: 200px;
    transform: none;
    width: auto;
  }

  .dungeon-hud-room {
    padding: 8px;
    margin-top: -70px;
  }

  .dungeon-hud-room-desc {
    font-size: 0.7rem;
    margin-bottom: 6px;
  }

  .dungeon-path-btn {
    padding: 8px 12px;
  }

  .dungeon-path-btn-icon {
    font-size: 1rem;
  }

  .monster-btns {
    flex-direction: column;
    align-items: stretch;
  }
  .monster-btns .dungeon-btn {
    width: 100%;
    text-align: center;
    font-size: 0.85rem;
    padding: 10px 0;
  }
}

/* Landscape mode optimization */
@media (max-width: 896px) and (orientation: landscape) {
  .dungeon-game-screen {
    height: clamp(420px, 82vh, 560px);
  }

  .dungeon-hud-minimap {
    width: 130px;
    bottom: 12px;
  }

  .dungeon-hud-center {
    left: 8px;
    right: 8px;
    top: 64px;
    bottom: 110px;
    transform: none;
    width: auto;
  }

  .dungeon-hud-room {
    max-height: none;
  }

  .dungeon-path-options {
    flex-wrap: wrap;
    justify-content: center;
  }

  .dungeon-path-btn-text {
    display: inline; /* Show text in landscape */
  }
}

/* Ensure tap targets are large enough on mobile */
@media (max-width: 768px) {
  .dungeon-path-btn,
  .dungeon-direction-btn,
  .dungeon-conn-btn,
  .dungeon-btn,
  .exchange-btn,
  .craft-btn {
    min-height: 44px;
  }

  .dungeon-btn-hud {
    min-height: 36px;
  }
}

@media (max-width: 768px) {
  .dungeon-overlay {
    padding: 10px;
  }
}

/* Fix modal button cutoff - ensure proper scrolling to edges */
.dungeon-overlay {
  scroll-padding: 20px;
}

/* No special scroll tricks needed: the overlay is the only scroll container. */
.guild-container { scroll-margin: 0; margin-top: 0; }

/* Overlay card should not become its own scroll container; the overlay scrolls instead. */
.dungeon-overlay-card {
  max-height: none;
  overflow: visible;
}

/* Add padding inside the scrollable area to ensure content isn't cut off */
.guild-container > *:first-child {
  margin-top: 0;
  padding-top: 0;
}

.guild-container > *:last-child {
  margin-bottom: 0;
  padding-bottom: 4px;
}

/* Backdrop should block clicks to underlying HUD/nav; the overlay card itself scrolls. */
.dungeon-overlay-backdrop {
  pointer-events: auto;
}

/* Make the modal card itself have some margin to ensure it doesn't touch edges */
.guild-overlay-card {
  margin: 20px auto;
}

/* For mobile, reduce margins to allow more space */
@media (max-width: 768px) {
  .guild-overlay-card {
    margin: 10px auto;
  }
  
  .dungeon-overlay {
    scroll-padding: 10px;
  }
}

@media (max-width: 480px) {
  .guild-overlay-card {
    margin: 8px auto;
  }
}

.exchange-reward-modal {
  position: fixed;
  inset: 0;
  z-index: 30000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(2px);
}

#skill-check-overlay {
  cursor: pointer;
}
#skill-check-overlay * {
  pointer-events: none;
}
