/* Emberroost -- phone-first. Everything is sized so the whole game is reachable
   with one thumb, and the layout is capped and centred so it also looks
   deliberate on a 4K desktop rather than stretching into a stripe. */

:root {
  /* "Banked Embers", chosen by Megan on 2026-10-02: a near-black hearth lit
     from below by embers, Kibyra's gold trim (#d9a43f / #e9c141), ember-red
     for what you press, and warm parchment text rather than white. */
  --bg:        #0b0605;
  --bg-2:      #140a07;
  --panel:     #1e0c08;
  --panel-2:   #2f150d;
  --line:      #6e3016;
  --frame:     #a06a26;
  --ink:       #efd9b4;
  --ink-dim:   #cfa67c;
  --ink-faint: #9a6c4a;
  --gold:      #e9c141;
  --ember:     #e2502c;
  --ember-2:   #f08a4b;     /* the bright edge of an ember: headings, rates */
  --deep:      #070403;     /* wells and tracks sunk into a panel */
  --good:      #6fbf73;
  --warn:      #e0a63c;
  --bad:       #d8604f;
  --accent:    #d9a43f;

  --r-sm: 4px;      /* tight corners sit better next to pixel art */
  --r:    6px;
  --r-lg: 10px;
  --tap:  46px;

  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --shadow: 0 6px 20px rgba(0,0,0,.4);

  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  height: 100%;
  overflow-x: hidden;
}

body {
  background:
    radial-gradient(120% 75% at 50% 108%, rgba(240,100,44,.55), rgba(170,40,14,.28) 40%, rgba(90,20,8,.1) 65%, transparent 80%),
    radial-gradient(90% 40% at 50% -8%, rgba(233,160,60,.16), transparent 70%),
    var(--bg);
  background-attachment: fixed;
  color: var(--ink);
  font: 400 16px/1.45 ui-rounded, "Segoe UI", system-ui, -apple-system, sans-serif;
  overscroll-behavior-y: contain;
}

#app {
  display: flex; flex-direction: column;
  min-height: 100dvh;
  max-width: 680px;           /* a phone game should stay phone-shaped */
  margin-inline: auto;
}

.boot { padding: 40vh 24px; text-align: center; color: var(--ink-dim); }

button { font: inherit; color: inherit; border: none; background: none; cursor: pointer; }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: .01em; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(var(--safe-t) + 10px) 16px 10px;
  background: linear-gradient(var(--bg) 70%, transparent);
  backdrop-filter: blur(8px);
}
.hoard { display: flex; align-items: baseline; gap: 8px; }
/* The coin: 7Soul1's CC0 gold coin (OpenGameArt), drawn crisp. */
.coin {
  display: inline-block; flex: none;
  background: url(../assets/ui/coin.png) center / contain no-repeat;
  image-rendering: pixelated;
}
.coin.pile { background-image: url(../assets/ui/coins.png); }
.hoard .coin {
  width: 24px; height: 24px;
  filter: drop-shadow(0 0 6px rgba(232,182,76,.45));
  align-self: center;
}
.hoard strong { font-size: 22px; font-variant-numeric: tabular-nums; }
.hoard small { color: var(--good); font-size: 13px; font-variant-numeric: tabular-nums; }
.icon-btn {
  width: var(--tap); height: var(--tap); border-radius: 50%;
  background: var(--panel); border: 1px solid var(--line); font-size: 18px;
}

/* ---------- screens ---------- */
main {
  flex: 1;
  padding: 4px 14px calc(96px + var(--safe-b));
  outline: none;
}
.screen-title {
  font-size: 13px; text-transform: uppercase; letter-spacing: .12em;
  color: var(--ember-2); margin: 14px 2px 10px;
}
.hint { color: var(--ink-dim); font-size: 14px; margin: 0 2px 12px; }
.tale-part { margin: 8px 2px 0; line-height: 1.45; font-style: italic; }
.tale-part b { font-style: normal; margin-right: 4px; }

/* ---------- dragon cards ---------- */
.roost-grid {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}
.card {
  position: relative;
  background: linear-gradient(170deg, var(--panel-2), var(--panel));
  border-radius: var(--r);
  padding: 10px 10px 12px;
  text-align: center;
  transition: transform .12s ease, border-color .12s ease;
}
.card { cursor: pointer; }
.card:active { transform: scale(.975); }
.card:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.card.ready { border-color: var(--gold); box-shadow: 0 0 14px rgba(240,184,74,.45), inset 0 0 0 2px var(--deep); }
.card.ready .portrait svg { animation: egg-wobble 1.6s ease-in-out infinite; transform-origin: 50% 85%; }
.card.ready .egg-timer { color: var(--gold); font-weight: 650; }
.card.cracking .portrait svg { animation: egg-crack .65s ease-in forwards; transform-origin: 50% 85%; }
@keyframes egg-wobble { 0%, 70%, 100% { transform: rotate(0) } 76% { transform: rotate(-7deg) } 84% { transform: rotate(6deg) } 92% { transform: rotate(-3deg) } }
@keyframes egg-crack { 0% { transform: rotate(0) } 20% { transform: rotate(-10deg) } 40% { transform: rotate(10deg) } 60% { transform: rotate(-6deg) scale(1.05) } 100% { transform: scale(1.25); opacity: 0; filter: brightness(2) } }
/* On a mouse, a card lifts to say it opens; until one is opened, the Roost says so too. */
@media (hover: hover) {
  .card:hover { transform: translateY(-3px); border-color: var(--gold); box-shadow: 0 6px 16px rgba(0,0,0,.45), inset 0 0 0 2px var(--deep), inset 0 0 0 3px var(--line); }
}
.roost-hint { margin: -2px 0 10px; }
.card .ribbon { z-index: 1; }
.card .portrait { display: flex; justify-content: center; align-items: center; height: 104px; }
.card .portrait svg { max-width: 100%; height: auto; }
.card .name {
  font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card .meta { font-size: 11.5px; color: var(--ink-dim); margin-top: 2px; }
.card .status { font-size: 11px; color: var(--accent, var(--ink)); margin-top: 1px; min-height: 0; }
.card .status:empty { display: none; }
.hero-status { font-size: 12.5px; color: var(--accent, var(--ink)); margin-top: 3px; display: flex; gap: 8px; align-items: center; }
.hero-status:has(span:empty):not(:has(button)) { display: none; }
.card .rate {
  font-size: 12px; color: var(--ember-2); margin-top: 6px; font-variant-numeric: tabular-nums;
}
.ribbon {
  position: absolute; top: 8px; left: 8px;
  font-size: 10px; letter-spacing: .06em; text-transform: uppercase;
  padding: 3px 7px; border-radius: 99px; font-weight: 700;
  background: rgba(0,0,0,.35);
}
.egg-timer {
  margin-top: 6px; font-size: 12px; color: var(--accent);
  font-variant-numeric: tabular-nums;
}

/* ---------- need bars ---------- */
.bars { display: flex; gap: 4px; margin-top: 8px; }

.statline { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 13px; }
.statline + .statline { margin-top: 7px; }
/* A dotted leader joins each label to its number, so the eye can follow a
   line across a wide panel. */
.statline::after {
  content: ''; order: 1; flex: 1 1 12px; align-self: flex-end; margin-bottom: 4px;
  border-bottom: 1px dotted color-mix(in srgb, var(--ink-dim) 45%, transparent);
}
.statline > :last-child { order: 2; text-align: right; }
/* The dragon page's figures: two columns where there is room. */
.stat-grid > .statline + .statline { margin-top: 7px; }
@media (min-width: 600px) {
  .stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px 32px; }
  .stat-grid > .statline + .statline { margin-top: 0; }
}
.statline span:last-child { color: var(--ink); font-variant-numeric: tabular-nums; }
.statline span:first-child { color: var(--ink-dim); }

/* ---------- panels, buttons ---------- */
.panel, .card {
  border: 2px solid var(--frame);
  box-shadow: inset 0 0 0 2px var(--deep), inset 0 0 0 3px var(--line);
}
.panel {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border-radius: var(--r); padding: 14px; margin-bottom: 12px;
}
.btn {
  min-height: var(--tap); padding: 0 18px; border-radius: var(--r-sm);
  background: linear-gradient(180deg, #3d1f15, #25120c);
  border: 1px solid var(--line); font-weight: 650;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn:active { transform: translateY(1px); }
a.btn { color: inherit; text-decoration: none; text-align: center; }
.btn.primary {
  background: linear-gradient(180deg, var(--ember), #9a2a14); border-color: var(--ember-2); color: #fff0d8;
  box-shadow: 0 0 12px rgba(226,80,44,.3);
}
.btn.ghost   { background: transparent; }
.btn.danger  { background: transparent; border-color: #7a3a2c; color: #e58b7c; }
.btn[disabled] { opacity: .42; pointer-events: none; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-row > .btn { flex: 1; }

/* ---------- care buttons ---------- */
/* On the dragon page: the portrait beside the name, then each care button
   beside the bar of the need it fills. */
.sheet-inner .hero { display: grid; grid-template-columns: 116px 1fr; gap: 6px 14px; align-items: center; }
.hero-main { min-width: 0; }
.hero .need-row { padding-left: 10px; }   /* a little air after the button */
.hero .need-row > span { min-width: 38px; font-size: 12.5px; }
.hero .care-btn {
  min-height: 34px; flex-direction: row; justify-content: flex-start; gap: 5px; padding: 0 7px;
  white-space: nowrap;
}
.hero .care-btn svg { width: 20px; height: 20px; }
.hero .care-btn span { color: var(--ink); }
.hero .care-btn small { margin-left: auto; font-size: 10px; }
.care-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.care-btn {
  min-height: 64px; border-radius: var(--r-sm);
  background: var(--panel-2); border: 1px solid var(--line);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 12px; color: var(--ink-dim);
}
.care-btn b { display: flex; line-height: 0; color: var(--ink); }
.care-btn svg { width: 24px; height: 24px; }
.care-btn[disabled] { opacity: .4; pointer-events: none; }

/* ---------- genetics panel ---------- */
.gene-table { display: grid; grid-template-columns: 1fr auto auto; gap: 8px 10px; font-size: 13.5px; }
.gene-table .k { color: var(--ink-dim); display: flex; align-items: baseline; gap: 8px; }
.gene-table .k::after {
  content: ''; flex: 1; align-self: flex-end; margin-bottom: 4px;
  border-bottom: 1px dotted color-mix(in srgb, var(--ink-dim) 45%, transparent);
}
.gene-table .v { text-align: right; }
.gene-table .g {
  font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12px;
  color: var(--ink-faint); text-align: right; min-width: 52px;
}
/* Two genes to a line where there is room, like the figures above. */
@media (min-width: 600px) {
  .gene-table { grid-template-columns: 1fr auto auto 1fr auto auto; column-gap: 10px; }
  .gene-table .k:nth-child(6n+4) { margin-left: 22px; }
}
.carrier-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip {
  font-size: 11.5px; padding: 4px 9px; border-radius: 99px;
  background: rgba(217,164,63,.14); border: 1px solid rgba(217,164,63,.42);
  color: #f0cf8a;
}
.filter-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 10px; }
.filter-chip { cursor: pointer; font: inherit; font-size: 12px; padding: 5px 11px;
  background: rgba(255,255,255,.05); border-color: var(--line); color: var(--ink-dim); }
.filter-chip[style*="--el"] { color: var(--el); }
.filter-chip[aria-pressed="true"] { background: rgba(217,164,63,.18); border-color: rgba(217,164,63,.6); color: var(--ink); }
.filter-chip[style*="--el"][aria-pressed="true"] { border-color: var(--el); background: color-mix(in srgb, var(--el) 20%, transparent); }
.chip.muted { background: rgba(255,255,255,.05); border-color: var(--line); color: var(--ink-dim); }
.chip.mutant { background: rgba(201,154,216,.16); border-color: rgba(201,154,216,.5); color: #e2c6f0; }

/* ---------- pedigree ---------- */
.ped-grid {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(8, minmax(30px, auto)); gap: 4px 6px; margin-top: 12px;
}
.ped-cell { display: flex; align-items: center; min-width: 0; }
.ped-node {
  width: 100%; min-width: 0; display: grid; grid-template-columns: auto 1fr; align-items: center;
  column-gap: 5px; padding: 4px 6px; text-align: left; font: inherit; font-size: 12px; color: var(--ink);
  background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--r-sm); cursor: pointer;
}
.ped-node:disabled { cursor: default; }
.ped-node.gone { background: transparent; border-style: dashed; color: var(--ink-dim); }
.ped-node i { width: 9px; height: 9px; border-radius: 50%; grid-row: span 2; border: 1px solid rgba(0,0,0,.4); }
.ped-node span, .ped-node small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ped-node small { font-size: 10px; }
.ped-none { font-size: 11px; color: var(--ink-faint); font-style: italic; padding-left: 6px; }
.dud { color: var(--bad); font-weight: 700; }
.dud-note { margin: 10px 0 0; font-size: 13px; color: #f0a99c; }
.kin-note { margin: 8px 2px 0 !important; text-align: center; font-size: 13px; }
.kin-note.warn { color: var(--warn); }

/* ---------- nest ---------- */
.parent-slots { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: center; }
.slot {
  min-height: 150px; border-radius: var(--r);
  border: 1.5px dashed var(--line); background: rgba(0,0,0,.18);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; padding: 8px; text-align: center; color: var(--ink-faint); font-size: 13px;
}
.slot.filled { border-style: solid; background: var(--panel); color: var(--ink); }
.slot svg { max-width: 100%; height: auto; }
.heart { display: flex; }
.picker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
.pick {
  border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--panel);
  padding: 6px; font-size: 11.5px; text-align: center;
}
.pick[aria-pressed="true"] { border-color: var(--ember); background: var(--panel-2); }
.pick[disabled] { opacity: .38; pointer-events: none; }
/* Kept at home (a station, training, a wound): shown as it is, with why, not to be picked. */
.pick.kept-home { pointer-events: none; }
.pick.kept-home .pick-sub { color: var(--ink-dim); }
.pick svg { max-width: 100%; height: auto; }

/* ---------- sheet (dragon detail) ---------- */
.sheet {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(10,7,4,.62); backdrop-filter: blur(3px);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet[hidden] { display: none; }
.sheet-inner {
  width: 100%; max-width: 680px; max-height: 92dvh; overflow-y: auto;
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  padding: 10px 16px calc(24px + var(--safe-b));
  animation: rise .22s cubic-bezier(.22,1,.36,1);
}
@keyframes rise { from { transform: translateY(26px); opacity: .4 } }
.grabber {
  width: 42px; height: 4px; border-radius: 99px; background: var(--line);
  margin: 4px auto 12px;
}
.hero { display: flex; gap: 14px; align-items: center; }
.hero .art { flex: 0 0 132px; display: flex; justify-content: center; }
.hero h2 { font-size: 20px; }
.name-edit {
  background: transparent; border: none; border-bottom: 1px dashed var(--line);
  color: var(--ink); font: inherit; font-size: 20px; font-weight: 650;
  width: 100%; padding: 2px 0; min-height: 34px;
}
.name-edit:focus { outline: none; border-bottom-color: var(--ember); }

/* ---------- misc ---------- */
.tabbar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 680px; z-index: 30;
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;   /* as many as are open */
  padding: 6px 6px calc(6px + var(--safe-b));
  background: rgba(11,6,5,.95); backdrop-filter: blur(12px);
  border-top: 1px solid #6a2a14;
}
.tabbar button {
  min-width: 0; min-height: var(--tap); border-radius: var(--r-sm);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 11px; color: var(--ink-faint);
}
.tabbar button span { display: flex; line-height: 0; }
.tabbar button[aria-selected="true"] { color: var(--gold); background: rgba(226,80,44,.2); box-shadow: inset 0 2px 0 var(--ember); }

.toasts {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(86px + var(--safe-b)); z-index: 80;
  display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none; width: min(92vw, 420px);
}
.toast {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--ink);
  padding: 10px 16px; border-radius: 99px; font-size: 14px; text-align: center;
  box-shadow: var(--shadow); animation: pop .2s ease;
}
.toast.good { border-color: #3f6b45; }
.toast.bad  { border-color: #6d3b38; }
@keyframes pop { from { transform: translateY(8px); opacity: 0 } }

.log-list { list-style: none; margin: 0; padding: 0; font-size: 13.5px; }
.log-list li { padding: 8px 0; border-bottom: 1px solid var(--line); color: var(--ink-dim); }
.log-list li:last-child { border-bottom: none; }

.empty { text-align: center; color: var(--ink-faint); padding: 32px 12px; font-size: 14px; }

textarea.backup {
  width: 100%; min-height: 86px; background: #0f0b07; color: var(--ink-dim);
  border: 1px solid var(--line); border-radius: var(--r-sm); padding: 10px;
  font: 12px/1.4 ui-monospace, Menlo, monospace; resize: vertical;
}

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

/* ---------- Kibyra pixel-art UI (trial: Shop screen + gold counter) ----------
   Art: "UI Fonts & Dragon HUDs Pack" by Kibyra -- https://kibyra.itch.io
   Pixel art is only shown at whole-number zoom (1x or 2x CSS px per art px) so
   every art pixel lands on whole device pixels; anything else smears it. */
.px { display: inline-flex; vertical-align: middle; }
.px > i {
  display: block; height: 100%;
  background: url(../assets/ui/glyphs.png) no-repeat;
  image-rendering: pixelated;
}
.gold-px { display: inline-flex; align-self: center; }
.hoard { align-items: center; }

.shop-crest { margin: 22px 0 4px; display: flex; justify-content: center; }
.shop-crest img { display: block; image-rendering: pixelated; }

.shop-item {
  padding: 14px 16px 12px;
}
.shop-item h3 { font-size: 15px; color: var(--gold); }
.shop-item p { margin: 3px 0 0; font-size: 13px; color: var(--ink-dim); }
.shop-item .lv { font-size: 12px; color: var(--accent); margin-top: 4px; }
.buy-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-top: 10px;
}
.price { display: inline-flex; align-items: center; gap: 8px; }
.price .coin { width: 20px; height: 20px; }
.price .coin.pile { width: 28px; height: 28px; }
.buy-btn {
  width: 188px; height: 62px; flex: none;
  background: url(../assets/ui/buy-button.png) center / 188px 62px no-repeat;
  image-rendering: pixelated;
}
.buy-btn:active { transform: translateY(2px); }
.buy-btn[disabled] { filter: grayscale(1) brightness(.55); pointer-events: none; }
.shop-item:has(.buy-btn[disabled]) .price { opacity: .5; }

/* Framed need bars. The frame is drawn over the colour fill, so its edges hide
   the fill's square ends. bar.png is 176x32; bar-short.png is the same art with
   40 px of plain tube cut from the middle, so it fits a card on a 360 px phone. */
.fbar { position: relative; width: 176px; height: 32px; margin: 6px auto 0; flex: none; }
.fbar::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: url(../assets/ui/bar.png) no-repeat;
  image-rendering: pixelated;
}
.fbar.short { width: 136px; }
.fbar.short::after { background-image: url(../assets/ui/bar-short.png); }
.fbar-track {
  position: absolute; left: 9px; top: 10px; width: 153px; height: 14px;
  display: flex; gap: 2px; background: var(--deep);
}
.fbar.short .fbar-track { width: 113px; }
.seg { flex: 1; overflow: hidden; background: #24190f; }
.seg > i {
  display: block; height: 100%; transition: width .3s ease;
  box-shadow: inset 0 3px 0 rgba(255,255,255,.22), inset 0 -3px 0 rgba(0,0,0,.28);
}
.seg.hunger > i { background-color: var(--ember); }
.seg.clean  > i { background-color: #375bb2; }
.seg.joy    > i { background-color: #419d40; }

.need-rows { display: grid; gap: 2px; margin-top: 10px; }
.need-row { display: flex; align-items: center; gap: 10px; }
.need-row > span { font-size: 13px; color: var(--ink-dim); min-width: 44px; }
.need-row .fbar { margin: 0; }

/* Portrait ring: ring.png (58x60) at 2x, framing just the dragon's head. Its
   hole is a circle of radius 19 art px centred at (31, 32); the hole div is a
   little larger so the ring overlaps its edge and no seam shows. */
.hero .art.ring { flex: 0 0 116px; width: 116px; height: 120px; position: relative; }
.hero .art.ring::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: url(../assets/ui/ring.png) 0 0 / 116px 120px no-repeat;
  image-rendering: pixelated;
}
.ring-hole {
  position: absolute; left: 22px; top: 24px; width: 80px; height: 80px;
  border-radius: 50%; overflow: hidden;
  background: radial-gradient(circle at 50% 45%, #4a2416, #160a06 75%);
  display: flex; align-items: center; justify-content: center;
}
.ring-hole svg { max-width: 100%; height: auto; }

.sell-row { margin-top: 8px; }
.sell-btn {
  width: 188px; height: 62px; flex: none;
  background: url(../assets/ui/sell-button.png) center / 188px 62px no-repeat;
  image-rendering: pixelated;
}
.sell-btn:active { transform: translateY(2px); }
.sell-btn.arming { filter: drop-shadow(0 0 6px var(--bad)) saturate(1.3); }
.sell-confirm { margin: 6px 2px 0; font-size: 13px; color: var(--bad); text-align: right; }

/* ---------- expansion: quests, codex, ancestors, legacy ---------- */
.card.away .portrait { opacity: .4; filter: saturate(.6); }
.card.away .rate { color: var(--ink-dim); }
.away-note { margin: 12px 0 0; font-size: 13.5px; color: var(--accent); }
.maxed { margin: 10px 0 0; font-size: 13px; color: var(--good); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip.want { font-size: 12.5px; padding: 5px 10px; color: var(--ink); }
.job-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.job-head h3 { font-size: 15px; color: var(--gold); }
.job-head .price { flex: none; }
.btn.small { min-height: 36px; font-size: 13px; padding: 0 14px; flex: 0 0 auto !important; }

.pick-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pick-sub { color: var(--ink-faint); font-size: 10.5px; }
.pick.arming { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(233,193,65,.35); }
.pick.arming .pick-sub { color: var(--gold); }
.pick-sub.haul-low, .haul-note { color: var(--warn); }

.trip { display: flex; align-items: center; gap: 12px; }
.trip-faces { display: flex; flex: none; }
.trip-faces > * + * { margin-left: -14px; }
.region-head { margin: 18px 2px 6px; font-size: 14px; font-weight: 700; color: var(--gold);
  letter-spacing: .04em; text-transform: uppercase; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.region-head .hint { margin: 0; text-transform: none; letter-spacing: 0; font-weight: 400; }
.locked-region { border-style: dashed; }
.locked-region .emb { vertical-align: -3px; margin-right: 2px; opacity: .7; }
.chart-bar { height: 8px; border-radius: 4px; background: rgba(255,255,255,.06); border: 1px solid var(--line); overflow: hidden; }
.chart-bar span { display: block; height: 100%; background: var(--gold); }
.relic-line .emb { vertical-align: -3px; margin-right: 4px; }
.relic.got strong { color: #8ce6eb; }
.relic:not(.got) .emb { opacity: .4; filter: grayscale(1); }
.trip strong { font-size: 14.5px; }
.place .chip { flex: none; background: transparent; }

.codex-row + .codex-row { margin-top: 12px; }
.codex-label { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-faint); margin-bottom: 6px; }
.codex-label .done { color: var(--good); text-transform: none; letter-spacing: 0; }

.carry {
  width: 100%; min-height: var(--tap); padding: 0 10px;
  background: var(--bg-2); color: var(--ink); font: inherit;
  border: 1px solid var(--frame); border-radius: var(--r-sm);
}

/* ---------- the nursery and deeds (Phase 17a) ---------- */
.pantry { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; margin: 4px 2px 12px; font-size: 14px; }
.pantry-item b { color: var(--gold); }
.sheet-pantry { justify-content: flex-end; margin: 10px 2px 0; }
.errand-row { display: grid; grid-template-columns: 1fr; gap: 8px; }
.ways { display: grid; gap: 6px; margin-top: 8px; }
.way {
  display: grid; grid-template-columns: 82px 1fr; grid-template-rows: auto auto; column-gap: 8px; align-items: center;
  min-height: var(--tap); padding: 8px 10px; text-align: left; font: inherit; color: var(--ink); cursor: pointer;
  background: var(--bg-2); border: 1px solid var(--line); border-left: 4px solid var(--c, var(--line)); border-radius: var(--r-sm);
}
.way b { grid-row: 1 / 3; font-size: 14px; color: var(--c); }
.way span { font-size: 13px; }
.way small { font-size: 11.5px; color: var(--ink-faint); }
.way[disabled] { opacity: .4; pointer-events: none; }
.way-help { --c: #7fc98a; }
.way-bargain { --c: var(--gold); }
.way-terrorize { --c: #e0584a; }
.rep { margin-top: 4px; }
.rep-track { position: relative; height: 10px; border-radius: 5px;
  background: linear-gradient(90deg, #8a2a1f, #3a2a24 45%, #3a2a24 55%, #3f8a4c); border: 1px solid var(--line); }
.rep-track i { position: absolute; top: -4px; width: 4px; height: 16px; margin-left: -2px; border-radius: 2px; background: var(--ink); box-shadow: 0 0 6px var(--gold); }
.rep-ends { display: flex; justify-content: space-between; align-items: baseline; margin-top: 4px; font-size: 11px; color: var(--ink-faint); }
.rep-ends b { font-size: 14px; color: var(--gold); }
.trick span.hint { display: block; font-size: 12.5px; }
/* Spirits (Phase 24c): a called one glows its element's colour at the edge. */
.spirit { padding: 8px 0 10px; border-top: 1px solid var(--line); }
.spirit:first-of-type { border-top: 0; }
.spirit.here { box-shadow: inset 3px 0 0 var(--c); padding-left: 10px; }
.spirit .buy-row { margin-top: 0; align-items: flex-start; }
.spirit-act { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: none; }
.spirit select { margin-top: 4px; width: 100%; }
.spark-pick { margin-top: 8px; }
.station-pick { display: block; margin: 8px 0 0; }
.station-pick select { width: 100%; margin-top: 4px; }
/* Guild trials: three ways through, one row each. */
.trial h3 { color: var(--gold); }
.trial-way { padding: 10px 0; border-top: 1px solid var(--line); }
.trial-way .buy-row { margin-top: 6px; }

/* Chores (Phase 25): one row each, a bar of how much is undone. */
.chore { padding: 10px 0; border-top: 1px solid var(--line); }
.chore:first-child { border-top: 0; padding-top: 0; }
.chore .buy-row { margin-top: 8px; }
.chore-track i { background: linear-gradient(90deg, #8a6a3a, #b0583a); }

/* ---------- welcome back (Phase 16) ---------- */
.tabbar button { position: relative; }
.tabbar button[hidden] { display: none; }   /* not yet open (unlocks.js) */
.tabbar button.dot::after {
  content: ''; position: absolute; top: 5px; right: calc(50% - 17px);
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--ember); box-shadow: 0 0 6px var(--ember);
}
.welcome { border-color: var(--gold); }
.welcome-head { margin: 6px 0 8px; font-size: 16px; font-weight: 700; color: var(--ink); }
.welcome-head.mythic, .welcome-head.relic, .welcome-head.wyrm, .welcome-head.trophy { color: var(--gold); }
.welcome .trip-faces { margin: 0 0 8px; }
.welcome-gold { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 6px; }
.welcome-ess { display: flex; flex-wrap: wrap; gap: 4px; }
.waiting { display: grid; gap: 6px; }
.waiting-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  min-height: var(--tap); padding: 6px 10px; text-align: left; font: inherit; font-size: 13.5px;
  color: var(--ink); background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--r-sm); cursor: pointer;
}
.waiting-row b { flex: none; color: var(--gold); font-size: 12px; }

/* ---------- friends (Phase 15) ---------- */
.name-input {
  width: 100%; min-height: var(--tap); padding: 0 10px;
  background: var(--bg-2); color: var(--ink); font: inherit;
  border: 1px solid var(--frame); border-radius: var(--r-sm);
}
.stud-head { display: flex; gap: 12px; align-items: center; }
.stud-pic { width: 72px; flex: none; }
.stud-pic svg, .album-page svg, .received-pic svg { max-width: 100%; height: auto; display: block; margin: 0 auto; }
.album-set + .album-set { margin-top: 14px; }
.album-pages { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 6px; }
.album-page {
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 2px;
  min-height: 64px; padding: 6px 4px; text-align: center;
  border: 1px dashed color-mix(in srgb, var(--ink-faint) 60%, transparent); border-radius: var(--r-sm);
  font-size: 10.5px; color: var(--ink-faint); line-height: 1.2;
}
.album-page.filled { border: 1px solid var(--frame); background: var(--panel-2); color: var(--ink-dim); }
.album-page svg { width: 48px; }
.album-page small { color: var(--ink-faint); font-size: 10px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.album-page.filled small { color: var(--ink); }
.compare-row { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 6px; padding: 5px 0; font-size: 13.5px;
  border-bottom: 1px dotted color-mix(in srgb, var(--ink-dim) 30%, transparent); }
.compare-row > span:not(:first-child) { text-align: right; overflow-wrap: anywhere; }
.compare-row > span:first-child { color: var(--ink-dim); }
.compare-head { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-faint); }
.compare-row .win { color: var(--gold); font-weight: 700; }
.received-pic { width: 180px; margin: 0 auto; }
.received-pic.small { width: 96px; margin-bottom: 6px; }

/* ---------- arcana ---------- */
.ess-grid { gap: 8px; }
.ess-cell {
  display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 8px;
  padding: 8px 10px; border-radius: var(--r-sm); background: rgba(0,0,0,.22);
  border-left: 3px solid var(--c);
}
.ess-name { grid-column: 1 / -1; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--c); }
.ess-cell strong { font-size: 18px; font-variant-numeric: tabular-nums; }
.ess-cell .ess-cap { font-size: 12px; font-weight: 400; color: var(--ink-faint); }
.ess-cell small.falling { color: var(--warn); }
.ess-cell small { align-self: center; justify-self: end; font-size: 11.5px; color: var(--ink-dim); font-variant-numeric: tabular-nums; }

/* An essence amount: a small diamond in the element's colour, then the number. */
.ess { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; font-variant-numeric: tabular-nums; color: var(--ink); }
.ess::before { content: ''; flex: none; }
.ess::before, .ess-name::before {
  width: 14px; height: 14px; display: inline-block;
  background: url(../assets/ui/emblems.png) no-repeat;
  background-size: calc(14px * 9) 14px; image-rendering: pixelated;
  background-position: calc(var(--ei) * -14px) 0;
}
.ess-name::before { content: ''; vertical-align: -2px; margin-right: 5px; }
[data-e="F"] { --ei: 2; } [data-e="I"] { --ei: 3; } [data-e="S"] { --ei: 4; } [data-e="E"] { --ei: 5; }
/* The outer elements have no emblem in the pack yet: a diamond in their colour. */
:is(.ess, .ess-name):is([data-e="W"], [data-e="L"], [data-e="D"], [data-e="A"], [data-e="N"], [data-e="Z"])::before {
  background: var(--c); clip-path: polygon(50% 8%, 92% 50%, 50% 92%, 8% 50%);
}
.cost { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
.cost .dur { font-size: 12.5px; color: var(--ink-dim); }
.cost .dur::before { content: '⧗ '; }

.school-title { margin: 18px 2px 8px; font-size: 13px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.school-title small { font-weight: 400; letter-spacing: 0; text-transform: none; color: var(--ink-faint); }
.rite h3, .spell h3, .study h3 { font-size: 15px; color: var(--gold); }
.rite p { margin: 4px 0 0; font-size: 13px; color: var(--ink-dim); }
.rite .lv { font-size: 12px; color: var(--accent); margin-top: 4px; }
.rite .kind { flex: none; font-size: 11.5px; color: var(--ink-faint); font-variant-numeric: tabular-nums; }
.rite .needs { color: var(--warn); font-size: 12.5px; }
.rite .needs span { color: var(--ink-faint); }
.rite.locked { opacity: .62; }
.rite.locked h3 { display: flex; align-items: center; gap: 6px; }
.spell .chip { flex: none; background: transparent; }
.study-track { height: 6px; margin-top: 10px; border-radius: 3px; background: var(--deep); overflow: hidden; }
.study-track i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--ember), var(--gold)); transition: width .3s; }

.odds-row { display: grid; grid-template-columns: 72px 1fr; gap: 8px; font-size: 13px; }
.odds-row + .odds-row { margin-top: 8px; }
.odds-row .k { color: var(--ink-dim); }
.odds-row .v { display: flex; flex-wrap: wrap; gap: 4px 12px; }
.odd b { color: var(--gold); font-weight: 650; font-variant-numeric: tabular-nums; }

/* ---------- Kibyra icons ----------
   Two strips cut from "UI Fonts & Dragon HUDs Pack" by Kibyra (kibyra.itch.io):
   actions.png holds ten framed action icons (40x38 art each, cropped from their
   64px canvases), emblems.png ten 32px emblems (the last, the relic gem, drawn for Emberroost). --s sets the drawn width; each
   class picks its cell. */
.act, .emb {
  display: inline-block; flex: none; vertical-align: middle;
  width: var(--s); height: var(--s); image-rendering: pixelated;
  background-repeat: no-repeat; background-position: calc(var(--i) * var(--s) * -1) 0;
}
.act {
  --s: 40px; height: calc(var(--s) * 0.95);
  background-image: url(../assets/ui/actions.png); background-size: calc(var(--s) * 10) 100%;
}
.emb { --s: 16px; background-image: url(../assets/ui/emblems.png); background-size: calc(var(--s) * 10) var(--s); }
.act-close { --i: 0; } .act-confirm { --i: 1; } .act-cancel { --i: 2; } .act-options { --i: 3; }
.act-save { --i: 4; } .act-load { --i: 5; } .act-restart { --i: 6; } .act-map { --i: 7; }
.act-quest { --i: 8; } .act-continue { --i: 9; }
.emb-heart { --i: 0; } .emb-star { --i: 1; } .emb-fire { --i: 2; } .emb-frost { --i: 3; }
.emb-storm { --i: 4; } .emb-earth { --i: 5; } .emb-lock { --i: 6; } .emb-trophy { --i: 7; } .emb-bell { --i: 8; }
.emb-gem { --i: 9; }

/* An icon on its own is the whole button: no circle behind the framed art. */
.icon-btn.art-btn { background: none; border: none; display: grid; place-items: center; }
.icon-btn.art-btn:active { transform: translateY(1px); }
.sheet-close { position: absolute; top: 8px; right: 8px; width: 44px; height: 44px; }
.sheet-inner { position: relative; }
.sheet-inner .hero { padding-right: 40px; }   /* room for the close icon */
.btn .act { --s: 26px; margin-left: -6px; }
.btn.small .act { --s: 22px; margin-left: -4px; }
.stars { display: inline-flex; gap: 1px; vertical-align: -2px; margin-left: 6px; }
.title-icon { display: flex; align-items: center; gap: 8px; }
.job-head h3 { display: flex; align-items: center; gap: 6px; }
.maxed .act { --s: 20px; margin-right: 4px; vertical-align: -5px; }

/* ---------- the lair and the opening ---------- */
.build-title { font-size: 15px; color: var(--gold); }
.place.first-flight { border-color: var(--gold); box-shadow: inset 0 0 0 2px var(--deep), inset 0 0 0 3px var(--line), 0 0 12px rgba(233,193,65,.25); }

/* ---------- training and trophies ---------- */
.xp-track { height: 5px; margin: 6px 0 2px; }
.xp-track i { background: linear-gradient(90deg, #6a9a5b, var(--good)); }
.trophy { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; padding: 7px 0; }
.trophy + .trophy { border-top: 1px solid var(--line); }
.trophy-text { display: flex; flex-direction: column; min-width: 0; }
.trophy-text strong { font-size: 13.5px; }
.trophy-text span { font-size: 12px; color: var(--ink-dim); }
.trophy-side { font-size: 12.5px; color: var(--ink-faint); font-variant-numeric: tabular-nums; }
.trophy.got strong { color: var(--gold); }
.trophy.got .trophy-side { color: var(--good); }
.trophy:not(.got) .emb { opacity: .55; }
.trophy-all { margin-top: 10px; }
.trophy-all summary { cursor: pointer; font-size: 13px; color: var(--accent); padding: 6px 0; min-height: 32px; display: flex; align-items: center; }

/* ---------- automation ---------- */
.toggle { display: flex; align-items: center; gap: 10px; margin-top: 10px; font-size: 13px; color: var(--ink-dim); min-height: 32px; }
.toggle input { width: 20px; height: 20px; accent-color: var(--ember); flex: none; }
.lodge select + select { margin-top: 8px; }

/* Runes and the Sanctum */
.rune-chip { display: inline-flex; align-items: center; margin-left: 8px; font-size: 13px;
  color: var(--c); font-variant-numeric: tabular-nums; }
.rune-grid { gap: 8px; }
.rune-grid .btn { justify-content: space-between; }
.attune-row .btn-row { flex-wrap: wrap; }
.relic.awake strong { color: var(--gold); }
.relic.awake .emb { filter: drop-shadow(0 0 3px rgba(233,193,65,.8)); }
.awaken-row { display: flex !important; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 6px; color: var(--ink) !important; }

/* ---------- the star tree ---------- */
.star-branch { margin-bottom: 10px; }
.star-node { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); }
.star-branch .codex-label + .star-node { border-top: 0; }
.star-node.child { padding-left: 14px; }
.star-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; font-size: 13px; }
.star-text span { color: var(--ink-dim); font-size: 12.5px; }
.star-text em { color: var(--ink-faint); font-style: normal; }
.star-node.lit strong { color: var(--gold); }
.star-btn { min-width: 64px; min-height: 38px; padding: 6px 10px; }
.star-cost { font-size: 12px; color: var(--gold); min-width: 64px; text-align: center; }

/* ---------- events ---------- */
.events {
  display: flex; flex-direction: column; gap: 6px; margin: 4px 0 10px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: var(--r); background: var(--bg-2); font-size: 13px;
}
.events b { color: var(--gold); font-weight: 650; }
.events span { color: var(--ink-dim); }
.patron { border-color: var(--gold); }

/* ---------- the next-step card and the Great Work ---------- */
.step-card {
  display: flex; flex-direction: column; gap: 4px; width: 100%; margin: 0 0 10px; padding: 10px 12px;
  border: 1px dashed var(--frame); border-radius: var(--r); background: var(--bg-2);
  font: inherit; font-size: 13px; color: var(--ink); text-align: left;
}
.step-card.closed { cursor: pointer; min-height: var(--tap); justify-content: center; }
.step-card.open { border-style: solid; border-color: var(--gold); }
.step-k { color: var(--gold); font-weight: 650; }
.step-v { color: var(--ink-dim); }
.step-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.step-hide {
  background: none; border: 0; color: var(--ink-faint); font: inherit; font-size: 12px;
  padding: 6px 2px; min-height: 32px; cursor: pointer;
}
.step-link { color: var(--ink-faint); font-size: 11.5px; letter-spacing: .04em; text-transform: uppercase; }
.step-card ul { margin: 4px 0 0; padding-left: 18px; color: var(--ink-dim); }
.step-card li + li { margin-top: 4px; }
.step-tip { margin: 6px 0 0; padding: 6px 8px; border-radius: 6px; background: var(--bg); color: var(--ink); font-size: 12.5px; }
.step-or { margin-top: 8px; padding-top: 6px; border-top: 1px solid var(--line); color: var(--ink-faint); font-size: 11.5px; letter-spacing: .04em; text-transform: uppercase; }
.step-card .step-others { font-size: 12.5px; }
.step-others b { color: var(--ink); font-weight: 600; }

.lore-line { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 8px; }
.lore-chip {
  display: inline-flex; align-items: center; gap: 2px; margin-left: 4px; padding: 1px 6px;
  border: 1px solid #8a7ab0; border-radius: var(--r-sm); color: #d6c9f4; font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.sigil-chip { --c: var(--gold); }

.gw-step { display: grid; grid-template-columns: 18px 1fr; gap: 8px; align-items: start; padding: 7px 0; }
.gw-step + .gw-step { border-top: 1px solid var(--line); }
.gw-mark { color: var(--ink-faint); text-align: center; font-weight: 700; }
.gw-step.done .gw-mark, .gw-step.done strong { color: var(--good); }
.gw-step.here .gw-mark, .gw-step.here strong { color: var(--gold); }
.gw-step:not(.done):not(.here) strong { color: var(--ink-dim); }

/* ---------- the Workshop, the market, duties ---------- */
.favour-chip {
  display: inline-flex; align-items: center; gap: 2px; padding: 1px 7px;
  border: 1px solid #9c7a3c; border-radius: var(--r-sm); color: #f0d79a; font-size: 12.5px;
  font-variant-numeric: tabular-nums; text-transform: none; letter-spacing: 0;
}
.workshop .statline span:last-child { display: inline-flex; flex-wrap: wrap; justify-content: flex-end; gap: 2px; }
.ware .buy-row select { flex: 1; min-width: 0; margin-right: 10px; }
.duties select { width: 100%; }

/* ---------- guilds ---------- */
.guild.mine { border-color: var(--gold); }
.perks { margin: 8px 0 0; padding: 0; list-style: none; font-size: 12.5px; color: var(--ink-dim); }
.perks li { padding: 3px 0; }
.perks li b { color: var(--ink-faint); font-weight: 650; margin-right: 4px; }
.perks li.got { color: var(--ink); }
.perks li.got b { color: var(--good); }
.guild-ware { border-color: #9c7a3c; }
.guild-others > .panel { margin-top: 10px; }

/* ---------- Kibyra frames (derived crops; see assets/ui) ---------- */
/* The dialogue box, its title tab cut away, framing the omen banner and the
   next-step card. Sliced 1:1 so its dragon stays at its drawn size. */
.events, .step-card {
  border: solid transparent; border-width: 21px 18px 16px 42px; border-radius: 0;
  border-image: url(../assets/ui/dialog.png) 21 18 16 42 fill / 21px 18px 16px 42px stretch;
  background: none; image-rendering: pixelated;
  padding: 2px 6px 4px 2px;
}
.step-card.open { border-color: transparent; }
.step-card.closed { min-height: 0; }

/* The seven-slot shelf: the relic shelf and what the Workshop has to hand. */
.shelf {
  position: relative; width: 100%; max-width: 362px; aspect-ratio: 181 / 61; margin: 6px 0 10px;
  background: url(../assets/ui/slots.png) 0 0 / 100% 100% no-repeat; image-rendering: pixelated;
}
.shelf .shelf-slot {
  position: absolute; top: calc(26 / 61 * 100%); width: calc(15 / 181 * 100%); height: calc(15 / 61 * 100%);
  display: flex; align-items: center; justify-content: center;
}
.shelf .shelf-slot:nth-child(1) { left: calc(17 / 181 * 100%); }
.shelf .shelf-slot:nth-child(2) { left: calc(39 / 181 * 100%); }
.shelf .shelf-slot:nth-child(3) { left: calc(61 / 181 * 100%); }
.shelf .shelf-slot:nth-child(4) { left: calc(83 / 181 * 100%); }
.shelf .shelf-slot:nth-child(5) { left: calc(105 / 181 * 100%); }
.shelf .shelf-slot:nth-child(6) { left: calc(127 / 181 * 100%); }
.shelf .shelf-slot:nth-child(7) { left: calc(149 / 181 * 100%); }
.shelf .shelf-slot b { position: absolute; right: -2px; bottom: -4px; font-size: 10px; color: var(--gold); text-shadow: 0 1px 0 #000; }
.shelf .shelf-slot.awake .emb { filter: drop-shadow(0 0 3px rgba(233,193,65,.9)); }

/* The skill-tree frame as a crest over the star tree. */
.star-crest { display: flex; justify-content: center; margin: 18px 0 -4px; }
.star-crest img { width: 150px; height: auto; image-rendering: pixelated; }

/* A view of the world from Kibyra's title scene, over the expeditions. */
.vista {
  height: 120px; margin: 16px 0 4px; border-radius: var(--r);
  background: url(../assets/ui/vista.png) center 30% / cover no-repeat; image-rendering: pixelated;
  border: 2px solid var(--frame); box-shadow: inset 0 0 0 2px var(--deep), inset 0 -30px 40px rgba(11,6,5,.55);
}

/* The Hall of ancestors: each elder's head in a small dragon ring. */
.ancestor { display: flex; align-items: center; gap: 10px; }
.ancestor + .ancestor { margin-top: 6px; }
.ancestor .statline { flex: 1; }
.mini-ring { position: relative; flex: none; width: 58px; height: 60px; }
.mini-ring::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: url(../assets/ui/ring.png) 0 0 / 58px 60px no-repeat; image-rendering: pixelated;
}
.mini-ring .ring-hole { left: 11px; top: 12px; width: 40px; height: 40px; }
#foraging { scroll-margin-top: 72px; }
.keeper-title { margin: 10px 0 0; text-align: center; font-style: italic; color: var(--gold); font-size: 14px; }
.foot { margin-bottom: 8px; }
.foot-tribute b { color: #e07a5f; }
.foot-gift b, .foot-festival b { color: var(--good); }
.renown-liked { color: var(--good); }
.renown-feared { color: #e07a5f; }
.panel.festival { border-color: var(--good); }
.panel.knight .ways { margin-top: 4px; }

/* ---------- the section menu (sections.js) ---------- */
.sec-menu, .sec-side {
  position: fixed; z-index: 36; display: flex; flex-direction: column; gap: 2px; padding: 10px;
  background: var(--panel); border: 1px solid var(--frame); border-radius: var(--r-lg); box-shadow: var(--shadow);
}
.sec-menu { right: max(12px, calc(50vw - 328px)); min-width: 200px; max-height: 60vh; overflow-y: auto; }
.sec-side { top: 80px; left: calc(50vw - 340px - 210px); width: 190px; max-height: calc(100dvh - 120px); overflow-y: auto; }
.sec-menu b, .sec-side b { font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: var(--ember-2); padding: 4px 8px 8px; }
.sec-menu button, .sec-side button { text-align: left; padding: 10px; border-radius: var(--r-sm); color: var(--ink); }
.sec-menu button:active, .sec-side button:hover { background: var(--panel-2); }
/* The top bar's button is the menu's ☰, and hidden on a tab with no sections. */
#btn-menu { visibility: hidden; }
body.sec-burger #btn-menu { visibility: visible; }
#btn-menu .act { display: none; }
#btn-menu::before { content: '☰'; font-size: 26px; line-height: 1; color: var(--ember-2); }
.sec-side { display: none; }

/* ---------- at a desk (html.desk: a mouse that can hover, set in main.js) ---------- */
/* However narrow display scaling makes the window, a computer gets the section
   sidebar, not the phone's ☰. Under 1116px there is no margin beside the game
   for it, so the game moves right (--side-room) to make one. A phone, however
   wide, keeps ☰ and one column. */
@media (min-width: 600px) {
  html.desk .sec-side { display: flex; left: max(8px, calc(50vw - 340px - 210px)); }
  html.desk body.sec-burger #btn-menu { visibility: hidden; }
  html.desk .sec-menu { display: none; }
}
@media (min-width: 600px) and (max-width: 1115px) {
  html.desk { --side-room: 210px; }
  html.desk body:has(.sec-side) #app { padding-left: var(--side-room); max-width: calc(680px + var(--side-room)); }
  html.desk body:has(.sec-side) .tabbar, html.desk body:has(.sec-side) .toasts { left: calc(50% + var(--side-room) / 2); }
  html.desk body:has(.sec-side) .tabbar { max-width: min(680px, calc(100vw - var(--side-room))); }
  html.desk body:has(.sec-side) .sheet { padding-left: var(--side-room); }
}
/* Cards two to a row at a desk: the Lair's buildings, chores, the guild market,
   the keeper's supplies. Each a small card, its button along the bottom. */
@media (min-width: 600px) {
  html.desk .two-col, html.desk .chores { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: stretch; }
  html.desk .two-col { margin-bottom: 12px; }
  html.desk .two-col > .panel { margin: 0; display: flex; flex-direction: column; min-width: 0; }
  html.desk .two-col > .panel > p:not(.hint):not(.maxed):not(.needs) { flex: 1; }
  html.desk .two-col .buy-row { margin-top: auto; padding-top: 8px; flex-wrap: wrap; }
  html.desk .chores { gap: 14px 16px; }
  html.desk .chores .chore { padding: 0; border-top: 0; display: flex; flex-direction: column; min-width: 0; }
  html.desk .chores .chore > .hint { flex: 1; }
  html.desk .chores .chore .job-head { flex-direction: column; align-items: flex-start; gap: 2px; }
  html.desk .chores .chore .buy-row { flex-wrap: wrap; }
}

/* ---------- element rows (elRow in ui.js) ---------- */
/* Even lines, a short last one centred: each item takes 1/cols of the row. */
.el-row { --gap: 6px; display: flex; flex-wrap: wrap; justify-content: center; gap: var(--gap); }
.el-row.rune-grid, .el-row.ess-grid { --gap: 8px; }
.el-row + .el-row { margin-top: var(--gap); }
.el-row > *, .el-row > .btn.small { flex: 0 0 calc((100% - (var(--cn) - 1) * var(--gap)) / var(--cn)) !important; min-width: 0; box-sizing: border-box; }
@media (min-width: 520px) { .el-row > *, .el-row > .btn.small { flex-basis: calc((100% - (var(--cw) - 1) * var(--gap)) / var(--cw)) !important; } }
.el-row > .btn.small { padding: 0 8px; gap: 4px; }
.el-row .chip, .el-row .filter-chip { justify-content: center; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filter-els { margin: -4px 0 10px; }
.el-row.ess-grid .ess-cell small { justify-self: start; grid-column: 1 / -1; }

/* ---------- the keeper (Phase 21) ---------- */
.keeper-card { display: flex; gap: 14px; align-items: center; }
.keeper-badge { width: 60px; height: 60px; border-radius: 50%; display: grid; place-items: center; flex: none;
  font-size: 28px; background: radial-gradient(circle at 40% 35%, #5a2a14, #1e0c08); border: 2px solid var(--frame); }
.keeper-card h3 { color: var(--gold); }
.xp-bar { height: 8px; border-radius: 4px; background: var(--deep); border: 1px solid var(--line); overflow: hidden; margin: 6px 0 4px; }
.xp-bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--ember), var(--gold)); }
.points { color: var(--gold); }
.calling { margin-top: 10px; }
.calling .job-head h3 { display: flex; gap: 8px; align-items: center; }
.pips { display: flex; gap: 5px; margin: 8px 0 6px; }
.pip { flex: 1; height: 8px; border-radius: 3px; background: var(--deep); border: 1px solid var(--line); }
.pip.on { background: var(--ember-2); border-color: var(--ember-2); }
.ranks { margin: 4px 0 0; padding: 0; list-style: none; font-size: 14px; }
.ranks li { padding: 3px 0 3px 22px; position: relative; color: var(--ink-faint); }
.ranks li::before { content: '○'; position: absolute; left: 2px; }
.ranks li.have { color: var(--ink); }
.ranks li.have::before { content: '●'; color: var(--ember-2); }
.ranks li.next { color: var(--ink-dim); }
.ranks li.next::before { content: '◎'; color: var(--gold); }
.homecoming .trip { display: flex; gap: 10px; align-items: center; }
.homecoming .trip svg { flex: none; }
.welcomes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; margin-top: 8px; }
@media (min-width: 520px) { .welcomes { grid-template-columns: repeat(4, 1fr); } }
.welcomes button { text-align: left; padding: 8px 10px; border-radius: var(--r-sm); background: var(--panel-2);
  border: 1px solid var(--line); color: var(--ink); font-size: 14px; }
.welcomes button small { display: block; color: var(--ink-faint); font-size: 12px; }
.welcome-set { color: var(--good); font-size: 13px; margin: 8px 2px 0; }
.welcome-need { margin: 8px 2px 0; }
.welcomes button.wanted { border-color: rgba(217,164,63,.75); background: rgba(217,164,63,.14); }

/* The pantry under the gold, in the top bar. */
.top-left { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.supplies { display: flex; flex-wrap: wrap; gap: 2px 10px; font-size: 13px; color: var(--ink-dim); font-variant-numeric: tabular-nums; white-space: nowrap; }
.supplies b { color: var(--ink); font-weight: 650; }
.supplies small { color: var(--good); font-size: 12px; }
.supplies small.falling { color: var(--warn); }
/* Tap an item, Lore or essence for where it comes from (like the gold). */
.supplies [data-pantry], .lore-line, .ess-grid .ess-cell { cursor: pointer; }
.flow-list { margin: 6px 0 0; padding-left: 18px; font-size: 13px; color: var(--ink-dim); }
.flow-list li + li { margin-top: 3px; }

/* The world below (Phase 22): the map, its tap card, and a land's ladder */
.map-frame { position: relative; border-radius: 14px; overflow: hidden; border: 2px solid var(--frame); box-shadow: var(--shadow);
  background: #1d1838; user-select: none; touch-action: pan-y; margin-top: 8px; }
.map-frame.zoomed { touch-action: none; }
.map-frame svg { display: block; width: 100%; height: auto; }
.map-frame.grabbing svg, .map-frame.grabbing .hit { cursor: grabbing; }
.map-frame svg .lod { display: none; font-size: calc(var(--u, 1) * 12px / 0.64); stroke-width: calc(var(--u, 1) * 3px / 0.64); }
.map-frame svg .realm { font-size: calc(var(--u, 1) * 17px / 0.64); stroke-width: calc(var(--u, 1) * 4.5px / 0.64); }
.map-frame svg[data-near] .lod { display: inline; }
.map-frame svg text { pointer-events: none; }
.map-frame .decor { pointer-events: none; }
.map-frame .hit { cursor: pointer; }
.map-frame .hit:hover > g:nth-of-type(1) { filter: brightness(1.15) drop-shadow(0 0 3px #fff8ea); }
.map-frame .locked { filter: grayscale(1) brightness(.75); }
.map-frame .zoom-btns { position: absolute; right: 8px; top: 8px; display: flex; flex-direction: column; gap: 4px; }
.map-frame .zoom-btns button { width: 34px; height: 34px; border-radius: 8px; font-size: 18px; font-weight: 700;
  color: #fff8ea; background: rgba(43,29,20,.75); border: 1px solid var(--frame); }
.map-card { position: fixed; left: 50%; bottom: 0; transform: translateX(-50%); width: min(460px, 100%); box-sizing: border-box; z-index: 50;
  max-height: 70vh; overflow-y: auto; padding: 14px 14px 22px; border-radius: 16px 16px 0 0;
  background: var(--panel); border: 2px solid var(--frame); border-bottom: none; box-shadow: 0 -8px 30px rgba(0,0,0,.55);
  animation: rise .2s ease-out; }
.map-card h3 { margin: 0 40px 2px 0; }
.map-card .close { position: absolute; right: 10px; top: 8px; width: 34px; height: 34px; border-radius: 50%; font-size: 18px;
  color: var(--ink); background: var(--panel-2); border: 1px solid var(--line); }
.map-card .where { color: var(--ink-dim); font-size: 13px; margin: 0 40px 6px 0; }
.map-card .panel { margin: 8px 0 0; }
.land-chips { margin: 8px 0 0; }
.land-panel { margin-top: 10px; }
.ladder { display: grid; gap: 6px; margin-top: 10px; }
.ladder div { text-align: center; padding: 6px 4px; border-radius: 6px; background: var(--panel-2); border: 1px solid var(--line); font-size: 12px; color: var(--ink-dim); }
.ladder div.open { border-color: var(--good); color: var(--good); }
.ladder div b { display: block; font-size: 15px; color: var(--ink); }
.flash { box-shadow: 0 0 0 3px var(--gold); transition: box-shadow .4s; }
.map-controls { margin-top: 8px; padding: 10px 12px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--line); }
.map-controls ul { margin: 0; padding-left: 18px; font-size: 13px; color: var(--ink-dim); line-height: 1.45; }
.map-controls b { color: var(--ink); }
.map-controls .mk-bang { display: inline-grid; place-items: center; width: 15px; height: 15px; border-radius: 50%; font-size: 10px;
  font-weight: 900; color: #fff; background: #f08a4b; border: 1px solid #2b1d14; vertical-align: 1px; }
.map-controls .emb { vertical-align: -2px; }

/* The gold breakdown (Phase 23a): tap the hoard in the top bar. */
.topbar .hoard { cursor: pointer; }
.statline.sub { padding-left: 14px; font-size: 12px; opacity: 0.85; }

/* ---------- the Guide, in Records ---------- */
.guide-topic { border-top: 1px solid var(--line); }
.guide-topic:first-of-type { border-top: 0; }
.guide-topic summary { cursor: pointer; font-size: 14px; color: var(--ink); padding: 8px 0; min-height: 36px; display: flex; align-items: center; }
.guide-topic[open] summary { color: var(--gold); }
.guide-hearts { margin: 0 0 10px; padding-left: 18px; font-size: 13px; color: var(--ink-dim); line-height: 1.5; }

/* The Star Ward's second way: one element's scales and essence (Phase 26). */
.ward-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.ward-grid .btn { display: flex; justify-content: space-between; align-items: center; gap: 6px; }

/* Income Sources in Records: a button for each. */
.income-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }

/* A dragon's temperament on the line (Phase 27): the rest dim, its own lit, a target outlined. */
.temper-line { display: flex; flex-wrap: wrap; gap: 4px; }
.temper-line .chip { background: rgba(255,255,255,.04); border-color: var(--line); color: var(--ink-dim); }
.temper-line .chip.on { background: rgba(217,164,63,.22); border-color: rgba(217,164,63,.7); color: #f0cf8a; font-weight: 700; }
.temper-line .chip.aim { border-style: dashed; border-color: rgba(217,164,63,.7); color: var(--ink); }

/* The tutorial's chapter card (tutorial.js), in the next-step card's place. */
.step-card.tutorial ul.quests { list-style: none; padding: 0; margin: 6px 0 2px; color: var(--ink); }
.step-card.tutorial .quests li { display: flex; align-items: baseline; gap: 8px; }
.step-card.tutorial .quests li + li { margin-top: 5px; }
.step-card.tutorial .tick { width: 1em; color: var(--ink-faint); flex: none; }
.step-card.tutorial .done .tick { color: var(--gold); }
.step-card.tutorial .done .q-name { color: var(--ink-dim); text-decoration: line-through; }
.step-card.tutorial .q-where { margin-left: auto; color: var(--ink-faint); font-size: 11.5px; white-space: nowrap; }
.step-card.tutorial .q-reward { margin: 6px 0 0; font-size: 12px; }
.step-card.tutorial .btn { margin-top: 8px; width: 100%; }

/* The Arcanum's charges (Phase 29): pips, then Fill and Slot. */
.charge-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin-top: 8px; }
.charge-row .hint { margin: 0; }
.charge-pips { color: var(--gold); letter-spacing: 2px; font-size: 13px; }

/* Sync (Phase 35): the code in Settings, and the two saves side by side. */
.sync-code { margin: 0; font: 600 1.1rem/1.3 ui-monospace, monospace; letter-spacing: .06em; user-select: all; overflow-wrap: anywhere; }
.sync-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sync-pick > .panel { margin: 0; min-width: 0; padding: 10px; }
.sync-pick .statline { display: flex; flex-direction: column; align-items: flex-start; gap: 0; padding: 3px 0; }
.sync-pick .statline > span:first-child { font-size: .8em; opacity: .75; }
.sync-pick .statline > span:last-child { font-weight: 600; }
.sync-pick .statline::after { display: none; }
.sync-pick .statline + .statline { margin-top: 2px; }
.sync-steps { margin: 0; padding-left: 20px; font-size: 13px; color: var(--ink-dim); }
.sync-steps li + li { margin-top: 2px; }
