/* Hearthmist — one fire, seen through mist.
   The design system (tokens, primitives, rules) is written up in docs/design.md. */

@font-face {
  font-family: "IM Fell English";
  src: url("../fonts/im-fell-english-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Alegreya Sans";
  src: url("../fonts/alegreya-sans-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Alegreya Sans";
  src: url("../fonts/alegreya-sans-500.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Alegreya Sans";
  src: url("../fonts/alegreya-sans-700.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  /* Ground: bog water and wet slate. Cool, so that anything warm reads as lit. */
  --bg: #0f1413;
  --panel: #171d1b;
  --panel-2: #1f2725;
  --panel-3: #2a3431;
  --line: #2b3533;
  --line-2: #46544f;

  /* Ink */
  --text: #ece4d0;
  --text-2: #c9c8b9;
  --muted: #9aa7a1;
  --mist: #b4c2bd;
  --ink: #0c100f;

  /* Fire. Ember is the only accent: it marks what can be acted on now. */
  --ember: #ffb24a;
  --ember-2: #ee7a30;
  --gold: #f2d28f;
  --lit: #2b2116;
  --lit-2: #3b2c19;

  /* State */
  --good: #a3d48e;
  --bad: #f58a76;
  --bad-fill: #b23c2c;

  /* Type */
  --serif: "IM Fell English", "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: "Alegreya Sans", "Gill Sans", "Gill Sans MT", "Trebuchet MS", system-ui, sans-serif;
  --fs-micro: 12.5px;
  --fs-small: 14px;
  --fs-text: 15px;
  --fs-body: 16px;
  --fs-name: 17px;
  --fs-title: 21px;
  --fs-display: 28px;

  /* Space, shape, depth */
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 24px;
  --r: 3px;
  --shadow: 0 8px 26px rgba(3, 6, 5, 0.55);
  --plate: rgba(18, 24, 22, 0.92);

  --rail-w: 60px;
  --panel-w: 400px;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font: 400 var(--fs-body)/1.4 var(--sans);
  font-variant-numeric: lining-nums tabular-nums;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}

h2, h3, p, ul, ol, dl, dd, dt { margin: 0; }
ul, ol { padding: 0; list-style: none; }
button { font: inherit; font-variant-numeric: inherit; color: inherit; }
b { font-weight: 700; }

/* The display face names things in the world. It has no tabular figures: never set a quantity in it. */
h2 {
  font-family: var(--serif);
  font-size: var(--fs-title);
  font-weight: 400;
  line-height: 1.15;
}

.muted { color: var(--muted); }
.good { color: var(--good); }
.bad { color: var(--bad); }

:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* ---------- icons ---------- */

.ic {
  width: 1.15em;
  height: 1.15em;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: -0.2em;
}

/* ---------- layout ---------- */

#app {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--panel-w);
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas:
    "top top"
    "map panel";
  height: 100vh;
  height: 100dvh;
  width: 100%;
}

#topbar {
  grid-area: top;
  display: flex;
  align-items: center;
  gap: 6px 20px;
  min-width: 0;
  padding: 6px 10px 6px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  z-index: 3;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
  font-family: var(--serif);
  font-size: calc(var(--fs-title) + 1px);
  line-height: 1;
  color: var(--text);
}
.brand .ic {
  width: 22px;
  height: 22px;
  color: var(--ember);
  fill: rgba(238, 122, 48, 0.4);
}

/* The stockpile: one fixed-width cell per resource, so a number is always in the same place. */
#resbar {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 4px;
  flex: 1 1 auto;
  min-width: 0;
}
.res {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  padding: 1px 0;
  cursor: default;
}
.res .ic { width: 19px; height: 19px; }
.res > div { display: flex; flex-direction: column; min-width: 0; line-height: 1.1; }
.res b { font-size: var(--fs-name); white-space: nowrap; }
.res small { font-size: var(--fs-micro); color: var(--muted); white-space: nowrap; }
.res small.up { color: var(--good); }
.res small.down { color: var(--bad); }

#hud-top { display: flex; align-items: center; gap: 2px; flex: none; }
#hud-top:empty { display: none; }
.top-actions { display: flex; gap: 2px; flex: none; }

#map-wrap {
  grid-area: map;
  position: relative;
  overflow: hidden;
  min-width: 0;
  min-height: 0;
  background: var(--bg);
}

canvas#map {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  outline: none;
}
canvas#map.dragging { cursor: grabbing; }

#panel {
  grid-area: panel;
  display: grid;
  grid-template-columns: var(--rail-w) minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
  background: var(--panel);
  border-left: 1px solid var(--line);
  z-index: 2;
}

/* ---------- tabs: an index rail down the spine of the panel ---------- */

#tabs {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 0;
  padding: 8px 0;
  overflow-y: auto;
  scrollbar-width: none;
  background: var(--bg);
  border-right: 1px solid var(--line);
}
#tabs::-webkit-scrollbar { display: none; }
#tabs button {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  flex: none;
  min-width: 0;
  margin-right: -1px;
  padding: 9px 2px 8px;
  background: none;
  border: 0;
  color: var(--muted);
  font-size: var(--fs-micro);
  font-weight: 500;
  line-height: 1.2;
  cursor: pointer;
  transition: color 0.12s, background-color 0.12s;
}
#tabs button .ic { width: 20px; height: 20px; }
#tabs button span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#tabs button:hover { color: var(--text); background: var(--panel-2); }
#tabs button.on {
  background: var(--panel);
  color: var(--text);
  box-shadow: inset 2px 0 0 var(--ember);
}
#tabs button.on .ic { color: var(--ember); }
#tabs button:focus-visible { outline-offset: -2px; }

/* A count on a tab. Keep it to three characters. */
.tab-badge {
  position: absolute;
  top: 3px;
  left: calc(50% + 5px);
  min-width: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--ember);
  color: var(--ink);
  font-size: calc(var(--fs-micro) - 1.5px);
  font-style: normal;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
}

#panel-body {
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--s4) var(--s4) 28px;
  scrollbar-width: thin;
  scrollbar-color: var(--line-2) transparent;
  overscroll-behavior: contain;
  /* The panel is rebuilt in place and its scroll position restored by hand; browser scroll anchoring
     on top of that makes the content creep a few pixels each time. */
  overflow-anchor: none;
}
#panel-body::-webkit-scrollbar { width: 8px; }
#panel-body::-webkit-scrollbar-track { background: transparent; }
#panel-body::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 4px; }

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 34px;
  padding: 5px 14px;
  background: var(--panel-2);
  border: 1px solid var(--line-2);
  border-radius: var(--r);
  color: var(--text);
  font-size: var(--fs-body);
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.12s, border-color 0.12s, color 0.12s;
}
.btn:hover { background: var(--panel-3); border-color: var(--muted); }
.btn:active { transform: translateY(1px); }

/* Primary: the one thing this block is for. Lit when it can be afforded, unlit when it cannot. */
.btn.primary {
  justify-content: space-between;
  background: var(--lit);
  border-color: var(--ember);
  color: var(--ember);
}
.btn.primary:hover { background: var(--lit-2); border-color: var(--gold); }
.btn.primary > span:only-child { margin: 0 auto; }

.btn.wide { display: flex; flex-wrap: wrap; row-gap: 4px; width: 100%; min-height: 40px; margin-top: 14px; padding-block: 7px; }
/* A cost too long for the label's line goes under it, and starts where the label starts. */
.btn.wide .cost { justify-content: flex-start; }

.btn.ghost { background: none; border-color: transparent; color: var(--muted); font-weight: 500; }
.btn.ghost:hover { background: var(--panel-2); border-color: transparent; color: var(--text); }

.btn.danger { color: var(--bad); }
.btn.danger:hover { border-color: var(--bad); }
.btn.danger.armed { background: var(--bad-fill); border-color: var(--bad); color: var(--text); }
.btn.danger.armed:hover { border-color: var(--text); }

.btn:disabled,
.btn:disabled:hover {
  background: none;
  border-color: var(--line-2);
  color: var(--muted);
  cursor: not-allowed;
  transform: none;
}

/* ---------- costs ---------- */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: var(--text);
  font-weight: 700;
  white-space: nowrap;
}
.chip .ic { width: 15px; height: 15px; }
.chip.short { color: var(--bad); }
.cost { display: inline-flex; flex-wrap: wrap; justify-content: flex-end; gap: 2px 10px; }
.btn .cost { white-space: normal; }

/* ---------- sections ---------- */

/* A card is a section of the panel. It has no box: space and one rule separate it from what came before. */
.card > p { margin-top: var(--s2); }
.card > p.muted { font-size: var(--fs-text); }
:where(.card, .opts, .ref, .goal) + .card {
  margin-top: 20px;
  padding-top: var(--s4);
  border-top: 1px solid var(--line);
}
.goal + .card { margin-top: var(--s4); padding-top: 0; border-top: 0; }

.card.empty p b { color: var(--text); font-weight: 500; }
.card.empty h2 { margin-top: var(--s3); }

.th { display: flex; align-items: center; gap: var(--s3); }
.th > div { min-width: 0; }
.th small { display: block; margin-top: 2px; color: var(--muted); font-size: var(--fs-small); }

/* Land is a hex. */
.swatch {
  flex: none;
  width: 30px;
  height: 34px;
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
  background: var(--line-2);
}
.swatch.fog {
  background:
    repeating-linear-gradient(170deg, rgba(180, 194, 189, 0.3) 0 2px, transparent 2px 7px),
    var(--panel-3);
}
.swatch.sm { width: 16px; height: 18px; }

/* A building is a disc with a ring, the same token it has on the map. */
.badge {
  display: grid;
  place-items: center;
  flex: none;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--ink);
  border: 2px solid var(--ring, var(--gold));
  color: var(--text);
}
.badge .ic { width: 21px; height: 21px; }
.badge.hot {
  border-color: var(--ember-2);
  background: var(--lit);
  color: var(--gold);
  box-shadow: 0 0 16px rgba(238, 122, 48, 0.4);
}
.badge.hot .ic { fill: rgba(238, 122, 48, 0.75); }

/* Heading for a list or a group of rows. It sits on a rule. */
.sec {
  margin: 22px 0 0;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: var(--fs-small);
  font-weight: 500;
  line-height: 1.3;
}
.sec.first { margin-top: 0; }
.sec.in { margin-top: 18px; margin-bottom: 6px; color: var(--gold); }

/* ---------- the goal ---------- */

.goal {
  padding: var(--s3) 14px 14px;
  background: var(--panel-2);
  border-radius: var(--r);
  cursor: pointer;
  transition: background-color 0.12s;
}
.goal:hover { background: var(--panel-3); }
.goal-h {
  display: flex;
  align-items: center;
  gap: var(--s2);
  font-family: var(--serif);
  font-size: var(--fs-name);
  line-height: 1.2;
}
.goal-h .ic { width: 18px; height: 18px; color: var(--ember); fill: rgba(238, 122, 48, 0.45); }

.progs { display: grid; gap: 5px; margin-top: 10px; }
.prog { display: flex; align-items: center; gap: var(--s2); }
.prog .ic { width: 16px; height: 16px; }
.prog > span {
  flex: none;
  min-width: 92px;
  text-align: right;
  font-size: var(--fs-small);
  color: var(--muted);
  white-space: nowrap;
}

.bar {
  flex: 1 1 auto;
  height: 5px;
  min-width: 0;
  background: var(--ink);
  border-radius: 2px;
  overflow: hidden;
}
.bar i {
  display: block;
  width: 0;
  height: 100%;
  background: var(--ember);
  transition: width 0.25s linear;
}
.bar.full i { background: var(--good); }

.goal.done { cursor: default; }
.goal.done:hover { background: var(--panel-2); }
.goal.done .goal-h { color: var(--gold); }

/* ---------- rows of figures ---------- */

/* Label on the left, figure on the right, a dotted leader to carry the eye across. */
.stat {
  display: flex;
  align-items: baseline;
  gap: var(--s2);
  padding: 3px 0;
  font-size: var(--fs-text);
}
.th + .stat, p + .stat, .sec + .stat { margin-top: var(--s2); }
.stat > span { display: flex; align-items: baseline; flex: 1 1 auto; min-width: 0; color: var(--muted); }
.stat > span::after {
  content: "";
  flex: 1 1 14px;
  min-width: 14px;
  margin-left: var(--s2);
  border-bottom: 1px dotted var(--line-2);
  transform: translateY(-3px);
}
.stat > b { flex: 0 1 auto; text-align: right; white-space: nowrap; }
.stat > b.muted { color: var(--muted); }
.stat > b.good { color: var(--good); }
.stat > b.bad { color: var(--bad); white-space: normal; }

ul.parts { margin-top: 2px; padding-left: var(--s3); font-size: var(--fs-small); }
ul.parts li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 1px 0;
  color: var(--muted);
}
ul.parts b { color: var(--text-2); font-weight: 500; white-space: nowrap; }
ul.parts b.bad { color: var(--bad); }

.eta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  min-height: 18px;
  margin-top: 5px;
  font-size: var(--fs-small);
  color: var(--muted);
}
.eta .gain { color: var(--good); font-weight: 700; }
.eta .gain + span { margin-left: auto; text-align: right; }
.eta:empty { min-height: 0; margin-top: 0; }

.row { display: flex; gap: var(--s2); margin-top: var(--s3); }
.row .btn { flex: 1 1 0; }

.hint { margin-top: 10px; font-size: var(--fs-small); line-height: 1.45; color: var(--muted); }
.hint .chip { margin-left: 5px; }
.hint .chip .ic { width: 14px; height: 14px; }

.unlocks { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; margin-top: var(--s2); font-size: var(--fs-text); }
.unlock { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.unlock .ic { width: 16px; height: 16px; color: var(--gold); }

.win-note {
  margin-top: var(--s4);
  padding-top: var(--s3);
  border-top: 1px solid var(--line);
  font-family: var(--serif);
  font-size: var(--fs-name);
  line-height: 1.35;
  color: var(--gold);
}

/* ---------- lists of things to act on: build options, research ---------- */

.opts { display: grid; }
.opt { padding: var(--s3) 0 14px; border-top: 1px solid var(--line); }
.opt:first-child { border-top: 0; }
.opt-h { display: flex; align-items: center; gap: var(--s2); min-width: 0; }
.opt-h .ic { width: 20px; height: 20px; }
.opt-h > .ic:first-child:not([style]) { color: var(--gold); }
.opt-h > b {
  overflow: hidden;
  font-family: var(--serif);
  font-size: var(--fs-name);
  font-weight: 400;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* What you would get. Green is a rate; gold is a kind of effect. */
.yield {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  color: var(--good);
  font-size: var(--fs-text);
  font-weight: 700;
  white-space: nowrap;
}
.yield .ic { width: 15px; height: 15px; }
.yield.aura { color: var(--gold); font-weight: 500; }

.opt-h .lvl { margin-left: auto; font-size: var(--fs-small); color: var(--muted); white-space: nowrap; }

.opt > p.muted { margin-top: 3px; font-size: var(--fs-text); }
.now { color: var(--good); font-weight: 700; white-space: nowrap; }

ul.syn { margin-top: 3px; font-size: var(--fs-small); color: var(--muted); }
ul.syn:empty { display: none; }
.opt > ul.parts { margin-top: 6px; padding: 6px 0 0; border-top: 1px dotted var(--line-2); }

p.here { margin-top: 5px; font-size: var(--fs-small); color: var(--muted); }
p.here.yes { color: var(--gold); }
/* A harm never reads as a help: red, and the sentence says so. */
p.here.bad { color: var(--bad); }

.opt-f { display: flex; flex-wrap: wrap; align-items: center; gap: 5px var(--s3); margin-top: 10px; }
/* The button keeps its cost on one line. When the note beside it no longer fits, the note goes underneath. */
.opt-f .btn { flex: 0 1 auto; min-width: 150px; max-width: 100%; }
.opt-f .btn .cost { flex-wrap: nowrap; }
.opt-f .eta { display: block; min-height: 0; margin: 0 0 0 auto; text-align: right; line-height: 1.25; }

/* Not yet: one quiet line, the name and what it waits for. */
.opt.locked { padding: 9px 0; }
.opt.locked .opt-h > b, .opt.locked .opt-h > .ic:first-child { color: var(--muted); }
.opt.locked .yield { color: var(--muted); }
.opt.locked .opt-f { margin-top: 6px; }
.locked-note { font-size: var(--fs-small); color: var(--muted); }
.opt-h > .locked-note { flex: none; margin-left: auto; white-space: nowrap; }

.opt.maxed .opt-h .lvl { color: var(--good); font-weight: 700; }

/* ---------- guide ---------- */

.guide ul { display: grid; gap: var(--s2); margin-top: var(--s3); font-size: var(--fs-text); color: var(--text-2); }
.guide ul b { color: var(--text); font-weight: 700; }
.guide > p.muted { margin-top: var(--s3); font-size: var(--fs-small); }

ul.ref li { display: flex; align-items: flex-start; gap: 10px; padding: var(--s2) 0; border-top: 1px solid var(--line); }
ul.ref li:first-child { border-top: 0; }
ul.ref li > .ic { width: 18px; height: 18px; margin-top: 2px; color: var(--gold); }
ul.ref li > .swatch { margin-top: 2px; }
ul.ref li > div { min-width: 0; }
ul.ref b { font-family: var(--serif); font-size: var(--fs-body); font-weight: 400; }
ul.ref em { margin-left: 6px; color: var(--muted); font-size: var(--fs-small); font-style: normal; white-space: nowrap; }
ul.ref small { display: block; margin-top: 1px; font-size: var(--fs-small); line-height: 1.4; color: var(--muted); }

/* ---------- over the map ---------- */

/* Anything that floats over the map is a plate: dark, hairlined, small. */
.plate, #next-reveal, #tip, .toast {
  background: var(--plate);
  border: 1px solid var(--line-2);
  border-radius: var(--r);
  box-shadow: var(--shadow);
}
.plate { padding: var(--s2) var(--s3); font-size: var(--fs-small); line-height: 1.35; }
/* The edge of a plate turns ember while something on it can be acted on now. Nothing inside it is lit. */
.plate.ready { border-color: var(--ember); }

/* Slots that modules fill. The slot itself ignores the pointer; what is put in it does not. */
.hud {
  position: absolute;
  z-index: 3;
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  max-width: min(280px, calc(100% - 24px));
  pointer-events: none;
}
.hud > * { pointer-events: auto; }
#map-hud-tl { top: 12px; left: 12px; align-items: flex-start; }
#map-hud-tr { top: 12px; right: 12px; align-items: flex-end; }
#map-hud-br { bottom: 12px; right: 12px; align-items: flex-end; flex-direction: column-reverse; }

#next-reveal {
  position: absolute;
  left: 12px;
  bottom: 12px;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 11px;
  color: var(--muted);
  font-size: var(--fs-small);
  pointer-events: none;
  transition: border-color 0.2s, color 0.2s;
}
#next-reveal:empty { display: none; }
#next-reveal.ready { border-color: var(--ember); color: var(--gold); }

#tip {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 4;
  display: flex;
  flex-direction: column;
  gap: 1px;
  max-width: 240px;
  padding: 7px 11px 8px;
  font-size: var(--fs-small);
  line-height: 1.35;
  white-space: nowrap;
  pointer-events: none;
}
#tip b { font-family: var(--serif); font-size: var(--fs-body); font-weight: 400; }
#tip .tip-rate { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); }
#tip .tip-rate > .ic { width: 14px; height: 14px; }
#tip .tip-rate .chip .ic { width: 13px; height: 13px; }

/* Word from the settlement stacks at the bottom left, above the next-reveal note, clear of the fire's
   column and of whatever waits for an answer at the bottom right. */
#toasts {
  position: absolute;
  left: 12px;
  bottom: 52px;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  width: max-content;
  /* never wider than what the bottom-right plates (280px and their gutter) leave free */
  max-width: min(400px, calc(100% - 324px));
  pointer-events: none;
}
.toast {
  max-width: 100%;
  padding: 7px 14px;
  border-left: 3px solid var(--muted);
  font-size: var(--fs-text);
  animation: toast-in 0.2s ease-out both;
  transition: opacity 0.35s;
}
.toast.good { border-left-color: var(--good); color: var(--text); }
.toast.bad { border-left-color: var(--bad); color: var(--text); }
.toast.out { opacity: 0; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* ---------- dialog ---------- */

dialog#dlg {
  width: calc(100% - 32px);
  max-width: 460px;
  max-height: calc(100dvh - 32px);
  margin: auto;
  padding: 0;
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line-2);
  border-radius: var(--r);
  box-shadow: 0 24px 70px rgba(3, 6, 5, 0.7);
  color: var(--text);
}
dialog#dlg::backdrop { background: rgba(9, 13, 12, 0.72); }
/* A dialog about the fire stands to one side, so the fire can be seen burning beside it. */
dialog#dlg.aside { margin-right: 24px; }
dialog#dlg.aside::backdrop { background: linear-gradient(to right, rgba(9, 13, 12, 0.2) 30%, rgba(9, 13, 12, 0.82) 72%); }
#dlg-body { padding: 28px 28px 22px; }
#dlg-body > .badge { width: 46px; height: 46px; margin-bottom: var(--s4); }
#dlg-body > .badge .ic { width: 26px; height: 26px; }
#dlg-body h2 { font-size: var(--fs-display); line-height: 1.12; }
#dlg-body p { margin-top: var(--s3); color: var(--text-2); line-height: 1.5; }
#dlg-body p b, #dlg-body li b { color: var(--text); }
#dlg-body ul, #dlg-body ol { margin-top: var(--s3); padding-left: 18px; color: var(--text-2); line-height: 1.5; }
#dlg-body ul { list-style: disc; }
#dlg-body ol { list-style: decimal; }
#dlg-body li { padding: 3px 0; }
#dlg-body li::marker { color: var(--ember-2); }
.dlg-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: var(--s2); margin-top: var(--s5); }
.dlg-actions .btn { min-width: 104px; justify-content: center; }

/* ---------- small screens: map above, panel below ---------- */

@media (max-width: 820px) {
  #app {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr) 46dvh;
    grid-template-areas:
      "top"
      "map"
      "panel";
  }
  #topbar { flex-wrap: wrap; gap: 4px 8px; padding: 4px 6px 6px 12px; }
  .brand { margin-right: auto; font-size: calc(var(--fs-title) - 1px); }
  #resbar { order: 5; flex: 1 0 100%; grid-template-columns: repeat(auto-fill, minmax(66px, 1fr)); gap: 4px 6px; }
  .res { gap: 5px; }
  .res .ic { width: 16px; height: 16px; }
  .res b { font-size: var(--fs-body); }
  .btn.ghost { min-height: 32px; padding: 4px 8px; }

  #panel { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); border-left: 0; border-top: 1px solid var(--line); }
  #tabs { flex-direction: row; gap: 0; padding: 0; overflow: visible; border-right: 0; border-bottom: 1px solid var(--line); }
  #tabs button { flex: 1 1 0; margin: 0 0 -1px; padding: 7px 1px 6px; }
  #tabs button.on { box-shadow: inset 0 2px 0 var(--ember); }
  #panel-body { padding: var(--s3) var(--s3) var(--s5); }
  #next-reveal { left: 8px; bottom: 8px; }
  /* On a phone the bottom of the map is spoken for, so word comes in under the season, the latest only. */
  #toasts { left: 8px; top: 50px; bottom: auto; max-width: calc(100% - 16px); }
  #toasts .toast:nth-last-child(n + 2) { display: none; }
  .progs { grid-template-columns: 1fr 1fr; gap: 5px var(--s4); }
  .prog > span { min-width: 0; }
  .opt-f .btn { min-width: 136px; }
  dialog#dlg.aside { margin: auto auto 16px; }
  dialog#dlg.aside::backdrop { background: linear-gradient(to bottom, rgba(9, 13, 12, 0.2) 25%, rgba(9, 13, 12, 0.82) 60%); }
  #dlg-body { padding: 22px 20px 18px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
