.theme-midnight .dungeon-route-map {
  display: grid;
  gap: 12px;
  margin: 18px 0 22px;
  padding: 16px;
  border: 1px solid rgba(120, 151, 255, .2);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(8, 14, 32, .78), rgba(5, 9, 23, .9));
}

.theme-midnight .dungeon-route-map.unavailable {
  background: rgba(255,255,255,.02);
}

.theme-midnight .dungeon-route-map-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.theme-midnight .dungeon-route-map-head h3 {
  margin: 4px 0 4px;
}

.theme-midnight .dungeon-route-map-head p {
  max-width: 760px;
  margin: 0;
  color: var(--muted, #9da8c9);
}

.theme-midnight .dungeon-map-toolbar {
  display: grid;
  justify-items: end;
  gap: 8px;
}

.theme-midnight .dungeon-map-controls,
.theme-midnight .dungeon-map-layers,
.theme-midnight .dungeon-map-modes {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.theme-midnight .dungeon-map-controls button,
.theme-midnight .dungeon-map-layers button,
.theme-midnight .dungeon-map-modes button {
  min-height: 34px;
  padding: 6px 11px;
}

.theme-midnight .dungeon-map-layers button {
  background: rgba(38, 35, 76, .7);
}

.theme-midnight .dungeon-map-layers button.active {
  border-color: rgba(217, 168, 78, .7);
  background: linear-gradient(180deg, rgba(116, 84, 183, .9), rgba(62, 43, 111, .95));
}

.theme-midnight .dungeon-map-modes {
  padding: 3px;
  border: 1px solid rgba(126,145,211,.2);
  border-radius: 10px;
  background: rgba(5,9,23,.55);
}

.theme-midnight .dungeon-map-modes button {
  min-width: 74px;
  border-color: transparent;
  background: transparent;
}

.theme-midnight .dungeon-map-modes button.active {
  border-color: rgba(141,108,255,.42);
  background: rgba(103,82,177,.52);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.06);
}

.theme-midnight .dungeon-map-viewport {
  position: relative;
  width: 100%;
  aspect-ratio: 2004 / 1336;
  min-height: 0;
  overflow: hidden;
  border: 1px solid rgba(126, 145, 211, .22);
  border-radius: 14px;
  outline: none;
  touch-action: none;
  cursor: grab;
  background:
    radial-gradient(circle at 50% 45%, rgba(102, 75, 180, .13), transparent 35%),
    linear-gradient(rgba(116, 126, 178, .07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(116, 126, 178, .07) 1px, transparent 1px),
    linear-gradient(180deg, #0b1125, #070b18);
  background-size: auto, 36px 36px, 36px 36px, auto;
  box-shadow: inset 0 0 60px rgba(0,0,0,.45);
}

.theme-midnight .dungeon-map-viewport:focus-visible {
  border-color: rgba(188, 174, 255, .58);
  box-shadow: inset 0 0 60px rgba(0,0,0,.45), 0 0 0 2px rgba(141,108,255,.18);
}

.theme-midnight .dungeon-map-viewport.dragging {
  cursor: grabbing;
}

.theme-midnight .dungeon-map-layer {
  position: absolute;
  inset: 0;
}

.theme-midnight .dungeon-map-layer[hidden] {
  display: none;
}

.theme-midnight .dungeon-map-canvas {
  position: absolute;
  inset: 0;
  transform-origin: center center;
  transition: transform .08s ease-out;
}

.theme-midnight .dungeon-map-background {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  user-select: none;
  pointer-events: none;
}

.theme-midnight .dungeon-map-viewport.dragging .dungeon-map-canvas {
  transition: none;
}

.theme-midnight .dungeon-map-route {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.theme-midnight .dungeon-map-engage-point {
  position: absolute;
  left: var(--engage-x);
  top: var(--engage-y);
  z-index: 2;
  width: 9px;
  height: 9px;
  transform: translate(-50%, -50%);
  border: 2px solid rgba(255,255,255,.92);
  border-radius: 50%;
  background: #d98b35;
  box-shadow: 0 0 0 2px rgba(5,9,23,.65);
  pointer-events: none;
}

.theme-midnight .dungeon-map-route line {
  stroke: rgba(222, 188, 112, .72);
  stroke-width: .55;
  stroke-dasharray: 1.8 1.8;
  vector-effect: non-scaling-stroke;
  filter: drop-shadow(0 0 3px rgba(217,168,78,.25));
}

.theme-midnight .dungeon-map-route marker path {
  fill: rgba(222, 188, 112, .9);
}

.theme-midnight .dungeon-map-movement {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  overflow: visible;
  pointer-events: none;
}

.theme-midnight .dungeon-map-movement[hidden] {
  display: none;
}

.theme-midnight .dungeon-map-movement polyline {
  fill: none;
  stroke: rgba(118, 218, 255, .9);
  stroke-width: 1.15;
  vector-effect: non-scaling-stroke;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 0 3px rgba(82,177,255,.45));
}

.theme-midnight .dungeon-route-map.movement-mode .dungeon-map-route {
  opacity: .22;
}

.theme-midnight .dungeon-route-map.movement-mode .dungeon-map-engage-point {
  opacity: .35;
}

.theme-midnight .dungeon-route-map.movement-mode .dungeon-map-marker {
  opacity: .86;
}

.theme-midnight .dungeon-map-marker {
  position: absolute;
  left: var(--map-x);
  top: var(--map-y);
  z-index: 2;
  width: 40px;
  height: 40px;
  padding: 0;
  transform: translate(-50%, -50%);
  border-radius: 999px !important;
  display: grid;
  place-items: center;
}

.theme-midnight .dungeon-map-marker.trash {
  border-color: rgba(107, 184, 255, .82);
  background: radial-gradient(circle at 35% 30%, #8fd8ff, #4365c2 46%, #202b63 100%);
}

.theme-midnight .dungeon-map-marker.boss {
  width: 46px;
  height: 46px;
  border-color: rgba(231, 185, 104, .95);
  background: radial-gradient(circle at 35% 30%, #ffe0a2, #b56d2d 44%, #5b2d18 100%);
}

.theme-midnight .dungeon-map-marker.selected {
  box-shadow: 0 0 0 3px rgba(255,255,255,.8), 0 0 26px rgba(141,108,255,.75), inset 0 1px 0 rgba(255,255,255,.25);
}

.theme-midnight .dungeon-route-map.pace-mode .dungeon-map-marker.trash {
  width: calc(40px * var(--pace-scale, 1));
  height: calc(40px * var(--pace-scale, 1));
}

.theme-midnight .dungeon-route-map.pace-mode .dungeon-map-marker.boss {
  width: calc(46px * var(--pace-scale, 1));
  height: calc(46px * var(--pace-scale, 1));
}

.theme-midnight .dungeon-route-map.pace-mode .dungeon-map-engage-point {
  opacity: .34;
}

.theme-midnight .dungeon-route-map.pace-mode .dungeon-map-route line {
  opacity: .42;
}

/* Midnight's global button hover uses transform: translateY(-1px).
   Map markers already use transform for centering, so replacing it makes the
   marker jump under the pointer. Keep the centering transform stable. */
.theme-midnight button.dungeon-map-marker:hover:not(:disabled),
.theme-midnight button.dungeon-map-marker:active:not(:disabled),
.theme-midnight button.dungeon-map-marker:focus-visible {
  transform: translate(-50%, -50%);
}

.theme-midnight button.dungeon-map-marker {
  transition: box-shadow .16s ease, filter .16s ease, border-color .16s ease;
}

.theme-midnight button.dungeon-map-marker:hover:not(:disabled) {
  filter: brightness(1.08);
}

.theme-midnight .dungeon-map-marker-index {
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  color: #fff;
  text-shadow: 0 1px 2px #000;
}

.theme-midnight .dungeon-map-tooltip {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 10px);
  z-index: 8;
  width: max-content;
  max-width: 290px;
  transform: translateX(-50%) translateY(4px);
  opacity: 0;
  pointer-events: none;
  display: grid;
  gap: 3px;
  padding: 9px 11px;
  border: 1px solid rgba(188, 174, 255, .32);
  border-radius: 9px;
  color: #f5f0ff;
  background: rgba(8, 8, 18, .96);
  box-shadow: 0 10px 28px rgba(0,0,0,.45);
  transition: opacity .13s ease, transform .13s ease;
}

.theme-midnight .dungeon-map-tooltip small {
  color: var(--muted, #aeb8d5);
  white-space: normal;
}

.theme-midnight .dungeon-map-marker:hover .dungeon-map-tooltip,
.theme-midnight .dungeon-map-marker:focus-visible .dungeon-map-tooltip {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.theme-midnight .dungeon-map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  align-items: center;
  color: var(--muted, #aeb8d5);
  font-size: 13px;
}

.theme-midnight .dungeon-map-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.theme-midnight .dungeon-map-legend i {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
}

.theme-midnight .dungeon-map-legend i.trash { background: #5b89df; }
.theme-midnight .dungeon-map-legend i.boss { background: #c47b36; }
.theme-midnight .dungeon-map-legend i.engage {
  width: 9px;
  height: 9px;
  border: 2px solid rgba(255,255,255,.85);
  background: #d98b35;
}
.theme-midnight .dungeon-map-legend .route-note { margin-left: auto; }

.theme-midnight .dungeon-pace-panel {
  display: grid;
  gap: 12px;
  padding: 13px;
  border: 1px solid rgba(126,145,211,.18);
  border-radius: 12px;
  background: rgba(11,17,37,.58);
}

.theme-midnight .dungeon-pace-panel[hidden] {
  display: none;
}

.theme-midnight .dungeon-pace-budget {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 9px;
}

.theme-midnight .dungeon-pace-budget > span {
  display: grid;
  gap: 3px;
  padding: 10px 12px;
  border: 1px solid rgba(126,145,211,.14);
  border-radius: 9px;
  background: rgba(255,255,255,.025);
}

.theme-midnight .dungeon-pace-budget small {
  color: var(--muted, #9da8c9);
}

.theme-midnight .dungeon-pace-budget strong {
  font-size: 18px;
  font-variant-numeric: tabular-nums;
}

.theme-midnight .dungeon-pace-lists {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.theme-midnight .dungeon-pace-lists section {
  display: grid;
  gap: 6px;
}

.theme-midnight .dungeon-pace-lists h4 {
  margin: 0 0 2px;
}

.theme-midnight .dungeon-pace-lists button {
  width: 100%;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  min-height: 34px;
  padding: 7px 10px;
  text-align: left;
  background: rgba(255,255,255,.025);
}

.theme-midnight .dungeon-pace-lists button strong {
  font-variant-numeric: tabular-nums;
}

.theme-midnight .dungeon-pace-note {
  margin: 0;
  color: var(--muted, #9da8c9);
  font-size: 12px;
}

.theme-midnight .dungeon-map-missing {
  color: var(--muted, #9da8c9);
  font-size: 13px;
}

.theme-midnight .dungeon-pull.map-selected {
  border-color: rgba(217, 168, 78, .62);
  box-shadow: 0 0 0 1px rgba(217,168,78,.13), 0 0 20px rgba(217,168,78,.08);
}

.theme-midnight .dungeon-group-evidence {
  margin-top: 8px;
  padding: 8px 10px;
  border: 1px solid rgba(126,145,211,.14);
  border-radius: 9px;
  background: rgba(255,255,255,.02);
}

.theme-midnight .dungeon-group-evidence summary {
  cursor: pointer;
  font-weight: 750;
}

.theme-midnight .dungeon-group-evidence p {
  margin: 7px 0 4px;
  color: var(--muted, #aeb8d5);
}

.theme-midnight .dungeon-group-evidence small {
  display: block;
  color: var(--muted, #8f9abc);
}

@media (max-width: 800px) {
  .theme-midnight .dungeon-route-map-head {
    display: grid;
  }

  .theme-midnight .dungeon-map-toolbar {
    justify-items: start;
  }

  .theme-midnight .dungeon-map-controls {
    justify-content: flex-start;
  }

  .theme-midnight .dungeon-pace-budget,
  .theme-midnight .dungeon-pace-lists {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .theme-midnight .dungeon-map-viewport {
    min-height: 0;
    height: auto;
  }

  .theme-midnight .dungeon-map-legend .route-note {
    width: 100%;
    margin-left: 0;
  }
}

@media (max-width: 520px) {
  .theme-midnight .dungeon-route-map {
    padding: 11px;
  }

  .theme-midnight .dungeon-map-viewport {
    min-height: 0;
    height: auto;
  }

  .theme-midnight .dungeon-map-marker {
    width: 36px;
    height: 36px;
  }

  .theme-midnight .dungeon-map-marker.boss {
    width: 41px;
    height: 41px;
  }

  .theme-midnight .dungeon-pace-budget,
  .theme-midnight .dungeon-pace-lists {
    grid-template-columns: 1fr;
  }

  .theme-midnight .dungeon-route-map.pace-mode .dungeon-map-marker.trash {
    width: calc(36px * var(--pace-scale, 1));
    height: calc(36px * var(--pace-scale, 1));
  }

  .theme-midnight .dungeon-route-map.pace-mode .dungeon-map-marker.boss {
    width: calc(41px * var(--pace-scale, 1));
    height: calc(41px * var(--pace-scale, 1));
  }
}


.theme-midnight .dungeon-composition-overview {
  margin-top: 18px;
  padding: 18px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 16px;
  background: rgba(7,11,24,.58);
}

.theme-midnight .dungeon-composition-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit,minmax(220px,1fr));
  gap: 10px;
}

.theme-midnight .dungeon-composition-pull {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  padding: 12px 14px;
  text-align: left;
  border: 1px solid rgba(122,154,220,.24);
  border-radius: 12px;
  background: rgba(16,24,45,.72);
}

.theme-midnight .dungeon-composition-pull strong {
  font-size: .9rem;
}

.theme-midnight .dungeon-composition-pull span {
  color: var(--muted);
  font-size: .8rem;
  line-height: 1.35;
}

.theme-midnight .dungeon-composition-pull:hover:not(:disabled),
.theme-midnight .dungeon-composition-pull:focus-visible {
  border-color: rgba(127,176,255,.62);
  background: rgba(26,38,67,.88);
}

.theme-midnight .dungeon-composition-note {
  margin-top: 10px;
  color: var(--muted);
  font-size: .78rem;
  line-height: 1.4;
}


.theme-midnight .dungeon-mdt-import {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin: 0 0 12px;
}

.theme-midnight .dungeon-mdt-file {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid rgba(127,176,255,.35);
  border-radius: 10px;
  background: rgba(25,36,63,.84);
  font-size: .82rem;
  cursor: pointer;
}

.theme-midnight .dungeon-mdt-file input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.theme-midnight .dungeon-mdt-state {
  color: var(--muted);
  font-size: .78rem;
  line-height: 1.35;
}

.theme-midnight .dungeon-mdt-state.ok { color: #9fd8b2; }
.theme-midnight .dungeon-mdt-state.bad { color: #ffaaa5; }

.theme-midnight .dungeon-composition-item {
  min-width: 0;
  border: 1px solid rgba(122,154,220,.15);
  border-radius: 12px;
  background: rgba(11,17,33,.46);
  overflow: hidden;
}

.theme-midnight .dungeon-composition-item .dungeon-composition-pull {
  width: 100%;
  border: 0;
  border-radius: 0;
}

.theme-midnight .dungeon-mdt-group-result {
  min-height: 0;
  padding: 0 12px 10px;
  color: var(--muted);
  font-size: .76rem;
  line-height: 1.35;
}

.theme-midnight .dungeon-mdt-group-result:empty {
  display: none;
}

.theme-midnight .dungeon-mdt-group-result strong {
  color: var(--text);
}

.theme-midnight .dungeon-mdt-group-result small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
}

.theme-midnight .dungeon-mdt-group-result.unique-composition {
  color: #b8d3ff;
}

.theme-midnight .dungeon-mdt-group-result.ambiguous-composition {
  color: #e7c78d;
}

.theme-midnight .dungeon-map-event-badges {
  display: none;
  position: absolute;
  left: calc(100% - 5px);
  top: -8px;
  z-index: 5;
  gap: 3px;
  white-space: nowrap;
  pointer-events: none;
}

.theme-midnight .dungeon-route-map.events-mode .dungeon-map-event-badges {
  display: flex;
}

.theme-midnight .dungeon-map-event-badges b {
  min-width: 22px;
  padding: 2px 5px;
  border: 1px solid rgba(126,145,211,.38);
  border-radius: 999px;
  background: rgba(9,14,30,.94);
  color: #cbd5f4;
  font-size: 10px;
  line-height: 1.2;
  font-weight: 850;
}

.theme-midnight .dungeon-map-event-badges b.death {
  border-color: rgba(226,123,123,.55);
  color: #ffd0d0;
}

.theme-midnight .dungeon-route-map.events-mode .dungeon-map-route {
  opacity: .42;
}

.theme-midnight .dungeon-events-panel {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(126,145,211,.18);
  border-radius: 12px;
  background: rgba(11,17,37,.58);
}

.theme-midnight .dungeon-events-panel[hidden] {
  display: none;
}

.theme-midnight .dungeon-events-grid {
  display: grid;
  grid-template-columns: repeat(2,minmax(0,1fr));
  gap: 12px;
}

.theme-midnight .dungeon-events-grid section {
  display: grid;
  gap: 6px;
}

.theme-midnight .dungeon-events-grid h4 {
  margin: 0 0 2px;
}

.theme-midnight .dungeon-events-grid button {
  width: 100%;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  min-height: 34px;
  padding: 7px 10px;
  text-align: left;
  background: rgba(255,255,255,.025);
}

.theme-midnight .dungeon-events-grid button strong {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.theme-midnight .dungeon-events-grid p,
.theme-midnight .dungeon-events-note {
  margin: 0;
  color: var(--muted, #9da8c9);
  font-size: 12px;
}

@media (max-width:800px){
  .theme-midnight .dungeon-events-grid{grid-template-columns:1fr;}
}

.theme-midnight .dungeon-movement-status {
  display: grid;
  gap: 3px;
  padding: 10px 12px;
  border: 1px solid rgba(118,218,255,.22);
  border-radius: 10px;
  background: rgba(32,86,116,.12);
}

.theme-midnight .dungeon-movement-status[hidden] {
  display: none;
}

.theme-midnight .dungeon-movement-status span {
  color: var(--muted, #9da8c9);
  font-size: 13px;
}

.theme-midnight .dungeon-movement-status.warning {
  border-color: rgba(217,168,78,.3);
  background: rgba(110,75,28,.12);
}

.theme-midnight .dungeon-movement-status.ready {
  border-color: rgba(118,218,255,.35);
}

.theme-midnight .dungeon-compare-panel {
  display: grid;
  gap: 12px;
  padding: 13px;
  border: 1px solid rgba(126,145,211,.18);
  border-radius: 12px;
  background: rgba(11,17,37,.58);
}

.theme-midnight .dungeon-compare-panel[hidden] {
  display: none;
}

.theme-midnight .dungeon-compare-panel > p {
  margin: 0;
  color: var(--muted, #9da8c9);
  font-size: 13px;
}

.theme-midnight .dungeon-compare-form {
  display: grid;
  grid-template-columns: minmax(0,1fr) auto;
  gap: 9px;
  align-items: end;
}

.theme-midnight .dungeon-compare-form label {
  display: grid;
  gap: 5px;
}

.theme-midnight .dungeon-compare-form label span {
  color: var(--muted, #aeb8d5);
  font-size: 12px;
}

.theme-midnight .dungeon-compare-form input {
  width: 100%;
  min-height: 38px;
}

.theme-midnight .dungeon-compare-summary {
  display: grid;
  grid-template-columns: repeat(4,minmax(0,1fr));
  gap: 8px;
}

.theme-midnight .dungeon-compare-summary > span {
  display: grid;
  gap: 2px;
  padding: 9px 10px;
  border: 1px solid rgba(126,145,211,.14);
  border-radius: 9px;
  background: rgba(255,255,255,.025);
}

.theme-midnight .dungeon-compare-summary small {
  color: var(--muted, #9da8c9);
}

.theme-midnight .dungeon-compare-summary strong {
  font-size: 18px;
  font-variant-numeric: tabular-nums;
}

.theme-midnight [data-compare-results] {
  display: grid;
  gap: 8px;
}

.theme-midnight .dungeon-compare-row {
  width: 100%;
  display: grid;
  justify-items: start;
  gap: 4px;
  padding: 10px 12px;
  text-align: left;
  border-color: rgba(126,145,211,.18);
  background: rgba(255,255,255,.025);
}

.theme-midnight .dungeon-compare-row small {
  color: var(--muted, #aeb8d5);
  white-space: normal;
}

.theme-midnight .dungeon-compare-relation {
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(103,82,177,.3);
  color: #dcd3ff;
  font-size: 11px;
  font-weight: 800;
}

.theme-midnight .dungeon-compare-unresolved {
  display: grid;
  gap: 3px;
  padding: 9px 11px;
  border: 1px solid rgba(217,168,78,.22);
  border-radius: 9px;
  background: rgba(110,75,28,.09);
}

.theme-midnight .dungeon-compare-unresolved span {
  color: var(--muted, #aeb8d5);
  font-size: 12px;
}

@media (max-width: 800px){
  .theme-midnight .dungeon-compare-summary {
    grid-template-columns: repeat(2,minmax(0,1fr));
  }

  .theme-midnight .dungeon-compare-form {
    grid-template-columns: 1fr;
  }

}
@media (max-width: 500px){

  .theme-midnight .dungeon-compare-summary {
    grid-template-columns: 1fr 1fr;
  }
}
