/* game-progression-township.css: collection, lore, talents, stats, wiki, township. Moved verbatim from css/game.css (TD-CONTENT-SPLIT-001); link order in index.html keeps the cascade. */

  /* UX-038: native disclosures make each collection card keyboard-accessible,
     while the summary keeps its progress and next bonus visible when closed. */
  #equipment-sets-list {
    flex-direction: column;
    align-items: stretch;
  }

  .equipment-set-card {
    flex: 1 1 100%;
    min-width: 0;
    border: 1px solid var(--wood);
    border-radius: 6px;
    background: var(--parchment);
    color: var(--text);
    overflow: hidden;
  }

  .equipment-set-summary {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 4px 10px;
    padding: 9px 10px;
    cursor: pointer;
    list-style: revert;
    overflow-wrap: anywhere;
  }

  .equipment-set-summary:focus-visible {
    outline: 2px solid var(--color-active);
    outline-offset: -3px;
  }

  .equipment-set-card[open] .equipment-set-summary {
    border-bottom: 1px solid var(--wood);
  }

  .equipment-set-name {
    color: var(--heading);
    font-weight: bold;
  }

  .equipment-set-progress {
    color: var(--muted);
    text-align: right;
  }

  .equipment-set-bonus-summary,
  .equipment-set-next {
    grid-column: 1 / -1;
    min-width: 0;
    overflow-wrap: anywhere;
  }

  .equipment-set-bonus-summary {
    font-weight: 600;
  }

  .equipment-set-next {
    color: var(--muted);
    font-size: 12px;
  }

  .equipment-set-piece-list {
    display: grid;
    gap: 4px;
    margin: 0;
    padding: 8px 10px;
    list-style: none;
  }

  .equipment-set-piece {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 8px;
    align-items: start;
    padding: 5px 0;
    border-bottom: 1px solid var(--parchment-dark);
  }

  .equipment-set-piece:last-child {
    border-bottom: 0;
  }

  .equipment-set-piece-name,
  .equipment-set-piece-ownership {
    min-width: 0;
    overflow-wrap: anywhere;
  }

  .equipment-set-piece-ownership {
    color: var(--muted);
    text-align: right;
  }

  .combat-log {
    background: var(--parchment);
    border: 1px solid var(--wood);
    border-radius: 6px;
    padding: 8px 10px;
    font-size: 12px;
    max-height: 160px;
    overflow-y: auto;
  }

  .combat-log-line {
    padding: 3px 0;
    border-bottom: 1px solid var(--parchment-dark);
  }

  .combat-log-line:last-child {
    border-bottom: none;
  }

  /* Phase 54 ("World & Lore"): four short flavor lines on existing screens
     (Township, Combat/enemy selector, Talents, Quests) — pure text, reuses
     the existing .footer-note pattern's spacing but is visually distinct
     (italic) so it reads as "world flavor" rather than "how this panel
     works" instructions. */
  .endless-task-row {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--wood);
  }

  .skill-task-help { margin-top: 8px; font-size: 12px; }
  .skill-task-help summary { cursor: pointer; padding: 6px 0; min-height: 44px; display: flex; align-items: center; }
  .skill-task-help ul { margin: 4px 0 0; padding-left: 18px; }
  .skill-task-help-line { margin: 4px 0 0; }
  .skill-task-help-more summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; }

  .endless-task-row .footer-note {
    margin-bottom: 6px;
  }

  .lore-flavor {
    font-style: italic;
    font-size: 12px;
    color: var(--heading);
    opacity: 0.85;
    margin-bottom: 8px;
  }

  /* The founding myth reuses .talent-branch's collapsible-disclosure look
     (see below) rather than inventing a second visual pattern for the same
     "collapsed by default, doesn't add page length" need. */
  .founding-myth {
    margin-bottom: 10px;
    border: 1px solid var(--wood);
    border-radius: 6px;
    padding: 8px 10px;
    background: rgba(255,255,255,0.15);
  }

  .founding-myth summary {
    font-size: 13px;
    font-weight: bold;
    color: var(--heading);
    cursor: pointer;
  }

  .founding-myth p {
    font-size: 12px;
    line-height: 1.6;
    margin: 8px 0 0;
  }

  /* QA/UI audit: talent branches became a <details> disclosure (see
     renderTalents()) so a player sees every branch's name and progress at
     a glance without the whole tree's ~40+ node cards being expanded and
     taking up scroll space at once. */
  .talent-branch {
    margin-bottom: 10px;
    border: 1px solid var(--wood);
    border-radius: 6px;
    padding: 8px 10px;
    background: rgba(255,255,255,0.15);
  }

  .talent-branch:last-child {
    margin-bottom: 0;
  }

  .talent-branch summary {
    margin: 0;
    font-size: 13px;
    font-weight: bold;
    color: var(--heading);
    cursor: pointer;
    list-style: revert;
  }

  .talent-branch summary:hover {
    color: var(--muted);
  }

  /* UX-071: next node + affordable marker in the branch header. */
  .talent-branch-next {
    margin-left: 10px;
    font-weight: normal;
    font-size: 12px;
    color: var(--muted);
  }

  /* UX-083: the one buyable node carries an explicit action, not just a brighter card. */
  /* UX-091: bulk learn, readable locked nodes, prestige CTA. */
  .talent-learn-all { margin-top: 8px; }
  .resource-btn.talent-node-locked:disabled { opacity: 1; color: var(--muted); }
  .resource-btn.talent-node-locked .resource-name { color: var(--muted); }
  .talent-prestige-cta { font-size: inherit; }

  .talent-learn-cta {
    align-self: flex-start;
    margin-top: 12px;
    padding: 3px 10px;
    border-radius: 4px;
    background: var(--gold);
    color: var(--on-accent);
    font-size: 12px;
    font-weight: 600;
  }
  .talent-learnable:hover .talent-learn-cta,
  .talent-learnable:focus-visible .talent-learn-cta { background: var(--gold-light); }

  .talent-affordable {

    margin-left: 10px;
    font-size: 12px;
    color: #f0cd7a;
  }

  .talent-affordable::before {
    content: "";
    display: inline-block;
    width: 8px;
    height: 8px;
    margin-right: 5px;
    border-radius: 50%;
    background: #d9b45c;
    vertical-align: middle;
  }

  #panel-talents > .footer-note,
  #panel-talents .talent-pane > .footer-note {
    text-align: left;
    font-size: 13px;
    max-width: 75ch;
  }

  .talent-branch[open] summary {
    margin-bottom: 6px;
  }

  .talent-branch .talent-node-list {
    margin-top: 8px;
  }

  /* UX-101 (DEC-120): WoW-style talent trees. Branches sit side by side; a
     branch is tiers of icon nodes joined by lines to the node they unlock.
     State never rests on colour alone: learned nodes carry a check, buyable
     ones a Learn label, locked ones a dashed edge and a dimmed icon. */
  /* UX-102: fixed columns (2, or 3 from 1200px) of 4px rows; fitTalentBranchRows()
     sets each branch's row span, so order holds and nothing overlaps. Closed
     branches share one header height. */
  .talent-tree-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-auto-rows: 4px;
    column-gap: var(--space-lg);
    align-items: start;
  }
  @media (min-width: 1200px) { .talent-tree-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
  .talent-tree-grid > .talent-branch { margin: 0; min-width: 0; }
  .talent-tree-grid > .talent-branch > summary { min-height: 40px; }
  .talent-tree-grid > .talent-branch:not([open]) > summary { margin-bottom: 0; }
  .talent-branch summary {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 2px 6px;
  }
  .talent-branch summary .talent-affordable,
  .talent-branch summary .talent-branch-next {
    margin-left: 0;
    flex-basis: 100%;
    min-width: 0; /* UX-124: wraps at word boundaries instead of clipping mid-word */
  }
  .talent-branch-icon { display: inline-flex; font-size: 18px; color: var(--muted); }
  .talent-branch-count { font-weight: normal; font-size: 12px; color: var(--muted); margin-left: auto; }

  .talent-tabs { display: none; }
  .talent-tree { margin-top: var(--space-md); }
  .talent-tier {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--space-lg);
  }
  .talent-tier + .talent-tier { margin-top: var(--space-lg); }
  /* UX-102: the path drops from the last node of a tier into the first node of
     the next one, which sits under it (tiers snake: odd ones run right to left).
     Column centre = half of one of three columns: (100% - 2 gaps) / 6. */
  .talent-tier-link {
    width: 3px;
    height: var(--space-lg);
    margin: 0 0 0 calc((100% - 2 * var(--space-lg)) / 6 - 1px);
    background: var(--muted);
    opacity: 0.6;
  }
  .talent-tier-link.at-end { margin: 0 calc((100% - 2 * var(--space-lg)) / 6 - 1px) 0 auto; }
  .talent-tier.is-reverse { direction: rtl; }
  .talent-tier.is-reverse > .talent-node { direction: ltr; }
  .talent-tier-link.is-lit { background: var(--color-active); opacity: 1; }

  .talent-node {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-sm);
    min-width: 0;
    min-height: 96px;
    padding: var(--space-md) var(--space-sm);
    border: 1px solid var(--wood);
    border-radius: var(--radius-md);
    background: var(--parchment);
    color: var(--text);
    font: inherit;
    cursor: default;
  }
  .talent-node.is-available { border-color: var(--gold); box-shadow: 0 0 0 1px rgba(217, 180, 92, 0.35); cursor: pointer; }
  .talent-node.is-owned,
  .talent-node.is-partial { border-color: var(--color-active); }
  .talent-node.is-locked { border-style: dashed; }
  .talent-node.is-locked .talent-node-icon { opacity: 0.4; }
  .talent-node.is-locked .talent-node-label { color: var(--muted); }
  .talent-node.is-owned::after {
    content: "\2713";
    position: absolute;
    top: 3px;
    left: 5px;
    font-size: 12px;
    font-weight: bold;
    color: var(--color-active);
  }
  .talent-node:focus-visible { outline: 2px solid var(--heading); outline-offset: 2px; }
  .talent-node-icon { display: flex; font-size: 30px; line-height: 1; color: var(--heading); }
  .talent-node-rank {
    position: absolute;
    top: 3px;
    right: 4px;
    padding: 0 4px;
    border-radius: var(--radius-sm);
    background: var(--wood-dark);
    font-size: 11px;
    color: var(--text);
  }
  .talent-node-label {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: 11px;
    line-height: 1.3;
    text-align: center;
    overflow-wrap: anywhere;
  }
  .talent-node .talent-learn-cta { align-self: center; margin-top: auto; padding: 2px 8px; font-size: 11px; white-space: nowrap; }
  .talent-node.talent-learnable:hover .talent-learn-cta,
  .talent-node.talent-learnable:focus-visible .talent-learn-cta { background: var(--gold-light); }

  /* The line from the node before (in the same tier) into this one. */
  .talent-tier.is-chained .talent-node + .talent-node::before {
    content: "";
    position: absolute;
    top: 28px;
    right: 100%;
    width: var(--space-lg);
    height: 3px;
    background: rgba(154, 164, 178, 0.6);
  }
  .talent-tier.is-reverse .talent-node + .talent-node::before { right: auto; left: 100%; }
  .talent-tier.is-chained .talent-node.link-lit::before { background: var(--color-active); }

  /* Tooltip: hover, keyboard focus or long-press (.show-tip). Edge nodes
     anchor to their own side so it never runs off a phone screen. */
  .talent-tip {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 50%;
    z-index: 20;
    width: 220px;
    max-width: 80vw;
    flex-direction: column;
    gap: 2px;
    padding: var(--space-md) 10px;
    border: 1px solid var(--muted);
    border-radius: var(--radius-md);
    background: var(--wood-dark);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    text-align: left;
    transform: translateX(-50%);
    pointer-events: none;
  }
  /* UX-POLISH-006-D: fitTalentTip() flips the tip to the node's left or right edge when it would leave the screen. */
  .talent-node.tip-start .talent-tip { left: 0; transform: none; }
  .talent-node.tip-end .talent-tip { left: auto; right: 0; transform: none; }
  .talent-node:hover .talent-tip,
  .talent-node:focus-visible .talent-tip,
  .talent-node.show-tip .talent-tip { display: flex; }
  .talent-node:hover, .talent-node:focus-visible, .talent-node.show-tip { z-index: 30; }
  .talent-tip .resource-name { font-size: 13px; font-weight: bold; color: var(--heading); }
  .talent-tip .resource-meta { font-size: 12px; color: var(--muted); }
  .talent-tip .talent-tip-desc { color: var(--text); }

  .talent-skill-label {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: var(--space-lg) 0 0;
    font-size: 12px;
    color: var(--muted);
  }

  .earned-bonus-list { margin: var(--space-md) 0 0; padding: 0; list-style: none; font-size: 13px; }
  .earned-bonus-list li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px; padding: var(--space-sm) 0; border-top: 1px solid var(--wood); }
  .earned-bonus-list li:first-child { border-top: 0; }

  /* Phones: one branch at a time, picked from a wrapping tab strip. */
  @media (max-width: 600px) {
    .talent-tabs { display: flex; flex-wrap: wrap; gap: var(--space-sm); margin-bottom: var(--space-md); }
    .talent-tab {
      min-height: 44px;
      padding: var(--space-sm) 10px;
      border: 1px solid var(--wood);
      border-radius: var(--radius-md);
      background: var(--parchment);
      color: var(--text);
      font: inherit;
      font-size: 13px;
    }
    .talent-tab[aria-selected="true"] { background: var(--wood); color: var(--heading); font-weight: bold; }
    .talent-tab.has-affordable::after {
      content: "";
      display: inline-block;
      width: 8px;
      height: 8px;
      margin-left: 6px;
      border-radius: 50%;
      background: var(--gold);
      vertical-align: middle;
    }
    .talent-tree-grid { grid-template-columns: minmax(0, 1fr); }
    .talent-tree-grid > .talent-branch:not(.is-current) { display: none; }
    .talent-tier { gap: var(--space-md); }
    .talent-tier.is-chained .talent-node + .talent-node::before { width: var(--space-md); }
    .talent-tier-link { margin-left: calc((100% - 2 * var(--space-md)) / 6 - 1px); }
    .talent-tier-link.at-end { margin-right: calc((100% - 2 * var(--space-md)) / 6 - 1px); }
  }

  .stats-search-label {
    display: block;
    margin: 14px 0 4px;
    color: var(--heading);
    font-size: 12px;
    font-weight: bold;
  }

  #stats-search {
    box-sizing: border-box;
    width: 100%;
    max-width: 560px;
    margin-bottom: 10px;
  }

  #stats-search-empty {
    margin: 8px 0;
  }

  .stats-groups {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr));
    align-items: start;
    gap: 8px;
  }

  .stats-groups .stats-domain {
    min-width: 0;
    margin: 0;
  }

  /* UX-068: Stats sections fold; jump row on top. */
  .stats-jump {
    display: flex;
    gap: 4px 16px;
    margin-bottom: 12px;
    overflow-x: auto;
    border-bottom: 1px solid var(--wood);
  }
  /* UX-093: navigation, not actions: text links on an iron rule, one scrolling row on mobile. */
  .stats-jump button {
    flex: none;
    padding: 6px 0;
    border: 0;
    background: none;
    color: var(--gold-light);
    font: inherit;
    text-decoration: underline;
    text-underline-offset: 3px;
    cursor: pointer;
  }
  .stats-jump button:hover { color: var(--heading); }
  .stats-jump button:focus-visible { outline: 2px solid var(--color-active); outline-offset: 2px; }

  .stats-section {
    margin: 0 0 12px;
  }

  .stats-section > summary {
    cursor: pointer;
    padding: 6px 0;
  }

  .stats-section > summary h3 {
    display: inline;
    margin: 0;
  }

  .pet-shelf {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 6px;
  }

  .pet-tile {
    display: grid;
    grid-template-columns: auto 1fr;
    column-gap: 8px;
    align-items: center;
    padding: 6px 8px;
    background: #151a21;
    border: 1px solid #39424f;
    border-radius: 6px;
    color: #9aa4b2;
  }

  .pet-tile > :first-child {
    grid-row: span 2;
  }

  .pet-tile-name {
    color: #dfe4ea;
    font-size: 13px;
  }

  .pet-tile-level {
    font-size: 12px;
  }

  .pet-tile.found {
    border-color: #d9b45c;
  }

  #resource-codex-search {
    box-sizing: border-box;
    width: 100%;
    max-width: 560px;
    margin-bottom: 10px;
  }

  /* WIKI-001: one column at every width; 44 px search and rows for touch. */
  .wiki-search {
    box-sizing: border-box;
    width: 100%;
    max-width: 560px;
    min-height: 44px;
    margin-bottom: 10px;
  }

  .wiki-back {
    min-height: 44px;
    margin-bottom: 8px;
  }

  .wiki-open {
    min-height: 44px;
    min-width: 44px;
    justify-self: start;
    margin-top: 6px;
  }

  .wiki-back[hidden] {
    display: none;
  }

  .wiki-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-width: 720px;
  }

  .wiki-row {
    box-sizing: border-box;
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    min-height: 44px;
    padding: 6px 10px;
    text-align: left;
    color: inherit;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 6px;
    cursor: pointer;
  }

  .wiki-row[aria-expanded="true"] {
    border-color: #d9b45c;
  }

  .wiki-chip {
    margin-left: auto;
    padding: 1px 6px;
    font-size: 11px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.1);
  }

  .wiki-card {
    padding: 4px 12px 10px;
    overflow-wrap: anywhere;
    border-left: 2px solid #d9b45c;
  }

  .wiki-card h4 {
    margin: 8px 0 4px;
    font-size: 13px;
  }

  .wiki-card ul {
    margin: 0;
    padding-left: 18px;
  }

  .wiki-card li {
    margin: 2px 0;
    line-height: 1.6;
  }

  .wiki-link {
    padding: 0;
    font: inherit;
    color: #8fc7ff;
    text-decoration: underline;
    background: none;
    border: 0;
    cursor: pointer;
  }

  #resource-codex-list .resource-codex-row[hidden] {
    display: none !important;
  }

  #stats-groups .market-row[hidden] {
    display: none !important;
  }

  .talent-node-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }

  .npc-capacity {
    font-size: 13px;
    font-weight: bold;
    color: var(--heading);
    margin-bottom: 8px;
  }

  .npc-row {
    display: block;
    background: var(--parchment);
    border: 1px solid var(--wood);
    border-radius: 0;
    padding: 4px 10px;
    font-size: 13px;
    margin-bottom: -1px; /* TOWN-TABS-001: rows read as one compact table */
  }

  .npc-row:last-child {
    margin-bottom: 0;
  }

  .npc-name {
    font-weight: bold;
  }

  .npc-summary {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 4px 10px;
    cursor: pointer;
    min-width: 0;
  }

  .npc-summary::marker {
    color: var(--heading);
  }

  .npc-assignment {
    color: var(--heading);
    font-size: 12px;
    overflow-wrap: anywhere;
  }

  .npc-details-controls {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-top: 10px;
    min-width: 0;
  }

  .npc-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    color: var(--heading);
    font-size: 11px;
    font-weight: bold;
    min-width: 0;
  }

  .queue-entry-label {
    flex: 1 1 auto;
    min-width: 0;
  }

  .queue-entry-controls {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex: 0 1 auto;
    gap: 4px;
    flex-wrap: wrap;
  }

  .npc-row select {
    font-size: 12px;
    width: 100%;
    min-width: 0;
    padding: 4px;
  }

  .npc-stat {
    font-size: 11px;
    color: var(--heading);
    grid-column: 1 / -1;
    overflow-wrap: anywhere;
  }

  .npc-details-actions {
    grid-column: 1 / -1;
    border-top: 1px solid var(--wood);
    padding-top: 8px;
  }

  .npc-row button.npc-dismiss {
    background: var(--red-fill);
    color: white;
    font-weight: bold;
  }

  .npc-row button {
    font-family: inherit;
    background: var(--red-fill);
    color: white;
    border: none;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 11px;
    cursor: pointer;
    flex: 0 0 auto;
  }

  @media (max-width: 480px) {
    .npc-details-controls {
      grid-template-columns: minmax(0, 1fr);
    }

    .npc-field select,
    .npc-group-controls .npc-set-all-apply {
      min-height: 44px; /* DEC-137: phone tap target */
    }

    .npc-stat,
    .npc-details-actions {
      grid-column: 1;
    }
  }

  /* UX-067: job groups lead the villager roster. */
  #village-food-cook-btn { margin: 0 0 12px; }

  .npc-group {
    background: var(--parchment);
    border: 1px solid var(--wood);
    border-radius: 6px;
    padding: 10px 12px;
    font-size: 13px;
    margin-bottom: 8px;
  }

  .npc-group-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 4px 12px;
  }

  .npc-group-title { font-weight: bold; }

  .npc-group-output,
  .npc-group-roles {
    font-size: 12px;
    color: var(--muted);
  }

  .npc-group-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
  }

  .npc-group-count { width: 72px; }

  .npc-group-controls button { min-height: 32px; }

  /* UX-090: Township jump links, presets, materials list, left-aligned notes. */
  .town-jump {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 12px;
    margin-bottom: 12px;
    font-size: 13px;
  }
  .town-jump a { color: var(--heading); text-underline-offset: 3px; }
  /* UX-TALENT-001: Manage talents panel. */
  .talent-manage { margin: 12px 0; padding: 8px 12px; border: 1px solid var(--wood); border-radius: 8px; }
  .talent-manage summary { cursor: pointer; font-weight: 600; color: var(--heading); min-height: 32px; display: flex; align-items: center; }
  @media (max-width: 539px) { .talent-manage summary { min-height: 44px; } }
  /* ONB-001: Township guide. */
  .township-guide { margin-bottom: 12px; padding: 8px 12px; border: 1px solid var(--wood); border-radius: 8px; }
  .township-guide summary { cursor: pointer; font-weight: 600; color: var(--heading); min-height: 32px; display: flex; align-items: center; }
  .township-guide h3 { margin: 10px 0 4px; font-size: var(--font-size-sm, 13px); }
  .township-guide ul { margin: 0; padding-left: 18px; font-size: var(--font-size-sm, 13px); }
  .township-guide li { margin: 2px 0; }
  .township-guide-housing { margin: 6px 0 0; font-size: var(--font-size-sm, 13px); }
  .township-guide-empty { font-weight: 600; color: var(--heading); }
  @media (max-width: 539px) {
    .township-guide summary, .township-guide-link { min-height: 44px; }
    .township-guide-link { vertical-align: middle; }
  }
  #panel-township #npc-capacity,
  #panel-township .town-subsection { scroll-margin-top: 96px; }
  #town-tabs[hidden], #panel-township [data-town-panel][hidden], #panel-township [data-town-tab][hidden] { display: none !important; }
  #town-tabs { margin-top: 0; }
  .town-note { margin: 0 0 8px; font-size: 12px; color: var(--muted); }
  #town-project-refund-why { margin-left: 8px; }
  .town-project-materials { margin: 6px 0 10px; padding-left: 18px; font-size: 12px; }
  .town-project-materials li { margin: 2px 0; }
  .npc-group-presets { display: inline-flex; gap: 4px; }
  .npc-group-controls .npc-group-preset { min-height: 32px; padding: 4px 8px; font-size: 12px; }
  /* UX-129 / UX-132: one-line notes with a jump button. */
  .township-diplomacy-waiting { margin: 10px 0 0; }
  .market-sell-row:has(.auto-seller-hint) { flex-wrap: wrap; }
  .auto-seller-hint { flex-basis: 100%; font-size: var(--font-size-sm, 13px); color: var(--muted); }
  @media (max-width: 539px) {
    .npc-group-controls button, .npc-group-controls .npc-group-preset, .npc-group-role,
    #township-diplomacy-waiting-btn, .auto-seller-hint-link { min-height: 44px; }
  }

  .npc-roster-details { margin-top: 12px; }

  .npc-roster-details > summary {
    cursor: pointer;
    font-weight: bold;
    margin-bottom: 8px;
    min-height: 32px;
    display: list-item;
  }

  #npc-show-all-btn { margin-top: 8px; }

  .offline-row .action { margin-top: 8px; }

  .market-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
  }

  .market-view-switch {
    display: flex;
    flex: 0 0 auto;
    gap: 4px;
  }

  .market-view-button {
    font-family: inherit;
    background: var(--surface-2);
    color: white;
    border: 1px solid var(--wood);
    border-radius: 4px;
    padding: 6px 12px;
    font-size: 12px;
    cursor: pointer;
  }

  .market-view-button[aria-pressed="true"] {
    background: var(--green);
    color: var(--on-accent);
  }

  .market-view-button:focus-visible {
    outline: 2px solid var(--heading);
    outline-offset: 2px;
  }

  .market-search-input {
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
    flex: 1 1 200px;
    padding: 6px 10px;
    margin-bottom: 0;
    font-size: 13px;
    font-family: inherit;
    border: 1px solid var(--wood);
    border-radius: 6px;
  }

  .market-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    background: var(--parchment);
    border: 1px solid var(--wood);
    border-radius: 6px;
    padding: 8px 10px;
    font-size: 13px;
    transition: background-color 0.6s ease; /* Phase 40: lets .level-up-flash pulse on a just-claimed quest row */
    margin-bottom: 6px;
  }

  .market-row:last-child {
    margin-bottom: 0;
  }

  .market-name {
    font-weight: bold;
    flex: 1 1 auto;
  }

  /* UX-025: Market/Inventory/Bestiary/Stats rows all reuse .market-meta for
     the price/qty/reward figure next to a .market-name -- same "important
     stat" tier as .resource-meta (13-14px), since it's the number a player
     is reading the row for. */
  .market-meta {
    color: var(--heading);
    font-size: 13px;
    flex: 0 1 auto;
    min-width: 0; /* BUG-PHONE-SCROLL-001: a long meta line wraps instead of pushing the row past the viewport */
    overflow-wrap: anywhere;
  }

  .market-row.bestiary-row {
    display: grid;
    width: 100%;
    grid-template-columns: minmax(0, 1fr);
    gap: 3px;
  }

  #bestiary-list {
    display: grid;
    gap: 6px;
  }
