/* Top HUD row: the town plaque, the currency and Renewal plaques, Happiness, Demand, and their hover cards.
   Every plaque has one height and a fixed width, so a number that grows never moves its neighbours. Only the town plaque
   sizes to its name. Wide windows keep the row on one line, plaques shrinking a little when it gets tight. Loaded last. */
:root{--plaque-h:74px}

/* The header is its own stacking layer, so its hover cards sit above the left column and the other cards. */
.top{z-index:40}

/* plaques: same height, a lift on hover, a press on click. Keyboard focus (not a click) lifts one too. */
.plaque{transition:transform .12s ease,box-shadow .12s ease}
.plaque:hover,.plaque:focus-visible{transform:translateY(-2px);box-shadow:0 7px 0 var(--ink),0 18px 30px rgba(43,38,32,.24)}
.plaque:active{transform:translateY(2px);box-shadow:0 2px 0 var(--ink),0 6px 12px rgba(43,38,32,.2)}
.plaque:focus-visible{outline:3px solid var(--sky);outline-offset:4px}
.brand,.chip{height:var(--plaque-h);box-sizing:border-box}
.brand{width:fit-content;min-width:232px;max-width:372px;padding:8px 18px 8px 10px;gap:10px;font-size:28px;flex:0 0 auto;transform:rotate(-1.4deg)}
.brand.plaque:hover,.brand.plaque:focus-visible{transform:translateY(-2px) rotate(-1.4deg)}
.brand.plaque:active{transform:translateY(2px) rotate(-1.4deg)}
.chips{gap:10px;flex-wrap:wrap;min-width:0}
.chip{min-width:0;flex:0 1 auto;padding:9px 14px 9px 10px;gap:10px}
.chip .badge{width:40px;height:40px}
.chip .badge svg{width:24px;height:24px}
.chip.res{width:184px}
.chip.ren{width:200px}
.chip.demand{width:250px;height:var(--plaque-h)}
.hpwrap{position:relative;flex:0 1 214px;min-width:0}
.chip.hp{width:100%;cursor:pointer}
.chip .cval{min-width:0;flex:1 1 auto;display:block}
.chip .cval b{white-space:nowrap;overflow:hidden}
/* Renewal and Happiness: the name on the left, the percentage on the right, one meter under both */
.chip.ren .cval b,.chip.hp .cval b{display:flex;justify-content:space-between;align-items:baseline;gap:8px;font-size:17px}
.chip.ren .cval b span,.chip.hp .cval b span{font-size:19px;font-variant-numeric:tabular-nums}
#hppct{display:inline-block;min-width:3ch;text-align:right}
#renewal{display:inline-block;min-width:3ch;text-align:right}
.chip .meter{width:100%;max-width:none}
.chip.ren .meter,.chip.hp .meter{margin-top:7px;height:15px}
.chip.hp .meter i{width:0;background:var(--sky);transition:width .6s ease}
.chip.hp.open>.pop{display:none}
/* one line from this width up, the plaques shrinking a little but never below the point where a number would clip */
@media (min-width:1480px){
  .chips{flex-wrap:nowrap}
  .chip.res{flex-basis:184px;min-width:172px}
  .chip.ren{flex-basis:200px;min-width:190px}
  .hpwrap{min-width:206px}
  .chip.demand{flex-basis:250px;min-width:228px}
}

/* the town plaque: the badge opens the picker, the name renames inline */
.townbadge{width:46px;height:46px;flex:0 0 auto;border-radius:50%;border:2.5px solid var(--ink);padding:0;display:grid;place-items:center;box-shadow:0 2px 0 var(--ink);transition:transform .08s,box-shadow .08s}
.townbadge:active{transform:translateY(2px);box-shadow:0 0 0 var(--ink)}
.townbadge[aria-expanded="true"]{outline:3px solid var(--sky);outline-offset:3px}
.townbadge svg{display:block}
.townname{min-width:0;flex:1 1 auto}
/* a long name steps its type down a little instead of being cut short */
.brand[data-len="mid"] .townnamebtn{font-size:24px}
.brand[data-len="long"] .townnamebtn{font-size:20px}
.townnamebtn{display:block;width:100%;margin:0;padding:2px 6px;border:0;border-radius:10px;background:none;font-family:var(--display);font-weight:800;font-size:28px;font-variation-settings:"SOFT" 100,"WONK" 1;line-height:1.15;text-align:left;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:var(--ink)}
.townnamebtn:hover{background:rgba(43,38,32,.07)}
.townedit{display:block;width:100%;box-sizing:border-box;margin:0;padding:2px 8px;border:2px solid var(--ink);border-radius:10px;background:var(--paper);font-family:var(--display);font-weight:800;font-size:24px;font-variation-settings:"SOFT" 100,"WONK" 1;color:var(--ink)}
.townedit:focus{outline:3px solid var(--sky);outline-offset:2px}

/* hover cards: paper cards under each plaque, shown on hover or keyboard focus */
.pop{position:absolute;top:calc(100% + 14px);left:0;z-index:25;width:296px;max-width:calc(100vw - 32px);padding:14px 16px;box-sizing:border-box;font-size:14px;line-height:1.4;font-weight:600;color:var(--ink);text-align:left;white-space:normal;opacity:0;visibility:hidden;transform:translateY(-6px);transform-origin:top left;transition:opacity .15s ease,transform .15s ease,visibility 0s linear .15s;pointer-events:none;cursor:default}
.pop.end{left:auto;right:0;transform-origin:top right}
.plaque:hover>.pop,.plaque:focus-visible>.pop{opacity:1;visibility:visible;transform:none;transition-delay:.25s,.25s,0s}
.pop:empty{display:none}
.pop h3{margin:0 0 4px;font-family:var(--display);font-weight:800;font-variation-settings:"SOFT" 100,"WONK" 1;font-size:21px;line-height:1.1}
.pc-lead{margin:0 0 10px;font-size:13.5px;color:var(--ink-soft);font-weight:600}
.pc-lead b{color:var(--ink);font-variant-numeric:tabular-nums}
.pr-list{margin:0 0 8px;display:flex;flex-direction:column;gap:5px}
.pr{display:flex;justify-content:space-between;align-items:baseline;gap:12px;font-size:13.5px;font-weight:700;padding-bottom:4px;border-bottom:1.5px dashed rgba(43,38,32,.22)}
.pr dt{margin:0;color:var(--ink-soft);font-weight:700}
.pr dd{margin:0;white-space:nowrap;font-variant-numeric:tabular-nums}
.pc-note{margin:6px 0 0;font-size:13px;font-weight:700;color:var(--sky-ink)}
.pc-next{display:grid;gap:2px;margin-top:10px;padding:9px 11px;border-radius:12px;background:var(--paper-2);border:2px solid var(--ink)}
.pc-next span{font-size:11.5px;font-weight:800;color:var(--ink-soft);text-transform:uppercase;letter-spacing:.07em}
.pc-next b{font-size:15px;font-weight:800;line-height:1.25}
.pc-next small{font-size:12.5px;color:var(--ink-soft);font-weight:600;font-variant-numeric:tabular-nums}
.pc-foot{margin:9px 0 0;font-size:12.5px;color:var(--ink-soft);font-weight:600;font-variant-numeric:tabular-nums}
.dr{display:grid;grid-template-columns:26px minmax(0,1fr);gap:10px;align-items:start;padding:7px 0;border-bottom:1.5px dashed rgba(43,38,32,.22)}
.dr:last-child{border-bottom:0}
.dr .dk{width:26px;height:26px;border-radius:50%;border:2px solid var(--ink);display:grid;place-items:center;font-family:var(--display);font-size:14px;font-weight:800;line-height:1;color:var(--ink)}
.dr b{display:flex;justify-content:space-between;gap:10px;font-size:14.5px;font-weight:800}
.dr em{font-style:normal;font-variant-numeric:tabular-nums}
.dr small{display:block;margin-top:2px;font-size:12.5px;color:var(--ink-soft);font-weight:600}

/* the badge picker: eight icons and six colours under the town plaque */
.townpick{position:absolute;top:calc(var(--hud-bottom,108px) + 12px);left:var(--gutter);z-index:30;width:276px;max-width:calc(100vw - 32px);padding:14px 14px 16px;box-sizing:border-box}
.townpick h3{margin:0 0 10px;font-family:var(--display);font-weight:800;font-variation-settings:"SOFT" 100,"WONK" 1;font-size:21px;line-height:1.1}
.tp-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:8px}
.tp-ic{aspect-ratio:1;display:grid;place-items:center;padding:0;border-radius:14px;border:2.5px solid var(--ink);background:var(--paper-2);box-shadow:0 3px 0 var(--ink);transition:transform .08s,box-shadow .08s}
.tp-ic:hover{transform:translateY(-2px)}
.tp-ic:active,.tp-ic[aria-pressed="true"]{transform:translateY(2px);box-shadow:0 1px 0 var(--ink)}
.tp-ic[aria-pressed="true"]{background:#FBE4B8}
.tp-sw{display:flex;gap:10px;margin-top:12px;flex-wrap:wrap}
.tp-col{width:32px;height:32px;padding:0;border-radius:50%;border:2.5px solid var(--ink);box-shadow:0 2px 0 var(--ink);transition:transform .08s}
.tp-col:active{transform:translateY(2px);box-shadow:none}
.tp-col[aria-pressed="true"]{outline:3px solid var(--action);outline-offset:2px}

@media (prefers-reduced-motion:reduce){.plaque,.pop,.townbadge,.tp-ic,.tp-col{transition:none!important}}
