/* Dungeon and achievements, legacy rules extracted from style.css. */
/* ── ACHIEVEMENTS PAGE (ARG) ── */

/* Scanlines */
/* Full-screen app layout — dungeon page never scrolls on desktop */
.ach-body {
  position: relative;
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
/* Footer is below the fold in app-mode; hidden by overflow */
body.ach-body footer { display: none; }
.ach-scanlines {
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0px,
    transparent 3px,
    rgba(0,0,0,0.04) 3px,
    rgba(0,0,0,0.04) 4px
  );
  pointer-events: none;
  z-index: 9990;
}

.ach-page {
  max-width: 1440px;
  width: 100%;
  box-sizing: border-box;
  margin: 0 auto;
  padding: 76px 24px 0 24px;
  position: relative;
  flex: 1;                /* fills body height */
  min-height: 0;
  overflow: hidden;
  /* Grid: narrow sidebar | dungeon (sidebar spans dungeon + footer rows) */
  display: grid;
  grid-template-columns: 40px 1fr;
  grid-template-rows: 1fr auto;
  grid-template-areas:
    "side main"
    "side foot";
  column-gap: 20px;
}

/* ── Sidebar header ── */
.ach-page-header {
  grid-area: side;
  margin-bottom: 0;
  border-right: 1px solid var(--border);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding-top: 10px;
  padding-right: 6px;
}

/* Terminal lines */
.ach-sys-lines {
  display: flex;
  flex-direction: row;   /* sidebar: 3 columns side-by-side */
  gap: 3px;
  margin-bottom: 0;
  overflow: hidden;
}

.ach-sys-line {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.06em;
  color: var(--muted);
  writing-mode: vertical-rl;
  transform: rotate(180deg);   /* read bottom-to-top */
  white-space: nowrap;
  line-height: 1.1;
  overflow: hidden;
}

.ach-prompt {
  color: var(--orange);
  margin-right: 8px;
  user-select: none;
}

.ach-sys-ok    { color: var(--green); }
.ach-sys-locked { color: #e05050; }
.ach-sys-muted  { color: var(--muted); }
.ach-sys-plat   { color: var(--plat-text) !important; }

/* Blinking cursor */
.ach-cursor {
  display: inline-block;
  color: var(--green);
  margin-left: 4px;
  animation: ach-blink 1.1s step-end infinite;
  line-height: 1;
}
@keyframes ach-blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

/* Figlet / ASCII title — hidden in sidebar layout, too wide for a 40px column */
.ach-page-title-art {
  display: none;
  font-family: var(--font-mono);
  font-size: clamp(4px, 0.6vw, 8px);
  line-height: 1;
  letter-spacing: 0;
  color: var(--text);
  display: block;
  width: fit-content;
  max-width: 100%;
  margin: 0 auto 4px;
  padding: 0;
  white-space: pre;
  overflow: hidden;
  animation: ach-glitch 7s infinite;
  text-shadow: 0 0 8px rgba(232, 228, 220, 0.08);
}
@keyframes ach-glitch {
  0%, 85%, 100% { transform: none; text-shadow: 0 0 8px rgba(232, 228, 220, 0.08); }
  87%  { transform: skewX(-4deg) translateX(3px);  text-shadow: -3px 0 var(--orange); }
  89%  { transform: skewX(3deg)  translateX(-2px); text-shadow: 3px 0 var(--green); }
  91%  { transform: none; text-shadow: 0 0 8px rgba(232, 228, 220, 0.08); }
  93%  { transform: translateX(2px); text-shadow: -2px 0 var(--orange); }
  95%  { transform: none; text-shadow: 0 0 8px rgba(232, 228, 220, 0.08); }
}

.ach-sys-divider {
  display: none; /* sidebar layout uses border-right on header instead */
}

/* Micro-footer — sits in the foot grid area (below dungeon, right of sidebar) */
.ach-mini-footer {
  grid-area: foot;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 0 7px;
  border-top: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.12em;
  color: var(--muted);
  opacity: 0.38;
  margin-top: 4px;
}

.troph-shelf {
  margin-bottom: 48px;
}

.troph-row {
  display: flex;
  justify-content: space-around;
  align-items: flex-end;
  padding: 8px 0 4px;
  gap: 8px;
  flex-wrap: wrap;
}

/* ASCII plank */
.troph-plank {
  font-family: var(--font-mono);
  font-size: 13px;
  color: rgba(232, 93, 4, 0.3);
  letter-spacing: -0.06em;
  overflow: hidden;
  white-space: nowrap;
  line-height: 1.2;
  user-select: none;
  margin: 0;
  padding: 0;
  text-align: center;
}

/* Individual trophy */
.troph-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: default;
}

/* Trophy label */
.troph-label {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-align: center;
  line-height: 1.4;
  white-space: nowrap;
  margin-top: 8px;
}

/* Description — revealed on hover */
.troph-desc {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-align: center;
  max-width: 130px;
  line-height: 1.5;
  margin-top: 5px;
  opacity: 0;
  transform: translateY(-3px);
  transition: opacity var(--dur-state) var(--ease-out), transform var(--dur-state) var(--ease-out);
  pointer-events: none;
}
.troph-item:hover .troph-desc { opacity: 1; transform: translateY(0); }
.troph-item--on  .troph-desc  { color: var(--muted); }
.troph-item--off .troph-desc  { color: #e05050; font-style: italic; }

/* ── Unlocked ── */
.troph-item--on .ta-art  { color: var(--orange); }
.troph-item--on .ta-stem { color: var(--orange); }
.troph-item--on .ta-base { color: var(--orange); }
.troph-item--on .troph-label { color: var(--text); }

/* ── Locked ── */
.troph-item--off .ta-art  { color: #383838; }
.troph-item--off .ta-stem { color: #383838; }
.troph-item--off .ta-base { color: #383838; }
.troph-item--off .ta-icon { color: #555; opacity: 0.55; }

/* Redact locked label like a classified document */
.troph-item--off .troph-label {
  background: rgba(255, 255, 255, 0.07);
  color: transparent !important;
  border-radius: 2px;
  padding: 1px 3px;
  user-select: none;
}

/* ── Platinum section ── */
.troph-platinum {
  margin-top: 8px;
  padding: 20px 24px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  text-align: center;
  background: var(--bg2);
}

.troph-plat-border {
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1;
  margin: 0;
  padding: 0;
  white-space: pre;
  overflow: hidden;
  width: 100%;
  color: #2a2a2a;
}
.troph-platinum--on .troph-plat-border  { color: rgba(176, 176, 216, 0.35); }
.troph-platinum--off .troph-plat-border { color: #252525; }

/* Platinum terminal header */
.troph-plat-header {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin-top: 20px;
  margin-bottom: 28px;
  align-self: flex-start;
  width: 100%;
}

/* Platinum name */
.troph-plat-name {
  font-family: var(--font-display);
  font-size: 32px;
  letter-spacing: 0.06em;
  margin-top: 10px;
}

/* Platinum desc */
.troph-plat-desc {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  margin-top: 6px;
  margin-bottom: 20px;
}

/* Platinum unlocked */
.troph-platinum--on {
  background: var(--surface-base);
}
.troph-platinum--on .ta-art  { color: var(--plat-text); }
.troph-platinum--on .ta-stem { color: var(--plat-text); }
.troph-platinum--on .ta-base { color: var(--plat-text); }
.troph-platinum--on .troph-plat-name { color: var(--plat-text); }
.troph-platinum--on .troph-plat-desc { color: var(--muted); }

/* Platinum locked */
.troph-platinum--off .ta-art  { color: #2a2a2a; }
.troph-platinum--off .ta-stem { color: #2a2a2a; }
.troph-platinum--off .ta-base { color: #2a2a2a; }
.troph-platinum--off .ta-icon { color: #444; opacity: 0.5; }
.troph-platinum--off .troph-plat-name { color: var(--muted); opacity: 0.4; }
.troph-platinum--off .troph-plat-desc { color: var(--muted); opacity: 0.5; font-style: italic; }

/* ── TROPHY LOOT (per-trophy equipment drop) ── */
.troph-loot {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding-top: 8px;
  border-top: 1px dashed #2a2a2a;
  width: 100%;
  max-width: 140px;
}

.troph-loot-label {
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: 0.22em;
  color: var(--muted);
  opacity: 0.55;
}

.troph-loot-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  white-space: nowrap;
}

.troph-loot-icon { font-size: 13px; line-height: 1; }

.troph-loot--on .troph-loot-name { color: var(--text); }
.troph-loot--off .troph-loot-icon { color: #3a3a3a; opacity: 0.5; }
.troph-loot--off .troph-loot-name { color: #3a3a3a; letter-spacing: 0.16em; }

/* ── PLATINUM KEY REWARD ── */
.troph-plat-reward {
  margin-top: 22px;
  padding-top: 14px;
  border-top: 1px dashed #2a2a2a;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 100%;
  max-width: 360px;
}

.troph-plat-reward-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.24em;
  color: var(--muted);
  opacity: 0.6;
}

.troph-plat-reward-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 14px;
  letter-spacing: 0.14em;
}

.troph-plat-reward-icon { font-size: 18px; line-height: 1; }

.troph-plat-reward-hint {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.1em;
  color: var(--muted);
  opacity: 0.65;
  font-style: italic;
  margin-top: 2px;
}

.troph-plat-reward--on .troph-plat-reward-name {
  color: var(--plat-text);
  text-shadow: 0 0 8px rgba(176, 176, 216, 0.3);
}
.troph-plat-reward--off .troph-plat-reward-icon { color: #3a3a3a; }
.troph-plat-reward--off .troph-plat-reward-name { color: #3a3a3a; letter-spacing: 0.22em; }

.dgn-header {
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 0.14em;
  color: var(--muted);
  margin-top: 0;
  margin-bottom: 10px;
  width: 100%;
}

.dgn-grid {
  display: grid;
  /* minmax(0,&) not 1fr: auto minimum is min-content, and the ASCII door
   blew both tracks past the container. */
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);   /* equipement legerement plus large */
  gap: 32px;
  width: 100%;
  align-items: start;
  padding-bottom: 0;
}

.dgn-equip {
  display: flex;
  flex-direction: column;
}

.dgn-equip-title {
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 0.16em;
  color: var(--muted);
  margin-bottom: 10px;
  text-transform: uppercase;
}

/* ── Equipment slot (2 lines: gear + achievement source) ── */
.dgn-slot {
  display: flex;
  flex-direction: column;
  padding: 7px 0;
  border-bottom: 1px dashed rgba(255,255,255,0.04);
}
.dgn-slot:last-child { border-bottom: none; }

.dgn-slot-head {
  font-family: var(--font-mono);
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 16px;
  white-space: pre;
  letter-spacing: 0.05em;
  line-height: 1.6;
}
.dgn-slot-type {
  color: var(--muted);
  letter-spacing: 0.14em;
  min-width: 76px;
  font-size: 12px;
}
.dgn-slot-icon {
  min-width: 42px;
  text-align: center;
  font-size: 15px;
}
.dgn-slot-name { letter-spacing: 0.1em; }

.dgn-slot-sub {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--muted);
  opacity: 0.85;
  margin-top: 3px;
  margin-left: 76px;
  line-height: 1.4;
}
.dgn-slot-from    { opacity: 0.55; }
.dgn-slot-ach     { color: var(--text); opacity: 0.85; }
.dgn-slot-achdesc { font-style: italic; }

/* Hint shown for locked slots — orange amber, terminal prompt feel */
.dgn-slot-hint-label {
  color: var(--orange);
  letter-spacing: 0.14em;
  text-transform: lowercase;
  font-size: 13px;
}
.dgn-slot-hint {
  color: var(--text);
  font-style: italic;
  letter-spacing: 0.04em;
  font-size: 13px;
}
.dgn-slot--key.dgn-slot--locked .dgn-slot-hint-label {
  color: var(--accent-b);
  font-size: 13px;
}
.dgn-slot--key.dgn-slot--locked .dgn-slot-hint {
  color: #aac;
  font-size: 13px;
}

/* Locked state */
.dgn-slot--locked .dgn-slot-icon    { color: #3a3a3a; }
.dgn-slot--locked .dgn-slot-name    { color: #3a3a3a; letter-spacing: 0.2em; }
.dgn-slot--locked .dgn-slot-sub     { opacity: 0.35; }
.dgn-slot--locked .dgn-slot-ach     { color: var(--muted); }

/* Owned state */
.dgn-slot--owned .dgn-slot-name { color: var(--text); }

.dgn-equip-divider {
  font-family: var(--font-mono);
  font-size: 11px;
  color: #2a2a2a;
  margin: 6px 0 2px;
  padding: 0;
  line-height: 1;
  white-space: pre;
  overflow: hidden;
}

/* Key slot — special platinum tint when owned */
.dgn-slot--key {
  background: rgba(176, 176, 216, 0.025);
  padding-left: 8px;
  padding-right: 8px;
  border-left: 2px solid rgba(176, 176, 216, 0.15);
  margin-left: -8px;
}
.dgn-slot--key.dgn-slot--owned {
  background: rgba(176, 176, 216, 0.07);
  border-left-color: var(--plat-text);
}
.dgn-slot--key.dgn-slot--owned .dgn-slot-icon { color: var(--plat-text); }
.dgn-slot--key.dgn-slot--owned .dgn-slot-name {
  color: var(--plat-text);
  text-shadow: 0 0 6px rgba(176, 176, 216, 0.3);
}
.dgn-slot--key.dgn-slot--owned .dgn-slot-ach {
  color: var(--plat-text);
  opacity: 0.9;
}

/* ── Door panel ── */
.dgn-door {
  /* cqw sizes the door from the COLUMN, not the window: correct in all three layouts. */
  container-type: inline-size;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
}

.dgn-door .dgn-equip-title {
  align-self: flex-start;
}

.dgn-dungeon-title {
  font-family: var(--font-mono);
  font-size: clamp(3.5px, 0.45vw, 6px);
  line-height: 1.15;
  color: var(--accent-b);
  white-space: pre;
  margin: 0 0 6px 0;
  padding: 0;
  letter-spacing: 0;
  display: block;
}

.dgn-door-art {
  font-family: var(--font-mono);
  /* 11px once the column can carry it (332px). 7px is the floor. */
  font-size: clamp(7px, 3.2cqw, 11px);
  line-height: 1;
  color: var(--accent-b);
  margin: 0;
  padding: 0;
  white-space: pre;
  letter-spacing: 0;
  animation: door-idle 4s ease-in-out infinite;
}

/* Open state — orange resting glow (no entry animation by default) */
.dungeon--open .dgn-door-art {
  color: var(--orange);
  animation: dgn-glow 2.6s ease-in-out infinite;
}

/* One-shot unlock, higher specificity than .dungeon--open's resting animation. */
.dungeon--open .dgn-door-art.is-unlocking {
  will-change: transform, filter, color;
  animation:
    door-unlock 5s cubic-bezier(0.5, 0.05, 0.4, 0.95) backwards,
    dgn-glow 2.6s ease-in-out 5s infinite;
}

@keyframes dgn-glow {
  0%, 100% { opacity: 0.78; }
  50%      { opacity: 1; }
}

.dgn-door-status {
  margin-top: 10px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.dgn-door-line {
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 0.14em;
  color: #e05050;
  line-height: 1.6;
}
.dgn-door-line--muted { color: var(--muted); opacity: 0.7; letter-spacing: 0.1em; }
.dgn-door-line--ok    { color: var(--green); }
.dgn-door-line--hint  {
  color: var(--plat-text);
  text-shadow: 0 0 8px rgba(176, 176, 216, 0.4);
  letter-spacing: 0.18em;
  animation: dgn-hint-pulse 2s ease-in-out infinite;
}

@keyframes dgn-hint-pulse {
  0%, 100% { opacity: 0.85; }
  50%      { opacity: 1; }
}

.dgn-enter-btn {
  background: transparent;
  border: 1px solid var(--orange);
  color: var(--orange);
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 0.18em;
  padding: 12px 22px;
  cursor: pointer;
  transition: background var(--dur-state) var(--ease-out), color var(--dur-state) var(--ease-out), box-shadow var(--dur-state) var(--ease-out), border-color var(--dur-state) var(--ease-out);
  margin-top: 8px;
}
.dgn-enter-btn:hover {
  background: var(--orange);
  color: #0e0e0e;
}

/* USE KEY variant — blue, pulsing to match the magical door state */
.dgn-use-btn {
  border-color: var(--accent-b);
  color: var(--accent-b);
  animation: dgn-use-pulse 1.8s ease-in-out infinite;
}
.dgn-use-btn:hover {
  background: color-mix(in srgb, var(--accent-b) 12%, transparent);
  border-color: var(--text-primary);
  color: var(--text-primary);
  text-shadow: 0 0 12px var(--text-primary);
}
@keyframes dgn-use-pulse {
  0%, 100% { background-color: transparent; }
  50%      { background-color: color-mix(in srgb, var(--accent-b) 14%, transparent); }
}
.dgn-use-btn--inserting {
  animation: none;
  border-color: var(--text-primary);
  color: var(--text-primary);
  background: color-mix(in srgb, var(--accent-b) 15%, transparent);
  cursor: default;
  pointer-events: none;
}

/* "KEY READY" header label — sits between locked and ok */
.dgn-status-ready {
  color: var(--accent-b);
  letter-spacing: 0.16em;
}

/* Door descent transition · ENTER DUNGEON click */
.dgn-door-art.is-descending {
  animation: door-descend 700ms ease-in forwards;
}

/* Combat UI */
.dgn-combat {
  font-family: var(--font-mono);
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px 24px;
  position: relative;
  border: 1px solid var(--border);
  background: var(--surface-base);
  border-radius: var(--radius-sm);
  margin: 0;
  flex: 1;                    /* fills .dungeon — viewport-height driven, never fixed px */
  min-height: 0;
  opacity: 1;
  transition: opacity var(--dur-struct) var(--ease-out);
}
.dgn-combat.is-entering { opacity: 0; }

/* ── Combat header ── */
.dgn-combat-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding-bottom: 7px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  letter-spacing: 0.05em;
}
.dgn-combat-room { flex: 1; color: var(--text); }
.dgn-combat-room .ach-prompt { color: var(--orange); margin-right: 8px; }
.dgn-combat-turn {
  color: var(--muted);
  letter-spacing: 0.18em;
  font-size: 12px;
}
.dgn-retreat-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  padding: 6px 14px;
  cursor: pointer;
  border-radius: 4px;
  transition:
    color var(--dur-state) var(--ease-out),
    background-color var(--dur-state) var(--ease-out),
    border-color var(--dur-state) var(--ease-out),
    box-shadow var(--dur-state) var(--ease-out),
    transform var(--dur-state) var(--ease-out);
}
.dgn-retreat-btn:hover {
  color: var(--orange);
  border-color: var(--orange);
}

/* ── Stage : enemy art + info ── */
/* ── Enemy stage : full-width frame ── */
.dgn-combat-stage {
  display: flex;
  flex-direction: column;
  flex: 1;                    /* absorbs all vertical space left after header/dialog/actions */
  min-height: 0;              /* critical: lets flex item shrink below natural content size */
  border: 1px dashed rgba(232, 93, 4, 0.3);
  border-radius: 8px;
  background: rgba(232, 93, 4, 0.04);
  overflow: hidden;
  position: relative;
}

/* ── Hit animations on enemy art ── */
@keyframes dgn-hit {
  0%   { transform: translateY(0);      filter: brightness(1) sepia(0); }
  22%  { transform: translateY(-11px);  filter: brightness(1.7) sepia(1) hue-rotate(295deg) saturate(4); }
  65%  { transform: translateY(-5px);   filter: brightness(1.2) sepia(0.3) hue-rotate(295deg); }
  100% { transform: translateY(0);      filter: brightness(1) sepia(0); }
}
@keyframes dgn-spell-hit {
  0%   { transform: translateY(0);      filter: brightness(1) sepia(0); }
  22%  { transform: translateY(-11px);  filter: brightness(1.8) sepia(1) hue-rotate(220deg) saturate(5); }
  65%  { transform: translateY(-4px);   filter: brightness(1.3) sepia(0.4) hue-rotate(220deg); }
  100% { transform: translateY(0);      filter: brightness(1) sepia(0); }
}
.dgn-enemy-art.is-hit       { animation: dgn-hit       0.46s ease-out; }
.dgn-enemy-art.is-spell-hit { animation: dgn-spell-hit 0.52s ease-out; }

/* ── Floating damage / heal numbers ── */
@keyframes dgn-float-up {
  0%   { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(-50px); }
}
.dgn-float-num {
  position: absolute;
  top: 30%;
  right: 22px;
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: bold;
  pointer-events: none;
  animation: dgn-float-up 0.85s ease-out forwards;
  z-index: 20;
  letter-spacing: 0.04em;
}
.dgn-float-num--dmg   { color: #ff4a4a; text-shadow: 0 0 10px rgba(255,74,74,0.55); }
.dgn-float-num--spell { color: #cc66ff; text-shadow: 0 0 10px rgba(204,102,255,0.55); }

/* ── Player stat bar flash ── */
@keyframes dgn-bar-dmg {
  0%, 100% { background: transparent; }
  28%       { background: rgba(255, 60, 60, 0.20); }
}
@keyframes dgn-bar-heal {
  0%, 100% { background: transparent; }
  28%       { background: rgba(60, 220, 120, 0.20); }
}
.dgn-player-bar.is-damaged { animation: dgn-bar-dmg  0.55s ease-out; border-radius: 4px; }
.dgn-player-bar.is-healed  { animation: dgn-bar-heal 0.55s ease-out; border-radius: 4px; }

/* ── HEADSET confirmed-intent tag ── */
.dgn-intent-confirmed {
  color: var(--orange);
  font-weight: bold;
  margin-right: 4px;
}
.dgn-enemy-art {
  font-family: var(--font-mono);
  font-size: 14px;            /* fallback — enemies override with inline fontSize (9–13px) */
  line-height: 1.1;
  color: var(--text);
  white-space: pre;
  margin: 0;
  text-align: center;
  padding: 12px 24px 8px;    /* reduced: was 48px top / 20px bottom */
  text-shadow: 0 0 10px rgba(232, 228, 220, 0.08);
  flex: 1;
  min-height: 0;
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
  overflow: hidden;
}
/* flavor + intent row, between art and HP bar */
.dgn-stage-sub {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 3px 16px 5px;
  font-family: var(--font-mono);
  font-size: 12px;
  flex-wrap: wrap;
}
.dgn-enemy-flavor {
  color: var(--muted);
  font-style: italic;
}
.dgn-enemy-intent {
  color: var(--text);
  opacity: 0.8;
}
.dgn-enemy-intent .ach-prompt { color: var(--orange); margin-right: 5px; }
/* HP bar pinned at the bottom of the stage frame */
.dgn-stage-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 16px;
  border-top: 1px solid rgba(232, 93, 4, 0.22);
  background: rgba(232, 93, 4, 0.07);
}
.dgn-enemy-name {
  font-family: var(--font-display);
  font-size: 18px;
  letter-spacing: 0.08em;
  color: var(--orange);
  flex: none;
}
/* Flavor quote inline in bottom bar, between name and HP */
.dgn-enemy-flavor-inline {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  font-style: italic;
  flex: 1;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0 12px;
}
.dgn-enemy-hp {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text);
  letter-spacing: 0.04em;
}
.dgn-enemy-hp .dgn-stat-num {
  color: var(--muted);
  margin-left: 4px;
  font-size: 11px;
}

/* ── Bottom row : player stats + actions side by side ── */
.dgn-combat-bottom {
  display: grid;
  grid-template-columns: minmax(160px, 26%) 1fr;
  gap: 10px;
  align-items: stretch;
}

/* ── Player stats (left column) — GEAR button pinned at bottom ── */
.dgn-combat-player {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.02);
  font-size: 13px;
  box-sizing: border-box;
}
/* GEAR stays close to stats, no floating to bottom */
.dgn-gear-btn {
  margin-top: 6px;
  width: 100%;
  text-align: center;
}

/* ── Right column : retreat on top, actions below ── */
.dgn-actions-col {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
/* RETREAT spans the full width of the right column */
.dgn-retreat-full {
  width: 100%;
  text-align: center;
}
.dgn-player-name {
  color: var(--text);
  font-size: 13px;
  letter-spacing: 0.06em;
}
.dgn-player-name .ach-prompt { color: var(--orange); margin-right: 6px; }
.dgn-player-bars {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text);
}
.dgn-player-bar { letter-spacing: 0.04em; }
.dgn-player-bar .dgn-stat-num {
  color: var(--muted);
  margin-left: 4px;
  font-size: 11px;
}
.dgn-player-meta {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.06em;
}

/* ── Dialog log ── */
.dgn-combat-dialog {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.3);
  height: 160px;        /* ~7 log lines visible */
  overflow: hidden;
  font-family: var(--font-mono);
  font-size: 12px;
}
.dgn-dialog-title {
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.2em;
  margin-bottom: 4px;
}
.dgn-dialog-title .ach-prompt { color: var(--orange); margin-right: 6px; }
.dgn-dialog-line {
  line-height: 1.5;
  animation: dgn-dialog-in 280ms ease;
}
.dgn-dialog-line--sys    { color: var(--text); }
.dgn-dialog-line--flavor { color: var(--muted); font-style: italic; }
.dgn-dialog-line--player { color: var(--orange); }
.dgn-dialog-line--enemy  { color: #d9534f; }
@keyframes dgn-dialog-in {
  0%   { opacity: 0; transform: translateX(-4px); }
  100% { opacity: 1; transform: translateX(0); }
}

/* ── Action menu : 4-col top row (ATTACK SPELL DEFEND INSPECT) + full-width bottom (USE ITEM, COMPLIMENT) ── */
.dgn-combat-actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  min-width: 0;
}
/* 5th child onward (USE ITEM, optional COMPLIMENT) span the full row */
.dgn-combat-actions > :nth-child(n+5) { grid-column: 1 / -1; }

/* USE ITEM compact: horizontal layout, sub/fn text pushed to the right */
.dgn-combat-actions > :nth-child(5) {
  flex-direction: row;
  align-items: center;
  padding: 4px 12px;
  gap: 12px;
}
.dgn-combat-actions > :nth-child(5) .dgn-action-top { flex: none; }
.dgn-combat-actions > :nth-child(5) .dgn-action-sub {
  margin-left: auto;
  font-size: 11px;
  color: var(--muted);
}
.dgn-combat-actions > :nth-child(5) .dgn-action-fn {
  font-size: 11px;
  color: var(--muted);
  flex: none;
}
.dgn-action-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-left: 3px solid var(--orange);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 0.05em;
  padding: 6px 12px;          /* compact — frees vertical space for the enemy stage */
  text-align: left;
  cursor: pointer;
  border-radius: 4px;
  transition:
    color var(--dur-state) var(--ease-out),
    background-color var(--dur-state) var(--ease-out),
    border-color var(--dur-state) var(--ease-out),
    box-shadow var(--dur-state) var(--ease-out),
    transform var(--dur-state) var(--ease-out);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.dgn-action-btn:hover:not(.is-disabled) {
  background: rgba(232, 93, 4, 0.08);
  border-color: var(--orange);
  transform: translateX(2px);
}
.dgn-action-btn.is-disabled {
  border-left-color: var(--border);
  color: var(--muted);
  cursor: not-allowed;
  opacity: 0.55;
}
/* top row: key + main label + optional suffix */
.dgn-action-top {
  display: flex;
  align-items: center;
  gap: 0;
}
.dgn-action-key {
  color: var(--orange);
  margin-right: 8px;
  font-weight: 500;
}
.dgn-action-btn.is-disabled .dgn-action-key { color: var(--muted); }
.dgn-action-suffix {
  color: var(--muted);
  font-size: 11px;
  margin-left: 6px;
  font-style: italic;
}
/* subtext: design-vocabulary label */
.dgn-action-sub {
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.12em;
  font-style: italic;
  padding-left: 26px;   /* indent to align under main label */
}
.dgn-action-btn.is-disabled .dgn-action-sub { opacity: 0.6; }
/* third info line on action buttons */
.dgn-action-fn {
  font-size: 0.82em;
  opacity: 0.55;
  letter-spacing: 0.04em;
  padding-left: 26px;
  margin-top: 1px;
}
.dgn-action-fn.is-warn { color: #d9534f; opacity: 0.8; }

/* combat log enriched feedback */
.dgn-dialog-line--dodge    { color: #5fd7af; font-weight: bold; }
.dgn-dialog-line--armor    { opacity: 0.55; font-size: 0.9em; padding-left: 12px; }
.dgn-dialog-line--buff     { color: var(--orange); font-size: 0.9em; padding-left: 12px; }
/* Chantier 5 log kinds */
.dgn-dialog-line--defend   { color: #5b9cf6; font-size: 0.9em; padding-left: 12px; }
.dgn-dialog-line--mechanic { color: var(--muted); font-style: italic; opacity: 0.85; }
.dgn-dialog-line--mechanic.success { color: #5fd7af; opacity: 1; }
.dgn-dialog-line--mechanic.fail    { color: #d9534f; opacity: 0.85; }
.dgn-dialog-line--fear     { color: #b76fc1; font-style: italic; opacity: 0.9; }
.dgn-dialog-line--special  { color: #e8b84b; font-weight: bold; }

/* ── Enemy mechanic tag (extra line below intent in stage-sub) ── */
.dgn-enemy-mechanic-tag {
  font-family: var(--font-mono);
  font-size: 0.82em;
  opacity: 0.75;
  margin-top: 3px;
  display: block;
}
.dgn-enemy-mechanic-tag.executing {
  color: #e8b84b;
  font-weight: bold;
  opacity: 1;
}
.dgn-enemy-mechanic-tag.warning {
  color: #d9534f;
  font-weight: bold;
  opacity: 1;
}

/* ── TV Head — inspect stack colours ── */
.dgn-enemy-mechanic-tag.stack-low  { opacity: 0.5; color: var(--muted); }
.dgn-enemy-mechanic-tag.stack-med  { color: #e8b84b; opacity: 0.9; }
.dgn-enemy-mechanic-tag.stack-high { color: #d9534f; font-weight: bold; opacity: 1; }

/* ── Abyssa — rage level colours ── */
.dgn-enemy-mechanic-tag.rage-low  { opacity: 0.5; color: var(--muted); }
.dgn-enemy-mechanic-tag.rage-med  { color: #e8b84b; opacity: 0.9; }
.dgn-enemy-mechanic-tag.rage-high { color: #d9534f; font-weight: bold; opacity: 1; }
.dgn-enemy-mechanic-tag.rage-crit {
  color: #d9534f; font-weight: bold; opacity: 1;
  animation: dgn-rage-pulse 0.9s ease-in-out infinite;
}
@keyframes dgn-rage-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.45; }
}

/* player buff summary line */
.dgn-player-buffs {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text);
  letter-spacing: 0.06em;
  line-height: 1.6;
}

/* ── Chantier 7 : backpack menu ── */
.backpack-menu {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--bg2);
  border: 1px solid var(--orange);
  border-left: 3px solid var(--orange);
  padding: 16px;
  min-width: 290px;
  max-width: 360px;
  width: 90%;
  z-index: 20;
  border-radius: 6px;
}
.backpack-header {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: bold;
  letter-spacing: 0.1em;
  color: var(--orange);
  margin-bottom: 12px;
  opacity: 0.95;
}
.backpack-item {
  padding: 8px 10px;
  cursor: pointer;
  border-left: 2px solid transparent;
  border-radius: 3px;
  transition: border-color var(--dur-press) var(--ease-out), background var(--dur-press) var(--ease-out);
  margin-bottom: 4px;
  font-family: var(--font-mono);
}
.backpack-item:hover {
  border-left-color: var(--orange);
  background: rgba(232,93,4,0.05);
}
.backpack-item-name {
  font-size: 12px;
  font-weight: bold;
  letter-spacing: 0.06em;
  color: var(--text);
}
.backpack-item-flavor {
  font-size: 10px;
  opacity: 0.55;
  font-style: italic;
  margin-top: 2px;
  color: var(--text);
  letter-spacing: 0.04em;
}
.backpack-close {
  margin-top: 12px;
  text-align: right;
}
.backpack-close button {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 4px 10px;
  cursor: pointer;
  border-radius: 3px;
  transition: border-color var(--dur-press) var(--ease-out), color var(--dur-press) var(--ease-out);
}
.backpack-close button:hover {
  border-color: var(--muted);
  color: var(--text);
}
/* log line for item use */
.dgn-dialog-line--item { color: #5fd7af; font-size: 0.9em; padding-left: 12px; }
.dgn-dialog-line--stun { color: #e8b84b; font-style: italic; opacity: 0.9; }
/* random events */
.dgn-event-wrap {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 0;
}
.dgn-event-title {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  color: var(--orange);
  font-weight: bold;
  margin-bottom: 4px;
}
.dgn-event-desc {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text);
  opacity: 0.8;
  font-style: italic;
  margin-bottom: 8px;
}
.dgn-event-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-left: 3px solid var(--border);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 8px 14px;
  text-align: left;
  cursor: pointer;
  border-radius: 4px;
  transition:
    color var(--dur-state) var(--ease-out),
    background-color var(--dur-state) var(--ease-out),
    border-color var(--dur-state) var(--ease-out),
    box-shadow var(--dur-state) var(--ease-out),
    transform var(--dur-state) var(--ease-out);
  width: 100%;
}
.dgn-event-btn:hover:not(:disabled) {
  border-left-color: var(--orange);
  background: rgba(232,93,4,0.05);
}
.dgn-event-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.dgn-event-btn-sub {
  font-size: 10px;
  color: var(--muted);
  display: block;
  margin-top: 3px;
  font-style: italic;
}
.dgn-event-result {
  font-family: var(--font-mono);
  font-size: 12px;
  color: #5fd7af;
  padding: 8px 0;
  border-top: 1px solid var(--border);
  margin-top: 4px;
}@media (max-width: 640px) {
  .backpack-menu { min-width: 240px; }
}

/* ── Result screens (win / lose) ── */
.dgn-combat-result {
  text-align: center;
  padding: 56px 32px;
  gap: 18px;
}
.dgn-result-title {
  font-family: var(--font-display);
  font-size: 42px;
  letter-spacing: 0.1em;
}
.dgn-combat-result--win  .dgn-result-title { color: var(--orange); text-shadow: 0 0 18px rgba(232,93,4,0.35); }
.dgn-combat-result--lose .dgn-result-title { color: var(--muted); }
.dgn-result-flavor {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--text);
  font-style: italic;
  opacity: 0.85;
}
.dgn-result-rewards {
  display: flex;
  justify-content: center;
  gap: 36px;
  margin-top: 8px;
}
.dgn-result-row {
  font-family: var(--font-mono);
  font-size: 16px;
  color: var(--text);
  letter-spacing: 0.06em;
}
.dgn-combat-result--win .dgn-result-row { color: var(--green); }
.dgn-result-row--bad { color: var(--muted) !important; }
.dgn-result-note {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.1em;
  margin-top: 14px;
}
.dgn-combat-result .dgn-enter-btn { margin-top: 18px; }

/* ── Inventory overlay ── */
.dgn-inventory { gap: 20px; }

.dgn-inv-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 13px;
}
.dgn-inv-row {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 4px;
  transition: border-color var(--dur-state) var(--ease-out);
}
.dgn-inv-row:hover { border-color: var(--border-hover); }
.dgn-inv-row--locked { opacity: 0.42; }
.dgn-inv-row--key {
  border-color: color-mix(in srgb, var(--accent-b) 30%, transparent);
  background: color-mix(in srgb, var(--accent-b) 3%, transparent);
}
.dgn-inv-main {
  display: flex;
  align-items: center;
  gap: 10px;
}
.dgn-inv-slot {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.08em;
  min-width: 7ch;
}
.dgn-inv-icon { font-size: 15px; }
.dgn-inv-name {
  color: var(--text);
  letter-spacing: 0.04em;
  flex: 1;
}
.dgn-inv-status {
  font-size: 10px;
  letter-spacing: 0.14em;
  padding: 2px 8px;
  border-radius: 2px;
  white-space: nowrap;
}
.dgn-inv-status--active  { color: var(--green); border: 1px solid var(--green); }
.dgn-inv-status--locked  { color: var(--muted); border: 1px solid var(--border); }
.dgn-inv-status--missing { color: #d9534f; border: 1px solid rgba(217,83,79,0.4); }
.dgn-inv-status--used    { color: var(--accent-b); border: 1px solid color-mix(in srgb, var(--accent-b) 40%, transparent); }
.dgn-inv-effect {
  font-size: 11px;
  color: var(--muted);
  font-style: italic;
  padding-left: calc(15px + 10px + 7ch);   /* icon + gap + slot width */
}
.dgn-inv-note {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.08em;
  border-top: 1px solid var(--border);
  padding-top: 14px;
}
.dgn-inv-btn {
  font-size: 11px;
  letter-spacing: 0.1em;
  padding: 6px 12px;
}

/* ── Name selection intro screen ── */
.dgn-name-select { gap: 38px; }

.dgn-name-section {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.dgn-name-label {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--text);
  letter-spacing: 0.06em;
}
.dgn-name-label .ach-prompt { color: var(--orange); margin-right: 8px; }

.dgn-name-input {
  background: transparent;
  border: none;
  border-bottom: 2px solid var(--orange);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 28px;
  letter-spacing: 0.22em;
  padding: 8px 4px;
  outline: none;
  width: 100%;
  max-width: 520px;
  caret-color: var(--orange);
  text-transform: uppercase;
  transition: box-shadow var(--dur-state) var(--ease-out);
}
.dgn-name-input:focus {
  box-shadow: 0 4px 0 -2px rgba(232, 93, 4, 0.35);
}
.dgn-name-input::placeholder {
  color: var(--muted);
  opacity: 0.35;
}

.dgn-name-door-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.dgn-name-door-label {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
  align-self: flex-start;
}
.dgn-name-door {
  font-family: var(--font-mono);
  font-size: 28px;
  line-height: 1.2;
  color: var(--accent-b);
  cursor: pointer;
  margin: 0;
  animation: door-idle 4s ease-in-out infinite;
  transition: transform var(--dur-state) var(--ease-out), color var(--dur-state) var(--ease-out), text-shadow var(--dur-state) var(--ease-out);
  outline: none;
  border-radius: 4px;
}
.dgn-name-door:hover,
.dgn-name-door:focus {
  color: var(--text-primary);
  transform: scale(1.04);
  animation-play-state: paused;
}
.dgn-name-door.is-door-opening {
  animation: door-descend 700ms ease-in forwards;
}
.dgn-name-door-prompt {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.16em;
  cursor: pointer;
}

/* ── Between-rooms screen ─────────────────────────────────────────── */
.dgn-between-summary {
  padding: 14px 20px;
  border-bottom: 1px solid rgba(232,93,4,0.18);
}
.dgn-between-title {
  font-family: var(--font-mono);
  color: var(--orange);
  font-size: 13px;
  letter-spacing: .1em;
  margin-bottom: 6px;
}
.dgn-between-row {
  font-family: var(--font-mono);
  color: var(--text);
  font-size: 12px;
}
.dgn-between-levelup {
  font-family: var(--font-mono);
  color: var(--accent-b);
  font-size: 12px;
  margin-top: 6px;
  letter-spacing: .06em;
}
.dgn-between-stats {
  padding: 10px 20px;
  border-bottom: 1px solid rgba(232,93,4,0.10);
}
.dgn-between-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-bottom: 1px solid rgba(232,93,4,0.10);
}
.dgn-between-col {
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.dgn-between-col + .dgn-between-col {
  border-left: 1px solid rgba(232,93,4,0.10);
}
.dgn-between-col-title {
  font-family: var(--font-mono);
  color: var(--orange);
  font-size: 12px;
  letter-spacing: .14em;
}
.dgn-cube-btn { width: 100%; }
.dgn-cube-result {
  font-family: var(--font-mono);
  color: var(--accent-b);
  font-size: 12px;
  min-height: 18px;
  opacity: 0;
  transition: opacity var(--dur-struct) var(--ease-out);
}
.dgn-cube-result.is-visible { opacity: 1; }

/* Workshop rows */
.dgn-workshop-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
  padding: 6px 0;
  border-bottom: 1px solid rgba(232,93,4,0.07);
  align-items: start;
}
.dgn-workshop-row--missing { opacity: .35; }
.dgn-workshop-name {
  font-family: var(--font-mono);
  color: var(--text);
  font-size: 12px;
  grid-column: 1;
}
.dgn-workshop-effect {
  font-family: var(--font-mono);
  color: var(--muted);
  font-size: 11px;
  grid-column: 1;
}
.dgn-workshop-btn {
  font-family: var(--font-mono);
  background: none;
  border: 1px solid rgba(232,93,4,0.45);
  color: var(--orange);
  font-size: 11px;
  padding: 4px 10px;
  cursor: pointer;
  transition: background var(--dur-state) var(--ease-out), color var(--dur-state) var(--ease-out);
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: center;
}
.dgn-workshop-btn:hover:not(:disabled) { background: rgba(232,93,4,0.12); }
.dgn-workshop-btn:disabled { opacity: .35; cursor: default; }
.dgn-workshop-active, .dgn-workshop-missing {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: .1em;
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: center;
}
.dgn-workshop-active  { color: var(--orange); }
.dgn-workshop-missing { color: var(--muted); }

.dgn-between-nav {
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ── Dungeon entrance (defeat / retreat / complete) ───────────────── */
.dgn-entrance-msg {
  padding: 20px 20px 12px;
}
.dgn-entrance-stats {
  padding: 12px 20px;
  border-top: 1px solid rgba(232,93,4,0.12);
  border-bottom: 1px solid rgba(232,93,4,0.12);
}
.dgn-entrance-note {
  font-family: var(--font-mono);
  color: var(--muted);
  font-size: 11px;
  margin-top: 6px;
}
.dgn-entrance-buttons {
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* pre-run lobby: art | workshop side by side */
.dgn-prerun-body {
  display: flex;
  flex-direction: row;
  flex: 1;
  min-height: 0;
  gap: 24px;
  align-items: stretch;
}
.dgn-prerun-art {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  min-width: 0;
  padding-right: 24px;
  border-right: 1px solid var(--border);
  justify-content: center;
}
.dgn-prerun-panel {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-top: 4px;
}
.dgn-prerun-panel .dgn-enter-btn { margin-top: auto; }

/* ── Between-rooms REST layout ── */
/* Side-by-side: left = campfire+log+stats, right = workshop+nav */
.dgn-between-body {
  display: flex;
  flex-direction: row;
  flex: 1;
  min-height: 0;
  gap: 24px;
}
.dgn-between-left {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  border-right: 1px solid var(--border);
  padding-right: 24px;
}
/* campfire stage grows to fill available height */
.dgn-between-rooms .dgn-combat-stage { flex: 1; min-height: 0; }
/* log is auto-height (only 1-2 lines of content) */
.dgn-between-rooms .dgn-combat-dialog { height: auto; min-height: 52px; flex: none; }
/* player stats block stays compact */
.dgn-between-rooms .dgn-combat-player { flex: none; }
/* right column is its own flex column */
.dgn-between-rooms .dgn-actions-col {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
/* workshop list scrolls internally */
.dgn-workshop-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}
/* descend/abandon buttons pinned at the bottom of right col */
.dgn-between-rooms .dgn-enter-btn { flex: none; margin-top: 10px; }
.dgn-between-rooms .dgn-retreat-btn { flex: none; margin-top: 6px; width: 100%; text-align: center; }

/* infinite mode button — purple so it reads differently from the orange */
@keyframes dgn-inf-pulse {
  0%, 100% { border-color: color-mix(in srgb, var(--accent-a) 45%, transparent); }
  50%      { border-color: var(--accent-a); }
}
.dgn-enter-btn.dgn-inf-btn {
  border-color: var(--accent-a);
  color: var(--accent-a);
  animation: dgn-inf-pulse 2.2s ease-in-out infinite;
}
.dgn-enter-btn.dgn-inf-btn:hover {
  background: color-mix(in srgb, var(--accent-a) 10%, transparent);
  border-color: var(--text-primary);
  color: var(--text-primary);
}

/* ── Run summary ── */
.dgn-summary-bonus {
  color: var(--accent-b);
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 8px 20px;
  border-top: 1px solid color-mix(in srgb, var(--accent-b) 15%, transparent);
}

/* Non-combat screens keep natural height: the stage must not absorb leftover space. */
.dgn-run-summary   .dgn-combat-stage,
.dgn-inventory     .dgn-combat-stage { flex: none; }

/* ── Run summary : dialogs grow to natural height, no 138px combat cap ── */
.dgn-run-summary .dgn-combat-dialog  { height: auto; overflow: visible; flex: none; }

/* Non-combat screens fill the dungeon and scroll internally */
.dgn-run-summary,
.dgn-inventory,
.dgn-name-select   { overflow-y: auto; flex: 1; min-height: 0; }
/* Pre-run lobby: 2-col layout — no outer scroll, panel scrolls internally */
.dgn-prerun-lobby  { overflow: hidden; flex: 1; min-height: 0; }
.dgn-combat            { min-width: 0; width: 100%; box-sizing: border-box; }
.dgn-combat-header,
.dgn-combat-stage,
.dgn-combat-dialog,
.dgn-combat-bottom     { min-width: 0; }
.dgn-combat-header     { overflow: hidden; }
.dgn-combat-bottom > *,
.dgn-combat-player,
.dgn-actions-col       { min-width: 0; overflow: hidden; }
.dgn-combat-actions,
.dgn-combat-actions > * { min-width: 0; }
.dgn-stage-bottom,
.dgn-stage-sub,
.dgn-enemy-name,
.dgn-enemy-hp,
.dgn-player-name,
.dgn-player-bars,
.dgn-player-meta       { min-width: 0; overflow: hidden; }
.dgn-prerun-panel,
.dgn-between-cols,
.dgn-run-summary       { min-width: 0; }
.dgn-between-col       { min-width: 0; overflow: hidden; }@media (max-width: 720px) {
  body.ach-body         { height: auto; overflow: auto; }
  body.ach-body footer  { display: flex; }
  .ach-page  {
    display: flex; flex-direction: column;
    flex: none; min-height: auto; overflow: visible; padding: 80px 16px 60px;
  }
  .ach-page-header {
    border-right: none; border-bottom: 1px solid var(--border);
    padding-right: 0; padding-bottom: 8px; margin-bottom: 12px;
  }
  .ach-sys-lines { flex-direction: column; gap: 4px; }
  .ach-sys-line  { writing-mode: horizontal-tb; transform: none; font-size: 9px; white-space: normal; }
  .ach-mini-footer { display: none; }
  .dgn-combat { flex: none; height: auto; padding: 18px 16px; gap: 16px; }
  .dgn-combat-stage { flex: none; }
  .dgn-run-summary,
  .dgn-prerun-lobby,
  .dgn-inventory,
  .dgn-name-select { flex: none; min-height: unset; }
  .dgn-prerun-body { flex-direction: column; gap: 16px; }
  .dgn-prerun-art  { border-right: none; border-bottom: 1px solid var(--border); padding-right: 0; padding-bottom: 12px; justify-content: flex-start; }
  .dgn-prerun-panel { overflow-y: visible; min-height: unset; }
  .dgn-prerun-panel .dgn-enter-btn { margin-top: 8px; }
  .dgn-enemy-art { flex: none; overflow: visible; font-size: 14px; padding: 18px 12px 8px; }
  .dgn-enemy-name { font-size: 18px; }
  .dgn-combat-bottom { grid-template-columns: 1fr; }
  .dgn-combat-actions { grid-template-columns: repeat(2, 1fr); }
  .dgn-combat-actions > :nth-child(n+5) { grid-column: 1 / -1; }
  .dgn-result-title { font-size: 28px; }
  .dgn-name-door { font-size: 18px; }
  .dgn-name-input { font-size: 20px; }
  .dgn-between-cols { grid-template-columns: 1fr; }
  .dgn-between-col + .dgn-between-col { border-left: none; border-top: 1px solid rgba(232,93,4,0.10); }
  /* between-rooms REST screen: stack vertically on mobile */
  .dgn-between-body { flex-direction: column; gap: 16px; }
  .dgn-between-left { border-right: none; border-bottom: 1px solid var(--border); padding-right: 0; padding-bottom: 12px; }
  .dgn-between-rooms .dgn-combat-stage { flex: none; }
  .dgn-between-rooms .dgn-combat-dialog { min-height: unset; }
  .dgn-workshop-scroll { overflow-y: visible; flex: none; }
  .dgn-between-rooms .dgn-actions-col { flex: none; min-height: unset; }
}
@media (max-width: 640px) {

  /* Achievements page */
  .ach-page { padding: 100px 20px 60px; }
  .ach-sys-line { font-size: 9px; }
  .troph-row { gap: 2px; }
  .troph-label { font-size: 8px; }
  .troph-desc  { font-size: 8px; max-width: 90px; }
  .troph-plat-name { font-size: 24px; }
  .ach-page-title-art { font-size: clamp(5px, 2.4vw, 10px); line-height: 1.05; }

  /* Trophy loot — compact on mobile */
  .troph-loot { max-width: 100px; padding-top: 5px; margin-top: 8px; gap: 2px; }
  .troph-loot-label { font-size: 7px; letter-spacing: 0.18em; }
  .troph-loot-row { font-size: 8px; gap: 4px; }
  .troph-loot-icon { font-size: 11px; }

  /* Platinum reward */
  .troph-plat-reward { margin-top: 16px; padding-top: 10px; }
  .troph-plat-reward-label { font-size: 9px; }
  .troph-plat-reward-row { font-size: 12px; }
  .troph-plat-reward-icon { font-size: 15px; }
  .troph-plat-reward-hint { font-size: 8px; text-align: center; }

  /* Dungeon — release full-screen mode, revert sidebar to stacked column on tablet */
  body.ach-body        { height: auto; overflow: auto; }
  body.ach-body footer { display: flex; }
  .ach-page  {
    display: flex; flex-direction: column;
    flex: none; min-height: auto; overflow: visible;
    padding: 100px 20px 60px;
  }
  .ach-page-header {
    border-right: none; border-bottom: 1px solid var(--border);
    padding-right: 0; padding-bottom: 8px; margin-bottom: 12px;
  }
  .ach-sys-lines { flex-direction: column; gap: 4px; }
  .ach-sys-line  { writing-mode: horizontal-tb; transform: none; font-size: 9px; white-space: normal; }
  .ach-page-title-art { display: none; }
  .ach-mini-footer { display: none; }
  .dgn-combat { flex: none; height: auto; }
  .dgn-combat-stage { flex: none; }
  .dgn-run-summary,
  .dgn-prerun-lobby,
  .dgn-inventory,
  .dgn-name-select { flex: none; min-height: unset; }
  .dgn-prerun-body { flex-direction: column; gap: 16px; }
  .dgn-prerun-art  { border-right: none; border-bottom: 1px solid var(--border); padding-right: 0; padding-bottom: 12px; justify-content: flex-start; }
  .dgn-prerun-panel { overflow-y: visible; min-height: unset; }
  .dgn-prerun-panel .dgn-enter-btn { margin-top: 8px; }
  .dgn-enemy-art { flex: none; overflow: visible; }
  /* minmax(0,1fr) not 1fr: the ASCII door is 332px at 11px. */
  .dgn-grid { grid-template-columns: minmax(0, 1fr); gap: 32px; }
  .dgn-slot-head { font-size: 11px; gap: 8px; }
  .dgn-slot-type { min-width: 58px; letter-spacing: 0.1em; }
  .dgn-slot-icon { min-width: 32px; font-size: 12px; }
  .dgn-slot-sub  { font-size: 8px; margin-left: 0; }
  .dgn-door      { align-self: center; }
  /* between-rooms REST screen: stack on tablet */
  .dgn-between-body { flex-direction: column; gap: 16px; }
  .dgn-between-left { border-right: none; border-bottom: 1px solid var(--border); padding-right: 0; padding-bottom: 12px; }
  .dgn-between-rooms .dgn-combat-stage { flex: none; }
  .dgn-between-rooms .dgn-combat-dialog { min-height: unset; }
  .dgn-workshop-scroll { overflow-y: visible; flex: none; }
  .dgn-between-rooms .dgn-actions-col { flex: none; min-height: unset; }

}@media (min-width: 1081px) {

  /* More breathing room in the page container */
  .ach-page {
    padding-left: 56px;
    padding-right: 56px;
    column-gap: 28px;
  }

  /* Sidebar text ticker */
  .ach-sys-line { font-size: 10px; }

  /* Mini-footer */
  .ach-mini-footer { font-size: 11px; }

  .dgn-header { font-size: 15px; }
  .dgn-equip-title { font-size: 15px; margin-bottom: 14px; }

  /* Equipment slots (antechamber gear list) */
  .dgn-slot { padding: 9px 0; }
  .dgn-slot-head { font-size: 16px; gap: 20px; }
  .dgn-slot-type { font-size: 14px; min-width: 92px; }
  .dgn-slot-icon { font-size: 17px; min-width: 52px; }
  .dgn-slot-sub  { font-size: 13px; margin-left: 92px; margin-top: 4px; }
  .dgn-slot-hint-label { font-size: 14px; }
  .dgn-slot-hint       { font-size: 14px; }
  .dgn-slot--key.dgn-slot--locked .dgn-slot-hint-label { font-size: 14px; }
  .dgn-slot--key.dgn-slot--locked .dgn-slot-hint       { font-size: 14px; }

  /* Door panel */
  /* 15px needs ~1220px of column; at 1081 the door overflows. */
  .dgn-door-art { font-size: clamp(11px, 3.2cqw, 15px); }
  .dgn-enter-btn { font-size: 15px; padding: 14px 28px; }

  /* ── Pre-run lobby (DUNGEON ENTRANCE · GEAR UP) ── */
  .dgn-player-buffs        { font-size: 13px; }
  .dgn-between-col-title   { font-size: 13px; }
  .dgn-workshop-row        { padding: 9px 0; }
  .dgn-workshop-name       { font-size: 14px; }
  .dgn-workshop-effect     { font-size: 13px; }
  .dgn-workshop-btn        { font-size: 13px; padding: 5px 12px; }
  .dgn-workshop-active,
  .dgn-workshop-missing    { font-size: 12px; }
  .troph-label  { font-size: 13px; }
  .troph-desc   { font-size: 11px; }

  /* ── Combat UI ── */
  .dgn-combat { padding: 22px 32px; gap: 14px; }

  .dgn-combat-header { font-size: 15px; gap: 20px; padding-bottom: 10px; }
  .dgn-combat-turn   { font-size: 14px; }
  .dgn-retreat-btn   { font-size: 13px; padding: 8px 18px; }

  /* Stage */
  .dgn-stage-sub  { font-size: 14px; padding: 4px 20px 6px; }
  .dgn-stage-bottom { padding: 6px 20px; }
  .dgn-enemy-name { font-size: 22px; }
  .dgn-enemy-hp   { font-size: 15px; }
  .dgn-enemy-hp .dgn-stat-num { font-size: 13px; }
  .dgn-enemy-art  { font-size: 16px; padding: 20px 32px 12px; }

  /* Player block */
  .dgn-combat-player { font-size: 15px; padding: 14px 18px; gap: 8px; }
  .dgn-player-name   { font-size: 15px; }
  .dgn-player-bars   { font-size: 14px; gap: 22px; }
  .dgn-player-bar .dgn-stat-num { font-size: 12px; }
  .dgn-player-meta   { font-size: 13px; }

  /* Dialog log */
  .dgn-combat-dialog { font-size: 14px; height: 138px; padding: 8px 18px; }
  .dgn-dialog-title  { font-size: 12px; }

  /* Action buttons */
  .dgn-combat-bottom { gap: 14px; }
  .dgn-actions-col   { gap: 10px; }
  .dgn-combat-actions { gap: 12px; }
  .dgn-action-btn     { font-size: 15px; padding: 10px 18px; }
  .dgn-action-suffix  { font-size: 12px; }
}
