/* Kings By Dawn website, new design: the Wiki home, the three hubs (buildings, units, guides) and the
   Army Planner. Loaded after site.css on those five pages only; the live <main> markup is unchanged.
   Same visual language as the chosen home page (home.css): white sheets with an Aegean header band floating on the
   sea, white toy cards with a 4 px Ink lip, Aegean rails with a raised gold segment, round toy buttons, Vollkorn SC
   for names, Sofia Sans Condensed for numbers. Phones first (390 px, checked at 360), then 1440 px. */

/* ---------- states the Wiki script (wiki.js) toggles ---------- */
.is-filtered-out { display: none !important; }

/* small drawn glyphs used below (data: images are allowed by the site's CSP) */
.wiki-body {
  --chev: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23143F8F' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 5l7 7-7 7'/%3E%3C/svg%3E");
  --tick: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='3.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m4.5 12.5 4.5 4.5 10-10'/%3E%3C/svg%3E");
}

/* ---------- page hero: the game's dawn title scene at its own size, as on the home page and /updates/ ----------
   The scene is anchored on its horizon, which sits --sea-h above the hero's bottom edge. All the text stays in the
   sky, and --clear keeps the islands (which rise up to ~75 px above the horizon) in open sky below the last line,
   so no island outline ever runs behind the title, lead, search or note. The lead and the note sit on dark dawn
   plates (as on /updates/), so the scene is shown bright, without a darkening layer.
   Phones and tablets use the tall scene (1000 x 1500, horizon at 520), desktops the wide one (2400 x 1300, horizon at
   600). The two small drawings in --shores-tall and --shores-wide repeat the island slopes the scenes now draw themselves;
   they are redundant but harmless. */
:is(.page--wiki-home, .page--wiki-hub, .page--planner) .codex-hero {
  --sea-h: 54px;     /* sea showing below the horizon */
  --clear: 44px;     /* open sky between the last line and the horizon */
  padding-bottom: calc(var(--sea-h) + var(--clear));
}
:is(.page--wiki-home, .page--wiki-hub, .page--planner) .codex-hero::before {
  /* phones: the sun stands 250 px in from the right edge, so the temple island shows at the right and the headland
     stays off-screen to the left */
  --shores-tall: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1000 1500' width='1000' height='1500'%3E%3Cpath d='M126 487.82L120 488C77.5 489.3 46 510 22 544L120 544L120 542.5L126 542.5Z' fill='%234E4479'/%3E%3Cpath d='M128 487.76L120 488C77.5 489.3 46 510 22 544L120 544' fill='none' stroke='%231B2A4E' stroke-width='3' stroke-linejoin='round'/%3E%3Cpath d='M761.6 512.98L767.6 514C795.8 518.8 818 527 842 532L767.6 532L767.6 530.5L761.6 530.5Z' fill='%236B5C91'/%3E%3Cpath d='M759.6 512.64L767.6 514C795.8 518.8 818 527 842 532L767.6 532' fill='none' stroke='%231B2A4E' stroke-width='3' stroke-linejoin='round'/%3E%3C/svg%3E");
  --shores-wide: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 2400 1300' width='2400' height='1300'%3E%3Cpath d='M266 529.78L260 530C196.6 532.3 148 570 106 634L260 634L260 632.5L266 632.5Z' fill='%234E4479'/%3E%3Cpath d='M268 529.71L260 530C196.6 532.3 148 570 106 634L260 634' fill='none' stroke='%231B2A4E' stroke-width='3' stroke-linejoin='round'/%3E%3Cpath d='M1434 581.6L1440 582.9C1483.2 592.3 1515 608 1550 618L1440 618L1440 616.5L1434 616.5Z' fill='%236B5C91'/%3E%3Cpath d='M1432 581.17L1440 582.9C1483.2 592.3 1515 608 1550 618L1440 618' fill='none' stroke='%231B2A4E' stroke-width='3' stroke-linejoin='round'/%3E%3Cpath d='M2182 593.93L2188 595C2228.3 602.2 2260 616 2290 622L2188 622L2188 620.5L2182 620.5Z' fill='%236B5C91'/%3E%3Cpath d='M2180 593.57L2188 595C2228.3 602.2 2260 616 2290 622L2188 622' fill='none' stroke='%231B2A4E' stroke-width='3' stroke-linejoin='round'/%3E%3C/svg%3E");
  background: var(--shores-tall) repeat-x, url("../img/scene/dawn-tall.svg") repeat-x, var(--dawn-1);
  background-size: 1000px 1500px, 1000px 1500px;
  background-position: calc(100% + 250px) calc(100% + 980px - var(--sea-h)), calc(100% + 250px) calc(100% + 980px - var(--sea-h));
}
:is(.page--wiki-home, .page--wiki-hub, .page--planner) .codex-hero::after { display: none; }
/* the planner's hero ends with the lead's full-width plate: the temple needs its whole height in open sky */
.page--planner .codex-hero { --clear: 84px; }
:is(.page--wiki-home, .page--wiki-hub, .page--planner) .codex-hero .eyebrow {
  height: 30px; padding: 0 14px; margin: 0 0 10px;
  background: var(--dawn-pill); border: 2px solid rgba(255,231,168,.55); border-radius: var(--r-pill);
  color: var(--dawn-sun); font: 800 13px/1 var(--font-label); letter-spacing: .03em; text-transform: none;
}
:is(.page--wiki-home, .page--wiki-hub, .page--planner) .codex-hero .eyebrow::before { width: 8px; height: 8px; }
:is(.page--wiki-home, .page--wiki-hub, .page--planner) .codex-hero .lead {
  width: fit-content; max-width: 40rem; margin-top: 12px; padding: 11px 16px 12px;
  background: var(--dawn-pill); border-radius: 16px; color: #EEF0FF; text-shadow: none;
  font: 600 16px/1.5 var(--font-body);
}
:is(.page--wiki-home, .page--wiki-hub, .page--planner) .codex-hero .snapshot {
  max-width: 34rem; padding: 8px 14px; background: var(--dawn-pill); border-radius: 14px;
}
/* phones: the counts become a compact row of number pills, so the content starts sooner */
@media (max-width: 599px) {
  .codex-stats { display: flex; flex-wrap: wrap; gap: 8px; }
  .codex-stats > div { flex: 0 1 auto; min-height: 42px; gap: 8px; padding: 4px 14px 4px 4px; }
  .codex-stats strong { min-width: 34px; height: 30px; padding: 0 7px; font-size: 17px; }
  .codex-stats span { font-size: 13px; }
}

/* ---------- a white toy button for "see all" links (the home page's secondary buttons) ---------- */
.page--wiki-home .text-link {
  display: inline-flex; align-items: center; gap: 8px; min-height: 46px; padding: 0 14px 0 18px; margin-bottom: 4px;
  background: linear-gradient(180deg, #FFFFFF, #E3EEF9); color: var(--aegean-shade);
  border: 3px solid var(--ink); border-radius: var(--r-btn);
  box-shadow: inset 0 3px 0 var(--highlight), inset 0 -4px 0 var(--paper-line), 0 4px 0 var(--ink);
  font: 800 16px/1.1 var(--font-label); text-decoration: none; white-space: nowrap;
  transition: transform .08s ease, box-shadow .08s ease;
}
.page--wiki-home .text-link:hover { text-decoration: none; }
.page--wiki-home .text-link:active { transform: translateY(3px); box-shadow: inset 0 3px 0 var(--highlight), inset 0 -2px 0 var(--paper-line), 0 1px 0 var(--ink); }
.page--wiki-home .text-link .arrow { display: grid; place-items: center; }
.page--wiki-home .text-link .arrow svg { width: 18px; height: 18px; stroke-width: 2.8; }
@media (hover: hover) { .page--wiki-home .text-link:hover { background: linear-gradient(180deg, #FFFFFF, #D9E7F6); } }

/* =====================================================================================================
   WIKI HOME
   ===================================================================================================== */

/* sheets on the sea: the section head becomes the Aegean header band */
.page--wiki-home .codex-section__head {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; min-height: 70px;
  margin: -18px -16px 18px; padding: 12px 14px;
  background: var(--aegean); border-bottom: 3px solid var(--ink); border-radius: 19px 19px 0 0; color: var(--on-head);
}
.page--wiki-home .codex-section__head > div { min-width: 0; flex: 1 1 220px; }
.page--wiki-home .codex-section__head h2 { padding: 2px 2px 4px; color: #fff; text-shadow: var(--ts-title); font: 900 26px/1.05 var(--font-display); letter-spacing: .01em; }
.page--wiki-home .codex-section__head p { margin-top: 1px; color: var(--on-head-2); font: 700 14px/1.3 var(--font-label); }

/* chapter sections float on the open sea: a name plate, then one sheet per chapter (the home page's legends) */
.page--wiki-home .codex-section:has(> .chapter-grid) { background: none; border: 0; box-shadow: none; padding: 0; margin-bottom: 34px; }
.page--wiki-home .codex-section:has(> .chapter-grid) > .codex-section__head {
  flex-direction: column; justify-content: center; text-align: center; gap: 10px;
  width: fit-content; max-width: 100%; margin: 4px auto 22px; padding: 14px 20px 14px;
  background: var(--paper); color: var(--ink); border: 3px solid var(--paper-line); border-radius: var(--r-panel);
  box-shadow: 0 4px 0 var(--shadow);
}
.page--wiki-home .codex-section:has(> .chapter-grid) > .codex-section__head > div { flex: none; }
.page--wiki-home .codex-section:has(> .chapter-grid) > .codex-section__head h2 { padding: 0; color: var(--ink); text-shadow: none; font-size: 30px; }
.page--wiki-home .codex-section:has(> .chapter-grid) > .codex-section__head p { margin-top: 6px; color: var(--ink-2); font: 600 15px/1.35 var(--font-label); }

/* "New to the kingdom?": three first-step rows (the home page's link rows) */
.start-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.start-card {
  display: grid; grid-template-columns: 60px minmax(0, 1fr); align-items: center; gap: 14px;
  min-height: 84px; padding: 10px 14px 10px 10px; margin-bottom: 4px;
  background: var(--paper); color: var(--ink); text-decoration: none;
  border: 3px solid var(--ink); border-radius: var(--r-btn);
  box-shadow: inset 0 -4px 0 var(--paper-line), 0 4px 0 var(--ink);
  transition: transform .08s ease, box-shadow .08s ease;
}
.start-card::before {
  content: ""; width: 60px; height: 60px; border-radius: var(--r-thumb);
  background: var(--paper-2) var(--icon, none) 50% 50% / 46px 46px no-repeat;
}
.start-card > img { display: none; }  /* the old painted art; the game's own icons are drawn instead */
.start-card[href="guides/city/"] { --icon: url("../icons/game/village.svg"); }
.start-card[href="guides/resources/"] { --icon: url("../icons/game/wood.svg"); }
.start-card[href="guides/training/"] { --icon: url("../icons/game/army.svg"); }
.start-card > div { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; min-width: 0; }
.start-card .num {
  display: inline-grid; place-items: center; min-width: 32px; height: 22px; padding: 0 7px;
  background: var(--role-chip); border: 2px solid var(--role-chip-line); border-radius: var(--r-pill);
  color: var(--ink); font-size: 13px; line-height: 1;
}
.start-card strong { font: 900 21px/1.1 var(--font-display); letter-spacing: .01em; }
.start-card small { color: var(--ink-2); font: 700 14px/1.35 var(--font-label); }
.start-card:active { transform: translateY(3px); box-shadow: inset 0 -2px 0 var(--paper-line), 0 1px 0 var(--ink); }
@media (hover: hover) { .start-card:hover { background: #F7FAFD; } }

/* "What changed": the rule changes as ticked rows, then the topic chips */
.latest { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; }
/* its title is the sheet's Aegean header band, like every other sheet here; the small "What changed" label above it
   only repeated the title, so it is hidden */
#latest .latest > div > .eyebrow { display: none; }
#latest .latest > div > h2 {
  display: flex; align-items: center; min-height: 70px; margin: -18px -16px 18px; padding: 14px 16px 16px;
  background: var(--aegean); border-bottom: 3px solid var(--ink); border-radius: 19px 19px 0 0;
  color: #fff; text-shadow: var(--ts-title); font: 900 26px/1.05 var(--font-display); letter-spacing: .01em; text-wrap: balance;
}
.latest p:not(.eyebrow) { color: var(--ink-2); font-size: 16px; line-height: 1.5; }
.latest .stack { display: grid; gap: 8px; margin: 16px 0 12px !important; padding: 0 !important; }
.latest .stack > li {
  position: relative; padding: 10px 12px 11px 46px;
  background: var(--paper); border: 2px solid var(--paper-line); border-radius: var(--r-card);
}
.latest .stack > li::before {
  content: ""; position: absolute; left: 11px; top: 11px; width: 24px; height: 24px; border-radius: 50%;
  background: var(--olive) var(--tick) 50% 50% / 14px no-repeat; border: 2px solid var(--ink);
}
.latest .stack strong { display: block; font: 800 16px/1.3 var(--font-label); color: var(--ink); }
.latest .stack .muted {
  display: inline-block; margin-top: 6px; padding: 2px 10px; border-radius: var(--r-pill);
  background: var(--paper-2); border: 2px solid var(--paper-line); color: var(--ink-2); font: 800 12px/1.4 var(--font-label);
}
.latest small { display: block; color: var(--ink-3); font: 700 13px/1.45 var(--font-label); }
.latest .links { display: flex; flex-wrap: wrap; align-content: flex-start; gap: 10px 8px; }
.latest .links .chip { min-height: 44px; font-size: 15px; }

/* chapters: a white sheet with an Aegean band, art on a tray, then the pages as tappable rows */
.chapter-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; }
.chapter {
  display: flex; flex-direction: column; min-width: 0; overflow: hidden;
  background: var(--paper); color: var(--ink);
  border: 3px solid var(--ink); border-radius: var(--r-panel); box-shadow: var(--sh-float); --focus: #167D8C;
}
.chapter__head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 60px; padding: 10px 14px 10px 16px;
  background: var(--aegean); border-bottom: 3px solid var(--ink);
}
.chapter__head h3 { padding: 2px 2px 4px; color: #fff; text-shadow: var(--ts-title); font: 900 24px/1.05 var(--font-display); letter-spacing: .01em; }
.chapter__count {
  display: inline-grid; place-items: center; flex: none; min-width: 34px; height: 30px; padding: 0 8px;
  background: var(--paper); color: var(--ink); border: 2.5px solid var(--ink); border-radius: var(--r-pill);
  box-shadow: inset 0 -3px 0 var(--paper-line);
  font: 800 17px/1 var(--font-num); font-variant-numeric: tabular-nums lining-nums;
}
.chapter__blurb { margin: 14px 16px 0; color: var(--ink-2); font: 600 15px/1.45 var(--font-label); }
.chapter__art {
  display: flex; justify-content: center; align-items: flex-end; gap: 2px;
  margin: 14px 14px 0; padding: 10px 8px 8px; border-radius: var(--r-card); background: var(--thumb-bg);
}
.chapter__art img { flex: 0 1 60px; min-width: 0; width: 60px; height: 56px; object-fit: contain; object-position: 50% 100%; }
/* buildings stand on a strip of grass */
.page--wiki-home section[aria-labelledby="b-title"] .chapter__art {
  padding-bottom: 6px;
  background: linear-gradient(180deg, var(--thumb-bg) 0 66%, var(--grass) 66% calc(100% - 6px), var(--grass-edge) calc(100% - 6px));
}
.page--wiki-home section[aria-labelledby="b-title"] .chapter__art img { height: 60px; }
.page--wiki-home section[aria-labelledby="u-title"] .chapter__art { gap: 6px; }
.page--wiki-home section[aria-labelledby="u-title"] .chapter__art img { flex-basis: 54px; width: 54px; height: 54px; }
.chapter__list { padding: 6px 14px 10px 16px; }
.chapter__list a {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 50px; padding: 6px 0;
  color: var(--ink); font: 800 16px/1.25 var(--font-label); text-decoration: none;
}
.chapter__list li + li a { border-top: 1.5px dashed var(--paper-line); }
.chapter__list a::after { content: ""; width: 22px; height: 22px; flex: none; background: var(--chev) 50% 50% / 20px no-repeat; }
.chapter__list a:hover { color: var(--aegean-shade); }
.chapter__list a:active { color: var(--aegean-shade); background: var(--paper-2); }
/* buildings and units: the names as round toy chips (the home page's muster roll) */
.page--wiki-home section[aria-labelledby="b-title"] .chapter__list,
.page--wiki-home section[aria-labelledby="u-title"] .chapter__list { display: flex; flex-wrap: wrap; gap: 10px 8px; padding: 14px 14px 16px; }
.page--wiki-home section[aria-labelledby="b-title"] .chapter__list a,
.page--wiki-home section[aria-labelledby="u-title"] .chapter__list a {
  min-height: 44px; padding: 0 15px; margin-bottom: 3px;
  background: var(--paper); color: var(--aegean-shade); border: 2.5px solid var(--ink); border-radius: var(--r-pill);
  box-shadow: inset 0 -3px 0 var(--paper-line), 0 3px 0 var(--ink);
  font: 800 15px/1.1 var(--font-label);
}
.page--wiki-home section[aria-labelledby="b-title"] .chapter__list a::after,
.page--wiki-home section[aria-labelledby="u-title"] .chapter__list a::after { display: none; }
.page--wiki-home section[aria-labelledby="b-title"] .chapter__list a:active,
.page--wiki-home section[aria-labelledby="u-title"] .chapter__list a:active { transform: translateY(2px); box-shadow: inset 0 -2px 0 var(--paper-line), 0 1px 0 var(--ink); background: var(--paper); }
@media (hover: hover) {
  .page--wiki-home section[aria-labelledby="b-title"] .chapter__list a:hover,
  .page--wiki-home section[aria-labelledby="u-title"] .chapter__list a:hover { background: #F2F7FD; }
}

/* =====================================================================================================
   HUBS: buildings, units, guides
   ===================================================================================================== */

/* the hub's content floats on the sea: a filter rail, then one sheet per district / branch / chapter */
.page--wiki-hub .codex-section { background: none; border: 0; box-shadow: none; padding: 0; margin-bottom: 0; }

/* the filter and view rails (the game's tabs: an Aegean rail with a raised gold segment) */
.page--wiki-hub .toolbar { align-items: flex-start; gap: 14px 18px; margin: 0 0 22px; }
.page--wiki-hub .toolbar .chips, .view-switch {
  display: flex; flex-wrap: wrap; gap: 4px; padding: 4px;
  background: var(--aegean-shade); border: 3px solid var(--ink); border-radius: 22px; box-shadow: 0 4px 0 var(--ink);
}
.page--wiki-hub .toolbar .chips { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); width: 100%; }
.page--wiki-hub .toolbar .chips .chip, .view-switch button {
  flex: 1 0 auto; justify-content: center; min-height: 44px; margin: 0; padding: 0 12px;
  background: transparent; color: #fff; border: 2.5px solid transparent; border-radius: 16px; box-shadow: none;
  font: 800 15px/1 var(--font-label); white-space: nowrap; cursor: pointer;
}
.page--wiki-hub .toolbar .chips .chip[aria-pressed="true"], .view-switch button[aria-pressed="true"] {
  background: linear-gradient(180deg, var(--gold-lit), var(--gold)); color: var(--ink); border-color: var(--ink);
  box-shadow: inset 0 -3px 0 rgba(217,144,26,.6);
}
.page--wiki-hub .toolbar .chips .chip:active, .view-switch button:active { transform: none; box-shadow: none; }
.page--wiki-hub .toolbar .chips .chip[aria-pressed="true"]:active, .view-switch button[aria-pressed="true"]:active { box-shadow: inset 0 -3px 0 rgba(217,144,26,.6); }
.page--wiki-hub .toolbar .chips .chip:focus-visible, .view-switch button:focus-visible { outline: 3px solid #fff; outline-offset: 1px; }
@media (hover: hover) {
  .page--wiki-hub .toolbar .chips .chip:not([aria-pressed="true"]):hover, .view-switch button:not([aria-pressed="true"]):hover { background: rgba(255,255,255,.14); }
}
.page--wiki-hub .toolbar .chips .chip { padding: 0 6px; }
.view-switch { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; }

/* a district / branch / chapter: white sheet, Aegean band */
.tile-group {
  margin-bottom: 22px; overflow: hidden;
  background: var(--paper); color: var(--ink);
  border: 3px solid var(--ink); border-radius: var(--r-panel); box-shadow: var(--sh-float); --focus: #167D8C;
}
.tile-group > h2 {
  display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 10px; min-height: 60px; padding: 12px 16px 12px;
  background: var(--aegean); border-bottom: 3px solid var(--ink);
  color: #fff; text-shadow: var(--ts-title); font: 900 26px/1.05 var(--font-display); letter-spacing: .01em;
}
.tile-group > h2 .count { flex-basis: 100%; margin-top: 4px; color: var(--on-head-2); text-shadow: none; font: 700 14px/1.3 var(--font-label); letter-spacing: 0; }
.tile-group > h2 .dash { display: none; }
.tile-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 10px; padding: 14px 12px 16px; }

/* building and unit tiles: white toy cards with an Ink lip, the art on top */
.tile {
  position: relative; display: flex; flex-direction: column; min-width: 0; height: calc(100% - 4px); margin-bottom: 4px; overflow: hidden;
  background: var(--paper); color: var(--ink); text-decoration: none;
  border: 3px solid var(--ink); border-radius: var(--r-btn);
  box-shadow: inset 0 -4px 0 var(--paper-line), 0 4px 0 var(--ink);
  transition: transform .08s ease, box-shadow .08s ease;
}
.tile:active { transform: translateY(3px); box-shadow: inset 0 -2px 0 var(--paper-line), 0 1px 0 var(--ink); }
@media (hover: hover) { .tile:hover { background: #F7FAFD; } .tile:hover .tile__title { color: var(--aegean-shade); } }
.tile__media { position: relative; display: grid; place-items: center; aspect-ratio: 4 / 3; background: var(--thumb-bg); border-bottom: 2.5px solid var(--ink); overflow: hidden; }
.tile__media img { position: relative; width: 86%; height: 86%; object-fit: contain; }
/* a building stands on its grass plot */
.tile--sprite .tile__media::before {
  content: ""; position: absolute; left: 50%; bottom: 9%; width: 84%; height: 30%; transform: translateX(-50%);
  border-radius: 50%; background: var(--grass); box-shadow: 0 5px 0 var(--grass-edge);
}
.tile--sprite .tile__media img { object-position: 50% 82%; }
/* a unit portrait on the parade ground */
.tile--portrait .tile__media { background: var(--sand-lit); }
.tile--portrait .tile__media img { width: auto; height: 80%; max-width: 86%; aspect-ratio: 1; }
.tile__body { display: flex; flex-direction: column; gap: 3px; flex: 1; padding: 9px 10px 13px; }
.tile__kicker { color: var(--ink-3); font: 800 12px/1.25 var(--font-label); letter-spacing: .02em; }
.tile__title { font: 900 16px/1.12 var(--font-display); letter-spacing: 0; color: var(--ink); overflow-wrap: break-word; hyphens: manual; }
.tile__text { display: none; color: var(--ink-2); font: 600 14px/1.42 var(--font-label); }
.wiki-hub--buildings .tile__kicker { display: none; }

/* guides: rows with the game's icons (the home page's link rows) */
.tile-grid--wide { grid-template-columns: minmax(0, 1fr); gap: 12px; }
.tile-grid--wide .tile {
  flex-direction: row; align-items: center; gap: 12px; min-height: 78px; padding: 10px 10px 12px 10px;
}
.tile-grid--wide .tile__media {
  flex: none; width: 56px; height: 56px; aspect-ratio: auto; border: 0; border-radius: var(--r-thumb);
  background: var(--paper-2) var(--icon, none) 50% 50% / 46px 46px no-repeat;
}
/* phones and tablets: the game's own icons keep the 22 rows short; desktops show each guide's own banner (below) */
.tile-grid--wide .tile__media img { display: none; }
.tile-grid--wide .tile__body { padding: 0; gap: 2px; }
.tile-grid--wide .tile__kicker { display: none; }
.tile-grid--wide .tile__title { font: 800 17px/1.22 var(--font-label); letter-spacing: 0; overflow-wrap: normal; }
.tile-grid--wide .tile__text {
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
  color: var(--ink-2); font: 600 14px/1.4 var(--font-label);
}
.tile-grid--wide .tile::after { content: ""; width: 22px; height: 22px; flex: none; background: var(--chev) 50% 50% / 20px no-repeat; }
.tile-grid--wide .tile[href="city/"] { --icon: url("../icons/game/village.svg"); }
.tile-grid--wide .tile[href="resources/"] { --icon: url("../icons/game/wood.svg"); }
.tile-grid--wide .tile[href="construction/"] { --icon: url("../icons/game/stone.svg"); }
.tile-grid--wide .tile[href="starter-quests/"] { --icon: url("../icons/game/quests.svg"); }
.tile-grid--wide .tile[href="new-player-protection/"] { --icon: url("../img/buildings/walls-128.webp"); }
.tile-grid--wide .tile[href="training/"] { --icon: url("../icons/game/army.svg"); }
.tile-grid--wide .tile[href="research/"] { --icon: url("../icons/game/research.svg"); }
.tile-grid--wide .tile[href="improvements/"] { --icon: url("../icons/game/metal.svg"); }
.tile-grid--wide .tile[href="combat/"] { --icon: url("../img/units/swordsman.svg"); }
.tile-grid--wide .tile[href="scouting/"] { --icon: url("../img/units/spy-scout.svg"); }
.tile-grid--wide .tile[href="stamina/"] { --icon: url("../icons/game/hourglass.svg"); }
.tile-grid--wide .tile[href="world-trade/"] { --icon: url("../icons/game/world.svg"); }
.tile-grid--wide .tile[href="transfers/"] { --icon: url("../icons/game/crate.svg"); }
.tile-grid--wide .tile[href="alliances/"] { --icon: url("../icons/game/alliance.svg"); }
.tile-grid--wide .tile[href="political-power/"] { --icon: url("../icons/game/trophy.svg"); }
.tile-grid--wide .tile[href="barbarians/"] { --icon: url("../img/scene/barbarian-camp.svg"); }
.tile-grid--wide .tile[href="pirates/"] { --icon: url("../img/world/pirate-camp.webp"); }
.tile-grid--wide .tile[href="kraken/"] { --icon: url("../img/world/kraken-active.webp"); }
.tile-grid--wide .tile[href="cyclops/"] { --icon: url("../img/world/cyclopes-island-active.webp"); }
.tile-grid--wide .tile[href="rewards/"] { --icon: url("../icons/game/events.svg"); }
.tile-grid--wide .tile[href="shop-speedups/"] { --icon: url("../icons/game/gems.svg"); }
.tile-grid--wide .tile[href="monuments-vip/"] { --icon: url("../icons/game/island.svg"); }

/* "At a glance" (buildings): the title, the note and the table drawn as one sheet with an Aegean band */
.wiki-hub--buildings .codex-section > h2.h3 {
  margin: 34px 0 0 !important; padding: 14px 16px 15px;
  background: var(--aegean); border: 3px solid var(--ink); border-radius: var(--r-panel) var(--r-panel) 0 0;
  color: #fff; text-shadow: var(--ts-title); font: 900 26px/1.05 var(--font-display);
}
.wiki-hub--buildings .codex-section > h2.h3 + p.muted {
  margin: 0; padding: 14px 16px; background: var(--paper); border-inline: 3px solid var(--ink);
  color: var(--ink-2); font: 600 15px/1.45 var(--font-label);
}
.wiki-hub--buildings .codex-section > p.muted + .table-wrap {
  margin: 0; border-top: 0; border-radius: 0 0 var(--r-panel) var(--r-panel); box-shadow: var(--sh-float);
}

/* units: the compare-table view, as a sheet */
.wiki-hub--units [data-view-panel="table"] {
  overflow: hidden; background: var(--paper); color: var(--ink);
  border: 3px solid var(--ink); border-radius: var(--r-panel); box-shadow: var(--sh-float); --focus: #167D8C;
}
.wiki-hub--units [data-view-panel="table"] > p.muted { padding: 14px 16px; color: var(--ink-2); font: 600 15px/1.45 var(--font-label); }
.wiki-hub--units [data-view-panel="table"] > .table-wrap { margin: 0; border: 0; border-top: 3px solid var(--ink); border-radius: 0; }
.wiki-hub--units .data-table td:nth-child(3) { min-width: 8.5rem; }
.wiki-hub--units .data-table td:nth-child(n+4):nth-child(-n+6) { min-width: 7.5rem; }
.wiki-hub--units .data-table td:nth-child(7) { min-width: 13rem; }
.wiki-hub--units .data-table td:nth-child(10) { min-width: 14rem; }
.wiki-hub--units .codex-section > .callout { margin: 26px 0 0 !important; }

/* tables: a unit or building with its picture, and the stat bars */
.data-table .unit-cell { display: flex; align-items: center; gap: 10px; min-width: 0; }
.data-table .unit-cell img { width: 38px; height: 38px; flex: none; object-fit: contain; }
.data-table .unit-cell a { display: inline-flex; align-items: center; min-height: 44px; color: var(--ink); font-weight: 800; text-decoration: none; }
.data-table .unit-cell a:hover { color: var(--link); text-decoration: underline; text-underline-offset: 3px; }
.data-table tbody th:has(.unit-cell) { white-space: normal; min-width: 150px; }
.wiki-hub--buildings .data-table td { min-width: 8.5rem; }
.wiki-hub--buildings .data-table td:nth-child(2) { min-width: 6.5rem; }
.wiki-hub--buildings .data-table td:nth-child(5) { min-width: 12rem; }
@media (max-width: 599px) {
  .data-table tbody th:has(.unit-cell) { min-width: 132px; padding-right: 8px; }
  .data-table .unit-cell { gap: 8px; }
  .data-table .unit-cell img { width: 32px; height: 32px; }
}
.data-table .bar { display: inline-grid; grid-template-columns: 46px auto; align-items: center; gap: 8px; justify-content: end; }
.data-table .bar i { position: relative; display: block; height: 12px; overflow: hidden; background: var(--track); border: 2px solid var(--ink); border-radius: var(--r-pill); }
.data-table .bar i::after { content: ""; position: absolute; inset: 0 auto 0 0; width: calc(var(--v, 0) * 100%); background: var(--aegean); }
.data-table .bar[style*="8b2b22"] i::after { background: var(--olive); }      /* health */
.data-table .bar[style*="50606c"] i::after { background: var(--aegean-lit); } /* armor */
.data-table .bar[style*="a86a1f"] i::after { background: var(--gold-shade); } /* damage */

/* =====================================================================================================
   ARMY PLANNER: a game screen (the army list, round toy steppers, the totals panel)
   ===================================================================================================== */
.page--planner .codex-section { background: none; border: 0; box-shadow: none; padding: 0; margin-bottom: 0; }
.planner { display: grid; grid-template-columns: minmax(0, 1fr); gap: 22px; align-items: start; --accent: var(--aegean); --border: var(--paper-line); }
.planner__units { display: grid; grid-template-columns: minmax(0, 1fr); gap: 22px; min-width: 0; }

/* presets and the facility level: a white panel */
.planner__units > .toolbar {
  display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; margin: 0 !important; padding: 14px 14px 16px;
  background: var(--paper); color: var(--ink); border: 3px solid var(--ink); border-radius: var(--r-panel); box-shadow: var(--sh-float);
  --focus: #167D8C;
}
.planner__units > .toolbar .chips { gap: 10px 8px; }
.planner__units > .toolbar button.chip { min-height: 44px; font-size: 15px; }
.planner__units > .toolbar label.chip {
  display: flex; flex-wrap: nowrap; gap: 12px !important; width: 100%; min-height: 56px; margin: 0; padding: 4px 8px 4px 14px;
  background: var(--paper-2); color: var(--ink); border: 2px solid var(--paper-line); border-radius: var(--r-btn); box-shadow: none;
  font: 800 15px/1.1 var(--font-label); cursor: default;
}
.planner__units > .toolbar label.chip:active { transform: none; box-shadow: none; }
.planner input[type="range"] {
  -webkit-appearance: none; appearance: none; flex: 1 1 auto; min-width: 0; width: auto !important; height: 44px; margin: 0;
  background: transparent; cursor: pointer;
}
.planner input[type="range"]:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 8px; }
.planner input[type="range"]::-webkit-slider-runnable-track { height: 14px; background: var(--track); border: 2.5px solid var(--ink); border-radius: var(--r-pill); }
.planner input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 30px; height: 30px; margin-top: -10.5px; border-radius: 50%;
  background: linear-gradient(180deg, var(--gold-lit), var(--gold)); border: 3px solid var(--ink); box-shadow: inset 0 -3px 0 rgba(217,144,26,.6), 0 2px 0 var(--ink);
}
.planner input[type="range"]::-moz-range-track { height: 9px; background: var(--track); border: 2.5px solid var(--ink); border-radius: var(--r-pill); }
.planner input[type="range"]::-moz-range-thumb {
  width: 24px; height: 24px; border-radius: 50%; background: var(--gold); border: 3px solid var(--ink); box-shadow: 0 2px 0 var(--ink);
}
.planner output[data-facility-out] {
  display: inline-grid; place-items: center; flex: none; min-width: 40px; height: 34px; padding: 0 8px;
  background: linear-gradient(180deg, var(--gold-lit), var(--gold)); border: 2.5px solid var(--ink); border-radius: var(--r-pill);
  box-shadow: inset 0 -3px 0 rgba(217,144,26,.6);
  font: 800 19px/1 var(--font-num); font-variant-numeric: tabular-nums lining-nums;
}

/* one branch of the army: a sheet with an Aegean band, the units as rows */
.planner__branch {
  min-width: 0; overflow: hidden; background: var(--paper); color: var(--ink);
  border: 3px solid var(--ink); border-radius: var(--r-panel); box-shadow: var(--sh-float); --focus: #167D8C;
}
.planner__branch > h2 {
  display: flex; align-items: center; min-height: 58px; padding: 10px 16px 11px;
  background: var(--aegean); border-bottom: 3px solid var(--ink);
  color: #fff; text-shadow: var(--ts-title); font: 900 26px/1.05 var(--font-display); letter-spacing: .01em;
}
.planner__list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; padding: 12px; }
.pick {
  display: grid; grid-template-columns: 56px minmax(0, 1fr); grid-template-areas: "art text" "art step";
  align-items: center; gap: 8px 12px; padding: 10px 12px 12px 10px;
  background: var(--paper); border: 2px solid var(--paper-line); border-radius: var(--r-card);
  transition: background-color .12s ease, border-color .12s ease;
}
.pick > img { grid-area: art; align-self: start; width: 56px; height: 56px; }
.pick > div:not(.stepper) { grid-area: text; min-width: 0; }
.pick strong { display: block; font: 900 18px/1.12 var(--font-display); letter-spacing: .01em; }
.pick strong a { display: inline-flex; align-items: center; min-height: 44px; color: var(--ink); text-decoration: underline 2px var(--whitewash-shade); text-underline-offset: 4px; }
.pick strong a:hover { color: var(--aegean-shade); text-decoration-color: currentColor; }
.pick small { display: block; margin-top: 3px; color: var(--ink-2); font: 700 14px/1.3 var(--font-num); letter-spacing: .01em; font-variant-numeric: tabular-nums lining-nums; }
.pick.has-qty { background: #FFF6DA; border-color: var(--gold-shade); }

/* the stepper: round toy minus / plus around a number pill */
.stepper { grid-area: step; display: inline-flex; align-items: center; gap: 8px; justify-self: start; padding-bottom: 3px; }
.stepper button {
  display: grid; place-items: center; width: 44px; height: 44px; padding: 0; flex: none;
  background: var(--paper); color: var(--ink); border: 3px solid var(--ink); border-radius: 50%;
  box-shadow: inset 0 -3px 0 var(--paper-line), 0 3px 0 var(--ink); cursor: pointer;
  transition: transform .08s ease, box-shadow .08s ease;
}
.stepper button svg { width: 20px; height: 20px; stroke-width: 3.2; }
.stepper button:active { transform: translateY(2px); box-shadow: inset 0 -2px 0 var(--paper-line), 0 1px 0 var(--ink); }
@media (hover: hover) { .stepper button:hover { background: #F2F7FD; } }
.stepper input {
  width: 78px; height: 44px; padding: 0 6px; margin: 0;
  background: #fff; color: var(--ink); border: 2.5px solid var(--ink); border-radius: var(--r-pill);
  box-shadow: inset 0 3px 0 var(--paper-2);
  text-align: center; font: 800 19px/1 var(--font-num); font-variant-numeric: tabular-nums lining-nums;
  -moz-appearance: textfield; appearance: textfield;
}
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.stepper input:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.pick.has-qty .stepper input { background: linear-gradient(180deg, var(--gold-lit), var(--gold)); box-shadow: inset 0 -3px 0 rgba(217,144,26,.6); }

/* the totals: a sheet with an Aegean band */
.summary-card {
  min-width: 0; padding: 0 16px 18px; overflow: hidden;
  background: var(--paper); color: var(--ink); border: 3px solid var(--ink); border-radius: var(--r-panel); box-shadow: var(--sh-float);
  --focus: #167D8C;
}
.summary-card > h2 {
  display: flex; align-items: center; min-height: 64px; margin: 0 -16px 14px; padding: 12px 16px 13px;
  background: var(--aegean); border-bottom: 3px solid var(--ink);
  color: #fff; text-shadow: var(--ts-title); font: 900 28px/1.05 var(--font-display); letter-spacing: .01em;
}
.summary-card .count { margin: 0 0 12px; color: var(--ink-2); font: 700 15px/1.35 var(--font-label); }
.summary-card dl { display: grid; padding: 2px 12px; background: var(--paper-2); border-radius: var(--r-card); }
.summary-card .row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 12px; min-height: 46px; padding: 8px 0; }
.summary-card .row + .row { border-top: 1.5px dashed var(--paper-line); }
.summary-card .row dt { color: var(--ink-2); font: 700 15px/1.3 var(--font-label); }
.summary-card .row dd { margin-left: auto; color: var(--aegean-shade); text-align: right; font: 800 19px/1.2 var(--font-num); font-variant-numeric: tabular-nums lining-nums; }
.summary-card .row dd .res-list { justify-content: flex-end; gap: 4px 12px; color: var(--ink); font-size: 17px; }
.summary-card .row dd .res img { width: 22px; height: 22px; }
.summary-card h3 { margin: 18px 0 6px; color: var(--ink-3); font: 800 13px/1.2 var(--font-label); letter-spacing: .06em; text-transform: uppercase; }
.summary-card .facility-list { display: grid; padding: 2px 12px; background: var(--paper-2); border-radius: var(--r-card); }
.summary-card .facility-list li { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 42px; padding: 6px 0; color: var(--ink-2); font: 700 15px/1.3 var(--font-label); }
.summary-card .facility-list li + li { border-top: 1.5px dashed var(--paper-line); }
.summary-card .facility-list li[style] { margin-top: 0 !important; padding-top: 6px !important; border-top: 2px solid var(--paper-line) !important; color: var(--ink); }
.summary-card .facility-list strong { color: var(--aegean-shade); font: 800 18px/1 var(--font-num); font-variant-numeric: tabular-nums lining-nums; white-space: nowrap; }
.summary-card [data-sum-note] { margin-top: 10px !important; color: var(--ink-3); font: 600 13px/1.45 var(--font-label) !important; }
.summary-card .warn { margin-top: 14px; }
.summary-card .warn > svg { background: var(--gold); }
.summary-card .actions { display: flex; flex-wrap: wrap; gap: 10px 12px; margin-top: 18px; }
.summary-card .actions .btn { flex: 1 1 140px; min-height: 48px; font-size: 17px; }
.summary-card .actions .btn--ghost {
  --_top: #FFFFFF; --_bottom: #E3EEF9; --_shade: var(--paper-line);
  margin-bottom: 4px; border-color: var(--ink); background: linear-gradient(180deg, var(--_top), var(--_bottom));
  box-shadow: inset 0 3px 0 var(--highlight), inset 0 -4px 0 var(--_shade), 0 4px 0 var(--ink);
}
.summary-card .actions .btn--ghost:active { box-shadow: inset 0 3px 0 var(--highlight), inset 0 -2px 0 var(--_shade), 0 1px 0 var(--ink); }

/* the note under the planner, on a white plate */
.page--planner .codex-section > p.faint {
  margin: 24px 0 0 !important; padding: 12px 16px; max-width: 52rem;
  background: var(--paper); color: var(--ink-2); border: 3px solid var(--paper-line); border-radius: var(--r-btn);
  box-shadow: 0 4px 0 var(--shadow); font: 600 14px/1.5 var(--font-label) !important; --focus: #167D8C;
}
.page--planner .codex-section > p.faint a { color: var(--link); text-underline-offset: 3px; }

/* the phone bar with the running totals: a floating panel just above the site's tab bar */
.planner-bar { display: none; }
@media (max-width: 999px) {
  .planner-bar {
    position: fixed; left: 8px; right: 8px; bottom: calc(var(--tabbar-h) + 8px); z-index: 35;
    display: flex; align-items: center; gap: 10px; max-width: 560px; margin: 0 auto; padding: 6px 6px 6px 8px;
    background: var(--paper); color: var(--ink); border: 3px solid var(--ink); border-radius: 18px;
    box-shadow: 0 5px 0 rgba(22,46,112,.3), 0 10px 24px rgba(22,46,112,.3);
    font: 700 14px/1.2 var(--font-label); --focus: #167D8C;
  }
  .planner-bar > span:first-child {
    display: inline-flex; align-items: center; gap: 6px; flex: none; height: 38px; padding: 0 12px 0 4px;
    background: var(--paper-2); border-radius: var(--r-pill); color: var(--ink-2);
  }
  .planner-bar [data-bar-count] {
    display: inline-grid; place-items: center; min-width: 30px; height: 30px; padding: 0 7px;
    background: linear-gradient(180deg, var(--gold-lit), var(--gold)); color: var(--ink); border: 2px solid var(--ink); border-radius: var(--r-pill);
    font: 800 17px/1 var(--font-num); font-variant-numeric: tabular-nums lining-nums;
  }
  .planner-bar [data-bar-cost] {
    flex: 1 1 auto; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: var(--ink-2);
    -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 22px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 22px), transparent);
  }
  .planner-bar [data-bar-cost] .res-list { flex-wrap: nowrap; gap: 10px; color: var(--ink); font-size: 15px; }
  .planner-bar .btn { flex: none; margin-bottom: 4px; --_top: #FFFFFF; --_bottom: #E3EEF9; --_shade: var(--paper-line); color: var(--aegean-shade); }
  /* room below the page for the bar, so the footer and the last rows never hide behind it */
  body:has([data-planner-bar]) { padding-bottom: calc(var(--tabbar-h) + var(--planner-bar-h, 60px) + 20px); }
  html:has([data-planner-bar]) { scroll-padding-bottom: calc(var(--tabbar-h) + var(--planner-bar-h, 60px) + 24px); }
  /* the bar steps aside while the "Your force" sheet is on screen, so it never covers the totals or the warnings it
     sums up. Driven by the sheet's place in the viewport (a CSS view timeline; the scroll padding above keeps the
     header and the bars out of that viewport). Browsers without view timelines simply keep the bar. */
  .page--planner .codex-section { timeline-scope: --kbd-summary; }
  .page--planner .summary-card { view-timeline-name: --kbd-summary; view-timeline-axis: block; }
  .page--planner .planner-bar {
    animation-name: kbd-planner-bar-away; animation-duration: 1ms; animation-timing-function: linear; animation-fill-mode: both;
    animation-timeline: --kbd-summary; animation-range: cover 0% cover 100%;
  }
}
/* browsers without view timelines: site.js sets .is-away while the "Your force" sheet is on screen */
@supports not (animation-timeline: --kbd-summary) {
  @media (max-width: 999px) {
    .page--planner .planner-bar { animation: none; } /* else its 1 ms fill would override .is-away */
    .page--planner .planner-bar.is-away { transform: translateY(calc(100% + var(--tabbar-h) + 16px)); opacity: 0; visibility: hidden; }
  }
}
@keyframes kbd-planner-bar-away {
  0%, 100% { transform: none; opacity: 1; visibility: visible; }
  4%, 96% { transform: translateY(calc(100% + var(--tabbar-h) + 16px)); opacity: 0; visibility: hidden; }
}
/* reduced motion: the bar fades instead of sliding (the site's reduced-motion rule would otherwise switch it off) */
@keyframes kbd-planner-bar-fade {
  0%, 100% { opacity: 1; visibility: visible; }
  4%, 96% { opacity: 0; visibility: hidden; }
}
@media (max-width: 999px) and (prefers-reduced-motion: reduce) {
  .page--planner .planner-bar {
    animation: kbd-planner-bar-fade 1ms linear both !important;
    animation-timeline: --kbd-summary !important; animation-range: cover 0% cover 100% !important;
  }
}

/* =====================================================================================================
   SMALL PHONES (under 360 px)
   ===================================================================================================== */
@media (max-width: 359px) {
  .tile-grid { gap: 12px 8px; padding: 12px 10px 14px; }
  .tile__title { font-size: 16px; }
  .chapter__art img { flex-basis: 52px; width: 52px; }
  .pick { grid-template-columns: 46px minmax(0, 1fr); gap: 8px 10px; }
  .pick > img { width: 46px; height: 46px; }
  .stepper input { width: 66px; }
  .planner-bar > span:first-child { padding-right: 8px; }
}

/* =====================================================================================================
   LARGER PHONES AND TABLETS
   ===================================================================================================== */
@media (min-width: 480px) {
  .pick { grid-template-columns: 56px minmax(0, 1fr) auto; grid-template-areas: "art text step"; }
  .pick > img { align-self: center; }
  .stepper { justify-self: end; }
  .start-card { grid-template-columns: 64px minmax(0, 1fr); }
  .start-card::before { width: 64px; height: 64px; }
}

@media (min-width: 600px) {
  .page--wiki-home .codex-section__head { margin: -24px -24px 22px; padding: 14px 18px; }
  #latest .latest > div > h2 { margin: -24px -24px 22px; padding: 14px 20px 16px; }
  .page--wiki-home .codex-section:has(> .chapter-grid) > .codex-section__head { margin: 4px auto 24px; padding: 16px 28px; }
  .chapter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tile-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px 14px; padding: 16px; }
  .tile__text { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
  .tile-grid--wide { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
  .page--wiki-hub .toolbar .chips { display: flex; width: auto; flex-wrap: nowrap; }
  .page--wiki-hub .toolbar .chips .chip { flex: none; padding: 0 16px; }
  .view-switch { display: flex; width: auto; }
  .view-switch button { flex: none; padding: 0 16px; }
  .tile__title { font-size: 17px; }
  .tile-group > h2 { padding: 14px 20px; min-height: 66px; }
  .planner__units > .toolbar { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: center; padding: 16px 18px 18px; }
  .summary-card { padding: 0 22px 22px; }
  .summary-card > h2 { margin: 0 -22px 16px; padding: 14px 22px; }
}

/* tablets: the counts are a full-width grid, so the islands need the whole of their height in open sky; the sun
   stands right of the page centre, as on /updates/ */
@media (min-width: 600px) and (max-width: 899px) {
  :is(.page--wiki-home, .page--wiki-hub, .page--planner) .codex-hero { --sea-h: 64px; --clear: 84px; --sun-dx: clamp(-200px, 500px - 50vw, 180px); }
  :is(.page--wiki-home, .page--wiki-hub, .page--planner) .codex-hero::before {
    background-position: calc(50% + var(--sun-dx)) calc(100% + 980px - var(--sea-h)), calc(50% + var(--sun-dx)) calc(100% + 980px - var(--sea-h));
  }
}

/* =====================================================================================================
   DESKTOP
   ===================================================================================================== */
@media (min-width: 900px) {
  .page--wiki-home .codex-section__head { margin: -28px -30px 24px; padding: 14px 20px 14px 24px; min-height: 86px; }
  .page--wiki-home .codex-section__head h2 { font-size: 32px; }
  .page--wiki-home .codex-section__head p { font-size: 15px; }
  .page--wiki-home .codex-section:has(> .chapter-grid) { margin-bottom: 44px; }
  .page--wiki-home .codex-section:has(> .chapter-grid) > .codex-section__head { margin: 8px auto 28px; padding: 18px 36px; }
  .page--wiki-home .codex-section:has(> .chapter-grid) > .codex-section__head h2 { font-size: 38px; }
  .start-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
  .latest { gap: 16px; }
  #latest .latest > div > h2 { margin: -28px -30px 24px; padding: 16px 24px 18px; min-height: 86px; font-size: 32px; }
  .latest p:not(.eyebrow) { max-width: 60rem; }
  .latest .stack { grid-template-columns: repeat(3, minmax(0, 1fr)); }

  .page--wiki-hub .toolbar { margin-bottom: 28px; }
  .tile-group { margin-bottom: 30px; }
  .tile-group > h2 { font-size: 32px; padding: 16px 24px; min-height: 80px; }
  .tile-group > h2 .count { font-size: 15px; }
  .tile-grid { grid-template-columns: repeat(auto-fill, minmax(196px, 1fr)); gap: 20px 18px; padding: 22px 24px 26px; }
  .wiki-hub--units .tile-grid { grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); }
  .tile-grid--wide { grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: 16px 18px; }
  /* each guide's banner (the same toy-island picture that heads the guide's page) as a framed 16:9 thumbnail */
  .tile-grid--wide .tile { gap: 16px; min-height: 96px; padding: 10px 12px 12px 10px; }
  .tile-grid--wide .tile__media { width: 128px; height: 72px; background: var(--thumb-bg); border: 2.5px solid var(--ink); border-radius: var(--r-card); }
  .tile-grid--wide .tile__media img { display: block; width: 100%; height: 100%; object-fit: cover; }
  .tile__title { font-size: 20px; }
  .wiki-hub--units .tile__title { font-size: 17px; }
  .tile-grid--wide .tile__title { font-size: 17px; }
  /* the hero scene at its own size: the sun rises behind the counts (60 px left of the counts column's centre), the
     headland lies under the text column in open sky, the temple island stands at the right; the galley sails below
     the hero's edge. --sun-dx is the sun's distance from the page centre: the counts column's centre is
     8.5 px + 0.287 x the container width right of it. */
  :is(.page--wiki-home, .page--wiki-hub, .page--planner) .codex-hero {
    --sea-h: 72px; --clear: 84px;
    --sun-dx: calc(min(1180px, 100vw - 32px) * .2872 - 51.5px);
  }
  :is(.page--wiki-home, .page--wiki-hub, .page--planner) .codex-hero::before {
    background-image: var(--shores-wide), url("../img/scene/dawn-wide.svg");
    background-size: 2400px 1300px, 2400px 1300px;
    background-position: calc(50% + 300px + var(--sun-dx)) calc(100% + 700px - var(--sea-h)), calc(50% + 300px + var(--sun-dx)) calc(100% + 700px - var(--sea-h));
  }
  :is(.page--wiki-home, .page--wiki-hub, .page--planner) .codex-hero .lead { font-size: 17px; padding: 13px 18px 14px; }
  .wiki-hub--buildings .codex-section > h2.h3 { padding: 18px 24px; font-size: 32px; }
  .wiki-hub--buildings .codex-section > h2.h3 + p.muted { padding: 16px 24px; }
  .wiki-hub--units [data-view-panel="table"] > p.muted { padding: 14px 24px; }
}

@media (min-width: 1000px) {
  .planner { grid-template-columns: minmax(0, 1fr) 24rem; gap: 30px; }
  .summary-card { position: sticky; top: calc(var(--topbar-h) + 18px); max-height: calc(100vh - var(--topbar-h) - 36px); overflow: auto; overscroll-behavior: contain; }
  .planner__list { grid-template-columns: minmax(0, 1fr); padding: 14px 16px 16px; }
}

@media (min-width: 1100px) {
  /* three across; a short last row is centred */
  .chapter-grid { display: flex; flex-wrap: wrap; justify-content: center; gap: 24px; }
  .chapter-grid > .chapter { flex: 0 1 calc((100% - 48px) / 3); }
}

@media (min-width: 1200px) {
  .planner__list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pick { grid-template-columns: 52px minmax(0, 1fr); grid-template-areas: "art text" "art step"; }
  .pick > img { align-self: start; width: 52px; height: 52px; }
  .stepper { justify-self: start; }
}

/* ---------- print ---------- */
@media print {
  .planner-bar { display: none !important; }
  .tile, .start-card, .chapter, .tile-group, .planner__branch, .summary-card { box-shadow: none; }
  :is(.page--wiki-home, .page--wiki-hub, .page--planner) .codex-hero :is(.eyebrow, .lead, .snapshot) { background: none; border-color: var(--ink); color: var(--ink); padding-inline: 0; }
}
