/* =============================================================
   Element Dungeon (Dungeon V.2) — element-dungeon.css
   Canvas roguelike over the periodic table. Loaded only by
   games/element-dungeon.html (bump ?v= there on every edit).
   ============================================================= */

/* ── Setup screen ─────────────────────────────────────────── */
.ed-setup-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 14px;
}
.ed-diff-card {
  border: 1.5px solid var(--border);
  border-radius: 14px;
  padding: 18px 16px;
  cursor: pointer;
  background: var(--surface2);
  transition: transform .12s ease, border-color .12s ease, box-shadow .12s ease;
  text-align: center;
  position: relative;
}
.ed-diff-card:hover { transform: translateY(-2px); }
.ed-diff-card.selected {
  border-color: var(--ed-diff-color, #f97316);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ed-diff-color, #f97316) 22%, transparent);
}
.ed-diff-card .ed-diff-icon { font-size: 2rem; margin-bottom: 6px; }
.ed-diff-card .ed-diff-name { font-weight: 800; font-size: 1.02rem; color: var(--ed-diff-color, var(--mg-text)); }
.ed-diff-card .ed-diff-desc { font-size: .74rem; color: var(--text2); margin-top: 6px; line-height: 1.45; }
.ed-diff-card .ed-diff-best { font-size: .72rem; color: var(--text3); margin-top: 8px; }
.ed-diff-card .ed-diff-best strong { color: var(--mg-text); }

.ed-begin-row { display: flex; gap: 10px; justify-content: center; align-items: center; flex-wrap: wrap; }
.ed-begin-btn {
  font-size: 1.05rem; font-weight: 800; padding: 12px 34px; border-radius: 12px;
  border: none; cursor: pointer; color: #1a1108;
  background: linear-gradient(180deg, #fbbf24, #f97316);
  box-shadow: 0 4px 14px rgba(249, 115, 22, .35);
  transition: transform .12s ease, box-shadow .12s ease;
}
.ed-begin-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(249, 115, 22, .45); }
/* Picking the Daily Descent recolours the one begin button rather than adding
   a second one, so the choice is visible before you commit to it. */
.ed-begin-btn.is-daily {
  color: #f2f5ff;
  background: linear-gradient(180deg, #818cf8, #4f46e5);
  box-shadow: 0 4px 14px rgba(99, 102, 241, .38);
}
.ed-begin-btn.is-daily:hover { box-shadow: 0 6px 18px rgba(99, 102, 241, .5); }
.ed-begin-btn:disabled { opacity: .55; cursor: default; transform: none; box-shadow: none; }

/* The Daily is chosen in the same grid as the difficulties, so it reads as one
   of the options — but keeps its own accent so it never looks like a fourth
   difficulty tier. */
.ed-diff-card.ed-diff-daily {
  border-style: dashed;
  background: rgba(129, 140, 248, .07);
}
.ed-diff-card.ed-diff-daily.selected {
  border-style: solid;
  background: rgba(129, 140, 248, .16);
}

.ed-asc-row {
  display: flex; align-items: center; gap: 7px; flex-wrap: wrap;
  margin: -4px 0 14px; padding: 9px 14px;
  border: 1.5px solid rgba(248, 113, 113, .35);
  background: rgba(248, 113, 113, .06);
  border-radius: 12px; font-size: .8rem;
}
.ed-asc-lbl { font-weight: 800; color: #f87171; white-space: nowrap; }
.ed-asc-pill {
  min-width: 30px; padding: 3px 0; border-radius: 8px; cursor: pointer;
  border: 1.5px solid var(--border); background: var(--surface2);
  color: var(--text2); font-weight: 800; font-size: .8rem;
  transition: border-color .1s ease, transform .1s ease;
}
.ed-asc-pill:hover { transform: translateY(-1px); border-color: #f87171; }
.ed-asc-pill.on { border-color: #f87171; background: rgba(248, 113, 113, .15); color: #f87171; }
.ed-asc-desc { font-size: .68rem; color: var(--text3); flex: 1; min-width: 160px; line-height: 1.45; }

.ed-resume-card {
  border: 1.5px dashed rgba(249, 115, 22, .5);
  background: rgba(249, 115, 22, .06);
  border-radius: 12px;
  padding: 12px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  flex-wrap: wrap; margin-bottom: 14px;
}

/* ── Game area / HUD ──────────────────────────────────────── */
#edGame { user-select: none; }
.ed-hud {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 10px 14px; margin-bottom: 10px;
  background: var(--surface2); border: 1px solid var(--border); border-radius: 12px;
  font-size: .85rem;
}
.ed-hud__hearts { font-size: 1rem; letter-spacing: 1px; white-space: nowrap; }
.ed-hud__item { color: var(--text2); white-space: nowrap; }
.ed-hud__item strong { color: var(--mg-text); font-variant-numeric: tabular-nums; }
.ed-hud__floor { font-weight: 800; color: #fb923c; white-space: nowrap; }
.ed-hud__spacer { flex: 1; }
.ed-hud__relics { font-size: 1rem; letter-spacing: 2px; cursor: default; }
.ed-xpbar { width: 90px; height: 7px; background: var(--surface3); border-radius: 4px; overflow: hidden; display: inline-block; vertical-align: middle; }
.ed-xpbar > div { height: 100%; background: linear-gradient(90deg, #a78bfa, #7c6ff7); transition: width .3s ease; }

.ed-potion-row { display: flex; gap: 6px; align-items: center; }
.ed-potion-btn {
  border: 1px solid var(--border); background: var(--surface3); border-radius: 9px;
  padding: 3px 8px; cursor: pointer; font-size: .95rem; line-height: 1.4;
  transition: transform .1s ease, border-color .1s ease;
}
.ed-potion-btn:hover { transform: translateY(-1px); border-color: #fb923c; }
.ed-potion-btn:disabled { opacity: .4; cursor: default; transform: none; }

.ed-canvas-wrap {
  position: relative;
  border-radius: 14px; overflow: hidden;
  border: 1px solid #2a2118;
  background: #0c0a08;
  box-shadow: 0 10px 34px rgba(0, 0, 0, .45);
}
#edCanvas { display: block; width: 100%; height: auto; touch-action: manipulation; }

.ed-floor-banner {
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%);
  background: rgba(12, 9, 5, .78); color: #fde68a;
  border: 1px solid rgba(251, 191, 36, .35);
  padding: 6px 18px; border-radius: 999px; font-weight: 800; font-size: .85rem;
  pointer-events: none; opacity: 0; transition: opacity .5s ease; white-space: nowrap;
}
.ed-floor-banner.show { opacity: 1; }

.ed-log {
  margin-top: 8px; min-height: 22px; font-size: .8rem; color: var(--text2);
  font-style: italic; text-align: center;
}

/* On-screen d-pad (touch devices only) */
.ed-dpad { display: none; }
@media (pointer: coarse) {
  .ed-dpad {
    display: grid; grid-template-columns: repeat(3, 54px); grid-template-rows: repeat(3, 54px);
    gap: 6px; margin: 12px auto 0; width: max-content;
  }
  .ed-dpad button {
    border: 1px solid var(--border); background: var(--surface2); color: var(--mg-text);
    border-radius: 12px; font-size: 1.3rem; cursor: pointer;
  }
  .ed-dpad button:active { background: var(--surface3); }
  .ed-dpad .blank { visibility: hidden; }
}

/* ── Battle overlay ───────────────────────────────────────── */
.ed-battle-modal {
  max-width: 560px; width: min(94vw, 560px);
  border: 1px solid rgba(249, 115, 22, .35);
}
.ed-battle-head { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }
.ed-battle-mon {
  font-size: 3.2rem; line-height: 1; filter: drop-shadow(0 4px 8px rgba(0,0,0,.5));
  animation: edMonBob 1.6s ease-in-out infinite;
}
.ed-battle-mon.hit { animation: edMonHit .35s ease; }
@keyframes edMonBob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
@keyframes edMonHit { 0% { transform: translateX(0); } 25% { transform: translateX(-7px) rotate(-5deg); } 55% { transform: translateX(6px) rotate(4deg); } 100% { transform: translateX(0); } }
.ed-battle-name { font-weight: 900; font-size: 1.05rem; }
.ed-battle-name .flavor { display: block; font-weight: 500; font-size: .72rem; color: var(--text2); margin-top: 2px; }
.ed-battle-hp { margin-top: 5px; font-size: .95rem; letter-spacing: 2px; }

.ed-q-elid { font-size: .78rem; color: var(--text3); margin-bottom: 4px; text-align: center; }
.ed-q-hint { font-size: .74rem; color: var(--text3); text-align: center; margin-bottom: 4px; }
.ed-q-text { font-size: 1.06rem; font-weight: 700; text-align: center; margin: 6px 0 12px; line-height: 1.45; }

.ed-timer-bar { height: 7px; background: var(--surface3); border-radius: 4px; overflow: hidden; margin-bottom: 14px; }
.ed-timer-fill { height: 100%; width: 100%; background: linear-gradient(90deg, #4ade80, #fbbf24, #ef4444); }

.ed-mc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.ed-mc-btn {
  padding: 11px 12px; border-radius: 11px; border: 1.5px solid var(--border);
  background: var(--surface2); color: var(--mg-text); font-weight: 700; font-size: .95rem;
  cursor: pointer; transition: border-color .12s ease, transform .12s ease;
}
.ed-mc-btn:hover { border-color: #fb923c; transform: translateY(-1px); }
.ed-mc-btn.correct { border-color: #4ade80; background: rgba(74, 222, 128, .12); color: #4ade80; }
.ed-mc-btn.wrong   { border-color: #ef4444; background: rgba(239, 68, 68, .12); color: #f87171; }
.ed-mc-btn.dimmed  { opacity: .3; pointer-events: none; }

.ed-fr-row { display: flex; gap: 8px; max-width: 340px; margin: 0 auto; }
.ed-fr-row input {
  flex: 1; padding: 10px 12px; font-size: 1rem; border-radius: 10px;
  border: 1.5px solid var(--border); background: var(--surface2); color: var(--mg-text);
}
.ed-fr-row input:focus { outline: none; border-color: #fb923c; }

.ed-battle-fb { text-align: center; min-height: 26px; margin-top: 12px; font-weight: 800; font-size: .95rem; }
.ed-battle-fb .good { color: #4ade80; }
.ed-battle-fb .bad  { color: #f87171; }

/* Wrong-answer reveal — big, readable, and it waits for you */
.ed-answer-reveal {
  border: 1.5px solid rgba(248, 113, 113, .4);
  background: rgba(248, 113, 113, .07);
  border-radius: 12px;
  padding: 12px 14px 14px;
  margin-top: 4px;
}
.ed-answer-reveal .rv-lbl { font-size: .78rem; font-weight: 700; color: #f87171; }
.ed-answer-reveal .rv-big {
  font-size: 1.55rem; font-weight: 900; color: var(--mg-text);
  margin: 4px 0 2px; line-height: 1.2;
}
.ed-answer-reveal .rv-id {
  font-size: .8rem; color: var(--text2); font-weight: 600; margin-bottom: 8px;
}
.ed-answer-reveal .rv-dmg { font-size: .9rem; font-weight: 800; color: #f87171; margin-top: 2px; }
.ed-answer-reveal .rv-note { font-size: .76rem; font-weight: 600; margin-top: 4px; }
.ed-answer-reveal .rv-btn { margin-top: 10px; }
.ed-answer-reveal .rv-key { opacity: .6; font-weight: 500; }
.ed-battle-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; gap: 8px; flex-wrap: wrap; }
.ed-battle-foot .ed-hearts-mini { font-size: .95rem; letter-spacing: 1px; }

/* ── Shrine / merchant / summary modals ───────────────────── */
.ed-choice-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 14px; }
.ed-choice-card {
  border: 1.5px solid var(--border); border-radius: 12px; background: var(--surface2);
  padding: 14px 10px; text-align: center; cursor: pointer;
  transition: transform .12s ease, border-color .12s ease;
}
.ed-choice-card:hover { transform: translateY(-2px); border-color: #a78bfa; }
.ed-choice-card .icon { font-size: 1.8rem; }
.ed-choice-card .nm   { font-weight: 800; font-size: .88rem; margin-top: 5px; }
.ed-choice-card .ds   { font-size: .7rem; color: var(--text2); margin-top: 4px; line-height: 1.4; }
.ed-choice-card.owned { opacity: .45; pointer-events: none; }
.ed-choice-card .price { font-size: .76rem; color: #fbbf24; font-weight: 800; margin-top: 6px; }
.ed-choice-card.cant-afford { opacity: .45; pointer-events: none; }

.ed-summary-hero { text-align: center; margin-bottom: 14px; }
.ed-summary-hero .big { font-size: 3rem; }
.ed-summary-hero .ttl { font-weight: 900; font-size: 1.3rem; margin-top: 4px; }
.ed-summary-hero .sub { color: var(--text2); font-size: .82rem; margin-top: 4px; }
.ed-summary-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 14px;
}
.ed-summary-grid .box {
  background: var(--surface2); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 6px; text-align: center;
}
.ed-summary-grid .box .v { font-weight: 900; font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.ed-summary-grid .box .l { font-size: .66rem; color: var(--text3); margin-top: 3px; text-transform: uppercase; letter-spacing: .04em; }
.ed-score-lines { font-size: .8rem; color: var(--text2); margin-bottom: 14px; }
.ed-score-lines div { display: flex; justify-content: space-between; padding: 3px 2px; }
.ed-score-lines .total { border-top: 1px solid var(--border); margin-top: 5px; padding-top: 7px; font-weight: 900; color: var(--mg-text); font-size: .92rem; }

/* ── Catalyst meter & cast buttons ────────────────────────── */
.ed-cat-pip {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--surface3); border: 1px solid var(--border);
  margin-left: 3px; vertical-align: middle;
}
.ed-cat-pip.on { background: #a78bfa; border-color: #a78bfa; box-shadow: 0 0 5px rgba(167, 139, 250, .7); }
.ed-cast-btn {
  border: 1px solid #a78bfa; border-radius: 9px; cursor: pointer;
  background: linear-gradient(180deg, rgba(167, 139, 250, .25), rgba(124, 111, 247, .25));
  color: #c4b5fd; font-weight: 800; font-size: .78rem; padding: 3px 10px;
  animation: edCastGlow 1.2s ease-in-out infinite;
}
.ed-cast-btn:hover { transform: translateY(-1px); }
@keyframes edCastGlow {
  0%, 100% { box-shadow: 0 0 4px rgba(167, 139, 250, .5); }
  50%      { box-shadow: 0 0 12px rgba(167, 139, 250, .9); }
}

/* ── Relic overflow badge ─────────────────────────────────── */
.ed-relic-more {
  font-size: .68rem; font-weight: 800; color: var(--text2);
  background: var(--surface3); border: 1px solid var(--border);
  border-radius: 999px; padding: 1px 6px; letter-spacing: 0; vertical-align: middle;
}

/* ── Damage flash on the battle modal ─────────────────────── */
.ed-battle-modal.dmg { animation: edModalDmg .45s ease; }
@keyframes edModalDmg {
  0%   { box-shadow: inset 0 0 0 3px rgba(239, 68, 68, .0); transform: translateX(0); }
  20%  { box-shadow: inset 0 0 40px rgba(239, 68, 68, .35); transform: translateX(-6px); }
  45%  { transform: translateX(5px); }
  70%  { box-shadow: inset 0 0 24px rgba(239, 68, 68, .2); transform: translateX(-3px); }
  100% { box-shadow: inset 0 0 0 0 rgba(239, 68, 68, 0); transform: translateX(0); }
}

/* ── Trait chips (battle header + bestiary) ───────────────── */
.ed-trait-chip {
  display: inline-block; font-size: .62rem; font-weight: 700;
  padding: 1px 7px; border-radius: 999px; margin: 2px 4px 0 0;
  background: var(--surface3); border: 1px solid var(--border); color: var(--text2);
  vertical-align: middle; white-space: nowrap;
}
.ed-battle-traits { display: block; margin-top: 3px; }

/* ── Setup meta row (Sanctum / Bestiary) ──────────────────── */
.ed-meta-row { display: flex; gap: 10px; justify-content: center; margin-top: 12px; flex-wrap: wrap; }
.ed-shard { color: #38bdf8; font-weight: 800; }

/* ── Sanctum & Bestiary overlays ──────────────────────────── */
.ed-scroll-body { max-height: 60vh; overflow-y: auto; margin-top: 12px; padding-right: 4px; }

.ed-sanct-grid, .ed-best-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px;
}
.ed-sanct-card {
  border: 1.5px solid var(--border); border-radius: 12px; background: var(--surface2);
  padding: 12px 10px; text-align: center;
  display: flex; flex-direction: column; gap: 4px; align-items: center;
}
.ed-sanct-card .icon { font-size: 1.7rem; }
.ed-sanct-card .nm   { font-weight: 800; font-size: .85rem; }
.ed-sanct-card .ds   { font-size: .7rem; color: var(--text2); line-height: 1.4; flex: 1; }
.ed-sanct-card.locked { opacity: .6; }
.ed-sanct-card.maxed  { border-color: rgba(74, 222, 128, .45); }
.ed-sanct-card .owned-tag { color: #4ade80; font-weight: 800; font-size: .78rem; }
.ed-sanct-card .pips { white-space: nowrap; }
.ed-sanct-card .pip {
  display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: var(--surface3); border: 1px solid var(--border); margin-left: 3px;
  vertical-align: middle;
}
.ed-sanct-card .pip.on { background: #38bdf8; border-color: #38bdf8; }

.ed-best-sec { font-weight: 900; font-size: .82rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text3); margin: 14px 0 8px; }
.ed-best-sec:first-child { margin-top: 0; }
.ed-best-card {
  border: 1.5px solid var(--border); border-radius: 12px; background: var(--surface2);
  padding: 12px 10px; text-align: center;
}
.ed-best-card .icon  { font-size: 1.9rem; }
.ed-best-card .nm    { font-weight: 800; font-size: .88rem; margin-top: 4px; }
.ed-best-card .meta  { font-size: .68rem; color: var(--text3); margin-top: 3px; }
.ed-best-card .ds    { font-size: .7rem; color: var(--text2); margin-top: 5px; line-height: 1.45; font-style: italic; }
.ed-best-card .kills { font-size: .7rem; color: #fb923c; font-weight: 700; margin-top: 6px; }
.ed-best-card.unknown { opacity: .55; }
.ed-best-card.unknown .icon { filter: grayscale(1); }
.ed-best-card.boss { border-color: rgba(248, 113, 113, .35); }

/* ── Tutorial ─────────────────────────────────────────────── */
.ed-tut-step { font-size: .72rem; color: var(--text3); letter-spacing: .06em; text-transform: uppercase; margin-bottom: 8px; }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 900px) {
  html:not(.force-desktop) .ed-setup-grid { grid-template-columns: 1fr; }
  html:not(.force-desktop) .ed-choice-grid { grid-template-columns: 1fr; }
  html:not(.force-desktop) .ed-summary-grid { grid-template-columns: repeat(2, 1fr); }
  html:not(.force-desktop) .ed-hud { gap: 8px; font-size: .78rem; padding: 8px 10px; }
  html:not(.force-desktop) .ed-mc-grid { grid-template-columns: 1fr; }
}
