/* Dungeon Exploration Screen Layout & Theme */

body[data-screen="dungeon"] {
  background: #080f19;
}

body[data-screen="dungeon"] #app {
  max-width: 1680px;
  padding: 0 14px 12px;
}

body[data-screen="dungeon"] #topbar {
  height: auto;
  min-height: 38px;
  padding: 4px 0;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

body[data-screen="dungeon"] #topbar h1 {
  font-size: 15px;
}

body[data-screen="dungeon"] .topActions button {
  min-height: 26px;
  padding: 3px 8px;
  font-size: 11px;
}

.dungeon-primary {
  background: linear-gradient(135deg, #274863, #173044 58%, #22354a);
  border-color: #f0ca81;
  box-shadow: 0 8px 26px rgba(240, 202, 129, 0.16);
}

.dungeon-screen {
  width: 100%;
  max-width: 1360px;
  margin: 0 auto;
  padding: 2px 0 8px;
}

.dungeon-shell {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.dungeon-topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  padding: 6px 12px;
  background: linear-gradient(180deg, rgba(20, 34, 50, 0.94), rgba(11, 20, 32, 0.96));
  border: 1px solid rgba(132, 184, 224, 0.25);
  border-radius: 8px;
}

.dungeon-floor-badge {
  display: flex;
  align-items: baseline;
  gap: 7px;
}

.dungeon-floor-badge span {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  background: #edcc92;
  color: #0e1824;
  font-weight: 800;
  font-size: 12px;
}

.dungeon-floor-badge strong {
  color: #f6eed9;
  font-size: 14px;
}

.dungeon-floor-badge small {
  color: #96b8d4;
  font-size: 11px;
}

.dungeon-vitals {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  font-size: 12px;
  color: #b8cde0;
}

.dungeon-vitals b {
  color: #fff3d1;
  font-variant-numeric: tabular-nums;
}

.dungeon-top-actions {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

.dungeon-top-actions button {
  padding: 4px 8px;
  min-height: 26px;
  border-radius: 5px;
  border: 1px solid rgba(145, 192, 226, 0.3);
  background: rgba(24, 42, 62, 0.85);
  color: #e4eef7;
  font-size: 11px;
  cursor: pointer;
}

.dungeon-main {
  display: grid;
  grid-template-columns: minmax(260px, 410px) minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

.dungeon-board-col {
  display: flex;
  flex-direction: column;
  gap: 5px;
  align-items: center;
  min-width: 0;
}

.dungeon-canvas-wrap {
  position: relative;
  width: 100%;
  max-width: 400px;
  border-radius: 10px;
  overflow: hidden;
  border: 2px solid rgba(237, 204, 146, 0.35);
  background: #08101a;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
}

#dgCanvas {
  display: block;
  width: 100%;
  height: auto;
  max-height: clamp(280px, 52vh, 456px);
  object-fit: contain;
  cursor: crosshair;
}

.dungeon-pin-bar {
  width: 100%;
  max-width: 400px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
  color: #adc4d8;
}

.dungeon-pin-bar button {
  padding: 3px 8px;
  min-height: 24px;
  font-size: 11px;
  border-radius: 5px;
  border: 1px solid rgba(237, 204, 146, 0.35);
  background: rgba(24, 38, 54, 0.85);
  color: #edcc92;
  cursor: pointer;
  flex-shrink: 0;
}

.dg-gate-overlay {
  position: absolute;
  inset: 0;
  background: rgba(6, 13, 22, 0.84);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.dg-gate-modal {
  background: #132131;
  border: 1px solid #edcc92;
  border-radius: 10px;
  padding: 14px;
  width: 100%;
  max-width: 340px;
  text-align: center;
}

.dg-gate-modal h3 {
  margin: 0 0 10px;
  color: #ffe9b3;
  font-size: 14px;
}

.dg-gate-choices {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.dg-gate-choices button {
  padding: 8px 10px;
  border-radius: 7px;
  border: 1px solid #9beeff;
  background: linear-gradient(90deg, #1b3852, #254a69);
  color: #f4fbff;
  font-weight: 700;
  cursor: pointer;
}

.dungeon-side {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.dg-box {
  background: rgba(16, 28, 42, 0.9);
  border: 1px solid rgba(132, 184, 224, 0.2);
  border-radius: 8px;
  padding: 8px 10px;
}

.dg-box h3 {
  margin: 0 0 6px;
  font-size: 12px;
  color: #edcc92;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.dg-stairs-dock {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.dg-stair-chip {
  flex: 1 1 150px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 9px;
  min-height: 30px;
  border-radius: 6px;
  border: 1px solid rgba(237, 204, 146, 0.35);
  background: rgba(18, 28, 42, 0.9);
  color: #f3deb2;
  font-size: 11px;
  text-align: left;
  cursor: pointer;
}

.dg-stair-chip span {
  font-weight: 700;
}

.dg-stair-chip small {
  font-size: 10px;
  opacity: 0.88;
}

.dg-stair-chip.locked {
  border-color: rgba(145, 160, 180, 0.28);
  color: #8f9fb4;
}

.dg-stair-chip.sealed {
  border-color: rgba(232, 186, 107, 0.5);
  background: rgba(42, 31, 18, 0.85);
}

.dg-stair-chip.exposed {
  border-color: #8cf2c2;
  background: linear-gradient(90deg, #164438, #22634f);
  color: #e4fff3;
  box-shadow: 0 0 12px rgba(140, 242, 194, 0.25);
}

.dg-objectives {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11.5px;
}

.dg-objectives li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 4px 7px;
  border-radius: 5px;
  background: rgba(12, 22, 34, 0.72);
  color: #cfe0ee;
}

.dg-objectives li.done {
  background: rgba(24, 62, 46, 0.7);
  color: #aef7cf;
}

.dg-objectives li small {
  font-size: 10.5px;
  color: #f3c978;
}

.dg-objectives li.done small {
  color: #7ee3b8;
  font-weight: 700;
}

.dg-loot-relic-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.dg-stance-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5px;
}

.dg-stance-row button {
  padding: 5px 4px;
  min-height: 30px;
  border-radius: 6px;
  border: 1px solid rgba(145, 192, 226, 0.25);
  background: rgba(14, 24, 36, 0.9);
  color: #bfd3e6;
  font-size: 11px;
  cursor: pointer;
}

.dg-stance-row button.on {
  border-color: #ffe08a;
  background: linear-gradient(180deg, #3a4f66, #213245);
  color: #fff6dc;
  font-weight: 700;
}

.dg-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.dg-chip {
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(34, 56, 78, 0.9);
  border: 1px solid rgba(154, 206, 244, 0.28);
  color: #e4f1fc;
  font-size: 11px;
}

.dg-chip.safe {
  border-color: #7ee3b8;
  color: #cfffe9;
}

.dg-chip.relic {
  border-color: #f3c46b;
  color: #ffe8b5;
}

.dg-muted, .dg-hint {
  color: #88a4bd;
  font-size: 11px;
  margin: 2px 0;
}

.dg-logs {
  margin: 0;
  padding-left: 14px;
  max-height: 150px;
  overflow-y: auto;
  font-size: 11px;
  color: #c9daea;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.dg-logs small {
  color: #799ab8;
  font-family: monospace;
}

.dungeon-hand-dock {
  background: rgba(13, 24, 36, 0.96);
  border: 1px solid rgba(132, 184, 224, 0.25);
  border-radius: 8px;
  padding: 8px 10px;
}

.dg-meters {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 10px;
  align-items: center;
  margin-bottom: 6px;
}

.dg-meter label {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: #bdd3e8;
  margin-bottom: 3px;
}

.dg-bar {
  height: 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.dg-bar span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #4db8ff, #8cf0ff);
  transition: width 100ms linear;
}

.dg-bar.break span {
  background: linear-gradient(90deg, #f09e48, #ffe17a);
}

.dg-deck-counts {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: #9cb8d1;
}

.dg-deck-counts button {
  padding: 4px 8px;
  min-height: 26px;
  border-radius: 5px;
  border: 1px solid #72d2f0;
  background: #17344a;
  color: #e2f7ff;
  font-size: 11px;
  cursor: pointer;
}

.dg-deck-counts button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.dg-hand-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}

.dg-card {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 2px;
  padding: 5px 6px;
  border-radius: 7px;
  border: 1px solid rgba(154, 206, 244, 0.3);
  background: linear-gradient(180deg, #1b2d40, #101b27);
  color: #eef5fc;
  text-align: left;
  cursor: pointer;
  min-height: 104px;
  min-width: 0;
}

.dg-card.playable:hover {
  border-color: #ffe08a;
  transform: translateY(-2px);
}

.dg-card.unplayable {
  opacity: 0.56;
}

.dg-card.camp-card {
  border-color: rgba(124, 232, 180, 0.55);
}

.dg-card-head {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
}

.dg-key {
  background: rgba(255, 255, 255, 0.12);
  padding: 0 4px;
  border-radius: 3px;
  font-weight: 700;
}

.dg-cost {
  color: #8be7ff;
  font-weight: 700;
}

.dg-card-art {
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 4px;
  background: rgba(8, 15, 23, 0.65);
}

.dg-card-art .card-art {
  width: 100%;
  height: 100%;
}

.dg-card-art img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.dg-card-name {
  font-size: 11.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dg-card-desc {
  font-size: 10px;
  line-height: 1.25;
  color: #b8cde0;
}

.dg-action-msg {
  margin: 4px 0 0;
  min-height: 15px;
  font-size: 11px;
  color: #ffe39b;
}

/* Safe Area */
.dungeon-safe {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.dg-safe-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 10px;
  background: linear-gradient(135deg, #16303c, #11202d);
  border: 1px solid rgba(126, 227, 184, 0.4);
}

.dg-safe-lead {
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: 720px;
}

.dg-safe-portrait {
  width: 78px;
  height: 104px;
  object-fit: cover;
  object-position: top center;
  border-radius: 8px;
  border: 1px solid rgba(237, 204, 146, 0.45);
  background: #0d1a26;
  flex-shrink: 0;
}

.dg-safe-dialogue {
  margin: 6px 0 0;
  color: #d6efe4;
  font-size: 13px;
}

.dg-safe-decisions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.dg-extract-btn {
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid #7ee3b8;
  background: #174435;
  color: #dcfff0;
  font-weight: 700;
  cursor: pointer;
}

.dg-safe-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.dg-safe-deck-box {
  grid-column: 1 / -1;
}

.dg-safe-actions {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: 10px;
}

.dg-safe-actions button {
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid rgba(154, 206, 244, 0.3);
  background: #1b2f44;
  color: #edf6ff;
  text-align: left;
  cursor: pointer;
}

.dg-safe-actions button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.dg-loot-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.dg-mini-card {
  width: 190px;
  padding: 8px;
  border-radius: 7px;
  border: 1px solid rgba(154, 206, 244, 0.25);
  background: #122030;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.dg-mini-card.selected {
  border-color: #ffe08a;
  box-shadow: 0 0 0 1px #ffe08a;
}

.dg-mini-card strong {
  font-size: 12.5px;
  color: #fff2cf;
}

.dg-mini-card small {
  font-size: 11px;
  color: #9eb7cd;
}

.dg-mini-actions {
  display: flex;
  gap: 5px;
  margin-top: 4px;
}

.dg-mini-actions button,
.dg-mini-card > button {
  padding: 4px 8px;
  border-radius: 5px;
  border: 1px solid rgba(237, 204, 146, 0.35);
  background: #1d334a;
  color: #f3e4bf;
  font-size: 11px;
  cursor: pointer;
}

.dg-swap-pick {
  padding: 6px 10px;
  border-radius: 6px;
  background: #2c3f2e;
  border: 1px solid #88e09b;
  color: #e4ffea;
  font-size: 12px;
  margin-bottom: 8px;
}

.dg-safe-deck-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 6px;
}

.dg-deck-slot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid rgba(145, 192, 226, 0.24);
  background: #132131;
  color: #e4eef7;
  font-size: 12px;
  cursor: pointer;
}

.dg-deck-slot.ready {
  border-color: #ffe08a;
  background: #23374d;
}

/* Result screen */
.dungeon-result {
  display: flex;
  justify-content: center;
  padding: 20px 10px;
}

.dg-result-card {
  width: 100%;
  max-width: 640px;
  background: #121f2e;
  border: 1px solid #edcc92;
  border-radius: 12px;
  padding: 20px;
}

.dg-res-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 14px 0;
}

.dg-res-stats div {
  background: #1a2c40;
  border-radius: 7px;
  padding: 8px;
  text-align: center;
}

.dg-res-stats span {
  display: block;
  font-size: 11px;
  color: #9eb7cd;
}

.dg-res-stats b {
  font-size: 16px;
  color: #ffe39b;
}

.dg-res-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

@media (max-width: 620px) {
  .dungeon-main {
    grid-template-columns: 1fr;
  }
  .dg-meters {
    grid-template-columns: 1fr;
  }
  .dg-hand-row {
    grid-template-columns: repeat(auto-fit, minmax(105px, 1fr));
  }
  .dg-safe-grid {
    grid-template-columns: 1fr;
  }
  .dg-res-stats {
    grid-template-columns: repeat(2, 1fr);
  }
}
