/* Экран выбора подземелья «Подземелья Британии» — классическая CRPG-эстетика */

:root {
  --dm-parchment: #c4a574;
  --dm-parchment-light: #d8be90;
  --dm-parchment-dark: #9e7d4d;
  --dm-iron: #3a342c;
  --dm-iron-light: #5c5348;
  --dm-iron-dark: #1f1b17;
  --dm-sea: #1d4e8f;
  --dm-forest: #3d6b32;
  --dm-snow: #e8eef2;
  --dm-torch: #e39b3a;
  --dm-ink: #1e150d;
  --dm-ink-soft: #3a2a1b;
  --dm-select-bg: rgba(86, 102, 128, 0.5);
  --dm-select-border: rgba(58, 73, 98, 0.72);
}

#dungeon-overlay {
  position: fixed;
  inset: 0;
  z-index: 12000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px 16px 14px;
  background: radial-gradient(ellipse at center, rgba(12, 10, 8, 0.58) 0%, rgba(6, 5, 4, 0.8) 100%);
  user-select: none;
  box-sizing: border-box;
  font-family: "Palatino Linotype", "Book Antiqua", Palatino, Georgia, "Times New Roman", serif;
  color: var(--dm-ink);
}

#dungeon-overlay[hidden] {
  display: none !important;
}

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

/* Внутри веб-клиента ClassicUO сохраняем игровой курсор */
body[data-cuo-layout] #dungeon-overlay,
body[data-cuo-layout] #dungeon-overlay button {
  cursor: inherit;
}

.dungeon-window {
  position: relative;
  width: min(960px, calc(100vw - 24px));
  height: min(636px, calc(100vh - 28px));
  min-height: 460px;
  display: flex;
  flex-direction: column;
  padding: 15px;
  background:
    repeating-linear-gradient(
      90deg,
      rgba(255, 255, 255, 0.02) 0px,
      rgba(255, 255, 255, 0.02) 2px,
      rgba(0, 0, 0, 0.04) 2px,
      rgba(0, 0, 0, 0.04) 5px
    ),
    linear-gradient(180deg, #4b443b 0%, var(--dm-iron) 22%, #2f2a23 78%, #24201a 100%);
  border: 2px solid #181410;
  box-shadow:
    0 26px 64px rgba(0, 0, 0, 0.85),
    0 4px 16px rgba(0, 0, 0, 0.65),
    inset 0 2px 0 rgba(182, 170, 154, 0.34),
    inset 2px 0 0 rgba(150, 138, 124, 0.22),
    inset -2px -2px 0 rgba(15, 12, 9, 0.85),
    inset 0 0 0 4px #3a342c;
}

/* Угловые орнаменты железной рамки из assets/frame.png */
.dungeon-corner {
  position: absolute;
  width: 108px;
  height: 108px;
  pointer-events: none;
  z-index: 6;
  user-select: none;
  -webkit-user-drag: none;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.65));
}

.dungeon-corner--tl {
  top: -2px;
  left: -2px;
}

.dungeon-corner--tr {
  top: -2px;
  right: -2px;
  transform: scaleX(-1);
}

.dungeon-corner--bl {
  bottom: -2px;
  left: -2px;
  transform: scaleY(-1);
}

.dungeon-corner--br {
  bottom: -2px;
  right: -2px;
  transform: scale(-1, -1);
}

/* Верхний свиток с заголовком «Подземелья Британии» */
.dungeon-scroll {
  position: absolute;
  top: -13px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 8;
  min-width: min(410px, 68%);
  padding: 7px 42px 8px;
  text-align: center;
  background:
    radial-gradient(ellipse at 50% 50%, rgba(242, 224, 188, 0.55) 0%, transparent 72%),
    linear-gradient(
      180deg,
      #a6834e 0%,
      #d8be90 18%,
      #cbb07f 50%,
      #d6bc8e 82%,
      #9a7744 100%
    );
  border-top: 2px solid #3a2916;
  border-bottom: 2px solid #2d1f10;
  box-shadow:
    0 5px 12px rgba(0, 0, 0, 0.58),
    inset 0 1px 0 rgba(255, 244, 220, 0.6),
    inset 0 -1px 0 rgba(92, 64, 30, 0.55);
}

/* Свёрнутые валики свитка слева и справа */
.dungeon-scroll::before,
.dungeon-scroll::after {
  content: "";
  position: absolute;
  top: -5px;
  bottom: -5px;
  width: 18px;
  border: 2px solid #332413;
  border-radius: 4px;
  background:
    radial-gradient(circle at 50% 10%, rgba(55, 38, 18, 0.45) 0%, transparent 32%),
    radial-gradient(circle at 50% 90%, rgba(55, 38, 18, 0.45) 0%, transparent 32%),
    linear-gradient(
      90deg,
      #6a4e29 0%,
      #c8a772 30%,
      #e6cfa3 50%,
      #a8844e 76%,
      #523b1e 100%
    );
  box-shadow:
    0 4px 8px rgba(0, 0, 0, 0.55),
    inset 0 1px 0 rgba(255, 243, 214, 0.65);
}

.dungeon-scroll::before {
  left: -10px;
}

.dungeon-scroll::after {
  right: -10px;
}

.dungeon-scroll-title {
  margin: 0;
  font-size: 22px;
  line-height: 1.15;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: #1c130b;
  text-shadow: 0 1px 0 rgba(255, 241, 214, 0.58);
  white-space: nowrap;
}

/* CSS-свиток активной вкладки поверх окна Valora menu */
.valora-tab-scroll {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9000;
  min-width: 310px;
  padding: 6px 38px 7px;
  pointer-events: none;
  user-select: none;
  font-family: "Palatino Linotype", "Book Antiqua", Palatino, Georgia, "Times New Roman", serif;
}

.valora-tab-scroll[hidden] {
  display: none !important;
}

/* Кнопка-крестик закрытия справа сверху */
.dungeon-close-btn {
  position: absolute;
  top: 7px;
  right: 36px;
  z-index: 9;
  width: 28px;
  height: 28px;
  padding: 0;
  display: grid;
  place-items: center;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
  color: #efe2cc;
  background: linear-gradient(180deg, #78382e 0%, #56251e 55%, #3c1813 100%);
  border: 2px solid #261b15;
  box-shadow:
    0 2px 5px rgba(0, 0, 0, 0.5),
    inset 1px 1px 0 rgba(206, 132, 118, 0.45),
    inset -1px -1px 0 rgba(32, 10, 8, 0.75);
  cursor: pointer;
  transition: filter 0.12s ease, transform 0.08s ease;
}

.dungeon-close-btn:hover {
  filter: brightness(1.16);
}

.dungeon-close-btn:active {
  transform: translateY(1px);
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.5),
    inset 1px 1px 2px rgba(20, 6, 4, 0.8);
}

.dungeon-close-btn:focus-visible {
  outline: 2px solid var(--dm-torch);
  outline-offset: 2px;
}

/* Внутреннее поле состаренного пергамента */
.dungeon-parchment {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 24px 18px 14px;
  background:
    radial-gradient(ellipse at 22% 28%, rgba(235, 212, 170, 0.42) 0%, transparent 52%),
    radial-gradient(ellipse at 76% 74%, rgba(228, 202, 158, 0.34) 0%, transparent 48%),
    radial-gradient(ellipse at 85% 18%, rgba(132, 95, 48, 0.22) 0%, transparent 42%),
    radial-gradient(ellipse at 14% 86%, rgba(124, 88, 44, 0.24) 0%, transparent 44%),
    repeating-linear-gradient(
      -12deg,
      rgba(68, 46, 20, 0.018) 0px,
      rgba(68, 46, 20, 0.018) 2px,
      transparent 2px,
      transparent 5px
    ),
    linear-gradient(180deg, #cca974 0%, var(--dm-parchment) 48%, #bc9b68 100%);
  border: 2px solid #261e17;
  box-shadow:
    inset 0 0 32px rgba(88, 58, 24, 0.48),
    inset 0 0 6px rgba(48, 32, 14, 0.45);
}

/* Основная сетка: узкая колонка слева, карта сверху справа, карточка снизу справа */
.dungeon-grid {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 244px minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr) auto;
  grid-template-areas:
    "sidebar map"
    "sidebar card";
  column-gap: 18px;
  row-gap: 12px;
  align-items: stretch;
}

/* Левая колонка со списком подземелий */
.dungeon-sidebar {
  grid-area: sidebar;
  position: relative;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding-right: 14px;
  border-right: 1px solid rgba(58, 52, 44, 0.42);
  box-shadow: 1px 0 0 rgba(238, 216, 178, 0.35);
}

/* Декоративный ромб на вертикальном разделителе */
.dungeon-sidebar::after {
  content: "❖";
  position: absolute;
  right: -7px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
  line-height: 1;
  color: #5b462b;
  background: var(--dm-parchment);
  padding: 3px 0;
}

.dungeon-sidebar-heading {
  margin: 0 0 7px;
  padding: 2px 4px 6px;
  font-size: 16px;
  font-weight: 700;
  color: #24190e;
  border-bottom: 1px solid rgba(68, 50, 28, 0.42);
  text-shadow: 0 1px 0 rgba(246, 228, 196, 0.45);
}

.dungeon-list {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 0;
  list-style: none;
  overflow-y: auto;
}

.dungeon-row {
  width: 100%;
  flex: 1 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 8px;
  margin: 0;
  background: transparent;
  border: 1px solid transparent;
  border-bottom-color: rgba(74, 54, 30, 0.26);
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.18;
  color: var(--dm-ink);
  text-align: left;
  cursor: pointer;
  transition: background-color 0.1s ease, border-color 0.1s ease;
}

.dungeon-row:hover:not(.is-selected) {
  background: rgba(92, 106, 128, 0.2);
}

/* Выбранная строка подсвечена серо-голубым */
.dungeon-row.is-selected {
  background: linear-gradient(
    90deg,
    rgba(82, 98, 124, 0.56) 0%,
    rgba(98, 115, 142, 0.48) 65%,
    rgba(82, 98, 124, 0.36) 100%
  );
  border-color: var(--dm-select-border);
  box-shadow:
    inset 0 1px 0 rgba(220, 232, 248, 0.36),
    inset 0 -1px 0 rgba(44, 55, 74, 0.42);
  color: #11151c;
}

.dungeon-row:focus-visible {
  outline: 2px solid var(--dm-iron);
  outline-offset: -2px;
  box-shadow: inset 0 0 0 2px var(--dm-torch);
}

.dungeon-row-icon {
  width: 24px;
  height: 24px;
  flex: none;
  object-fit: contain;
  pointer-events: none;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.35));
}

.dungeon-row-name {
  flex: 1;
  letter-spacing: 0.015em;
  text-shadow: 0 1px 0 rgba(245, 228, 198, 0.42);
}

/* Правая верхняя область — карта */
.dungeon-map-section {
  grid-area: map;
  min-height: 0;
  container-type: size;
  display: grid;
  place-items: center;
  padding-right: 2px;
}

.dungeon-map-frame {
  position: relative;
  width: min(100cqw, calc(100cqh * 16 / 9));
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--dm-sea);
  border: 3px solid var(--dm-iron);
  box-shadow:
    0 3px 10px rgba(0, 0, 0, 0.36),
    inset 0 0 0 1px #17130f;
}

.dungeon-map-img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  object-position: center;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

.dungeon-map-markers {
  position: absolute;
  inset: 0;
}

.dungeon-map-marker {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 4.8%;
  aspect-ratio: 1 / 1;
  min-width: 24px;
  min-height: 24px;
  padding: 0;
  margin: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  display: grid;
  place-items: center;
  cursor: pointer;
  z-index: 2;
}

.dungeon-map-marker:hover:not(.is-selected)::after {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: 50%;
  border: 1.5px solid rgba(246, 218, 92, 0.55);
  pointer-events: none;
}

/* Выбранный вход на карте обведён жёлтым кольцом */
.dungeon-map-marker.is-selected {
  z-index: 4;
}

.dungeon-map-marker.is-selected::after {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  border: 2.5px solid #f7de52;
  box-shadow:
    0 0 8px 2px rgba(247, 222, 82, 0.9),
    0 0 14px 3px rgba(227, 155, 58, 0.65),
    inset 0 0 5px rgba(247, 222, 82, 0.7);
  pointer-events: none;
}

/* Правая нижняя карточка: интерьер, название, описание и кнопка «Войти» */
.dungeon-card {
  grid-area: card;
  position: relative;
  display: flex;
  align-items: stretch;
  gap: 18px;
  padding: 14px 6px 4px 2px;
  border-top: 1px solid rgba(58, 52, 44, 0.42);
  box-shadow: inset 0 1px 0 rgba(238, 216, 178, 0.35);
}

.dungeon-card::before {
  content: "❖";
  position: absolute;
  top: -8px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  line-height: 1;
  color: #5b462b;
  background: var(--dm-parchment);
  padding: 0 5px;
}

.dungeon-interior-frame {
  width: 132px;
  height: 132px;
  flex: none;
  overflow: hidden;
  background: #1c1916;
  border: 3px solid var(--dm-iron);
  box-shadow:
    0 3px 8px rgba(0, 0, 0, 0.42),
    inset 0 0 0 1px #14110e;
}

.dungeon-interior-img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  object-position: center;
  user-select: none;
  -webkit-user-drag: none;
}

.dungeon-card-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
}

.dungeon-card-text {
  min-width: 0;
}

.dungeon-title-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px;
}

.dungeon-title-bar::before,
.dungeon-title-bar::after {
  content: "";
  height: 1px;
  flex: 1;
  max-width: 96px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(58, 44, 26, 0.65) 50%,
    rgba(58, 44, 26, 0.85) 100%
  );
}

.dungeon-title-bar::after {
  background: linear-gradient(
    90deg,
    rgba(58, 44, 26, 0.85) 0%,
    rgba(58, 44, 26, 0.65) 50%,
    transparent 100%
  );
}

.dungeon-detail-name {
  margin: 0;
  font-size: 25px;
  line-height: 1.1;
  font-weight: 700;
  letter-spacing: 0.025em;
  color: #1a120a;
  text-shadow: 0 1px 0 rgba(248, 232, 202, 0.55);
}

.dungeon-detail-desc {
  margin: 0;
  font-size: 16px;
  line-height: 1.42;
  color: #281c10;
  text-shadow: 0 1px 0 rgba(245, 226, 194, 0.35);
}

.dungeon-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: auto;
}

.dungeon-enter-feedback {
  min-height: 26px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  font-size: 14.5px;
  font-weight: 700;
  color: #24180c;
  background: rgba(227, 155, 58, 0.22);
  border: 1px solid rgba(116, 76, 28, 0.55);
  box-shadow: inset 0 1px 0 rgba(255, 240, 208, 0.45);
}

.dungeon-enter-feedback[hidden] {
  display: none !important;
}

.dungeon-enter-feedback code {
  font-family: inherit;
  font-weight: 700;
  color: #5c2410;
}

/* Резкая каменная/железная кнопка «Войти» на CSS */
.dungeon-enter-btn {
  margin-left: auto;
  min-width: 136px;
  height: 40px;
  padding: 6px 32px 7px;
  font-family: inherit;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: #16110c;
  text-shadow: 0 1px 0 rgba(232, 224, 212, 0.52);
  background:
    repeating-linear-gradient(
      90deg,
      rgba(255, 255, 255, 0.025) 0px,
      rgba(255, 255, 255, 0.025) 2px,
      rgba(0, 0, 0, 0.025) 2px,
      rgba(0, 0, 0, 0.025) 4px
    ),
    linear-gradient(180deg, #9d948a 0%, #837a70 46%, #6b635a 100%);
  border: 2px solid #2a241e;
  box-shadow:
    0 3px 7px rgba(0, 0, 0, 0.42),
    inset 2px 2px 0 rgba(218, 210, 198, 0.65),
    inset -2px -2px 0 rgba(48, 42, 36, 0.82);
  cursor: pointer;
  transition: filter 0.12s ease, transform 0.08s ease;
}

.dungeon-enter-btn:hover {
  filter: brightness(1.08);
}

.dungeon-enter-btn:active {
  transform: translateY(1px);
  box-shadow:
    0 1px 3px rgba(0, 0, 0, 0.45),
    inset 2px 2px 3px rgba(42, 36, 30, 0.85),
    inset -1px -1px 0 rgba(196, 188, 176, 0.4);
}

.dungeon-enter-btn:focus-visible {
  outline: 2px solid var(--dm-torch);
  outline-offset: 2px;
}

@media (max-width: 780px) {
  .dungeon-window {
    overflow-y: auto;
  }

  .dungeon-grid {
    grid-template-columns: 1fr;
    grid-template-areas:
      "map"
      "sidebar"
      "card";
  }

  .dungeon-sidebar {
    padding-right: 0;
    padding-bottom: 10px;
    border-right: 0;
    border-bottom: 1px solid rgba(58, 52, 44, 0.42);
    box-shadow: none;
  }

  .dungeon-sidebar::after {
    display: none;
  }

  .dungeon-list {
    max-height: 190px;
  }

  .dungeon-scroll {
    min-width: 260px;
    padding: 6px 24px 7px;
  }

  .dungeon-scroll-title {
    font-size: 18px;
  }
}
