/* ==========================================================================
   Game — Dungeon (unit F). Prefix gm-dun-.
   ==========================================================================
   The Game's darkest room, drawn in tokens only so every palette still
   applies: depth is the accent sinking into the page plane, the torch is
   gold (--warning, the colour of loot), a failed delve is --critical.
   Stone is two faint --grid courses. The panels injected into Focus's
   session screen take their colour from that screen (currentColor), since
   Focus draws its own night there.                                         */

.gm-dun { display: flex; flex-direction: column; gap: 14px; max-width: 760px; margin: 0 auto; }
.gm-dun .hint { line-height: 1.45; }
.gm-dun-k {
  font-family: var(--s-mono); font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-muted);
}
.gm-dun-sec-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 10px; }
.gm-dun-sec-head .gm-link, .gm-dun-sec-head .hint { margin-left: auto; }

/* --- the hero: today's descent -------------------------------------------- */

.gm-dun-hero {
  position: relative; overflow: hidden; isolation: isolate;
  display: flex; flex-direction: column; gap: 10px;
  padding: 18px 18px 16px;
  border-color: color-mix(in srgb, var(--accent) 28%, var(--border));
  background:
    radial-gradient(120% 70% at 18% 0%, color-mix(in srgb, var(--warning) 12%, transparent), transparent 60%),
    radial-gradient(90% 90% at 80% 110%, color-mix(in srgb, var(--accent) 26%, transparent), transparent 70%),
    linear-gradient(180deg, var(--surface-1), color-mix(in srgb, var(--surface-0) 70%, var(--accent) 8%));
}
/* Stone courses, faint, offset every other row. */
.gm-dun-hero::before {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none; opacity: 0.55;
  background:
    repeating-linear-gradient(0deg, transparent 0 21px, var(--grid) 21px 22px),
    repeating-linear-gradient(90deg, transparent 0 55px, var(--grid) 55px 56px);
  -webkit-mask-image: linear-gradient(180deg, transparent 10%, var(--text-primary) 100%);
          mask-image: linear-gradient(180deg, transparent 10%, var(--text-primary) 100%);
}
.gm-dun-hero-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.gm-dun-depth { font-family: var(--s-display); font-size: 17px; color: var(--text-secondary); margin-top: 3px; }
.gm-dun-depth b {
  font-family: var(--s-value-f); font-weight: var(--s-value-w, 600); font-size: 44px; line-height: 1;
  color: var(--text-primary); font-variant-numeric: tabular-nums; letter-spacing: -0.02em;
}
.gm-dun-hero.cleared .gm-dun-depth b { color: var(--warning); }
.gm-dun-hero-side { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.gm-dun-hero-best { font-family: var(--s-mono); font-size: 10.5px; color: var(--text-muted); }
.gm-dun-hero-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.gm-dun-hero-sq { position: absolute; right: 18px; top: 72px; opacity: 0; }   /* the bar's a11y twin */

.gm-dun-descent { display: block; width: 100%; height: auto; max-height: 190px; margin: 2px 0 0; overflow: visible; }
.gm-dun-ledge { fill: none; stroke: color-mix(in srgb, var(--text-muted) 45%, transparent); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.gm-dun-ledge.on {
  stroke: var(--accent); stroke-width: 3.2;
  filter: drop-shadow(0 0 5px color-mix(in srgb, var(--accent) 55%, transparent));
  animation: gm-dun-draw 0.7s var(--d, 0s) cubic-bezier(0.3, 0.7, 0.2, 1) both;
}
.gm-dun-floor { fill: var(--text-muted); font-family: var(--s-mono); font-size: 9.5px; letter-spacing: 0.08em; }
.gm-dun-floor.on { fill: var(--accent); }
.gm-dun-torch { fill: var(--warning); stroke: var(--surface-1); stroke-width: 1.5; }
.gm-dun-flicker { animation: gm-dun-flicker 2.6s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }

.gm-dun-enter { display: inline-flex; align-items: center; justify-content: center; gap: 8px; width: 100%; margin-top: 4px; }
.gm-dun-enter.live, .gm-dun-hub-go.live { background: var(--accent-quiet); color: var(--accent); border-color: var(--accent); }
.gm-dun-pulse {
  width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none;
  animation: gm-dun-pulse 1.4s ease-in-out infinite;
}

.gm-dun-flame {
  display: inline-flex; align-items: center; gap: 3px; white-space: nowrap;
  font-family: var(--s-mono); font-size: 13px; font-weight: 600; color: var(--warning);
}
.gm-dun-flame.cold { color: var(--text-muted); font-weight: 500; }

/* --- the party ------------------------------------------------------------ */

.gm-dun-party { display: flex; flex-direction: column; }
.gm-dun-party-row {
  display: grid; grid-template-columns: 26px minmax(0, 1fr) auto; align-items: center; gap: 8px;
  padding: 8px 0; border-bottom: 1px solid var(--grid); font-size: 14px;
}
.gm-dun-party-row:last-child { border-bottom: 0; }
.gm-dun-party-row.slain .gm-dun-party-name { color: var(--text-muted); text-decoration: line-through; }
.gm-dun-party-name { min-width: 0; overflow-wrap: anywhere; line-height: 1.3; }
.gm-dun-mon-ico {
  width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center;
  color: var(--critical); background: color-mix(in srgb, var(--critical) 12%, transparent);
}
.gm-dun-party-row.slain .gm-dun-mon-ico { color: var(--good-text); background: color-mix(in srgb, var(--good-text) 12%, transparent); }
.gm-dun-x {
  appearance: none; width: 30px; height: 30px; border-radius: 50%; cursor: pointer; display: grid; place-items: center;
  border: 1px solid var(--border); background: transparent; color: var(--text-muted);
}

/* --- stats, domains, donut ---------------------------------------------- */

.gm-dun-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 620px) { .gm-dun-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.gm-dun-stat {
  padding: 12px 13px; border-radius: var(--radius); background: var(--surface-1);
  border: 1px solid var(--border); box-shadow: var(--shadow);
}
.gm-dun-stat-v {
  font-family: var(--s-value-f); font-weight: var(--s-value-w, 600); font-size: 22px; margin-top: 4px;
  font-variant-numeric: tabular-nums;
}
.gm-dun-stat-sub { font-size: 12px; color: var(--text-muted); margin-top: 1px; }

.gm-dun-cols { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
@media (min-width: 900px) { .gm-dun-cols { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; } }

.gm-dun-dom { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; font-size: 12px; color: var(--text-secondary); min-width: 0; }
.gm-dun-dom svg { color: var(--accent); flex: none; }
.gm-dun-dom.none { color: var(--text-muted); }
.gm-dun-dep { display: grid; grid-template-columns: minmax(0, 118px) minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 6px 0; }
.gm-dun-dep .gm-dun-dom { overflow: hidden; text-overflow: ellipsis; }
.gm-dun-dep-track { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.gm-dun-dep-track i {
  display: block; height: 100%; border-radius: 4px;
  background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 55%, var(--surface-2)), var(--accent));
  transform-origin: left; animation: gm-dun-grow 0.6s calc(var(--i, 0) * 60ms) cubic-bezier(0.3, 0.7, 0.2, 1) both;
}
.gm-dun-dep-v { font-family: var(--s-value-f); font-size: 12.5px; color: var(--text-secondary); font-variant-numeric: tabular-nums; white-space: nowrap; }

.gm-dun-donutwrap { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; justify-content: center; }
.gm-dun-donutwrap .gm-dun-legend { flex: 1 1 180px; }
.gm-dun-donut { flex: none; --dun-rest: var(--surface-2); }
.gm-dun-donut-track { fill: none; stroke: var(--surface-2); stroke-width: 11; }
.gm-dun-donut-seg {
  fill: none; stroke: var(--c); stroke-width: 11;
  animation: gm-dun-fade 0.5s calc(var(--i, 0) * 80ms) ease-out both;
}
.gm-dun-donut-n { fill: currentColor; font-family: var(--s-value-f); font-weight: 600; font-size: 19px; }
.gm-dun-donut-u { fill: currentColor; opacity: 0.6; font-family: var(--s-mono); font-size: 6.5px; letter-spacing: 0.1em; text-transform: uppercase; }
.gm-dun-legend { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.gm-dun-legend-row { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; gap: 8px; align-items: center; font-size: 13px; }
.gm-dun-legend-row i { width: 10px; height: 10px; border-radius: 3px; }
.gm-dun-legend-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gm-dun-legend-row.slain .gm-dun-legend-name { text-decoration: line-through; opacity: 0.7; }
.gm-dun-legend-v { font-family: var(--s-mono); font-size: 11.5px; opacity: 0.75; white-space: nowrap; }
.gm-dun-card { --dun-rest: var(--surface-2); }

.gm-dun-rules { display: flex; flex-direction: column; gap: 12px; }
.gm-dun-rules .gm-dun-sec-head { margin-bottom: 0; }
.gm-dun-rule { display: grid; grid-template-columns: 38px minmax(0, 1fr); gap: 12px; align-items: start; }
.gm-dun-rule-ico {
  width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center;
  color: var(--warning); background: color-mix(in srgb, var(--warning) 12%, transparent);
}
.gm-dun-rule-t { font-size: 14.5px; font-weight: 600; margin-bottom: 2px; }

/* --- the delve log --------------------------------------------------------- */

.gm-dun-log { display: flex; flex-direction: column; gap: 6px; }
.gm-dun-day { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.gm-dun-day-head { display: flex; align-items: baseline; justify-content: space-between; padding: 0 2px; }
.gm-dun-day-v { font-family: var(--s-mono); font-size: 11.5px; color: var(--text-secondary); }
.gm-dun-list { display: flex; flex-direction: column; gap: 8px; }
.gm-dun-delve {
  position: relative; overflow: hidden; cursor: pointer;
  display: grid; grid-template-columns: 38px minmax(0, 1fr) auto; gap: 11px; align-items: center;
  padding: 11px 12px 11px 13px;
  background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  transition: transform 0.12s ease, border-color 0.12s ease;
}
.gm-dun-delve::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--accent); }
.gm-dun-delve.s-withered::before { background: var(--critical); }
.gm-dun-delve.s-growing::before { background: var(--warning); }
.gm-dun-delve:hover { border-color: var(--border-strong); }
.gm-dun-delve:active { transform: scale(0.99); }
.gm-dun-delve:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.gm-dun-delve-ico {
  width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center;
  color: var(--warning); background: color-mix(in srgb, var(--warning) 13%, transparent);
}
.gm-dun-delve.s-withered .gm-dun-delve-ico { color: var(--critical); background: color-mix(in srgb, var(--critical) 12%, transparent); }
.gm-dun-delve.s-withered { background: transparent; box-shadow: none; }
.gm-dun-delve.s-withered .gm-dun-delve-title { color: var(--text-secondary); }
.gm-dun-delve.s-growing .gm-dun-delve-ico { color: var(--accent); background: var(--accent-quiet); }
.gm-dun-delve-main { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.gm-dun-delve-title { font-size: 14.5px; font-weight: 500; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gm-dun-delve-n { font-family: var(--s-mono); font-size: 11px; color: var(--text-muted); margin-right: 6px; }
.gm-dun-delve-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 3px 10px; font-size: 11.5px; color: var(--text-muted); }
.gm-dun-delve-meta svg { vertical-align: -1px; }
.gm-dun-delve-side { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; }
.gm-dun-delve-side .gm-chip { font-size: 10.5px; padding: 1px 6px; }
.gm-dun-delve-min { font-family: var(--s-value-f); font-weight: 600; font-size: 16px; font-variant-numeric: tabular-nums; }
.gm-dun-delve.s-withered .gm-dun-delve-min { color: var(--text-muted); text-decoration: line-through; }
.gm-dun-bad { color: var(--critical); font-weight: 600; font-size: 12px; }
.gm-dun-now { color: var(--accent); font-weight: 600; }

.gm-dun-empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; padding: 24px 20px; }
.gm-dun-empty .sub { max-width: 400px; line-height: 1.5; }
.gm-dun-empty-ico {
  width: 60px; height: 60px; border-radius: 18px; display: grid; place-items: center; margin-bottom: 4px;
  color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent);
}

.gm-dun-one .gm-dun-depth b { font-size: 38px; }
.gm-dun-one.s-withered .gm-dun-depth b { color: var(--text-muted); text-decoration: line-through; }

/* --- the hub card ----------------------------------------------------------- */

.gm-dun-hub { display: flex; flex-direction: column; gap: 10px; }
.gm-dun-hub-head { display: flex; align-items: center; gap: 11px; cursor: pointer; }
.gm-dun-hub-head .grow { flex: 1; min-width: 0; }
.gm-dun-fx-ico {
  width: 36px; height: 36px; border-radius: 11px; flex: none; display: grid; place-items: center;
  color: var(--accent); background: color-mix(in srgb, var(--accent) 13%, transparent);
}
.gm-dun-hub-n { font-size: 14px; color: var(--text-secondary); margin-top: 2px; }
.gm-dun-hub-n b { font-family: var(--s-value-f); font-size: 20px; color: var(--text-primary); font-variant-numeric: tabular-nums; }
.gm-dun-hub.cleared .gm-dun-hub-n b { color: var(--warning); }
.gm-dun-hub-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.gm-dun-hub-go { display: inline-flex; align-items: center; justify-content: center; gap: 7px; }

/* --- inside Focus: Plant, the growing screen, the result ------------------- */

.gm-dun-fx { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.gm-dun-fx-head { display: flex; align-items: center; gap: 10px; }
.gm-dun-fx-head .grow { flex: 1; min-width: 0; }
.gm-dun-fx-line { font-size: 13.5px; color: var(--text-secondary); margin-top: 2px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.gm-dun-fx-line b { color: var(--text-primary); font-weight: 600; }
.gm-dun-fx-title { font-size: 15px; font-weight: 600; margin-top: 2px; }
.gm-dun-live-add.gm-dun-add { flex: none; color: var(--accent); }

/* The growing screen is Focus's own night, so these borrow its colour. */
.gm-dun-live {
  width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 6px;
  padding: 10px 12px; border-radius: 14px;
  background: color-mix(in srgb, currentColor 6%, transparent);
  border: 1px solid color-mix(in srgb, currentColor 13%, transparent);
}
.gm-dun-live .gm-eyebrow { color: inherit; opacity: 0.7; }
.gm-dun-live-line { font-size: 12.5px; opacity: 0.8; text-align: center; }
.gm-dun-live-line b { font-family: var(--s-mono); font-weight: 600; opacity: 1; }
.gm-dun-live-head { display: flex; align-items: center; justify-content: space-between; }
.gm-dun-live-add {
  appearance: none; font: inherit; font-size: 12.5px; color: inherit; cursor: pointer;
  display: inline-flex; align-items: center; gap: 3px; padding: 5px 10px; border-radius: 999px;
  background: color-mix(in srgb, currentColor 8%, transparent); border: 1px solid color-mix(in srgb, currentColor 18%, transparent);
}
.gm-dun-live-bar { height: 3px; border-radius: 2px; background: color-mix(in srgb, currentColor 12%, transparent); overflow: hidden; }
.gm-dun-live-bar i { display: block; height: 100%; background: currentColor; transition: width 0.4s ease; }
.gm-dun-live-row {
  display: grid; grid-template-columns: 32px minmax(0, 1fr) auto 34px; align-items: center; gap: 8px;
  padding: 5px 4px; border-radius: 10px; transition: background 0.2s ease, opacity 0.35s ease, transform 0.35s ease;
}
.gm-dun-live-row.on { background: color-mix(in srgb, currentColor 9%, transparent); }
.gm-dun-live-row.slain { opacity: 0.5; }
.gm-dun-live-row.slain .gm-dun-live-name { text-decoration: line-through; }
.gm-dun-live-row.slaying { opacity: 0; transform: translateX(14px) scale(0.97); }
.gm-dun-live-go, .gm-dun-live-slay {
  appearance: none; color: inherit; cursor: pointer; display: grid; place-items: center;
  width: 32px; height: 32px; border-radius: 50%; padding: 0;
  background: transparent; border: 1.5px solid color-mix(in srgb, currentColor 28%, transparent);
}
.gm-dun-live-row.on .gm-dun-live-go { background: currentColor; }
.gm-dun-live-row.on .gm-dun-live-go svg { color: var(--fx-night, var(--surface-0)); }
.gm-dun-live-go:disabled { cursor: default; }
.gm-dun-live-slay { width: 34px; height: 34px; }
.gm-dun-live-name { font-size: 14px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gm-dun-live-t { font-family: var(--s-mono); font-size: 13px; font-variant-numeric: tabular-nums; opacity: 0.85; }
.gm-dun-live-slain { font-family: var(--s-mono); font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; opacity: 0.8; }

.gm-dun-loot {
  width: 100%; max-width: 380px; display: flex; flex-direction: column; align-items: center; gap: 10px;
  --dun-rest: color-mix(in srgb, currentColor 18%, transparent);
}
.gm-dun-loot .gm-eyebrow { color: inherit; opacity: 0.7; }
.gm-dun-loot-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: center; animation: gm-dun-fade 0.5s 0.2s ease-out both; }
.gm-dun-loot-line .gm-chip { font-size: 14px; padding: 3px 9px; }
.gm-dun-loot-dom { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; opacity: 0.85; }
.gm-dun-loot.failed .gm-dun-loot-line { opacity: 0.8; }
.gm-dun-loot-donut { display: flex; align-items: center; gap: 14px; width: 100%; }
.gm-dun-loot-donut .gm-dun-legend { flex: 1; }
.gm-dun-loot .gm-dun-donut-track { stroke: color-mix(in srgb, currentColor 12%, transparent); }

/* --- the picker and settings ------------------------------------------------- */

.gm-dun-pick { display: flex; flex-direction: column; gap: 6px; max-height: 46vh; overflow-y: auto; margin-bottom: 12px; }
.gm-dun-pick-row {
  appearance: none; font: inherit; color: var(--text-primary); cursor: pointer; text-align: left;
  display: grid; grid-template-columns: 24px minmax(0, 1fr) auto; gap: 10px; align-items: center;
  padding: 10px 12px; border-radius: var(--radius-s); background: var(--surface-2); border: 1px solid transparent;
}
.gm-dun-pick-row[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-quiet); }
.gm-dun-pick-box {
  width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center;
  border: 1.5px solid var(--border-strong); color: transparent;
}
.gm-dun-pick-row[aria-pressed="true"] .gm-dun-pick-box { background: var(--accent); border-color: var(--accent); color: var(--surface-1); }
.gm-dun-pick-name { font-size: 14px; line-height: 1.3; overflow-wrap: anywhere; }
.gm-dun-pick-due { font-size: 11.5px; color: var(--text-muted); white-space: nowrap; }
.gm-dun-pick-due.now { color: var(--accent); font-weight: 600; }
.gm-dun-pick-due.late { color: var(--critical); font-weight: 600; }

.gm-dun-set-sub { font-size: 12px; font-weight: 600; color: var(--text-secondary); margin-top: 6px; }
.gm-dun-set-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 10px; align-items: center; }
.gm-dun-set-k { font-size: 13.5px; display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
.gm-dun-set-k i { width: 9px; height: 9px; border-radius: 50%; flex: none; }

/* --- motion ------------------------------------------------------------------- */

@keyframes gm-dun-draw { from { stroke-dasharray: 0 999; } }
@keyframes gm-dun-grow { from { transform: scaleX(0); } }
@keyframes gm-dun-fade { from { opacity: 0; transform: translateY(4px); } }
@keyframes gm-dun-flicker { 0%, 100% { opacity: 0.85; transform: scale(1); } 40% { opacity: 1; transform: scale(1.12); } 70% { opacity: 0.7; transform: scale(0.94); } }
@keyframes gm-dun-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }
@media (prefers-reduced-motion: reduce) {
  .gm-dun-ledge.on, .gm-dun-dep-track i, .gm-dun-donut-seg, .gm-dun-flicker, .gm-dun-pulse, .gm-dun-loot-line { animation: none; }
  .gm-dun-live-row, .gm-dun-delve, .gm-dun-live-bar i { transition: none; }
}
