/* ===== Dungeons — global styles ===== */

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

:root {
  --bg: #0b0a12;
  --panel: #1a1726;
  --panel-light: #2a2640;
  --gold: #f3c552;
  --hp: #e6443b;
  --xp: #5ec8f0;
  --text: #e8e4f0;
  --muted: #9a93b3;
}

html, body {
  width: 100%;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  overflow: hidden;
  user-select: none;
}

#game {
  position: absolute;
  inset: 0;
}

#canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
}

.hidden { display: none !important; }

/* ===== HUD ===== */
#hud {
  position: absolute;
  top: 14px;
  left: 14px;
  right: 14px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  pointer-events: none;
  z-index: 5;
}

#hudLeft { display: flex; flex-direction: column; gap: 8px; }

.bar { display: flex; align-items: center; gap: 8px; }
.barLabel {
  width: 26px;
  font-weight: bold;
  font-size: 13px;
  color: var(--muted);
  text-align: right;
}
.barTrack {
  width: 240px;
  height: 18px;
  background: #00000066;
  border: 2px solid #000000aa;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 2px 6px #00000080;
}
.barFill {
  height: 100%;
  width: 100%;
  transition: width 0.18s ease;
}
.barFill.hp { background: linear-gradient(#ff7a6e, #c0241b); }
.barFill.xp { background: linear-gradient(#9be4ff, #2aa0d8); }
.barText {
  font-size: 12px;
  color: var(--text);
  text-shadow: 0 1px 2px #000;
  min-width: 70px;
}

#hudRight { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
#levelBadge, #goldBadge, #floorBadge {
  background: var(--panel);
  border: 2px solid #000000aa;
  border-radius: 8px;
  padding: 4px 12px;
  font-weight: bold;
  font-size: 14px;
  box-shadow: 0 2px 6px #00000080;
}
#levelBadge { color: var(--xp); }
#goldBadge { color: var(--gold); }
#floorBadge { color: var(--text); }

/* ===== Ability bar ===== */
#abilityBar {
  position: absolute;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
  z-index: 5;
}
.ability {
  width: 60px;
  height: 60px;
  background: var(--panel);
  border: 2px solid #000;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  box-shadow: 0 3px 8px #000000a0;
}
.ability .icon { font-size: 26px; line-height: 1; }
.ability .key {
  position: absolute;
  top: -8px;
  left: -8px;
  background: var(--panel-light);
  border: 2px solid #000;
  border-radius: 6px;
  font-size: 11px;
  font-weight: bold;
  padding: 1px 5px;
}
.ability .cd {
  position: absolute;
  inset: 0;
  background: #000000bb;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 18px;
}

/* ===== Banner / objective ===== */
#banner {
  position: absolute;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  background: #000000aa;
  border: 2px solid var(--gold);
  border-radius: 10px;
  padding: 8px 20px;
  font-size: 16px;
  font-weight: bold;
  color: var(--gold);
  z-index: 5;
  text-align: center;
  box-shadow: 0 3px 10px #000;
}

/* ===== Overlays (title, class select, win/lose) ===== */
#overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  text-align: center;
}
#overlay.empty { display: none; }

#overlay::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, #1a1430cc 0%, #06040bee 80%);
  z-index: -1;
}

.title-art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.3;
  z-index: -1;
  filter: saturate(1.1);
}

.title-big {
  font-size: 84px;
  font-weight: 900;
  letter-spacing: 4px;
  color: var(--gold);
  text-shadow: 0 0 24px #f3c55266, 0 6px 0 #6b4e10, 0 8px 18px #000;
  margin-bottom: 4px;
}
.title-sub {
  font-size: 18px;
  color: var(--muted);
  margin-bottom: 40px;
  letter-spacing: 1px;
}

/* save slots */
.slot-grid { display: flex; gap: 16px; margin-bottom: 28px; flex-wrap: wrap; justify-content: center; }
.slot-card {
  width: 220px;
  background: linear-gradient(var(--panel-light), var(--panel));
  border: 3px solid #000;
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 4px 0 #000, 0 8px 18px #00000080;
}
.slot-card.empty { opacity: 0.9; }
.slot-head { font-size: 13px; color: var(--muted); letter-spacing: 2px; margin-bottom: 8px; }
.slot-hero { font-size: 20px; font-weight: bold; margin-bottom: 6px; }
.slot-sub { font-size: 13px; color: var(--muted); line-height: 1.5; margin-bottom: 12px; }
.slot-btns { display: flex; gap: 8px; justify-content: center; }

.btn {
  background: linear-gradient(var(--panel-light), var(--panel));
  color: var(--text);
  border: 2px solid #000;
  border-radius: 12px;
  padding: 14px 38px;
  font-size: 20px;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 4px 0 #000, 0 6px 14px #00000080;
  transition: transform 0.08s, box-shadow 0.08s;
  font-family: inherit;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 6px 0 #000, 0 10px 18px #00000080; }
.btn:active { transform: translateY(2px); box-shadow: 0 2px 0 #000; }
.btn.gold { color: #2a1c00; background: linear-gradient(#ffd970, #e0a92e); }

.panel-text {
  max-width: 640px;
  color: var(--text);
  font-size: 17px;
  line-height: 1.5;
  margin-bottom: 30px;
}
.panel-text .muted { color: var(--muted); }

/* ===== Class select ===== */
.class-grid {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 900px;
  margin-bottom: 28px;
}
.class-card {
  width: 200px;
  background: linear-gradient(var(--panel-light), var(--panel));
  border: 3px solid #000;
  border-radius: 14px;
  padding: 18px 16px;
  cursor: pointer;
  transition: transform 0.1s, border-color 0.1s;
}
.class-card:hover { transform: translateY(-4px); }
.class-card.selected { border-color: var(--gold); box-shadow: 0 0 18px var(--gold); }
.class-card .emoji { font-size: 50px; }
.class-card .cname { font-size: 22px; font-weight: bold; margin: 6px 0; }
.class-card .cdesc { font-size: 13px; color: var(--muted); line-height: 1.4; min-height: 56px; }
.class-card .cstats { font-size: 12px; color: var(--text); margin-top: 8px; text-align: left; }
.class-card .cstats span { color: var(--gold); }

/* ===== Loot / level-up popups ===== */
.popup-card {
  background: linear-gradient(var(--panel-light), var(--panel));
  border: 3px solid var(--gold);
  border-radius: 14px;
  padding: 26px 34px;
  max-width: 520px;
  box-shadow: 0 0 30px #00000090;
}
.popup-card h2 { font-size: 30px; margin-bottom: 10px; }
.popup-card .reward { font-size: 18px; margin: 6px 0; }

.result-title { font-size: 64px; font-weight: 900; margin-bottom: 10px; }
.result-title.win { color: var(--gold); text-shadow: 0 0 24px var(--gold); }
.result-title.lose { color: var(--hp); text-shadow: 0 0 24px var(--hp); }

/* rarity colors */
.r-common { color: #d8d8d8; }
.r-uncommon { color: #5ed66a; }
.r-rare { color: #4aa6ff; }
.r-epic { color: #c46bff; }
.r-legendary { color: #ffb13d; }
.r-mythic { color: #ff5a8a; }
.r-ancient { color: #3fe0c0; }
.r-celestial { color: #fff2a0; }

/* ability count badge (potions) */
.ability .count {
  position: absolute;
  bottom: -8px;
  right: -8px;
  background: var(--panel-light);
  border: 2px solid #000;
  border-radius: 8px;
  font-size: 12px;
  font-weight: bold;
  padding: 0 6px;
  color: var(--gold);
}

.btn.small {
  padding: 7px 16px;
  font-size: 15px;
  box-shadow: 0 3px 0 #000, 0 4px 8px #00000080;
}
.btn.small:active { box-shadow: 0 1px 0 #000; }
.btn[disabled] { opacity: 0.4; cursor: not-allowed; filter: grayscale(0.6); }

/* ===== Town hub ===== */
.town {
  width: min(1100px, 94vw);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  background: linear-gradient(#171426, #0d0b16);
  border: 3px solid #000;
  border-radius: 16px;
  box-shadow: 0 0 40px #000a;
  overflow: hidden;
}
.town-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 22px;
  background: #221d36;
  border-bottom: 2px solid #000;
  font-size: 16px;
  flex-wrap: wrap;
  gap: 8px;
}
.town-header .th-gold { color: var(--gold); }
/* tabs */
.town-tabs {
  display: flex;
  gap: 6px;
  padding: 10px 16px 0;
  background: #1a1626;
  flex-wrap: wrap;
}
.town-tab {
  background: var(--panel);
  color: var(--muted);
  border: 2px solid #000;
  border-bottom: none;
  border-radius: 10px 10px 0 0;
  padding: 8px 16px;
  font-size: 15px;
  font-weight: bold;
  cursor: pointer;
  font-family: inherit;
}
.town-tab:hover { color: var(--text); }
.town-tab.active { background: var(--panel-light); color: var(--gold); }

.town-body {
  padding: 16px;
  overflow-y: auto;
  max-height: 70vh;
  min-height: 0;
}
.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* merchant cards */
.merch-card {
  background: linear-gradient(var(--panel-light), var(--panel));
  border: 2px solid #000;
  border-radius: 12px;
  padding: 12px 14px;
  text-align: left;
}
.merch-card h4 { font-size: 17px; margin-bottom: 4px; }
.merch-card p { font-size: 13px; margin-bottom: 8px; }
.merch-card .btn { margin: 3px 4px 0 0; }
.ench-row { display: flex; flex-wrap: wrap; gap: 5px; }

.btn.tiny {
  padding: 5px 10px;
  font-size: 13px;
  box-shadow: 0 2px 0 #000;
  border-radius: 8px;
}

/* inventory */
.equip-row { display: flex; flex-direction: column; gap: 4px; text-align: left; font-size: 15px; margin-bottom: 10px; }
.inv-controls { text-align: left; margin-bottom: 10px; font-size: 13px; }
.inv-controls .btn.tiny { margin: 2px; }
.inv-list { display: flex; flex-direction: column; gap: 5px; }
.inv-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--panel);
  border: 1px solid #000;
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 14px;
  text-align: left;
}

/* collection */
.col-count { text-align: left; font-size: 16px; margin-bottom: 10px; color: var(--gold); }
.col-grid { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.col-head { width: 100%; text-align: left; color: var(--muted); font-size: 13px; margin: 8px 0 2px; text-transform: capitalize; }
.col-cell {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  background: var(--panel);
  border: 2px solid #000;
  border-radius: 7px;
  font-size: 18px;
}
.col-cell.locked { opacity: 0.35; filter: grayscale(1); }
.col-cell.uni { box-shadow: 0 0 8px #ffd23d; }

/* collection list with names */
.coll-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 230px;
  background: var(--panel);
  border: 1px solid #000;
  border-left: 4px solid #000;
  border-radius: 8px;
  padding: 5px 9px;
  text-align: left;
}
.coll-item.locked { opacity: 0.5; }
.coll-item.uni { box-shadow: 0 0 8px #ffd23d; }
.coll-item .ci-emoji { font-size: 18px; }
.coll-item .ci-name { font-size: 13px; font-weight: bold; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.coll-item .ci-tier { font-size: 10px; color: var(--muted); white-space: nowrap; }

/* enchanting */
.ench-current { background: var(--panel); border: 2px solid #000; border-radius: 10px; padding: 10px 14px; margin-bottom: 14px; text-align: left; }
.ench-weap { font-size: 16px; font-weight: bold; margin-bottom: 6px; }
.ench-slot { font-size: 13px; padding: 4px 0; border-top: 1px solid #0006; }
.ench-card { display: flex; align-items: center; gap: 10px; background: var(--panel); border: 1px solid #000; border-radius: 8px; padding: 7px 10px; text-align: left; }
.ench-card .ec-mid { flex: 1; }
.ench-card .ec-name { font-size: 14px; font-weight: bold; }
.ench-card .ec-desc { font-size: 11px; color: var(--muted); }

/* skill tree */
.skill-start { display: flex; justify-content: center; margin-bottom: 6px; }
.skill-start .skill-node { width: 260px; }
.skill-cols { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.skill-col { text-align: center; }
.skill-col h4 { font-size: 16px; color: var(--gold); margin-bottom: 6px; }
.skill-node {
  background: var(--panel);
  border: 2px solid #000;
  border-radius: 10px;
  padding: 7px 10px;
  text-align: left;
  opacity: 0.6;
}
.skill-node.owned { opacity: 1; border-color: var(--uncommon, #5ed66a); border-color: #5ed66a; }
.skill-node.avail { opacity: 1; border-color: var(--gold); }
.skill-node.ult .sk-top b { color: #ff8a3d; }
.skill-node .sk-top { font-size: 14px; display: flex; align-items: center; gap: 6px; }
.skill-node .sk-cost { margin-left: auto; color: var(--muted); font-size: 12px; }
.skill-node .sk-desc { font-size: 12px; color: var(--muted); margin: 3px 0 5px; }
.sk-link { text-align: center; color: var(--muted); font-size: 13px; line-height: 1; }

/* gallery */
.gallery { text-align: left; }
.gallery h4 { font-size: 17px; color: var(--gold); margin: 6px 0 8px; }
.gallery-img {
  width: 100%;
  border: 2px solid #000;
  border-radius: 8px;
  margin-bottom: 16px;
  display: block;
}

/* achievements / goals */
.ach-list { display: flex; flex-direction: column; gap: 6px; }
.ach {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--panel);
  border: 2px solid #000;
  border-radius: 10px;
  padding: 8px 12px;
  text-align: left;
  opacity: 0.6;
}
.ach.got { opacity: 1; border-color: var(--gold); }
.ach-i { font-size: 24px; }
.ach-m { flex: 1; }
.ach-n { font-size: 15px; font-weight: bold; }
.ach-d { font-size: 12px; color: var(--muted); }
.ach-r { font-size: 13px; color: var(--gold); font-weight: bold; }

/* hero stat sheet */
.hero-head { text-align: left; font-size: 20px; margin-bottom: 12px; }
.stat-grid { display: flex; flex-direction: column; gap: 4px; }
.stat-row {
  display: flex;
  justify-content: space-between;
  background: var(--panel);
  border: 1px solid #000;
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 14px;
  text-align: left;
}
.stat-row b { color: var(--gold); }

/* unique-drop celebration flash */
.unique-flash {
  position: absolute;
  inset: 0;
  z-index: 9;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.35s ease;
  background: radial-gradient(ellipse at center, #ffd23d33 0%, #ffd23d10 35%, transparent 65%);
}
.unique-flash.show { opacity: 1; }
.unique-flash .uf-title {
  font-size: 40px;
  font-weight: 900;
  color: var(--gold);
  text-shadow: 0 0 22px #ffd23d, 0 4px 0 #6b4e10, 0 6px 14px #000;
  letter-spacing: 3px;
}
.unique-flash .uf-name {
  font-size: 30px;
  font-weight: bold;
  color: #fff;
  text-shadow: 0 2px 8px #000;
}
.unique-flash .uf-aff { font-size: 16px; color: #ffe9a8; text-shadow: 0 2px 6px #000; }

.mission-card {
  background: linear-gradient(var(--panel-light), var(--panel));
  border: 2px solid #000;
  border-radius: 12px;
  padding: 12px 14px;
  text-align: left;
}
.mission-card.locked { opacity: 0.72; }
.mission-card .m-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.mission-card .m-name { font-size: 17px; font-weight: bold; color: var(--text); }
.mission-card .m-theme { font-size: 12px; color: var(--muted); }
.mission-card .m-flavor { font-size: 13px; color: var(--muted); margin: 5px 0; line-height: 1.35; }
.mission-card .m-obj { font-size: 13px; color: #bfe6ff; margin-bottom: 3px; }
.mission-card .m-reward { font-size: 13px; color: var(--gold); margin-bottom: 8px; }
.mission-card .m-locked { font-size: 13px; color: #ff8a8a; font-weight: bold; }

.shop-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: linear-gradient(var(--panel-light), var(--panel));
  border: 2px solid #000;
  border-radius: 12px;
  padding: 10px 14px;
  text-align: left;
}
.shop-card .s-emoji { font-size: 30px; }
.shop-card .s-mid { flex: 1; }
.shop-card .s-name { font-size: 15px; font-weight: bold; }
.shop-card .s-desc { font-size: 12px; color: var(--muted); }
.shop-card .s-owned { font-size: 22px; color: var(--xp); }

.hint {
  margin-top: 22px;
  color: var(--muted);
  font-size: 14px;
}
.hint kbd {
  background: var(--panel-light);
  border: 1px solid #000;
  border-radius: 4px;
  padding: 1px 7px;
  font-family: monospace;
  color: var(--text);
}
