/* Legends of Abbedorp — a shared valley.
   Pixel-serif headings, rice-paper panels, lacquered wood and vermilion. */

@font-face {
  font-family: "Pixelify Sans";
  src: url("/static/PixelifySans-Regular.ttf") format("truetype");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Pixelify Sans";
  src: url("/static/PixelifySans-SemiBold.ttf") format("truetype");
  font-weight: 600;
  font-display: swap;
}
@font-face {
  font-family: "Pixelify Sans";
  src: url("/static/PixelifySans-Bold.ttf") format("truetype");
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: "Silkscreen";
  src: url("/static/Silkscreen-Regular.ttf") format("truetype");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Silkscreen";
  src: url("/static/Silkscreen-Bold.ttf") format("truetype");
  font-weight: 700;
  font-display: swap;
}
/* Figures: digits and the signs beside them, and nothing else. Pixelify Sans
   draws a 5 whose top is pixel-identical to its 8, which turns a large "+15%"
   into "+18%". Silkscreen's 5 is open on the top right. The family is limited
   by unicode-range so a "%", unit or slash still falls through to the display
   face — Silkscreen's own percent mark is a tiny unreadable block. The Regular
   cut is registered at 700 on purpose: readouts are bold, and the Bold cut at
   the same size is heavy enough to wrap the text beside it. */
@font-face {
  font-family: "Abbedorp Figures";
  src: url("/static/Silkscreen-Regular.ttf") format("truetype");
  font-weight: 700;
  font-display: swap;
  unicode-range: U+002B, U+002D, U+002E, U+002C, U+0030-0039;
}

:root {
  color-scheme: dark;
  --font-display: "Pixelify Sans", "Trebuchet MS", sans-serif;
  --font-pixel: "Silkscreen", "__MESSENGER_FONT__", monospace;
  /* Standalone figures. Pixelify Sans draws its 5 with a closed top that is
     pixel-identical to its 8, so a large "+15%" can read as "+18%". The
     Abbedorp Figures face (above) swaps only the digits; words and the "%"
     stay in --font-display. */
  --font-figure: "Abbedorp Figures", "Pixelify Sans", "Trebuchet MS", sans-serif;
  --font-body: "Segoe UI", "Trebuchet MS", sans-serif;
  --ink: #262019;
  --ink-soft: #534737;
  --paper: #f2e3c2;
  --paper-light: #fbf2d9;
  --paper-deep: #ddc691;
  --night: #151c20;
  --wood: #2e2119;
  --wood-light: #4b3524;
  --teal: #286d6c;
  --teal-dark: #164246;
  --vermilion: #c94a31;
  --vermilion-dark: #8e2b20;
  --gold: #e8b94f;
  --gold-dark: #a97b24;
  --moss: #738046;
  --cream: #fff3d5;
  --shadow: 0 18px 50px rgba(8, 13, 13, .34);
  --pixel-shadow: 0 2px 0 rgba(46, 32, 20, .25);
  /* The phone navbar's size preference (50%-150%). The editor writes this on
     :root; 1 keeps every screen at its shipped 100% shape without JavaScript. */
  --nav-button-scale: 1;
  /* Only the page behind a pinned status bar fades; the box itself is the same
     opaque paper as every other category box. The scrim starts clear and
     deepens into the page's teal, so content scrolling under the bar dissolves
     instead of ending at a hard edge. */
  --tab-status-scrim: linear-gradient(180deg, rgba(9, 23, 22, 0) 0%, rgba(9, 23, 22, .58) 100%);
  /* The gap above and below each status box; the workshop's phone strips reuse
     it to mask the page scrolling behind their pinned bench. */
  --tab-status-backdrop: linear-gradient(160deg, rgba(29, 70, 66, .2) 0%, rgba(20, 47, 45, .2) 100%);
}

*,
*::before,
*::after { box-sizing: border-box; }

[hidden] { display: none !important; }

html {
  height: 100%;
  -webkit-text-size-adjust: 100%;
}

html,
body {
  margin: 0;
}

body {
  min-height: 100%;
  overflow: hidden;
  background: #1b2727;
  color: var(--ink);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

h1, h2, h3, p { margin: 0; }

svg { display: block; }

/* ------------------------------------------------------------------ */
/* Login                                                              */
/* ------------------------------------------------------------------ */

.login-screen {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(390px, .8fr);
  background: #1c2826;
  overflow: hidden;
}

/* The page puts this class on <html> before the gate markup is parsed. A saved
   session opens on the camera, so the sign-in columns must never paint for a
   frame while the module graph is still on its way. playIntro(), revealGate()
   and the startup watchdog remove the class once the path is known; without
   JavaScript the class is never added and the form stays usable. */
html.gate-booting .login-screen {
  visibility: hidden;
}
html.gate-booting body {
  background: #020508;
}

.login-hero {
  position: relative;
  grid-column: 1;
  grid-row: 1;
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
  isolation: isolate;
  background: #27322e;
}

.hero-sky {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, #24333a 0%, #6b5d55 32%, #c37b58 62%, #e7a364 78%, #2a3330 100%);
}

.hero-sky::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: .17;
  background-image:
    linear-gradient(90deg, rgba(255,255,255,.22) 1px, transparent 1px),
    linear-gradient(0deg, rgba(24,21,18,.45) 1px, transparent 1px);
  background-size: 7px 7px;
  mix-blend-mode: overlay;
  pointer-events: none;
}

.hero-sun {
  position: absolute;
  left: 17%;
  top: 13%;
  width: clamp(110px, 14vw, 188px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: #f4c477;
  box-shadow:
    0 0 0 9px rgba(244, 196, 119, .12),
    0 0 70px 20px rgba(240, 155, 105, .32);
}

.hero-sun::after {
  content: "";
  position: absolute;
  inset: 30%;
  background: linear-gradient(180deg, transparent 46%, #d7875d 47%, #d7875d 53%, transparent 54%);
  opacity: .8;
}

.hero-sun { animation: hero-sun-breathe 9s ease-in-out infinite alternate; }

@keyframes hero-sun-breathe {
  from { transform: scale(1); filter: brightness(1); }
  to { transform: scale(1.015); filter: brightness(1.06); }
}

.cloud {
  position: absolute;
  height: 20px;
  background: rgba(244, 214, 178, .44);
  box-shadow:
    30px -12px 0 rgba(244, 214, 178, .34),
    63px 4px 0 rgba(244, 214, 178, .38),
    98px -7px 0 rgba(244, 214, 178, .24);
  opacity: .8;
  animation: hero-cloud-drift var(--cloud-drift, 38s) ease-in-out infinite alternate;
}
.cloud-a { width: 85px; left: 43%; top: 18%; --cloud-drift: 28s; }
.cloud-b { width: 58px; left: 9%; top: 31%; --cloud-scale: .8; --cloud-drift: 41s; opacity: .55; }
.cloud-c { width: 110px; right: 5%; top: 12%; --cloud-scale: .65; --cloud-drift: 34s; opacity: .48; }

@keyframes hero-cloud-drift {
  from { transform: translate3d(-7%, 0, 0) scale(var(--cloud-scale, 1)); }
  to { transform: translate3d(8%, -4%, 0) scale(var(--cloud-scale, 1)); }
}

.hero-ridge {
  position: absolute;
  left: -8%;
  right: -8%;
  bottom: 0;
  height: 62%;
  clip-path: polygon(0 68%, 8% 58%, 16% 64%, 26% 38%, 38% 55%, 48% 28%, 58% 53%, 68% 41%, 79% 60%, 89% 46%, 100% 59%, 100% 100%, 0 100%);
}

.ridge-far {
  height: 65%;
  background: #39504d;
  opacity: .6;
  transform: translateY(8%);
}
.ridge-mid {
  height: 52%;
  background: #263e3c;
  clip-path: polygon(0 76%, 10% 63%, 20% 70%, 30% 47%, 41% 65%, 55% 42%, 68% 64%, 82% 50%, 93% 69%, 100% 60%, 100% 100%, 0 100%);
}
.ridge-near {
  height: 38%;
  background: #172826;
  clip-path: polygon(0 80%, 12% 66%, 26% 76%, 42% 55%, 55% 75%, 70% 62%, 85% 78%, 100% 66%, 100% 100%, 0 100%);
}

/* Slow valley mist between the ridges keeps the painted landscape alive
   without moving the skyline itself. */
.hero-mist {
  position: absolute;
  left: -14%;
  right: -14%;
  height: 24%;
  z-index: 0;
  border-radius: 50%;
  background: radial-gradient(ellipse at 50% 50%, rgba(228, 203, 166, .22), transparent 68%);
  filter: blur(13px);
  pointer-events: none;
  animation: hero-mist-drift var(--mist-drift, 24s) ease-in-out infinite alternate;
}
.mist-a { bottom: 27%; }
.mist-b { bottom: 14%; --mist-drift: 31s; opacity: .7; animation-delay: -9s; }

@keyframes hero-mist-drift {
  from { transform: translate3d(-3%, 0, 0) scaleX(1); }
  to { transform: translate3d(3%, -2%, 0) scaleX(1.12); }
}

.hero-pines {
  position: absolute;
  bottom: 9%;
  width: 170px;
  height: 260px;
  opacity: .9;
  transform-origin: 50% 100%;
  background:
    linear-gradient(90deg, transparent 46%, #12201e 47%, #12201e 53%, transparent 54%),
    repeating-linear-gradient(150deg, transparent 0 24px, #162724 25px 32px);
  clip-path: polygon(46% 0, 62% 22%, 56% 22%, 76% 46%, 64% 46%, 83% 66%, 58% 66%, 58% 100%, 42% 100%, 42% 66%, 17% 66%, 36% 46%, 24% 46%, 44% 22%, 38% 22%);
  animation: hero-pine-sway 11s ease-in-out infinite alternate;
}
.pines-left { left: 4%; --pine-scale: 1.15; animation-delay: -3s; }
.pines-right { right: 3%; --pine-scale: .9; opacity: .72; animation-delay: -7s; }

@keyframes hero-pine-sway {
  from { transform: scale(var(--pine-scale, 1)) rotate(-.35deg); }
  to { transform: scale(var(--pine-scale, 1)) rotate(.35deg); }
}

.hero-village {
  position: absolute;
  left: 50%;
  bottom: 6%;
  width: min(72%, 520px);
  height: 160px;
  transform: translateX(-50%);
  opacity: .95;
}
.roof {
  position: absolute;
  bottom: 16px;
  width: 110px;
  height: 58px;
  background: #1b2422;
  clip-path: polygon(50% 0, 100% 70%, 88% 70%, 88% 100%, 12% 100%, 12% 70%, 0 70%);
  filter: drop-shadow(0 5px 0 rgba(7, 12, 11, .35));
}
.roof::after {
  content: "";
  position: absolute;
  left: 18%;
  right: 18%;
  top: 68%;
  height: 3px;
  background: rgba(224, 154, 92, .48);
  animation: roof-glow 5.5s ease-in-out infinite alternate;
}

@keyframes roof-glow {
  from { opacity: .5; }
  to { opacity: 1; }
}
.roof-a { left: 3%; transform: scale(.76) translateY(8px); }
.roof-b { left: 22%; transform: scale(1.05); }
.roof-c { right: 23%; transform: scale(.86) translateY(17px); }
.roof-d { right: 1%; transform: scale(.62) translateY(30px); }

.torii {
  position: absolute;
  left: 48%;
  bottom: 0;
  width: 74px;
  height: 104px;
  border-top: 15px solid #211a16;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
}
.torii::before,
.torii::after {
  content: "";
  position: absolute;
  top: -15px;
  width: 8px;
  height: 104px;
  background: #211a16;
}
.torii::before { left: 8px; }
.torii::after { right: 8px; }

.firefly {
  position: absolute;
  width: 4px;
  height: 4px;
  background: #f3cd75;
  box-shadow: 0 0 9px 2px rgba(243, 205, 117, .7);
  animation: drift 6s ease-in-out infinite alternate;
}
.f1 { left: 32%; top: 59%; animation-delay: -1s; }
.f2 { left: 67%; top: 51%; animation-delay: -2.7s; }
.f3 { left: 76%; top: 68%; animation-delay: -4s; }
.f4 { left: 21%; top: 73%; animation-delay: -.5s; }
.f5 { left: 54%; top: 45%; animation-delay: -3.3s; }

@keyframes drift {
  0% { transform: translate3d(0, 0, 0); opacity: .35; }
  50% { opacity: 1; }
  100% { transform: translate3d(17px, -28px, 0); opacity: .5; }
}

.hero-copy {
  position: absolute;
  z-index: 2;
  left: clamp(28px, 5vw, 80px);
  bottom: clamp(118px, 16vh, 190px);
  max-width: 610px;
  color: var(--cream);
  text-shadow: 0 3px 0 rgba(20, 28, 26, .4);
}

.hero-kicker,
.eyebrow {
  font-family: var(--font-pixel);
  font-size: 10px;
  letter-spacing: .16em;
  text-transform: uppercase;
}

.hero-kicker { color: #f1c579; margin-bottom: 14px; }

.hero-title {
  font-family: var(--font-display);
  font-size: clamp(54px, 7.4vw, 112px);
  font-weight: 700;
  line-height: .9;
  letter-spacing: -.04em;
  color: #fff3d4;
  text-shadow:
    0 4px 0 #6c3324,
    0 9px 0 rgba(17, 27, 24, .3);
}

.hero-tagline {
  max-width: 460px;
  margin-top: 24px;
  font-size: clamp(15px, 1.4vw, 19px);
  line-height: 1.5;
  color: #ede1c5;
}

.hero-foot {
  position: absolute;
  z-index: 2;
  left: clamp(28px, 5vw, 80px);
  right: clamp(28px, 5vw, 80px);
  bottom: clamp(26px, 4vh, 46px);
  display: flex;
  justify-content: space-between;
  gap: 16px;
  color: #b9ae93;
  font-family: var(--font-pixel);
  font-size: 10px;
  letter-spacing: .1em;
}

.hero-live {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.hero-live i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #8fcb84;
  box-shadow: 0 0 0 3px rgba(143, 203, 132, .13);
}

/* ------------------------------------------------------------------ */
/* Login intro — the camera falls out of deep space into the valley    */
/* ------------------------------------------------------------------ */

/* A fixed proscenium in front of the gate. While it is up, the real hero is
   lifted above it and flown in from a distant marble, so the last frame of
   the intro is the actual wallpaper rather than a copy that has to match it.
   The login panel and the village register wait below the space layer and
   fade in once the valley has arrived. */
.login-intro {
  position: fixed;
  inset: 0;
  /* Above the app chrome: a saved session paints its village underneath this
     layer, and the camera must stay in front until the hand-off is complete. */
  z-index: 200;
  overflow: hidden;
  isolation: isolate;
  /* Transparent on purpose: the space layer below is the only thing hiding the
     real gate, so it can dissolve directly into the valley instead of fading
     a dark veil over a landscape that is already in place. */
  background: transparent;
  pointer-events: none;
  contain: layout paint;
}

.login-intro .intro-skip { pointer-events: auto; }

body.intro-playing { overflow: hidden !important; background: #020508; }

.intro-nebula {
  position: absolute;
  inset: -28%;
  pointer-events: none;
  opacity: .58;
  background:
    radial-gradient(ellipse 38% 30% at 31% 38%, rgba(46, 109, 108, .34), transparent 70%),
    radial-gradient(ellipse 30% 24% at 73% 61%, rgba(201, 74, 49, .16), transparent 72%),
    radial-gradient(ellipse 46% 34% at 58% 22%, rgba(232, 185, 79, .1), transparent 70%);
  filter: blur(12px);
  animation: intro-nebula-drift 16s ease-in-out infinite alternate;
}

@keyframes intro-nebula-drift {
  from { transform: translate3d(-2%, -1%, 0) scale(1); }
  to { transform: translate3d(2%, 2%, 0) scale(1.08); }
}

.intro-stars {
  position: absolute;
  inset: -12%;
  pointer-events: none;
  will-change: transform, opacity;
}

.intro-stars i {
  position: absolute;
  display: block;
  border-radius: 50%;
  background: #fff;
  opacity: var(--star-opacity, .8);
  box-shadow: 0 0 5px rgba(255, 249, 226, .55);
  animation: intro-twinkle var(--star-twinkle, 1s) ease-in-out infinite alternate;
}

.intro-stars-far i { background: #dfe9e2; }
.intro-stars-near i { background: #fff6dd; }

/* The camera: deep space, a drawn planet, a cloud deck, then the polder
   below. The space layer owns the opaque sky so the proscenium itself can be
   transparent. */
.intro-space {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  will-change: transform, opacity;
  background-image:
    radial-gradient(1px 1px at 20% 30%, rgba(255, 255, 255, .9), transparent),
    radial-gradient(1px 1px at 71% 64%, rgba(255, 255, 255, .72), transparent),
    radial-gradient(1.4px 1.4px at 44% 82%, rgba(255, 246, 221, .85), transparent),
    radial-gradient(circle at 50% 47%, #17363b 0%, #0b1a20 32%, #05090d 70%, #020508 100%);
  background-size: 340px 340px, 470px 470px, 610px 610px, auto;
}

.intro-horizon {
  position: absolute;
  left: -12%;
  right: -12%;
  bottom: -34%;
  height: 72%;
  border-radius: 50%;
  background:
    radial-gradient(ellipse at 50% 100%, rgba(41, 92, 123, .46), transparent 62%),
    radial-gradient(ellipse at 50% 100%, rgba(8, 17, 28, .9), transparent 72%);
  filter: blur(18px);
  opacity: .9;
}

.intro-earth-wrap {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: grid;
  place-items: center;
  pointer-events: none;
}

.intro-earth-body {
  position: relative;
  /* Keep the marble a constant share of the viewport's short edge. The old
     940px cap made the same globe look stranded on a 1440p screen. */
  width: min(82vmin, 1400px);
  aspect-ratio: 1;
  transform-origin: 50% 50%;
  opacity: 0;
  transform: scale(.12);
  will-change: transform, opacity;
}

.intro-earth {
  position: absolute;
  inset: 0;
  z-index: 2;
}

.intro-globe {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
  user-select: none;
}

/* The drawn world turns under the camera. Two identical map tiles sit side by
   side and the track slides one tile; the circular clip is the horizon. */
.intro-globe-land-track {
  animation: intro-globe-drift 46s linear infinite;
}
.intro-globe-cloud-track {
  animation: intro-globe-drift 29s linear infinite;
  opacity: .9;
}
@keyframes intro-globe-drift {
  from { transform: translateX(0); }
  to { transform: translateX(-1000px); }
}

.intro-earth-glow {
  position: absolute;
  z-index: 1;
  inset: 1%;
  border-radius: 50%;
  background:
    radial-gradient(circle at 34% 28%, rgba(255, 228, 174, .27), transparent 34%),
    radial-gradient(circle at 68% 74%, rgba(22, 70, 71, .38), transparent 62%);
  box-shadow:
    0 0 30px 8px rgba(236, 182, 116, .2),
    0 0 98px 32px rgba(65, 111, 99, .15),
    inset -20px -24px 58px rgba(1, 9, 11, .58);
  filter: blur(2px);
}

/* Cloud decks stay within a modest multiple of the viewport. A filtered layer
   much larger than the screen can exceed the compositor's texture limit,
   which carved the bank into visible rectangular bands; the deck is now a
   viewport-relative layer with gradient-only puffs, so it has no large blur
   surfaces to clip and costs almost nothing to composite. */
.intro-cloud-layer {
  position: absolute;
  inset: -8%;
  z-index: 2;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  will-change: transform, opacity;
  background:
    radial-gradient(ellipse 58% 32% at 26% 32%, rgba(255, 244, 224, .62), transparent 72%),
    radial-gradient(ellipse 64% 34% at 76% 56%, rgba(236, 210, 184, .5), transparent 76%),
    radial-gradient(ellipse 50% 26% at 51% 16%, rgba(217, 226, 211, .4), transparent 72%);
}

.intro-cloud-back { z-index: 2; }
.intro-cloud-front { z-index: 4; background-position: 4% 8%; }

/* Generated puffs give the deck structure; each is a soft radial pearl with a
   little drift of its own, so the banks move even while the camera holds.
   The falloff is painted into the gradient rather than applied with a blur:
   that keeps the edge vapour-soft at every resolution and avoids a stack of
   expensive filtered layers on a 1440p screen. */
.intro-puff {
  position: absolute;
  display: block;
  border-radius: 50%;
  background:
    radial-gradient(ellipse at 42% 36%,
      rgba(255, 251, 239, var(--puff-light, .86)) 0%,
      rgba(249, 234, 213, .56) 24%,
      rgba(224, 214, 199, .26) 52%,
      rgba(161, 180, 172, .08) 76%,
      transparent 100%);
  opacity: var(--puff-opacity, .72);
  animation: intro-puff-drift var(--puff-time, 9s) ease-in-out infinite alternate;
  animation-delay: var(--puff-delay, 0s);
}

@keyframes intro-puff-drift {
  from { transform: translate3d(-2.5%, 0, 0) scale(.97); }
  to { transform: translate3d(2.5%, -2%, 0) scale(1.07); }
}

.intro-whiteout {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  opacity: 0;
  background:
    radial-gradient(circle at 50% 44%, rgba(255, 255, 255, .96) 0%, rgba(202, 227, 235, .82) 34%, rgba(89, 144, 171, .32) 68%, transparent 100%),
    linear-gradient(180deg, rgba(219, 239, 245, .58), rgba(152, 192, 207, .28));
  mix-blend-mode: screen;
  will-change: opacity;
}

.intro-warmth {
  position: absolute;
  inset: 0;
  z-index: 6;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 40% 38%, rgba(232, 170, 104, .38), transparent 56%),
    linear-gradient(180deg, rgba(51, 68, 71, .22), rgba(180, 100, 62, .16));
  opacity: 0;
  will-change: opacity;
}

.intro-vignette {
  position: absolute;
  inset: 0;
  z-index: 7;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 50% 48%, transparent 44%, rgba(2, 6, 10, .32) 78%, rgba(1, 4, 7, .68) 100%),
    linear-gradient(180deg, rgba(2, 8, 12, .18), transparent 22%, transparent 74%, rgba(2, 7, 10, .25));
}

.intro-vignette::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: .035;
  background-image:
    linear-gradient(90deg, rgba(255, 255, 255, .28) 1px, transparent 1px),
    linear-gradient(0deg, rgba(0, 0, 0, .32) 1px, transparent 1px);
  background-size: 6px 6px;
  mix-blend-mode: overlay;
}

@keyframes intro-twinkle {
  from { opacity: .18; }
  to { opacity: 1; }
}

.intro-caption {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(50% + 170px);
  z-index: 12;
  display: grid;
  justify-items: center;
  gap: 7px;
  opacity: 0;
  pointer-events: none;
  text-align: center;
  text-shadow: 0 2px 0 rgba(3, 8, 8, .5);
}

/* Before the module graph starts the camera, the caption is the only label on
   the loading starfield; the intro animation takes over the moment it begins. */
.login-intro:not([hidden]) .intro-caption { opacity: 1; }

/* A slow module download used to show an empty sky and then pop the marble in
   at the exact moment the zoom started, which read as a half-loaded intro.
   The finished globe is now placed on the starfield first, at rest, and the
   camera's first keyframe repeats this pose, so the fall begins from a drawn
   world rather than fading one in while it is still being painted. */
.login-intro.is-ready .intro-earth-body {
  opacity: 1;
  transform: scale(.13) rotate(-2deg);
  transition: opacity .3s ease;
}

.intro-caption span {
  color: #e8b94f;
  font-family: var(--font-pixel);
  font-size: 11px;
  letter-spacing: .3em;
}

.intro-caption em {
  color: #c3d0c7;
  font-family: var(--font-body);
  font-style: normal;
  font-size: 14px;
  letter-spacing: .04em;
}

.intro-skip {
  position: absolute;
  right: clamp(18px, 3vw, 34px);
  bottom: clamp(18px, 3vw, 30px);
  z-index: 20;
  min-height: 34px;
  padding: 8px 13px;
  border: 1px solid rgba(232, 185, 79, .38);
  border-radius: 2px;
  background: rgba(8, 17, 18, .58);
  color: #e7d5ac;
  font-family: var(--font-pixel);
  font-size: 9px;
  letter-spacing: .12em;
  text-transform: uppercase;
  cursor: pointer;
  backdrop-filter: blur(4px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: border-color .15s ease, color .15s ease, background .15s ease, opacity .2s ease;
}

.login-intro.is-ready .intro-skip {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.intro-skip:hover,
.intro-skip:focus-visible {
  border-color: rgba(232, 185, 79, .88);
  background: rgba(14, 28, 29, .82);
  color: #fff3d4;
}

.intro-skip span { margin-left: 4px; font-family: var(--font-body); font-size: 15px; }

/* A saved session can outlast the camera on a slow connection. The last frame
   holds the valley wash; this line says the wait is the village loading, not a
   stalled page, and the login form stays hidden underneath. */
.intro-status {
  position: absolute;
  left: 50%;
  bottom: clamp(112px, 20vh, 210px);
  z-index: 20;
  transform: translateX(-50%);
  margin: 0;
  padding: 9px 15px;
  border: 1px solid rgba(232, 185, 79, .3);
  border-radius: 2px;
  background: rgba(8, 17, 18, .6);
  color: #e7d5ac;
  font-family: var(--font-pixel);
  font-size: 9px;
  letter-spacing: .14em;
  text-align: center;
  text-transform: uppercase;
  pointer-events: none;
  backdrop-filter: blur(4px);
  animation: intro-status-breathe 1.8s ease-in-out infinite alternate;
}

@keyframes intro-status-breathe {
  from { opacity: .55; }
  to { opacity: 1; }
}

/* While the camera is still above the valley, the gate's own columns must not
   show through the thinning cloud deck. A full-bleed dusk wash stands in for
   the ground until the painted hero and the panel fade up together. */
.login-screen.is-intro {
  background:
    radial-gradient(circle at 24% 22%, rgba(244, 196, 119, .28), transparent 40%),
    linear-gradient(180deg, #24333a 0%, #6b5d55 32%, #c37b58 62%, #e7a364 78%, #2a3330 100%);
}

/* The real wallpaper is already in its frame behind the proscenium. The
   camera lands on that exact frame, so only the overlay is faded away. */
.login-screen.is-intro .login-hero {
  z-index: 1;
  opacity: 0;
}

.login-screen.is-booting .auth-panel,
.login-screen.is-booting .auth-card,
.login-screen.is-booting .main-menu-box,
.login-screen.is-booting .login-rankings {
  opacity: 0;
  visibility: hidden;
}

.login-screen.is-intro .auth-panel,
.login-screen.is-intro .hero-copy,
.login-screen.is-intro .hero-foot,
.login-screen.is-intro .auth-card,
.login-screen.is-intro .main-menu-box,
.login-screen.is-intro .auth-credit,
.login-screen.is-intro .login-rankings {
  opacity: 0;
  pointer-events: none;
}

@media (max-width: 860px) {
  /* The stacked layout's hero is only the top third of the page. While the
     camera is above it, continue the dark near ridge below that band instead
     of showing an unrelated dusk wash under the fold. */
  .login-screen.is-intro {
    background: linear-gradient(180deg, #172826 0 36vh, #0f1b19 100%);
  }
  .intro-caption { top: calc(50% + 120px); }
  .intro-caption span { font-size: 9px; letter-spacing: .22em; }
  .intro-caption em { display: none; }
  .intro-skip { right: 14px; bottom: 14px; }
  .intro-earth-body { width: min(96vmin, 720px); }
  .intro-earth-glow { box-shadow: 0 0 26px 8px rgba(236, 182, 116, .22), 0 0 90px 30px rgba(65, 111, 99, .16); }
  .intro-cloud-layer { inset: -10%; }
}

.auth-panel {
  position: relative;
  grid-column: 2;
  grid-row: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  /* A tall register card (the tribe banners add height) must not overflow the
     top of a centered panel, where it could never be scrolled back into view.
     `safe` keeps the card centered while it fits and starts it at the top when
     it does not. */
  justify-content: center;
  justify-content: safe center;
  padding: 36px clamp(24px, 4vw, 58px);
  background:
    radial-gradient(circle at 78% 15%, rgba(210, 156, 72, .13), transparent 34%),
    linear-gradient(145deg, #1d2927, #111a19 72%);
  border-left: 1px solid rgba(232, 185, 79, .2);
  overflow-y: auto;
}

.auth-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: .19;
  pointer-events: none;
  background-image:
    linear-gradient(45deg, rgba(235, 221, 184, .22) 1px, transparent 1px),
    linear-gradient(-45deg, rgba(235, 221, 184, .12) 1px, transparent 1px);
  background-size: 22px 22px;
}

.auth-card {
  position: relative;
  z-index: 1;
  width: min(100%, 438px);
  padding: clamp(26px, 4vw, 44px);
  background:
    linear-gradient(rgba(255, 247, 224, .56), rgba(255, 247, 224, .2)),
    repeating-linear-gradient(0deg, #f2e3c2 0 3px, #f5e9cd 3px 6px);
  border: 1px solid #b49762;
  box-shadow:
    0 0 0 7px #2b2119,
    0 0 0 8px #6e5536,
    0 28px 70px rgba(0, 0, 0, .48);
  color: var(--ink);
}

.auth-card::before,
.auth-card::after {
  content: "";
  position: absolute;
  width: 22px;
  height: 22px;
  border-color: #9a7537;
  border-style: solid;
}
.auth-card::before { left: 9px; top: 9px; border-width: 2px 0 0 2px; }
.auth-card::after { right: 9px; bottom: 9px; border-width: 0 2px 2px 0; }

.auth-back {
  position: absolute;
  top: 16px;
  right: 17px;
  z-index: 1;
  padding: 0;
  border: 0;
  background: none;
  color: #7d6747;
  font-family: var(--font-pixel);
  font-size: 8px;
  letter-spacing: .08em;
  text-decoration: none;
  text-transform: uppercase;
  cursor: pointer;
}
.auth-back:hover { color: #4d3a22; }

/* The Main menu box sits in the auth card's slot. It is a .panel so it keeps
   the same paper, border, shadow and padding tokens as every game box; only the
   wider frame and the valley rows are local. */
.main-menu-box.panel {
  position: relative;
  z-index: 1;
  width: min(100%, 438px);
  color: var(--ink);
  box-shadow:
    var(--ui-box-shadow),
    0 28px 70px rgba(0, 0, 0, .48);
}
.main-menu-box[hidden] { display: none; }
.main-menu-box [hidden] { display: none; }

.main-menu-kicker {
  margin: 0 0 9px;
  color: #8f6839;
  font-family: var(--font-pixel);
  font-size: 10px;
  letter-spacing: .12em;
  text-transform: uppercase;
}

#main-menu-title {
  margin: 0;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: clamp(31px, 3vw, 40px);
  font-weight: 700;
  line-height: .98;
  letter-spacing: -.02em;
}

.main-menu-summary {
  margin-top: 9px;
  color: #6f5c41;
  font-size: 13px;
  line-height: 1.45;
}

.main-menu-notice {
  margin-top: 13px;
  padding: 9px 11px;
  border: 1px solid #b4935c;
  border-left: 4px solid #a6412d;
  background: rgba(255, 250, 235, .6);
  color: #6b5537;
  font-size: 12px;
  line-height: 1.45;
}
.main-menu-notice[hidden] { display: none; }
.main-menu-notice.is-good { border-left-color: #527a58; }

.main-menu-servers {
  display: flex;
  flex-direction: column;
  gap: 9px;
  max-height: min(38vh, 330px);
  margin-top: 16px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.main-menu-server {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 11px;
  border: 1px solid #b99d6d;
  border-radius: 2px;
  background: rgba(255, 249, 233, .55);
  color: #3d2d1b;
  text-align: left;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.main-menu-server:hover { background: rgba(255, 249, 233, .9); }
.main-menu-server.is-selected {
  border-color: #8c5f2f;
  background: rgba(255, 249, 233, .94);
  box-shadow: inset 0 0 0 2px rgba(140, 95, 47, .22);
}
.main-menu-server.is-planned { opacity: .58; cursor: not-allowed; }
.main-menu-server.is-closed { opacity: .68; cursor: not-allowed; }

.main-menu-server-mark {
  width: 13px;
  height: 13px;
  transform: rotate(45deg);
  border: 1px solid #8f703f;
  background: #c94a31;
  box-shadow: inset 0 0 0 3px #f2e3c2;
}

.main-menu-server-copy {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.main-menu-server-name {
  display: flex;
  align-items: center;
  gap: 7px;
  color: #3d2d1b;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  line-height: 1.05;
}
.main-menu-server-home {
  padding: 1px 4px;
  border: 1px solid #b4935c;
  background: rgba(226, 203, 153, .45);
  color: #806a46;
  font-family: var(--font-pixel);
  font-size: 7px;
  font-weight: 400;
  letter-spacing: .03em;
  text-transform: uppercase;
}
.main-menu-server-desc {
  color: #7d6747;
  font-size: 11.5px;
  line-height: 1.35;
}
.main-menu-server-when {
  color: #8f6839;
  font-family: var(--font-pixel);
  font-size: 8px;
  letter-spacing: .02em;
  line-height: 1.4;
}
.main-menu-server-stats {
  color: #6b563c;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.35;
}
.main-menu-server-badge {
  flex: 0 0 auto;
  padding: 2px 5px;
  border: 1px solid #b4935c;
  background: rgba(226, 203, 153, .45);
  color: #806a46;
  font-family: var(--font-pixel);
  font-size: 8px;
  letter-spacing: .02em;
  white-space: nowrap;
}
.main-menu-server.is-selected .main-menu-server-badge {
  border-color: #8c5f2f;
  background: #c94a31;
  color: #fff4dd;
}

.main-menu-empty {
  margin: 0;
  padding: 12px;
  color: #7d6747;
  font-size: 12px;
  text-align: center;
}
.main-menu-empty.is-error { color: #9c3222; }

.main-menu-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 18px;
}
/* A paused tutorial is a whole menu-level choice, so its way back sits above
   the world list instead of below it. */
.main-menu-resume {
  width: 100%;
  margin-top: 14px;
  font-size: 18px;
}
.main-menu-actions .auth-switch {
  min-height: 46px;
  margin-top: 0;
  font-size: 16px;
}
.main-menu-actions .auth-submit { font-size: 18px; }
.main-menu-actions .auth-submit:disabled { cursor: not-allowed; }

.auth-mark {
  position: relative;
  width: 44px;
  height: 44px;
  margin-bottom: 20px;
  transform: rotate(45deg);
  border: 2px solid #6c4e2a;
  background: #c94a31;
  box-shadow: inset 0 0 0 4px #f2e3c2, inset 0 0 0 5px #9e3726;
}
.auth-mark::before {
  content: "";
  position: absolute;
  inset: 13px;
  background: #f6e7c7;
}
.mark-roof, .mark-gate { display: none; }

.auth-heading .eyebrow { color: #8f6839; margin-bottom: 10px; }

.auth-heading h2 {
  font-family: var(--font-display);
  font-size: clamp(33px, 3.2vw, 44px);
  font-weight: 700;
  line-height: .98;
  letter-spacing: -.02em;
}

.auth-heading p:last-child {
  margin-top: 10px;
  color: #6f5c41;
  font-size: 14px;
  line-height: 1.45;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 15px;
  margin-top: 28px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.field > span {
  font-family: var(--font-pixel);
  font-size: 10px;
  letter-spacing: .08em;
  color: #79603e;
  text-transform: uppercase;
}

.field input {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  border: 1px solid #b99d6d;
  border-radius: 2px;
  background: rgba(255, 249, 233, .74);
  color: #2a2118;
  font-size: 15px;
  box-shadow: inset 0 2px 0 rgba(91, 66, 34, .06);
}

.field input::placeholder { color: #a68f6d; }

.field input:focus {
  border-color: #8c5f2f;
  background: #fffaf0;
  outline: none;
  box-shadow: 0 0 0 3px rgba(159, 106, 41, .15);
}

.form-error {
  min-height: 0;
  margin: -4px 0 0;
  color: #9c3222;
  font-size: 12.5px;
  line-height: 1.4;
}
.form-error:empty { display: none; }

/* The tribe choice on the account-creation cards. It stands where the player is
   already choosing who they are, so the in-game sheet never has to interrupt
   the first village. Each banner is a small plate: a lacquered emblem in the
   people's own colour, the name and its stat chip, and the gift it carries.
   The chosen plate is stamped, not just tinted, because the choice is final. */
.tribe-choice {
  display: grid;
  gap: 8px;
  margin-top: 2px;
  padding-top: 13px;
  border-top: 1px solid rgba(121, 96, 62, .28);
}

.tribe-choice-kicker {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: #79603e;
  font-family: var(--font-pixel);
  font-size: 10px;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.tribe-choice-kicker::before {
  content: "";
  flex: none;
  width: 3px;
  height: 11px;
  background: #a6412d;
  box-shadow: 0 0 0 1px rgba(166, 65, 45, .22);
}

.tribe-choice-kicker::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, rgba(121, 96, 62, .38), transparent);
}

.tribe-choice-hint {
  margin: 0;
  color: #7d6a49;
  font-size: 11.5px;
  line-height: 1.4;
}

.tribe-choice-cards {
  display: grid;
  gap: 8px;
  margin-top: 3px;
}

.tribe-choice-card {
  --tribe: #a6412d;
  --tribe-deep: #6d2418;
  --tribe-wash: rgba(166, 65, 45, .13);
  position: relative;
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) 17px;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 10px 11px 10px 12px;
  overflow: hidden;
  border: 1px solid #bda274;
  border-left: 3px solid var(--tribe);
  border-radius: 2px;
  background:
    linear-gradient(100deg, var(--tribe-wash), rgba(255, 250, 235, .6) 48%),
    rgba(255, 249, 233, .76);
  color: #3b2e20;
  text-align: left;
  cursor: pointer;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .6),
    0 1px 1px rgba(71, 51, 28, .09);
  transition:
    border-color .16s ease,
    background-color .16s ease,
    box-shadow .16s ease,
    transform .16s ease;
}

.tribe-choice-card[data-tribe="vikings"] {
  --tribe: #a6412d;
  --tribe-deep: #6d2418;
  --tribe-wash: rgba(166, 65, 45, .13);
}

.tribe-choice-card[data-tribe="ninjas"] {
  --tribe: #2f5852;
  --tribe-deep: #17332f;
  --tribe-wash: rgba(47, 88, 82, .14);
}

.tribe-choice-card[data-tribe="pirates"] {
  --tribe: #38474b;
  --tribe-deep: #1b2426;
  --tribe-wash: rgba(56, 71, 75, .14);
}

/* A slow light sweep on hover, like tilting a lacquered plate. */
.tribe-choice-card::before {
  content: "";
  position: absolute;
  inset: -50% -25%;
  pointer-events: none;
  background: linear-gradient(105deg,
    transparent 40%,
    rgba(255, 255, 255, .5) 50%,
    transparent 60%);
  transform: translateX(-115%);
  transition: transform .6s ease;
}

.tribe-choice-card:hover,
.tribe-choice-card:focus-visible {
  border-color: var(--tribe);
  background-color: #fffaf0;
  transform: translateX(2px);
  outline: none;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .7),
    0 5px 14px rgba(64, 44, 24, .16);
}

.tribe-choice-card:hover::before,
.tribe-choice-card:focus-visible::before {
  transform: translateX(115%);
}

.tribe-choice-card.is-selected {
  border-color: var(--tribe);
  background:
    linear-gradient(100deg, var(--tribe-wash), rgba(255, 246, 226, .96) 52%),
    #fff6e2;
  transform: translateX(2px);
  box-shadow:
    inset 0 0 0 1px var(--tribe),
    inset 0 1px 0 rgba(255, 255, 255, .8),
    0 5px 16px rgba(64, 44, 24, .18);
}

.tribe-choice-emblem {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  padding: 4px;
  border: 1px solid var(--tribe-deep);
  border-radius: 2px;
  background:
    radial-gradient(circle at 32% 18%, rgba(255, 255, 255, .85), transparent 62%),
    linear-gradient(160deg, #fdf4de, #ebd8ae);
  color: var(--tribe-deep);
  font-family: var(--font-display);
  font-size: 21px;
  line-height: 1;
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, .55),
    inset 0 0 0 3px rgba(140, 95, 47, .16),
    0 2px 4px rgba(51, 33, 16, .22);
  transition: transform .18s ease, box-shadow .18s ease;
}

.tribe-choice-emblem svg {
  display: block;
  width: 100%;
  height: 100%;
}

.tribe-choice-card.is-selected .tribe-choice-emblem {
  transform: rotate(-2deg) scale(1.04);
  border-color: var(--tribe);
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, .7),
    inset 0 0 0 3px rgba(140, 95, 47, .2),
    0 0 0 2px var(--tribe-wash),
    0 3px 8px rgba(51, 33, 16, .28);
}

.tribe-choice-text {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.tribe-choice-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
}

.tribe-choice-name {
  flex: 1;
  min-width: 0;
  color: #2f2418;
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: .01em;
}

.tribe-choice-bonus {
  flex: none;
  padding: 2px 6px;
  border: 1px solid var(--tribe);
  background: rgba(255, 255, 255, .42);
  color: var(--tribe-deep);
  font-family: var(--font-pixel);
  font-size: 9px;
  letter-spacing: .05em;
  line-height: 1.4;
  text-transform: uppercase;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .5);
}

.tribe-choice-blurb {
  color: #6f5c41;
  font-size: 11px;
  line-height: 1.35;
}

.tribe-choice-tick {
  display: grid;
  place-items: center;
  width: 17px;
  height: 17px;
  border: 1px solid #b39a6f;
  border-radius: 50%;
  background: rgba(255, 250, 238, .7);
  color: transparent;
  font-family: var(--font-pixel);
  font-size: 9px;
  line-height: 1;
  transition:
    background-color .16s ease,
    border-color .16s ease,
    color .16s ease,
    transform .16s ease;
}

.tribe-choice-card.is-selected .tribe-choice-tick {
  border-color: var(--tribe-deep);
  background: var(--tribe);
  color: #fff3d8;
  transform: scale(1.06);
}

.tribe-choice-selected {
  min-height: 14px;
  margin: 0;
  color: #7a5d33;
  font-family: var(--font-pixel);
  font-size: 9px;
  letter-spacing: .04em;
  line-height: 1.4;
  text-transform: uppercase;
}

.tribe-choice-selected:not(:empty)::before {
  content: "▸ ";
  color: #a6412d;
}

@media (prefers-reduced-motion: reduce) {
  .tribe-choice-card,
  .tribe-choice-card::before,
  .tribe-choice-emblem,
  .tribe-choice-tick {
    transition: none;
  }
  .tribe-choice-card:hover,
  .tribe-choice-card:focus-visible,
  .tribe-choice-card.is-selected {
    transform: none;
  }
  .tribe-choice-card:hover::before,
  .tribe-choice-card:focus-visible::before {
    transform: translateX(-115%);
  }
}

.auth-submit {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  min-height: 51px;
  margin-top: 5px;
  padding: 0 16px 0 20px;
  border: 1px solid #79291e;
  border-radius: 2px;
  background: var(--vermilion);
  color: #fff4dd;
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, .17),
    inset 0 -3px 0 rgba(86, 26, 16, .38),
    0 3px 0 #65231a;
  transition: transform .1s ease, background .15s ease;
}

.auth-submit:hover { background: #d3563b; }
.auth-submit:active { transform: translateY(2px); box-shadow: inset 0 2px 0 rgba(255, 255, 255, .12), 0 1px 0 #65231a; }
.auth-submit:disabled { opacity: .65; cursor: progress; }
.submit-arrow { font-family: var(--font-body); font-size: 24px; line-height: 1; }

.auth-switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  min-height: 51px;
  margin-top: 12px;
  padding: 0 16px 0 20px;
  border: 1px solid #274b6d;
  border-radius: 2px;
  background: #3a6f9c;
  color: #f2f7ff;
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
  text-align: left;
  text-decoration: none;
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, .2),
    inset 0 -3px 0 rgba(17, 45, 68, .35),
    0 3px 0 #1b3a55;
  transition: transform .1s ease, background .15s ease;
}
.auth-switch:hover { background: #4a82b5; color: #fff; }
.auth-switch:active { transform: translateY(2px); box-shadow: inset 0 2px 0 rgba(255, 255, 255, .14), 0 1px 0 #1b3a55; }
.auth-switch:disabled {
  opacity: .55;
  cursor: not-allowed;
  filter: saturate(.55);
}
.auth-switch:disabled:hover { background: #3a6f9c; color: #f2f7ff; }
.auth-switch:disabled:active { transform: none; }
.auth-switch span { display: inline-block; margin-left: 3px; font-family: var(--font-body); font-size: 24px; line-height: 1; transition: transform .15s ease; }
.auth-switch:hover span { transform: translateX(3px); }

/* The recovery card's email form. The modal supplies the paper, so these rules
   only arrange the controls inside it. */
.recovery-form {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}
.recovery-form .button { justify-self: start; }
.recovery-status {
  margin: 12px 0 0;
  padding: 9px 11px;
  border-left: 3px solid #b99d6d;
  background: rgba(185, 157, 109, .12);
  color: #6a5639;
  font-size: 12.5px;
  line-height: 1.45;
}
.recovery-status.is-ready {
  border-left-color: #527a58;
  background: rgba(82, 122, 88, .12);
  color: #3d583f;
}

.auth-persistence {
  margin-top: 17px;
  color: #998365;
  font-size: 11px;
  line-height: 1.4;
  text-align: center;
}

/* A special-friend link paints this note before anyone signs in. It uses the
   same parchment and brass language as the gate's recovery card. */
.auth-invite {
  margin: 16px 0 0;
  padding: 10px 12px;
  border: 1px solid #b4935c;
  border-left: 4px solid #a6412d;
  background: rgba(255, 250, 235, .6);
  color: #6b5537;
  font-size: 12px;
  line-height: 1.45;
}
.auth-invite[hidden] { display: none; }

.auth-credit {
  position: relative;
  z-index: 1;
  margin-top: 28px;
  color: #6d756b;
  font-family: var(--font-pixel);
  font-size: 10px;
  letter-spacing: .08em;
  text-align: center;
}

/* ------------------------------------------------------------------ */
/* App frame                                                          */
/* ------------------------------------------------------------------ */

.app {
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-rows: 64px minmax(0, 1fr) auto;
  background: var(--teal-dark);
  overflow: hidden;
}

/* Safari 26 floats its address bar and buttons over the bottom of the page,
   and `100dvh` can resolve to the large (behind-the-bars) viewport before the
   first scroll. The small viewport is the band between the bars, so anchoring
   the app to it keeps the dock and the foot of every screen above Safari's
   buttons. The status-bar inset is added back because `svh` starts below the
   top bar, while the app still starts at the screen edge. An installed web app
   has no Safari bars, so it keeps the full dynamic viewport. */
@media (display-mode: browser) {
  @supports (-webkit-touch-callout: none) {
    .app { height: calc(100svh + env(safe-area-inset-top, 0px)); }
  }
}

.hud {
  position: relative;
  z-index: 30;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 20px;
  padding: 0 22px;
  color: #f4e4c1;
  background:
    linear-gradient(180deg, rgba(255,255,255,.07), transparent 36%),
    repeating-linear-gradient(90deg, rgba(255,255,255,.022) 0 2px, transparent 2px 8px),
    linear-gradient(180deg, #39291f, #241b16);
  border-bottom: 2px solid #aa7b32;
  box-shadow: 0 3px 0 rgba(15, 12, 10, .6), 0 8px 24px rgba(5, 10, 10, .25);
}

.hud::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -5px;
  height: 3px;
  background: linear-gradient(90deg, transparent, rgba(232, 185, 79, .45), transparent);
  pointer-events: none;
}

.hud-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.crest {
  position: relative;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  background: #ede0c0;
  border: 2px solid #a97b38;
  border-radius: 50%;
  box-shadow: inset 0 0 0 2px #5c4527, 0 2px 0 rgba(0,0,0,.25);
}
.crest::before {
  content: "";
  width: 15px;
  height: 15px;
  background: #c94a31;
  transform: rotate(45deg);
  box-shadow: 0 0 0 3px #2f4b41;
}
.crest span {
  position: absolute;
  width: 4px;
  height: 4px;
  background: #f2e3c2;
  transform: rotate(45deg);
}

.hud-village { min-width: 0; max-width: 100%; }

.hud-clan {
  font-family: var(--font-display);
  font-size: 21px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: .01em;
  color: #ffedc9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 2px 0 #1a120d;
}
.hud-owner {
  margin-top: 4px;
  color: #b7a17f;
  font-family: var(--font-pixel);
  font-size: 10px;
  letter-spacing: .09em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hud-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 18px;
  min-width: 0;
}

.gold-purse {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 6px 0;
  color: #fbf0d3;
}
.gold-icon {
  align-self: center;
  width: 16px;
  height: 16px;
  background: var(--gold);
  border: 2px solid #8b651f;
  border-radius: 50%;
  box-shadow: inset 0 0 0 2px #f5d883, 0 2px 0 rgba(0, 0, 0, .25);
}
.gold-purse strong {
  font-family: var(--font-pixel);
  font-size: 17px;
  font-weight: 700;
  color: #f7cf6e;
  letter-spacing: .01em;
  text-shadow: 0 2px 0 #5b3e13;
}
.gold-unit {
  font-family: var(--font-pixel);
  font-size: 11px;
  color: #9d845d;
}

.logout-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 33px;
  padding: 0 12px;
  color: #cbb998;
  background: rgba(15, 18, 16, .35);
  border: 1px solid #5e4a31;
  font-family: var(--font-pixel);
  font-size: 10px;
  letter-spacing: .05em;
  text-transform: uppercase;
  transition: color .15s ease, border-color .15s ease, background .15s ease;
}
.logout-button:hover {
  color: #fff0cf;
  border-color: #a97b38;
  background: rgba(85, 47, 30, .42);
}
.logout-icon {
  position: relative;
  width: 13px;
  height: 10px;
  border-top: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
}
.logout-icon::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 2px;
  border-top: 2px solid currentColor;
}
.logout-icon::after {
  display: none;
}

/* The HUD's music switch is both the state readout and the user gesture that
   lets a browser start playback after an autoplay block. */
.music-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 33px;
  padding: 0 11px;
  color: #cbb998;
  background: rgba(15, 18, 16, .35);
  border: 1px solid #5e4a31;
  font-family: var(--font-pixel);
  font-size: 10px;
  letter-spacing: .05em;
  text-transform: uppercase;
  transition: color .15s ease, border-color .15s ease, background .15s ease, opacity .15s ease;
}
.music-button:hover {
  color: #fff0cf;
  border-color: #a97b38;
  background: rgba(85, 47, 30, .42);
}
.music-button.is-off { color: #8f7c61; opacity: .78; }
.music-button.is-off:hover { color: #d8c3a0; opacity: 1; }
.music-button.is-waiting { color: #fff0cf; border-color: #c99a4a; }
.music-icon {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 13px;
  height: 13px;
  font-size: 14px;
  line-height: 1;
}
.music-button.is-off .music-icon::after {
  content: "";
  position: absolute;
  left: -2px;
  top: 50%;
  width: 18px;
  height: 2px;
  background: currentColor;
  transform: translateY(-50%) rotate(-45deg);
  box-shadow: 0 0 0 1px rgba(20, 14, 10, .45);
}

.screen {
  position: relative;
  min-height: 0;
  overflow: hidden;
  outline: none;
  background: var(--teal-dark);
}

/* ------------------------------------------------------------------ */
/* Dock                                                               */
/* ------------------------------------------------------------------ */

.dock {
  position: relative;
  z-index: 25;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px 18px 9px;
  background:
    linear-gradient(180deg, rgba(255,255,255,.07), transparent 27%),
    repeating-linear-gradient(90deg, rgba(255,255,255,.018) 0 2px, transparent 2px 9px),
    linear-gradient(180deg, #39291f, #1f1713 80%);
  border-top: 2px solid #a97b38;
  box-shadow: 0 -6px 24px rgba(6, 12, 12, .3);
}

.dock::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -5px;
  height: 2px;
  background: linear-gradient(90deg, transparent, #d6a84f, transparent);
}

.dock-head {
  width: min(100%, 940px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 2px;
}

.dock-title {
  color: #8d7a5c;
  font-family: var(--font-pixel);
  font-size: 9px;
  letter-spacing: .14em;
  line-height: 1;
  text-transform: uppercase;
  white-space: nowrap;
}

.nav-collapse {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border: 1px solid #5e4a31;
  background: rgba(13, 17, 15, .3);
  color: #c8b48d;
  font-family: var(--font-pixel);
  font-size: 10px;
  letter-spacing: .05em;
  line-height: 1.2;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}

.nav-collapse:hover,
.nav-collapse:focus-visible {
  border-color: #a97b38;
  background: rgba(201, 74, 49, .22);
  color: #ffe6ac;
}

.nav-collapse-arrow {
  color: #e7b64e;
  font-family: Georgia, serif;
  font-size: 12px;
  line-height: 1;
}

.nav-window {
  width: min(100%, 940px);
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.nav-row {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 5px;
}

.nav-row[hidden] { display: none; }

.nav-button {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-width: 0;
  height: 50px;
  padding: 4px 2px 3px;
  border: 1px solid transparent;
  background: transparent;
  color: #a9997e;
  transition: color .16s ease, transform .16s ease, background .16s ease;
}

.nav-button::after {
  content: "";
  position: absolute;
  left: 26%;
  right: 26%;
  bottom: 2px;
  height: 2px;
  background: transparent;
  transition: background .16s ease;
}

.nav-button:hover {
  color: #f3e0b9;
  background: rgba(245, 227, 193, .06);
}

.nav-button:disabled {
  opacity: .38;
  cursor: not-allowed;
}
.nav-button:disabled:hover {
  color: #a9997e;
  background: transparent;
}

.nav-button.active {
  color: #ffedc4;
  background:
    linear-gradient(180deg, rgba(201, 74, 49, .24), rgba(201, 74, 49, .05));
  border-color: rgba(205, 154, 65, .45);
  transform: translateY(-2px);
}
.nav-button.active::after { background: var(--gold); }
.nav-button.active .nav-icon { filter: drop-shadow(0 2px 0 rgba(80, 28, 18, .6)); }
.nav-button .nav-icon { width: 24px; height: 24px; }

/* Unread dock events. The amber mark is finished work the player has not
   looked at; the red mark is an attack. Both disappear as soon as the section
   is opened, and the guide's own tutorial pulse still wins while it is due. */
.nav-button.nav-alert:not(.active):not(.tutorial-target) {
  border-color: rgba(232, 185, 79, .72);
  color: #fff0c8;
  background:
    linear-gradient(180deg, rgba(232, 185, 79, .26), rgba(232, 185, 79, .05));
  box-shadow: 0 0 0 1px rgba(232, 185, 79, .38), 0 0 18px rgba(232, 185, 79, .34);
  animation: nav-alert-pulse 1.6s ease-in-out infinite;
}
.nav-button.nav-alert:not(.active):not(.tutorial-target)::after { background: var(--gold); }
.nav-button.nav-alert:not(.active):not(.tutorial-target)::before,
.nav-button.nav-alert-danger:not(.active):not(.tutorial-target)::before {
  content: "";
  position: absolute;
  top: 5px;
  right: 7px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 8px rgba(232, 185, 79, .9);
}
/* A ready villager is an action, not just unread work: the Villagers button
   wears a brighter gold pulse and an up-arrow mark until the bar is spent. */
.nav-button.nav-alert-levelup:not(.active):not(.tutorial-target) {
  border-color: #ffcf6a;
  color: #fff3ce;
  background:
    linear-gradient(180deg, rgba(255, 183, 64, .38), rgba(201, 74, 49, .08));
  box-shadow:
    0 0 0 2px rgba(255, 198, 90, .52),
    0 0 26px rgba(255, 171, 43, .5);
  animation: nav-alert-pulse 1.25s ease-in-out infinite;
}
.nav-button.nav-alert-levelup:not(.active):not(.tutorial-target)::after { background: #ffc14d; }
.nav-button.nav-alert-levelup:not(.active):not(.tutorial-target)::before {
  content: "↑";
  top: 1px;
  right: 5px;
  display: grid;
  place-items: center;
  width: 12px;
  height: 12px;
  border-radius: 0;
  background: transparent;
  color: #ffe09a;
  font-family: var(--font-pixel);
  font-size: 13px;
  line-height: 1;
  text-shadow: 0 0 8px rgba(255, 180, 52, .95);
  box-shadow: none;
}
.nav-button.nav-alert-danger:not(.active):not(.tutorial-target) {
  border-color: #e4553c;
  color: #ffe1d6;
  background:
    linear-gradient(180deg, rgba(201, 74, 49, .44), rgba(201, 74, 49, .08));
  box-shadow: 0 0 0 2px rgba(228, 85, 60, .42), 0 0 22px rgba(228, 85, 60, .46);
  animation: nav-alert-danger-pulse 1.15s ease-in-out infinite;
}
.nav-button.nav-alert-danger:not(.active):not(.tutorial-target)::after { background: #e4553c; }
.nav-button.nav-alert-danger:not(.active):not(.tutorial-target)::before {
  background: #ff5a3c;
  box-shadow: 0 0 10px rgba(255, 90, 60, .95);
}
.nav-button.nav-alert-danger:not(.active):not(.tutorial-target) .nav-icon {
  filter: drop-shadow(0 0 6px rgba(255, 90, 60, .8));
}
@keyframes nav-alert-pulse {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.18); }
}
@keyframes nav-alert-danger-pulse {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.28); }
}

.nav-label {
  font-family: var(--font-pixel);
  font-size: 12px;
  line-height: 1;
  letter-spacing: .01em;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dock-flourish {
  position: absolute;
  left: 50%;
  bottom: 2px;
  display: flex;
  gap: 4px;
  transform: translateX(-50%);
}
.dock-flourish span { width: 3px; height: 3px; background: #8b6d35; transform: rotate(45deg); }
.dock-flourish span:nth-child(2) { background: #c19441; }

/* The Settings tab's reduced-motion preference. */
html.reduce-motion *,
html.reduce-motion *::before,
html.reduce-motion *::after {
  animation-duration: .001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: .001ms !important;
  scroll-behavior: auto !important;
}
html.reduce-motion .nav-button.active { transform: none; }

/* ------------------------------------------------------------------ */
/* Shared panels and typography                                       */
/* ------------------------------------------------------------------ */

.tab-screen {
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: #9d804f rgba(8, 17, 17, .2);
  background:
    radial-gradient(circle at 82% 0%, rgba(237, 191, 95, .16), transparent 34%),
    linear-gradient(160deg, #173a39 0%, #1e4a47 54%, #16312f 100%);
}
.tab-screen::-webkit-scrollbar { width: 9px; }
.tab-screen::-webkit-scrollbar-thumb { background: #9d804f; border: 2px solid #193633; }
.tab-screen::-webkit-scrollbar-track { background: rgba(8, 17, 17, .2); }

.tab-inner {
  width: min(100% - 44px, 1190px);
  margin: 0 auto;
  padding: 30px 0 42px;
  display: flex;
  flex-direction: column;
  min-height: 100%;
}
.tab-inner > * { flex: 0 0 auto; }

/* A tab whose last child is the pinned footer owns no bottom padding: the
   scroller ends exactly at the dock, so the sticky footer stays flush with the
   navbar at the end of the scroll instead of rising by that padding. The
   footer's own 18px band already supplies the gap below the status box. */
.tab-inner.tab-inner--pinned { padding-bottom: 0; }

/* ------------------------------------------------------------------ */
/* Pinned tab footer                                                   */
/* ------------------------------------------------------------------ */
/* Each section supplies its own footer: live Current/Queue tiles, a    */
/* party strip, forecast buttons, a trade filter or the food bonus. It  */
/* sticks to the foot of the scroller, above the navbar, so the control  */
/* the section cares about never scrolls away. A floating tutorial card  */
/* lifts it by the card's clearance; when the guide instead stands in    */
/* the bar, it simply takes the bar's content slot.                      */

.tab-footer {
  position: sticky;
  z-index: 11;
  bottom: var(--tutorial-guide-clearance, 0px);
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  /* 46px bar keeps its own 1px border and 7px inner padding; the extra 18px
     above and below is the band that separates it from the page and navbar. */
  min-height: 82px;
  margin-top: auto;
  /* 18px of band above and below matches the gap between the panels. The band
     masks content scrolling behind the pinned bar so the gap reads as a
     margin rather than as the cut-off page underneath. */
  padding: 26px 12px;
  color: #f4e6c6;
  background: linear-gradient(160deg, #1d4642 0%, #142f2d 100%);
  border: 0;
  box-shadow: none;
}
/* The status bar itself, drawn between the two 18px gaps. */
.tab-footer::before {
  content: "";
  position: absolute;
  inset: 18px 0;
  z-index: -1;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .06), transparent 42%),
    linear-gradient(180deg, #2b3f38, #172823);
  border: 1px solid #a98b56;
  box-shadow:
    0 0 0 2px rgba(10, 24, 21, .72),
    0 -6px 18px rgba(4, 12, 11, .28);
}
.tab-footer > * {
  position: relative;
  z-index: 1;
}
.tab-footer-kicker {
  flex: 0 0 auto;
  color: #d6ac58;
  font-family: var(--font-pixel);
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.tab-footer-items {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 20px;
  min-width: 0;
}
.tab-footer-item {
  display: flex;
  align-items: baseline;
  gap: 7px;
  min-width: 0;
}
.tab-footer-item em {
  color: #94ab98;
  font-family: var(--font-pixel);
  font-size: 11px;
  font-style: normal;
  letter-spacing: .06em;
  text-transform: uppercase;
  white-space: nowrap;
}
.tab-footer-item strong {
  color: #f7e7c3;
  font-family: var(--font-pixel);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tab-footer-meta {
  color: #a9bda7;
  font-family: var(--font-pixel);
  font-size: 11px;
  letter-spacing: .02em;
  white-space: nowrap;
}
.tab-footer-bonus {
  color: #e8c477;
  font-family: var(--font-pixel);
  font-size: 22px;
  font-weight: 700;
  line-height: 1;
}
.tab-footer-empty {
  color: #a9bda7;
  font-family: var(--font-pixel);
  font-size: 12px;
  letter-spacing: .03em;
}
.tab-footer .forecast-picker {
  border-color: #a98b56;
  background: rgba(255, 247, 230, .08);
}
.tab-footer .forecast-picker-label { color: #d6ac58; }
.tab-footer .forecast-chip { color: #d9e3cf; }
.tab-footer .forecast-chip:hover { background: rgba(255, 247, 230, .12); }
.tab-footer .forecast-chip:focus-visible { outline-color: #e0c481; }
.tab-footer .forecast-chip.is-active {
  border-color: #e0a24d;
  background: #3d5a45;
  color: #fff1d6;
}

/* Every tab's pinned status bar is the same opaque paper box. The footer
   wrapper is only the 18px gap; it carries no fill so the page scrolls behind
   the box at full height. Only that exposed band fades, so the page softens
   into the bar while the paper itself keeps its solid cream. */
.tab-footer.tab-status-footer {
  display: block;
  min-height: 0;
  padding: 18px 0;
  background: transparent;
  border: 0;
  box-shadow: none;
}
/* The box supplies its own frame; the wrapper's band only fades the page
   behind it, never the box. The overlaid full-screen map bars (World and
   Village on desktop) paint no band at all: the map itself runs behind them. */
.tab-footer.tab-status-footer::before {
  content: "";
  position: absolute;
  top: -34px;
  right: 0;
  bottom: auto;
  left: 0;
  height: 52px;
  z-index: -1;
  background: var(--tab-status-scrim);
  border: 0;
  box-shadow: none;
  pointer-events: none;
}
/* The band between the box and the dock fades the page the same way, but
   deeper, so content scrolling under the bar dissolves instead of peeking out
   in the gap above the navbar. */
.tab-footer.tab-status-footer::after {
  content: "";
  position: absolute;
  top: auto;
  right: 0;
  bottom: 0;
  left: 0;
  height: 18px;
  z-index: -1;
  background: linear-gradient(180deg, rgba(9, 23, 22, .15) 0%, rgba(9, 23, 22, .9) 100%);
  border: 0;
  box-shadow: none;
  pointer-events: none;
}

/* The shared contents of those boxes. Each tab keeps its own values; only the
   paper palette and row layout are standardised. The Market's stack is the
   template: a kicker and headline, an optional progress rail, then facts. */
.tab-status-box {
  position: relative;
  display: grid;
  grid-template-rows: 1fr;
  width: 100%;
  /* Every tab's bar is the same height: head, rail (or slot strip) and facts
     all fit inside this box on desktop. */
  min-height: 118px;
  overflow: visible;
  /* The whole bar folds into the button in one motion: the content row
     collapses while the paper fades and the footer band closes up. */
  transition:
    grid-template-rows .38s cubic-bezier(.4, 0, .2, 1),
    min-height .38s cubic-bezier(.4, 0, .2, 1),
    padding-top .38s cubic-bezier(.4, 0, .2, 1),
    padding-bottom .38s cubic-bezier(.4, 0, .2, 1);
}
.tab-status-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  width: 100%;
  min-height: 0;
  overflow: hidden;
  transition:
    opacity .38s cubic-bezier(.4, 0, .2, 1),
    transform .38s cubic-bezier(.4, 0, .2, 1);
}
/* The paper is its own layer so it can fade while the row collapses. The
   shared panel frame is drawn by the pseudo-element instead of the box. */
.panel.tab-status-box {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}
.panel.tab-status-box::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  background: var(--ui-box-background);
  border: var(--ui-box-border);
  box-shadow: var(--ui-box-shadow);
  pointer-events: none;
  transition: opacity .38s cubic-bezier(.4, 0, .2, 1);
}
/* The inset hairline is the panel's second painted layer. It has to fade with
   the paper, or a collapsed bar leaves a thin empty frame behind. */
.panel.tab-status-box::after {
  transition: opacity .38s cubic-bezier(.4, 0, .2, 1);
}
.tab-status-box .tab-footer-kicker { color: #92764b; }
.tab-status-box .tab-footer-item em { color: #806d4c; }
.tab-status-box .tab-footer-item strong { color: #4f3d27; }
.tab-status-box .tab-footer-meta { color: #806d4c; }
.tab-status-box .tab-footer-bonus { color: #8a3a27; }
.tab-status-box .tab-footer-empty { color: #7b6038; }
.tab-status-box .construction-bar { margin-top: 10px; }
.tab-status-box .construction-facts { margin-top: 8px; }
.tab-status-box .upgrade-kicker { color: #92764b; }

/* Every pinned status bar carries one small chevron in its top-right corner.
   It folds that section's own bar into a single paper box, then unfolds it
   again. The reserved right padding keeps the head's countdown clear of it. */
.panel.tab-status-box.has-status-collapse { padding-right: 44px; }
.status-collapse {
  position: absolute;
  top: 7px;
  right: 7px;
  z-index: 3;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 1px solid #b4935c;
  border-radius: 2px;
  color: #7b5a2e;
  background-color: rgba(255, 246, 224, .5);
  box-shadow: 0 1px 0 #634f32, 0 0 0 0 rgba(33, 54, 50, 0);
  cursor: pointer;
  transition:
    top .38s cubic-bezier(.4, 0, .2, 1),
    width .38s cubic-bezier(.4, 0, .2, 1),
    height .38s cubic-bezier(.4, 0, .2, 1),
    transform .38s cubic-bezier(.4, 0, .2, 1),
    background-color .26s ease,
    border-color .26s ease,
    color .26s ease,
    box-shadow .26s ease;
}
.status-collapse svg {
  width: 14px;
  height: 14px;
  transition:
    width .38s cubic-bezier(.4, 0, .2, 1),
    height .38s cubic-bezier(.4, 0, .2, 1),
    transform .38s cubic-bezier(.4, 0, .2, 1);
}
.status-collapse:hover { background-color: rgba(201, 74, 49, .12); border-color: #8d5e3a; }
.status-collapse:focus-visible { outline: 2px solid #7a5a2f; outline-offset: 2px; }
.status-collapse:active { transform: translateY(1px); }
/* Folded: the paper frame fades away with the row and only the button's own
   box remains, centred at the right edge with its chevron turned upward. */
.tab-status-box.is-collapsed {
  min-height: 38px;
  padding-top: 2px;
  padding-bottom: 2px;
  grid-template-rows: 0fr;
}
.tab-status-box.is-collapsed::before,
.tab-status-box.is-collapsed::after { opacity: 0; }
.tab-status-box.is-collapsed .tab-status-content {
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
}
.tab-status-box.is-collapsed .status-collapse {
  top: 50%;
  width: 34px;
  height: 34px;
  transform: translateY(-50%);
  background-color: #f4e7c9;
  border-color: #b4935c;
  color: #8a3a27;
  box-shadow: 0 2px 0 #634f32, 0 0 0 2px #213632;
}
.tab-status-box.is-collapsed .status-collapse svg {
  width: 16px;
  height: 16px;
  transform: rotate(180deg);
}
.tab-status-box.is-collapsed .status-collapse:active {
  transform: translateY(calc(-50% + 1px));
}

/* The footer band closes around the lone button instead of leaving the
   full-width strip behind. Its page scrims fade with the paper. */
.tab-footer.tab-status-footer,
.world-status {
  transition:
    padding .38s cubic-bezier(.4, 0, .2, 1),
    min-height .38s cubic-bezier(.4, 0, .2, 1),
    box-shadow .38s cubic-bezier(.4, 0, .2, 1);
}
.tab-footer.tab-status-footer::before,
.tab-footer.tab-status-footer::after,
.world-status::before,
.world-status::after {
  transition: opacity .38s cubic-bezier(.4, 0, .2, 1);
}
.tab-footer.tab-status-footer.is-collapsed,
.world-status.is-collapsed {
  min-height: 0;
  padding: 6px 0 8px;
}
/* The docked World bar floats over the atlas. Folded, its shadow is the last
   trace of the closed panel, so it fades out with the paper. */
.world-status.is-collapsed {
  box-shadow: none;
}
.tab-footer.tab-status-footer.is-collapsed::before,
.tab-footer.tab-status-footer.is-collapsed::after,
.world-status.is-collapsed::before,
.world-status.is-collapsed::after {
  opacity: 0;
}
/* Folded, the World bar is only a transparent strip holding the chevron. The
   footer must not paint its own paper or shadow, or the atlas behind it reads
   as a closed panel instead of empty map. */
#screen > section > footer.world-status.is-collapsed {
  background: transparent;
  box-shadow: none;
}

/* A section paints its bar open and folds it once the markup is in the DOM.
   The renderer may measure the fresh tab before that, so without this guard
   the open geometry is computed first and the fold starts its 0.38s transition
   -- the bar flashes open whenever the player switches between two sections
   whose bars are both folded. `main.js` adds the class before the paint and
   drops it after the fold and the first entry frame have settled. */
#screen.is-status-settling .tab-status-box,
#screen.is-status-settling .tab-status-box::before,
#screen.is-status-settling .tab-status-box::after,
#screen.is-status-settling .tab-status-content,
#screen.is-status-settling .status-collapse,
#screen.is-status-settling .status-collapse svg,
#screen.is-status-settling .tab-footer.tab-status-footer,
#screen.is-status-settling .tab-footer.tab-status-footer::before,
#screen.is-status-settling .tab-footer.tab-status-footer::after,
#screen.is-status-settling .world-status,
#screen.is-status-settling .world-status::before,
#screen.is-status-settling .world-status::after {
  transition: none !important;
}

/* The School, Hospital, Research and Workshop bars split in half: the work in
   hand keeps the left half and its waiting slots take the right half. The queue
   board fills one row of five before it starts the second, so ten unlocked
   slots form exactly two rows of five. */
.tab-status-ledger {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  align-items: stretch;
  gap: 14px;
  width: 100%;
  min-height: 72px;
}
/* A hall with no queue keeps the whole bar for its current work. */
.tab-status-ledger.is-solo {
  grid-template-columns: minmax(0, 1fr);
}
.tab-status-current {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
  padding-right: 0;
}
.tab-status-current .construction-head > div {
  min-width: 0;
}
.tab-status-current .construction-head strong {
  max-width: 100%;
  overflow: hidden;
  font-size: 14px;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* The waiting board. Every slot is the same little square whichever hall owns
   it, and the board grows its second row only once the first five are used. */
.tab-status-queue {
  display: grid;
  grid-auto-rows: minmax(0, 1fr);
  gap: 4px;
  align-content: stretch;
  min-width: 0;
  padding-left: 14px;
  border-left: 1px solid rgba(154, 124, 74, .32);
}
.tab-status-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: 0;
  min-height: 0;
  padding: 2px;
  border: 1px solid rgba(154, 124, 74, .42);
  background:
    linear-gradient(160deg, rgba(255, 255, 255, .3), rgba(255, 251, 235, 0) 70%),
    rgba(255, 249, 232, .28);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .22);
  overflow: hidden;
}
/* A filled slot shows only what it holds: a portrait, a tool or a treatise
   icon, with the job's own clock beneath. The name stays in the tooltip. */
.tab-status-slot-glyph {
  display: grid;
  place-items: center;
  width: 25px;
  height: 25px;
  min-height: 0;
  overflow: hidden;
  color: #8a3a27;
}
.tab-status-slot-glyph svg {
  display: block;
  width: 100%;
  height: 100%;
}
.tab-status-slot-time {
  max-width: 100%;
  overflow: hidden;
  color: #6f5a3a;
  font-family: var(--font-pixel);
  font-size: 9px;
  line-height: 1;
  letter-spacing: .02em;
  white-space: nowrap;
  text-overflow: ellipsis;
}
/* The exact clock is the default; a phone swaps in the leading unit below. */
.tab-status-slot-time-short { display: none; }
/* A free slot reads as openly waiting: a dashed outline and a centred plus. */
.tab-status-slot.is-empty {
  border-style: dashed;
  border-color: rgba(154, 124, 74, .6);
  background: rgba(255, 249, 232, .14);
  box-shadow: none;
  color: #8a6a3a;
}
.tab-status-slot-add {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  opacity: .9;
}
.tab-status-slot-add svg {
  width: 16px;
  height: 16px;
}

/* The Inventory's rarity-stacking switch sits in the status head, so the bar
   still reads as a headline plus one compact control. The ON state uses the
   same green as an active forecast chip and the OFF state the paper border of
   the unpressed chips. */
.status-toggle {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: baseline;
  gap: 7px;
  padding: 5px 9px;
  border: 1px solid #b59b6c;
  background: rgba(255, 246, 224, .34);
  color: #7b6645;
  cursor: pointer;
}
.status-toggle span {
  color: #8a7049;
  font-family: var(--font-pixel);
  font-size: 10px;
  letter-spacing: .07em;
  text-transform: uppercase;
}
.status-toggle strong {
  color: #8a3a27;
  font-family: var(--font-pixel);
  font-size: 12px;
  font-weight: 400;
}
.status-toggle:hover { background: rgba(201, 74, 49, .1); border-color: #8d5e3a; }
.status-toggle:focus-visible { outline: 2px solid #7a5a2f; outline-offset: 2px; }
.status-toggle.is-on {
  border-color: #2f4a2c;
  background: #3b5a3a;
}
.status-toggle.is-on span,
.status-toggle.is-on strong { color: #f3e7c8; }

/* Compact status-bar controls keep the head's height: the kicker and the
   headline value set the box's height on every screen. */
.tab-status-box .construction-head .status-toggle {
  align-self: flex-start;
  padding: 3px 8px;
  gap: 6px;
  border-color: #b59b6c;
  background: rgba(255, 246, 224, .34);
}
.tab-status-box .construction-head .status-toggle span { font-size: 9px; }
.tab-status-box .construction-head .status-toggle strong { margin-top: 0; font-size: 11px; }
.tab-status-box .construction-head .status-toggle.is-on {
  border-color: #2f4a2c;
  background: #3b5a3a;
}

/* The Village growth head keeps its population count and the births toggle
   together at the right edge. The toggle matches the Inventory switch, and
   wraps under the count on a narrow phone instead of squeezing it. */
.city-growth-aside {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 4px 8px;
}
.city-growth-aside > span { white-space: nowrap; }
.tab-status-box .construction-head .city-growth-aside .status-toggle { align-self: center; }
.tab-status-box .construction-head .city-growth-aside .status-toggle.is-on {
  border-color: #8d3d28;
  background: rgba(201, 74, 49, .2);
}
.tab-status-box .construction-head .city-growth-aside .status-toggle.is-on span,
.tab-status-box .construction-head .city-growth-aside .status-toggle.is-on strong { color: #7b2f20; }

/* Only the trade rate stays on the left of the fact row; the refill countdown
   takes the right edge. */
.market-buffer-refill {
  margin-left: auto;
  text-align: right;
}

/* The lower rail carries controls that need their own hit targets (forecast
   windows, villager trades) without breaking the Market's stacked layout. */
.tab-status-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(154, 124, 74, .32);
}
.tab-status-controls .tab-filter-strip { width: 100%; }

/* The Villagers bar splits one-to-two: the job filter and stat order on the
   left, the growth clock and its rail on the wider right. A phone gives both
   halves an equal share instead. */
.tab-status-split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
  gap: 14px;
  width: 100%;
}
/* The Food bar gives both of its readings the same share of the bar. */
.tab-status-split--even {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}
.tab-status-pane {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0;
  min-width: 0;
}
.tab-status-pane-note {
  margin: 0;
  color: #806d4c;
  font-family: var(--font-pixel);
  font-size: 9px;
  letter-spacing: .03em;
}

/* The Food bar is one row of two readings, so centre that row in the shared
   118px box instead of leaving it at the top edge. */
.tab-status-box.food-status .tab-status-content {
  justify-content: center;
}

/* The Food bar keeps the bonus card's mark and display value, centred both
   ways inside the status box so the bonus reads on its own. */
.tab-status-pane--food {
  padding-right: 14px;
  border-right: 1px solid rgba(154, 124, 74, .32);
}
.tab-status-food {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  width: 100%;
}
.tab-status-food .food-bonus-mark {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  margin: 0;
  font-size: 21px;
}
.tab-status-food-copy {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: 0;
  text-align: center;
}
.tab-status-food-copy .food-bonus-kicker { margin: 0; font-size: 11px; }
.tab-status-food-copy .food-bonus-value { margin: 0; font-size: 34px; }

/* The right half of the Food bar is the one consumption rate the villagers
   take from every food type, so it mirrors the bonus headline without a mark. */
.tab-status-pane--consumption {
  align-items: center;
  justify-content: center;
  gap: 2px;
  text-align: center;
}
.tab-status-pane--consumption .food-bonus-kicker { margin: 0; font-size: 11px; }
.tab-status-consumption-value {
  color: #8a3a27;
  font-family: var(--font-figure);
  font-size: 34px;
  font-weight: 700;
  line-height: 1;
}

.tab-status-box .forecast-picker {
  border-color: #aa8b58;
  background: rgba(255, 246, 224, .34);
}
/* The Warehouse keeps its forecast window in the status head, where the trade
   size sits for the Market, so the bar stays one head-plus-facts row tall. */
.tab-status-box .construction-head .tab-footer-forecast {
  display: inline-flex;
  align-self: flex-start;
  margin-top: 0;
  padding: 2px 4px;
}
.tab-status-box .construction-head .tab-footer-forecast .forecast-picker-label {
  display: none;
}
.tab-status-box .construction-head .tab-footer-forecast .forecast-chip {
  padding: 3px 5px;
  font-size: 10px;
}
.tab-status-box .forecast-picker-label { color: #8a7049; }
.tab-status-box .forecast-chip { color: #6d5838; }
.tab-status-box .forecast-chip:hover { background: rgba(120, 95, 55, .14); }
.tab-status-box .forecast-chip:focus-visible { outline-color: #7a5a2f; }
.tab-status-box .forecast-chip.is-active {
  border-color: #2f4a2c;
  background: #3b5a3a;
  color: #f3e7c8;
}
.tab-status-box .filter-pill {
  border-color: #b59b6c;
  background: transparent;
  color: #7b6645;
}
.tab-status-box .filter-pill.active {
  background: #c94a31;
  border-color: #8d2e20;
  color: #fff2d9;
}
.tab-status-box .tab-party-tile {
  border-color: #c0a46e;
  background: rgba(255, 252, 242, .5);
}
.tab-status-box .tab-party-tile em { color: #8a7049; }
.tab-status-box .tab-party-tile strong { color: #4f3d27; }
.tab-status-box .tab-party-tile > span { color: #806d4c; }
.tab-status-box .tab-party-tile b { color: #8a3a27; }
.tab-status-box .tab-party-tile.is-returning {
  border-color: #c9a24a;
  background: rgba(201, 162, 74, .16);
}

/* The Research bar keeps the desk's own icon in the current tile; the queue is
   now the last three columns of the shared ledger, so the whole bar reads with
   the same current-and-queue rhythm as the School and Workshop. */
.research-status-head-copy {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.research-status-mark {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  border: 1px solid #b59b6c;
  background: rgba(255, 246, 224, .42);
  box-shadow: inset 0 0 0 2px rgba(128, 96, 50, .12);
  color: #8a3a27;
}
.research-status-mark svg { width: 17px; height: 17px; }
.research-status-title { min-width: 0; }
.research-status-head .upgrade-kicker { font-size: 10px; line-height: 1; }
.tab-status-box .research-status-title strong {
  display: block;
  margin-top: 3px;
  max-width: 100%;
  overflow: hidden;
  color: #4f3d27;
  font-family: var(--font-pixel);
  font-size: 14px;
  font-weight: 400;
  line-height: 1.1;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.research-status-head .construction-eta b { color: #8d3d28; }
.research-status-facts {
  align-items: center;
  justify-content: flex-start;
  flex-wrap: nowrap;
  gap: 10px;
}
.research-status-rate {
  display: inline-flex;
  flex-wrap: nowrap;
  align-items: baseline;
  gap: 2px 10px;
  min-width: 0;
  overflow: hidden;
}
.research-status-rate > span { white-space: nowrap; }

/* One small tile per party in the field. */
.tab-party-strip {
  display: flex;
  gap: 6px;
  width: 100%;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: thin;
}
.tab-party-tile {
  flex: 1 1 0;
  min-width: 0;
  padding: 4px 9px;
  border: 1px solid rgba(169, 139, 86, .5);
  background: rgba(255, 247, 230, .06);
}
.tab-party-tile em {
  display: block;
  color: #94ab98;
  font-family: var(--font-pixel);
  font-size: 9px;
  font-style: normal;
  letter-spacing: .1em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tab-party-tile strong {
  display: block;
  color: #f7e7c3;
  font-family: var(--font-pixel);
  font-size: 12px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tab-party-tile > span {
  display: block;
  color: #a9bda7;
  font-family: var(--font-pixel);
  font-size: 10px;
  white-space: nowrap;
}
.tab-party-tile b {
  color: #f0d18c;
  font-weight: 700;
}
.tab-party-tile.is-returning {
  border-color: #c9a24a;
  background: rgba(201, 162, 74, .14);
}

/* Villager trade filter lives in the footer so it stays reachable while
   the register scrolls. */
.tab-filter-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  width: 100%;
}

.screen-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 26px;
  width: 100%;
  margin-bottom: 22px;
  padding-bottom: 20px;
  border-bottom: 1px solid rgba(195, 158, 90, .28);
  color: #f6e8c9;
}

.screen-head .eyebrow { color: #d6ac58; margin-bottom: 7px; }

.screen-title {
  font-family: var(--font-display);
  font-size: clamp(38px, 4.3vw, 59px);
  font-weight: 700;
  line-height: .88;
  letter-spacing: -.025em;
  color: #fff0cf;
  text-shadow: 0 3px 0 rgba(8, 22, 20, .3);
}

.screen-subtitle {
  max-width: 590px;
  margin-top: 10px;
  color: #b9c9b8;
  font-size: 14px;
  line-height: 1.5;
}

.head-stats {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.mini-stat {
  min-width: 94px;
  padding: 9px 12px;
  border: 1px solid rgba(195, 158, 90, .34);
  background: rgba(15, 34, 32, .52);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .05);
}
.mini-stat span {
  display: block;
  color: #8fa98f;
  font-family: var(--font-pixel);
  font-size: 12px;
  letter-spacing: .05em;
  text-transform: uppercase;
}
.mini-stat strong {
  display: block;
  margin-top: 6px;
  color: #f4dfb1;
  font-family: var(--font-pixel);
  font-size: 14px;
}

.panel {
  position: relative;
  padding: 22px;
  color: var(--ink);
  background:
    linear-gradient(160deg, rgba(255, 252, 242, .35), rgba(255, 251, 235, 0) 60%),
    repeating-linear-gradient(0deg, #f0e0bd 0 3px, #f4e7c9 3px 6px);
  border: 1px solid #b4935c;
  box-shadow:
    0 0 0 3px #213632,
    0 0 0 4px #634f32,
    0 12px 28px rgba(4, 12, 11, .25);
}
.panel::after {
  content: "";
  position: absolute;
  inset: 7px;
  border: 1px solid rgba(128, 96, 50, .16);
  pointer-events: none;
}

.panel-head {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 15px;
  padding-bottom: 11px;
  border-bottom: 1px solid #c3aa78;
}
.panel-head h3 {
  font-family: var(--font-display);
  font-size: 25px;
  font-weight: 700;
  line-height: 1;
}
.panel-head p {
  color: #806d4c;
  font-family: var(--font-pixel);
  font-size: 10px;
  letter-spacing: .04em;
  text-align: right;
}

.pixel-label {
  color: #806c49;
  font-family: var(--font-pixel);
  font-size: 10px;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid #7b5a2c;
  border-radius: 2px;
  background: #e7d1a3;
  color: #3f3020;
  font-family: var(--font-pixel);
  font-size: 10px;
  letter-spacing: .03em;
  text-transform: uppercase;
  box-shadow: 0 2px 0 #8a6c3b;
  transition: background .14s ease, transform .1s ease;
}
.button:hover:not(:disabled) { background: #f6e7c5; }
.button:active:not(:disabled) { transform: translateY(1px); box-shadow: 0 1px 0 #8a6c3b; }
.button:disabled { opacity: .42; cursor: not-allowed; box-shadow: none; }

.button.primary {
  border-color: #72281e;
  background: var(--vermilion);
  color: #fff1d7;
  box-shadow: 0 2px 0 #61241b;
}
.button.primary:hover:not(:disabled) { background: #d65a3f; }

.button.dark {
  border-color: #1a3330;
  background: #234843;
  color: #edddb9;
  box-shadow: 0 2px 0 #122924;
}
.button.dark:hover:not(:disabled) { background: #2c5851; }

/* A deliberate defend order is the one blue order on the atlas: it is neither
   an attack (vermilion) nor an ordinary march (dark teal). */
.button.defend {
  border-color: #1f4a6b;
  background: #2f6f9e;
  color: #eaf4ff;
  box-shadow: 0 2px 0 #173a54;
}
.button.defend:hover:not(:disabled) { background: #3b83b8; }

.button.ghost {
  background: transparent;
  color: #6c5637;
  box-shadow: none;
}
.button.ghost:hover:not(:disabled) { background: rgba(132, 100, 55, .1); }

.button.danger {
  border-color: #7d3026;
  background: transparent;
  color: #883228;
  box-shadow: none;
}
.button.danger:hover:not(:disabled) { background: rgba(161, 64, 47, .1); }

.button svg { width: 13px; height: 13px; }

.cost-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
}
.cost-item {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: #6c5736;
  font-family: var(--font-pixel);
  font-size: 12px;
  line-height: 1;
}
.cost-item b { font-weight: 400; }
.cost-item.short { color: #a63b29; }
.cost-item .cost-icon { width: 10px; height: 10px; color: #8a5d2e; }
.cost-item.short .cost-icon { color: #a63b29; }
.cost-item .cost-name {
  font-size: 10px;
  color: #85704d;
  letter-spacing: .02em;
}
.cost-item.short .cost-name { color: #a63b29; }
.build-card.unaffordable .build-name { color: #8a7254; }
.action-note {
  margin-top: 12px;
  padding: 8px 10px;
  border-left: 2px solid #b28a4c;
  background: rgba(151, 119, 65, .1);
  color: #806a49;
  font-size: 10.5px;
  line-height: 1.45;
}
.tab-screen > .tab-inner.is-entering { animation: tab-in .22s ease-out; }
@keyframes tab-in {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: none; }
}

/* ------------------------------------------------------------------ */
/* City                                                               */
/* ------------------------------------------------------------------ */

.city-screen {
  position: relative;
  height: 100%;
  overflow: hidden;
  background: #1b5558;
  isolation: isolate;
}

/* The Village map is the one full-screen section. On a phone it ends above the
   same pinned status bar every other section carries; on desktop the map runs
   to the dock and the bar floats over its foot. #screen is the column either
   way. The bar sits in a `.tab-inner` wrapper so it keeps the shared width and
   side gutters instead of stretching to the screen edge. */
#screen[data-active-tab="city"] {
  display: flex;
  flex-direction: column;
}
#screen[data-active-tab="city"] > .city-screen {
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
}
/* A short landscape phone gives the open crew picker the whole band, but the
   map still keeps the status bar's height: the flex item must not be forced
   back to 100% when the picker opens. */
#screen[data-active-tab="city"]:has(.construction-picker) > .city-screen {
  flex: 1 1 auto;
  height: auto;
}
#screen[data-active-tab="city"] > .city-status-inner {
  flex: 0 0 auto;
  min-height: 0;
  padding: 0;
  gap: 0;
}

/* On desktop the Village map owns the whole band between the HUD and the dock,
   exactly like the World atlas: the status bar floats over the foot of the map
   and the floating panels inside the map stop above it. A phone keeps the
   docked bar, where the narrower screen cannot spare the overlapped strip. */
@media (min-width: 861px) {
  #screen[data-active-tab="city"] > .city-status-inner {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 6;
    width: min(100% - 44px, 1190px);
    min-height: 0;
    margin: 0 auto;
    padding: 0;
    pointer-events: none;
  }
  #screen[data-active-tab="city"] > .city-status-inner > .tab-footer {
    position: relative;
    bottom: auto;
    margin-top: 0;
    pointer-events: auto;
  }
  /* The overlaid bar is part of the map, so it paints no fade bands. */
  #screen[data-active-tab="city"] > .city-status-inner .tab-footer.tab-status-footer::before,
  #screen[data-active-tab="city"] > .city-status-inner .tab-footer.tab-status-footer::after {
    display: none;
  }
  /* Floating map panels clear the ground the bar covers. city.js publishes the
     measured bar height as --city-bar-clearance. */
  #screen[data-active-tab="city"] .city-inspector {
    bottom: calc(16px + var(--city-bar-clearance, 0px));
  }
  #screen[data-active-tab="city"] .road-placement {
    bottom: calc(64px + var(--city-bar-clearance, 0px) + var(--tutorial-guide-clearance, 0px));
  }
}

.city-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: crosshair;
}
.city-canvas.dragging { cursor: grabbing; }

.city-screen::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  box-shadow:
    inset 0 0 110px rgba(4, 23, 22, .38),
    inset 0 20px 34px rgba(4, 23, 22, .18);
  background: radial-gradient(circle at 50% 44%, transparent 42%, rgba(7, 27, 26, .14) 100%);
}

.city-title-row {
  position: absolute;
  z-index: 3;
  top: 14px;
  left: 18px;
  right: 18px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  pointer-events: none;
}
.city-title-copy { min-width: 0; }
.city-title-row .eyebrow { color: #e2bd72; margin-bottom: 5px; }
.city-title {
  font-family: var(--font-display);
  font-size: clamp(26px, 3vw, 38px);
  font-weight: 700;
  line-height: .95;
  letter-spacing: -.02em;
  color: #fff0cf;
  text-shadow: 0 2px 0 rgba(8, 22, 20, .35);
}

/* The screen's floating foot controls share one bottom-left column. The Village
   Tip sits above the Tutorial book and both use the same box, so neither drifts
   when the other is hidden: the column stays pinned to the book's old spot. */
.screen-fab-stack {
  position: absolute;
  z-index: 13;
  left: 16px;
  bottom: 62px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  pointer-events: none;
}
.screen-fab-stack > * { pointer-events: auto; }
.tip-fab { order: 1; }
.tutorial-launcher { order: 2; }

.screen-fab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  width: 76px;
  height: 48px;
  padding: 4px 6px;
  border: 1px solid #a97b38;
  border-radius: 3px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .07), transparent 40%),
    linear-gradient(180deg, #3a2a20, #201812);
  color: #f4e4c1;
  box-shadow: 0 2px 0 rgba(0, 0, 0, .45), 0 8px 18px rgba(4, 10, 10, .4);
  text-align: center;
  cursor: pointer;
  transition: transform .15s ease, color .15s ease, border-color .15s ease, background .15s ease;
}
.screen-fab:hover,
.screen-fab:focus-visible {
  transform: translateY(-1px);
  border-color: #d6a84f;
  color: #fff1c4;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .1), transparent 40%),
    linear-gradient(180deg, #4a3526, #2a1f17);
}
.screen-fab-icon {
  width: 22px;
  height: 22px;
  color: #e7b64e;
}
.tip-fab .screen-fab-icon {
  filter: drop-shadow(0 0 6px rgba(242, 202, 105, .35));
}
.screen-fab-label {
  font-family: var(--font-pixel);
  font-size: 10px;
  line-height: 1;
  letter-spacing: .04em;
  text-transform: uppercase;
}

/* A tip target is re-applied by its tab after every repaint. The outline keeps
   it clear of the card's own border and shadow. */
.tip-target {
  outline: 3px solid rgba(242, 202, 105, .9);
  outline-offset: 3px;
  animation: tip-glow 1.7s ease-in-out infinite;
}
@keyframes tip-glow {
  0%, 100% { outline-color: rgba(242, 202, 105, .45); }
  50% { outline-color: #ffe9a8; }
}
.reduce-motion .tip-target { animation: none; outline-color: rgba(242, 202, 105, .9); }

/* A pointer that lands on a card in a grid. The Workshop and the Inventory both
   use this one treatment, so "the card the Village means" reads the same
   wherever the player is sent: the siblings recede and the chosen card gets a
   solid gold frame, warm paper, a ribbon and the shared tip pulse. */
.tip-grid--tip > .workshop-card:not(.tip-card),
.tip-grid--tip > .inventory-card:not(.tip-card) {
  opacity: .38;
  filter: saturate(.5);
  transition: opacity .18s ease, filter .18s ease;
}
.tip-target.tip-card {
  position: relative;
  z-index: 2;
  border-style: solid;
  border-color: #c19441;
  background:
    linear-gradient(150deg, rgba(255, 252, 239, .72), transparent 54%),
    rgba(255, 243, 207, .5);
  outline: 3px solid #f2ca69;
  outline-offset: 3px;
  box-shadow:
    0 0 0 1px #7b5a2a,
    0 10px 26px rgba(58, 38, 10, .2),
    0 0 34px rgba(242, 202, 105, .32);
}
.tip-card::before {
  content: "SUGGESTED";
  position: absolute;
  z-index: 3;
  top: -11px;
  left: 12px;
  padding: 3px 9px 2px;
  border: 1px solid #ffe9a8;
  background: #c19441;
  color: #241a10;
  font-family: var(--font-pixel);
  font-size: 9px;
  letter-spacing: .1em;
  line-height: 1.2;
  box-shadow: 0 2px 0 rgba(70, 45, 12, .35);
}
.tip-card .button.primary {
  box-shadow: 0 0 0 2px rgba(242, 202, 105, .35), 0 0 18px rgba(242, 202, 105, .3);
}

.city-top {
  position: absolute;
  z-index: 3;
  top: 100px;
  left: 18px;
  right: 18px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  pointer-events: none;
}

.city-stats {
  display: flex;
  align-items: stretch;
  flex-wrap: wrap;
  gap: 6px;
  max-width: min(70%, 640px);
}
.city-stat {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 40px;
  padding: 7px 10px;
  border: 1px solid rgba(207, 173, 104, .42);
  background: rgba(15, 34, 31, .76);
  color: #f5e5c2;
  box-shadow: 0 3px 10px rgba(5, 14, 13, .18);
  backdrop-filter: blur(3px);
}
.city-stat svg { width: 15px; height: 15px; color: #e1b85c; flex: 0 0 auto; }
.city-stat span {
  display: block;
  font-family: var(--font-pixel);
  font-size: 12px;
  letter-spacing: .04em;
  color: #9eb29d;
  text-transform: uppercase;
}
.city-stat strong {
  display: block;
  margin-top: 2px;
  font-family: var(--font-pixel);
  font-size: 13px;
  color: #f8e9c8;
  white-space: nowrap;
}

.city-tools {
  display: flex;
  gap: 5px;
  pointer-events: auto;
}
.map-button {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(207, 173, 104, .46);
  background: rgba(15, 34, 31, .78);
  color: #f0d59b;
  font-family: var(--font-pixel);
  font-size: 13px;
  box-shadow: 0 3px 10px rgba(5, 14, 13, .18);
  transition: background .15s ease;
  /* A quick double tap on +/− is two zoom steps, never Safari's page zoom. */
  touch-action: manipulation;
}
.map-button:hover { background: rgba(58, 91, 76, .9); }
.map-button svg { width: 16px; height: 16px; }
.map-button.active {
  background: rgba(169, 63, 45, .9);
  border-color: #f0c765;
  color: #fff1c9;
  box-shadow: 0 0 0 1px rgba(240, 199, 101, .35), 0 3px 10px rgba(5, 14, 13, .18);
}

.city-help {
  position: absolute;
  z-index: 2;
  left: 18px;
  bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  background: rgba(14, 32, 30, .66);
  border: 1px solid rgba(197, 162, 94, .28);
  color: #c8cbb1;
  font-family: var(--font-pixel);
  font-size: 12px;
  line-height: 1.5;
  letter-spacing: .02em;
  pointer-events: none;
}
.city-help kbd {
  padding: 1px 4px;
  border: 1px solid #8f7b55;
  background: rgba(235, 215, 172, .1);
  color: #e7cf9e;
  font-family: inherit;
  font-size: 12px;
}

/* Shaped-road placement tray. The map underneath keeps the pointer, so the
   tray must stay out of the way and anchor to the bottom of the viewport. */
.road-placement {
  position: absolute;
  z-index: 4;
  left: 50%;
  bottom: calc(64px + var(--tutorial-guide-clearance, 0px));
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 14px;
  width: max-content;
  max-width: min(760px, calc(100% - 32px));
  padding: 10px 12px;
  border: 1px solid rgba(207, 173, 104, .54);
  background: rgba(14, 32, 30, .93);
  color: #f2e4c3;
  box-shadow: 0 8px 26px rgba(4, 18, 16, .4), inset 0 0 0 1px rgba(255, 244, 213, .05);
  backdrop-filter: blur(5px);
}
.road-placement[hidden] { display: none; }
.road-placement-art {
  width: 108px;
  height: 66px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border: 1px solid rgba(207, 173, 104, .34);
  background: radial-gradient(circle at 50% 45%, rgba(44, 77, 66, .9), rgba(10, 27, 25, .92));
}
.road-placement-art img { width: 100%; height: 100%; object-fit: contain; }
.road-placement-copy { min-width: 0; }
.road-placement-copy strong {
  display: block;
  font-family: var(--font-display);
  font-size: 19px;
  line-height: 1;
  color: #fff0cd;
}
.road-placement-kicker {
  display: block;
  margin-bottom: 3px;
  color: #d9a95f;
  font-family: var(--font-pixel);
  font-size: 10px;
  letter-spacing: .07em;
}
.road-placement-copy p {
  margin: 5px 0 0;
  max-width: 400px;
  color: #b9c3b0;
  font-size: 10.5px;
  line-height: 1.4;
}
.road-placement-copy p kbd {
  padding: 0 3px;
  border: 1px solid rgba(207, 173, 104, .4);
  color: #e7cd94;
  font-size: 9px;
}
.road-placement-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 14px;
  margin-top: 6px;
  color: #d9dfcc;
  font-family: var(--font-pixel);
  font-size: 10px;
}
.road-placement-legend span { display: inline-flex; align-items: center; gap: 5px; }
.road-legend-swatch {
  width: 14px;
  height: 8px;
  display: inline-block;
  border: 1px solid rgba(255, 255, 255, .35);
}
.road-legend-road { background: rgba(154, 216, 245, .6); border-color: rgba(196, 238, 255, .65); }
.road-legend-building { background: rgba(249, 225, 143, .6); border-color: rgba(255, 240, 171, .6); }
.road-placement-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 7px;
  margin-left: auto;
  flex: 0 0 auto;
  color: #d6c193;
  font-family: var(--font-pixel);
  font-size: 11px;
}
.road-placement-actions .button { min-height: 27px; color: #e6d3a0; border-color: rgba(207, 173, 104, .45); }
.road-placement-actions kbd {
  margin-left: 3px;
  padding: 0 3px;
  border: 1px solid rgba(207, 173, 104, .45);
  color: #d9c087;
  font-size: 9px;
}

/* ------------------------------------------------------------------ */
/* New-player tutorial                                                */
/* ------------------------------------------------------------------ */

.map-button:disabled {
  opacity: .42;
  cursor: not-allowed;
}

.tutorial-guide {
  position: absolute;
  z-index: 12;
  left: 16px;
  bottom: 16px;
  width: min(390px, calc(100% - 32px));
  max-height: calc(100% - 32px);
  overflow-y: auto;
  padding: 14px 15px 15px;
  color: #2b261c;
  background:
    linear-gradient(150deg, rgba(255, 250, 234, .55), transparent 52%),
    repeating-linear-gradient(0deg, #f0e0bd 0 3px, #f6ead0 3px 6px);
  border: 1px solid #ad8b53;
  box-shadow:
    0 0 0 3px rgba(24, 46, 42, .9),
    0 0 0 4px #6a5434,
    0 14px 38px rgba(5, 14, 13, .42);
  pointer-events: auto;
}
/* The card is always anchored to the foot of #screen, directly above the
   navbar. That is where the dock sits, so the lesson reads as part of the
   navigation on every tab and at every step: no lesson floats at the top of
   the screen or under a toolbar. When the card needs to keep a panel
   readable, it moves sideways (see .is-combat-report), never upwards. */
/* The report summary runs across the top of the replay. Keep that card's
   callout in the lower corner so turns, survivors and the winning side stay
   readable while the report is being explained. */
.tutorial-guide.is-combat-report {
  top: auto;
  right: 16px;
  bottom: 16px;
  left: auto;
}
/* While the guide is open it stands in the tab's pinned status bar: the bar
   keeps its paper frame and the lesson replaces the bar's own readout. The
   status content stays in the DOM, hidden but ready for the moment the card is
   dismissed. A section without a status bar keeps the floating card. */
.tutorial-open .tab-status-box > :not(.tutorial-status-slot) { display: none; }
/* The bar is a one-column grid (the shared box only declares its rows), so the
   lesson needs an explicit full-width track. Left at its implicit auto column,
   the slot sizes to the lesson's max-content and the bar reads half empty; the
   old `flex-start` packing made that worse by keeping the column narrow. */
.tutorial-open .tab-status-box {
  grid-template-columns: minmax(0, 1fr);
  justify-content: stretch;
}
/* The open lesson owns the whole paper box, so the box's own padding must step
   aside: the collapse chevron is hidden by .tutorial-open, yet its reserved
   44px would still shrink the card and leave an empty column beside it. Move
   that inset onto the slot instead; the tutorial then spans the bar and keeps
   the same inner spacing as its floating card. */
.tutorial-open .tab-status-box,
.tutorial-open .tab-status-box.has-status-collapse {
  padding: 0;
}
.tutorial-status-slot {
  /* The status box draws its paper in an absolutely positioned ::before with
     z-index 0. The slot must sit above that layer, exactly like the native
     .tab-status-content, or the cream paper paints over the lesson and the bar
     reads as empty. */
  position: relative;
  z-index: 1;
  width: 100%;
  min-width: 0;
  padding: 14px 15px 15px;
}
.tutorial-status-slot .tutorial-guide {
  position: static;
  width: 100%;
  max-height: none;
  padding: 0;
  overflow: visible;
  background: none;
  border: 0;
  box-shadow: none;
}
.tutorial-status-slot .tutorial-guide.is-combat-report {
  position: static;
  inset: auto;
}
/* The World status box is a capped two-column grid by default. When it carries
   the guide it becomes one full-width column that can grow with the lesson. */
.world-status.tutorial-open .world-status-box {
  display: block;
  max-height: min(56vh, 520px);
  overflow-y: auto;
}
/* A full-screen map with no status bar of its own still gets a framed bar for
   the open guide, pinned to the foot of the map. */
.tab-footer.tutorial-floating-status {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 9;
  display: block;
  margin: 0;
  padding: 18px 22px;
  max-height: 100%;
  overflow-y: auto;
}
.tutorial-floating-status .tab-status-box {
  width: 100%;
  max-width: 1190px;
  margin: 0 auto;
}
.tutorial-guide-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.tutorial-kicker {
  color: #92764b;
  font-family: var(--font-pixel);
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
}
/* The cross itself is the shared red overlay control (.cross-close); the card
   only keeps it from being squeezed by the kicker. */
.tutorial-dismiss {
  flex: 0 0 auto;
}
/* The way back into a closed lesson: a book button pinned to the left foot of
   the screen, just above the navbar. It is a .screen-fab, so it matches the Tip
   button stacked above it. */
.tutorial-title {
  margin-top: 6px;
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
  line-height: 1.05;
}
.tutorial-body {
  margin-top: 7px;
  color: #4f4430;
  font-family: var(--font-pixel);
  font-size: 13px;
  line-height: 1.55;
}
.tutorial-page-body > * + * {
  margin-top: 8px;
}
.tutorial-page-body .tutorial-body:first-child {
  margin-top: 7px;
}
.tutorial-guide-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 12px;
}
.tutorial-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.tutorial-skip {
  flex: 0 0 auto;
  margin: 0 0 0 auto;
  padding: 0;
  border: 0;
  background: none;
  color: #8a7550;
  font-family: var(--font-pixel);
  font-size: 11px;
  letter-spacing: .04em;
  white-space: nowrap;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}
.tutorial-skip:hover {
  color: #8d3e29;
}
/* The tutorial claim card. It is the one blocking step in the guide: the
   village is already built, and these three facts carry it to a live world. */
.tutorial-claim-scrim {
  position: fixed;
  inset: 0;
  z-index: 420;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(22, 18, 12, .62);
  backdrop-filter: blur(2px);
}
.tutorial-claim-scrim[hidden] { display: none; }
body.tutorial-claim-open { overflow: hidden; }
.tutorial-claim {
  width: min(430px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
  display: grid;
  gap: 10px;
  margin: 0;
}
.tutorial-claim-kicker {
  color: var(--ui-box-kicker, #8a7550);
  font-family: var(--font-pixel);
  font-size: 10px;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.tutorial-claim-title {
  margin: 0;
  font-family: var(--ui-box-heading-font, var(--font-pixel));
  font-size: 24px;
  line-height: 1.05;
  color: var(--ui-box-heading, #3b2e20);
}
.tutorial-claim-copy {
  margin: 0;
  color: var(--ui-box-body, #4f4430);
  font-size: 13px;
  line-height: 1.5;
}
.tutorial-claim-field {
  display: grid;
  gap: 4px;
  font-family: var(--font-pixel);
  font-size: 11px;
  letter-spacing: .04em;
  color: #5d4d32;
}
.tutorial-claim-field input {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 11px;
  border: 1px solid #b99d6d;
  border-radius: 2px;
  background: #fff9e9;
  color: #3b2e20;
  font: 15px/1.2 Georgia, "Times New Roman", serif;
}
.tutorial-claim-field input:focus {
  outline: 2px solid #a6412d;
  outline-offset: 1px;
}
.tutorial-claim-hint {
  margin: 0;
  color: #7d6a49;
  font-size: 11px;
  line-height: 1.4;
}
.tutorial-claim-error {
  min-height: 1em;
  margin: 0;
  color: #8d3e29;
  font-family: var(--font-pixel);
  font-size: 11px;
  line-height: 1.4;
}
.tutorial-claim-submit {
  justify-self: start;
}
@media (max-width: 520px) {
  .tutorial-claim-scrim { padding: 12px; }
  .tutorial-claim { max-height: calc(100vh - 24px); }
}
.tutorial-stat-list {
  display: grid;
  gap: 6px;
  margin-top: 9px;
}
.tutorial-stat-row {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  padding: 7px 9px;
  border-left: 3px solid #b8934f;
  background: rgba(255, 252, 242, .46);
  color: #4f4430;
  font-family: var(--font-pixel);
  font-size: 11.5px;
  line-height: 1.5;
}
.tutorial-stat-row b {
  color: #8d3e29;
  font-size: 12px;
  letter-spacing: .04em;
}
.tutorial-stat-row strong {
  color: #33291b;
}
.tutorial-slot-list {
  display: grid;
  gap: 4px;
  margin-top: 8px;
  color: #4f4430;
  font-family: var(--font-pixel);
  font-size: 11.5px;
  line-height: 1.5;
}
.tutorial-slot-list span {
  padding: 5px 8px;
  border: 1px solid rgba(144, 116, 69, .34);
  background: rgba(255, 252, 242, .4);
}
.tutorial-slot-list b {
  display: inline-block;
  min-width: 58px;
  color: #8d3e29;
}
.tutorial-item-card {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  padding: 9px 11px;
  border: 1px solid #b2915c;
  background: rgba(255, 248, 232, .55);
}
.tutorial-item-glyph {
  min-width: 42px;
  padding: 7px 4px;
  border: 1px solid #b49a6a;
  background: rgba(214, 189, 139, .4);
  color: #6b5127;
  font-family: var(--font-pixel);
  font-size: 12px;
  text-align: center;
}
.tutorial-item-card strong {
  display: block;
  font-family: var(--font-display);
  font-size: 19px;
  line-height: 1;
}
.tutorial-item-card span {
  display: block;
  margin-top: 3px;
  color: #6f5a3c;
  font-family: var(--font-pixel);
  font-size: 11px;
  line-height: 1.45;
}
.tutorial-compare {
  margin-top: 10px;
  border: 1px solid #b2915c;
  background: rgba(255, 248, 232, .5);
}
.tutorial-compare-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 10px;
  color: #5a4a31;
  font-family: var(--font-pixel);
  font-size: 11.5px;
}
.tutorial-compare-row + .tutorial-compare-row {
  border-top: 1px solid rgba(157, 126, 75, .3);
}
.tutorial-compare-row strong {
  color: #33291b;
  font-size: 13px;
}
.tutorial-compare-row.is-better {
  background: rgba(126, 168, 96, .16);
}
.tutorial-compare-row.is-better strong {
  color: #2f5d2a;
}
.tutorial-compare-row em {
  color: #2f5d2a;
  font-style: normal;
  font-size: 11px;
}
/* The gear lesson reads as one before-and-after row: base production on the
   left, the same Farm after the Hoe's percentage on the right. */
.tutorial-compare.is-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: stretch;
  overflow: hidden;
}
.tutorial-compare-cell {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  padding: 8px 10px;
  color: #5a4a31;
  font-family: var(--font-pixel);
  font-size: 11px;
  line-height: 1.35;
}
.tutorial-compare-cell > span {
  color: #6f5a3c;
  font-size: 10px;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.tutorial-compare-cell strong {
  color: #33291b;
  font-size: 16px;
  line-height: 1.1;
  white-space: nowrap;
}
.tutorial-compare-cell strong small {
  color: #6f5a3c;
  font-size: 10px;
  font-weight: normal;
}
.tutorial-compare-cell em {
  color: #2f5d2a;
  font-style: normal;
  font-size: 10.5px;
}
.tutorial-compare-cell.is-better {
  background: rgba(126, 168, 96, .16);
}
.tutorial-compare-cell.is-better strong {
  color: #2f5d2a;
}
.tutorial-compare-arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 2px;
  color: #9d7e4b;
  font-family: var(--font-pixel);
  font-size: 14px;
}
@media (max-width: 380px) {
  .tutorial-compare-cell {
    padding: 7px 7px;
    font-size: 10px;
  }
  .tutorial-compare-cell strong {
    font-size: 14px;
  }
}
.tutorial-shortfall {
  color: #8d3e29;
}
.tutorial-page-body b.is-short {
  color: #a3341c;
}
/* The ordered choices the first Adventure lesson asks for, one row each. */
.tutorial-sequence {
  display: grid;
  gap: 5px;
  margin-top: 9px;
}
.tutorial-sequence-row {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  align-items: start;
  gap: 9px;
  padding: 7px 9px;
  border: 1px solid rgba(144, 116, 69, .38);
  background: rgba(255, 252, 242, .44);
  color: #6b5a3d;
  font-family: var(--font-pixel);
  font-size: 11.5px;
  line-height: 1.5;
}
.tutorial-sequence-row b {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 1px solid #b2915c;
  background: rgba(214, 189, 139, .34);
  color: #8a5a1c;
  font-size: 11px;
}
.tutorial-sequence-row strong {
  color: #33291b;
}
.tutorial-sequence-row.is-current {
  border-color: #c79a3f;
  background: rgba(245, 211, 111, .2);
}
.tutorial-sequence-row.is-done {
  border-color: rgba(79, 110, 63, .45);
  background: rgba(79, 110, 63, .1);
  color: #4f5f3f;
}
.tutorial-sequence-row.is-done b {
  border-color: #6d7f52;
  background: rgba(109, 127, 82, .22);
  color: #3e5630;
}
.tutorial-sequence-row.is-done span {
  text-decoration: line-through;
  text-decoration-color: rgba(79, 110, 63, .5);
}
/* The live "required / available" table the gathering wait and the Tavern
   build card both use. */
.tutorial-needs {
  display: grid;
  gap: 5px;
  margin-top: 9px;
}
.tutorial-need {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: baseline;
  gap: 9px;
  padding: 7px 9px;
  border: 1px solid rgba(144, 116, 69, .4);
  background: rgba(255, 252, 242, .5);
  color: #4f4430;
  font-family: var(--font-pixel);
  font-size: 12px;
}
.tutorial-need strong {
  color: #33291b;
  font-size: 13px;
}
.tutorial-need em {
  font-style: normal;
  font-size: 11px;
  color: #7a6744;
}
.tutorial-need.is-short {
  border-color: rgba(163, 52, 28, .55);
  background: rgba(163, 52, 28, .08);
}
.tutorial-need.is-short em {
  color: #a3341c;
}
.tutorial-need.is-met em {
  color: #2f5d2a;
}
/* The gathering wait's two required-resource bars: what the stores hold
   against the Market's price, one bar for wood and one for stone. */
.tutorial-haul-bars {
  display: grid;
  gap: 7px;
  margin-top: 9px;
}
.tutorial-haul-bars .tutorial-site {
  margin-top: 0;
}
.tutorial-haul-bar.is-met .tutorial-site-head strong {
  color: #2f5d2a;
}
.tutorial-haul-bar.is-met .tutorial-site-bar i {
  background: linear-gradient(90deg, #6d8a4d, #9ab968);
}
/* The works countdown the waiting lessons show after a site is placed. */
.tutorial-site {
  margin-top: 9px;
  padding: 9px 10px;
  border: 1px solid rgba(144, 116, 69, .45);
  background: rgba(255, 252, 242, .5);
}
.tutorial-site-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  color: #4f4430;
  font-family: var(--font-pixel);
  font-size: 11px;
}
.tutorial-site-head span {
  white-space: nowrap;
}
.tutorial-site-head strong {
  margin-left: auto;
  color: #8a5a1c;
  font-size: 12px;
  white-space: nowrap;
}
.tutorial-site-bar {
  height: 7px;
  margin-top: 7px;
  border: 1px solid rgba(144, 116, 69, .5);
  background: rgba(120, 98, 60, .16);
}
.tutorial-site-bar i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #c79a3f, #e7c260);
  transition: width .3s linear;
}
.tutorial-site-note {
  margin: 7px 0 0;
  color: #7a6744;
  font-family: var(--font-pixel);
  font-size: 11px;
  line-height: 1.5;
}
/* The exact control a lesson page is talking about. */
.tutorial-spot {
  position: relative;
  z-index: 2;
  outline: 2px solid #f5d36f;
  outline-offset: 2px;
  box-shadow: 0 0 0 3px rgba(245, 211, 111, .35), 0 0 20px rgba(245, 211, 111, .32);
  animation: tutorial-glow 1.6s ease-in-out infinite;
}
.tutorial-footnote {
  margin-top: 8px;
  color: #7a6744;
  font-family: var(--font-pixel);
  font-size: 11px;
  line-height: 1.5;
}
.tutorial-fact-row {
  display: flex;
  gap: 6px;
  margin-top: 10px;
}
.tutorial-fact {
  flex: 1;
  padding: 6px 8px;
  border: 1px solid rgba(144, 116, 69, .4);
  background: rgba(255, 252, 242, .46);
  text-align: center;
}
.tutorial-fact b {
  display: block;
  font-family: var(--font-pixel);
  font-size: 17px;
  color: #3e3422;
}
.tutorial-fact small {
  display: block;
  margin-top: 1px;
  color: #84714c;
  font-family: var(--font-pixel);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.tutorial-report-facts {
  display: flex;
  gap: 6px;
  margin-top: 10px;
}
.tutorial-report-facts > span {
  flex: 1;
  padding: 6px 7px;
  border: 1px solid rgba(144, 116, 69, .4);
  background: rgba(255, 252, 242, .46);
  text-align: center;
}
.tutorial-report-facts b {
  display: block;
  color: #3e3422;
  font-family: var(--font-pixel);
  font-size: 13px;
}
.tutorial-report-facts small {
  display: block;
  margin-top: 2px;
  color: #84714c;
  font-family: var(--font-pixel);
  font-size: 9px;
  letter-spacing: .03em;
  text-transform: uppercase;
}
.tutorial-action {
  width: 100%;
  margin-top: 12px;
}
.tutorial-highlight {
  animation: tutorial-glow 1.6s ease-in-out infinite;
}
.build-card.tutorial-highlight {
  outline: 2px solid rgba(245, 211, 111, .78);
  outline-offset: 3px;
  background: rgba(245, 211, 111, .14);
}
.detail-slot.tutorial-highlight {
  border-color: #f5d36f;
  box-shadow: 0 0 0 2px rgba(245, 211, 111, .5), 0 0 18px rgba(245, 211, 111, .35);
}
.villager-tile.tutorial-highlight {
  border-color: #f5d36f;
  box-shadow: 0 0 0 2px rgba(245, 211, 111, .45), 0 0 22px rgba(245, 211, 111, .3);
}
.construction-block.tutorial-highlight {
  outline: 2px solid rgba(245, 211, 111, .72);
  outline-offset: 3px;
}
.nav-button.tutorial-target {
  border-color: #f5d36f;
  color: #fff1c4;
  box-shadow: 0 0 0 2px rgba(245, 211, 111, .55), 0 0 24px rgba(245, 211, 111, .45);
  animation: tutorial-glow 1.6s ease-in-out infinite;
}
@keyframes tutorial-glow {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.22); }
}

@media (max-width: 900px) {
  /* Every lesson sits in the same place on a phone too: the foot of the
     screen, immediately above the navbar. */
  .tutorial-guide {
    left: 10px;
    right: 10px;
    top: auto;
    bottom: 10px;
    width: auto;
    max-height: calc(100% - 20px);
  }
  /* The phone Villagers dossier rides over the section as a sheet (80) and its
     item picker over that (90). The guide has to stay readable above both, or
     the card -- and the button that claims the step -- disappears behind them.
     It still sits below the toast and the confirmation dialogs. */
  .tutorial-guide { z-index: 95; }
  /* The way back into a closed card, and the Village Tip above it, ride above
     the phone sheets, like the card itself, so the lesson stays one tap away on
     a narrow screen. */
  .screen-fab-stack { left: 10px; bottom: 68px; z-index: 96; }
  .tutorial-guide.is-combat-report {
    top: auto;
    right: 10px;
    bottom: 10px;
    left: 10px;
    width: auto;
  }
  /* A callout pinned to the foot of the screen would cover the last rows of the
     open tab. End the scrollable tab -- and the two full-screen maps -- at the
     card's top so every section can be scrolled or panned clear of it. This also
     shortens the City building inspector and the World panels anchored inside
     those screens. tutorial.js publishes the card's footprint and sets it back
     to zero whenever the card is hidden. */
  #screen > .tab-screen,
  #screen > .city-screen,
  #screen > .world-screen {
    height: calc(100% - var(--tutorial-guide-tab-clearance, 0px));
  }
}

.city-coordinate {
  position: absolute;
  z-index: 4;
  top: 0;
  left: 0;
  padding: 4px 7px;
  background: rgba(12, 26, 25, .82);
  border: 1px solid rgba(206, 171, 99, .4);
  color: #ddc792;
  font-family: var(--font-pixel);
  font-size: 12px;
  pointer-events: none;
  transform: translate(12px, 12px);
  white-space: nowrap;
}

.city-inspector {
  position: absolute;
  z-index: 8;  top: 16px;
  right: 16px;
  bottom: 16px;
  width: min(390px, calc(100% - 32px));
  display: flex;
  flex-direction: column;
  color: var(--ink);
  background:
    linear-gradient(150deg, rgba(255, 250, 234, .4), transparent 48%),
    repeating-linear-gradient(0deg, #f0e0bd 0 3px, #f6ead0 3px 6px);
  border: 1px solid #ad8b53;
  box-shadow:
    0 0 0 3px rgba(24, 46, 42, .9),
    0 0 0 4px #6a5434,
    0 18px 50px rgba(5, 14, 13, .4);
  animation: inspector-in .18s ease-out;
}
@keyframes inspector-in {
  from { opacity: 0; transform: translateX(16px); }
  to { opacity: 1; transform: translateX(0); }
}

.inspector-head {
  position: relative;
  flex: 0 0 auto;
  padding: 18px 18px 14px;
  border-bottom: 2px solid #b18e54;
  background: rgba(195, 159, 94, .12);
}
/* A selected structure shows its own plot in the header; the tile picture is
   the quickest way to tell one road shape from another. */
.inspector-head-tile {
  display: grid;
  grid-template-columns: 100px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 13px 18px 11px;
}
.inspector-tile-art {
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  width: 100px;
  height: 62px;
  padding: 3px;
  border: 1px solid rgba(154, 124, 74, .5);
  background:
    radial-gradient(ellipse at 50% 45%, rgba(159, 177, 101, .22), transparent 66%),
    rgba(255, 247, 230, .36);
  box-shadow: inset 0 0 0 1px rgba(255, 250, 235, .4);
  overflow: hidden;
}
.inspector-tile-art img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
}
.inspector-head-copy { min-width: 0; }
.inspector-kicker {
  color: #92764b;
  font-family: var(--font-pixel);
  font-size: 12px;
  letter-spacing: .08em;
}
.inspector-title {
  margin-top: 5px;
  padding-right: 26px;
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 700;
  line-height: 1;
}
.inspector-coord {
  margin-top: 7px;
  color: #786546;
  font-family: var(--font-pixel);
  font-size: 10px;
  letter-spacing: .03em;
}
.inspector-close {
  position: absolute;
  top: 12px;
  right: 12px;
}

.inspector-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 16px 18px 22px;
  scrollbar-width: thin;
  scrollbar-color: #ae925f transparent;
}
.inspector-body::-webkit-scrollbar { width: 6px; }
.inspector-body::-webkit-scrollbar-thumb { background: #ae925f; }

.inspector-desc {
  color: #6f5e42;
  font-size: 12.5px;
  line-height: 1.5;
}

.build-group { margin-top: 18px; }
.build-group h4 {
  margin: 0 0 8px;
  padding-bottom: 5px;
  border-bottom: 1px solid rgba(147, 116, 67, .34);
  color: #7b6038;
  font-family: var(--font-pixel);
  font-size: 10px;
  font-weight: 400;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.build-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  margin-top: 14px;
  padding: 8px;
  border: 1px solid rgba(154, 124, 74, .36);
  background: rgba(255, 247, 230, .3);
}
.build-filters-label {
  margin-right: 2px;
  color: #8a7654;
  font-family: var(--font-pixel);
  font-size: 10px;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.build-filter-tag {
  padding: 4px 8px;
  border: 1px solid #b2915d;
  background: rgba(255, 247, 230, .32);
  color: #6e5836;
  font-family: var(--font-pixel);
  font-size: 12px;
  letter-spacing: .02em;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.build-filter-tag:hover {
  border-color: #9b3322;
  background: rgba(201, 74, 49, .12);
}
.build-filter-tag:focus-visible { outline: 2px solid #7a5a2f; outline-offset: 1px; }
.build-filter-tag:disabled {
  opacity: .42;
  cursor: not-allowed;
}
.build-filter-tag.active {
  border-color: #8d2e20;
  background: #c94a31;
  color: #fff1d6;
  box-shadow: inset 0 0 0 1px rgba(255, 240, 203, .25);
}
.build-empty {
  margin: 10px 0 4px;
  color: #7b6038;
  font-size: 13px;
}

.build-card {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  gap: 9px;
  align-items: center;
  padding: 9px 0;
  border-bottom: 1px dashed rgba(148, 118, 71, .3);
}
.build-card:last-child { border-bottom: 0; }
.build-icon {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  background: #dfcb9f;
  border: 1px solid #b79a66;
  color: #5e4a2c;
}
.build-icon svg { width: 20px; height: 20px; }
.build-card-road { grid-template-columns: 62px minmax(0, 1fr) auto; }
.build-icon-road {
  width: 62px;
  height: 42px;
  padding: 1px;
  overflow: hidden;
  background: radial-gradient(circle at 50% 45%, #8c9c59, #758647);
  border-color: #8f7947;
}
.build-icon-road img { width: 100%; height: 100%; object-fit: contain; }
.build-copy { min-width: 0; }
.build-name {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 600;
  line-height: 1;
}
.build-tier {
  margin-left: 7px;
  color: #8d3e29;
  font-family: var(--font-pixel);
  font-size: 8px;
  font-weight: 400;
  letter-spacing: .04em;
  vertical-align: middle;
  white-space: nowrap;
}
.build-effect {
  margin-top: 4px;
  color: #7f6a47;
  font-size: 10.5px;
  line-height: 1.35;
}
.build-warning { color: #9b3322; }
.build-cost {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 9px;
  margin-top: 5px;
  color: #6e5836;
  font-family: var(--font-pixel);
  font-size: 12px;
}
.build-cost b { color: #9b3322; font-weight: 400; }
.build-free {
  color: #2f6b33;
  font-weight: 700;
  letter-spacing: .02em;
}
.build-first-note { color: #7f6a47; font-size: 10px; }
.road-shape-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  margin-top: 5px;
  color: #6e5836;
  font-family: var(--font-pixel);
  font-size: 9px;
  line-height: 1.4;
}
.road-shape-summary b {
  margin-right: 4px;
  color: #8d3e29;
  font-weight: 400;
}
.build-road-hint {
  margin: 8px 0 2px;
  padding: 7px 9px;
  border: 1px dashed rgba(148, 118, 71, .44);
  background: rgba(195, 159, 94, .12);
  color: #7f6a47;
  font-size: 10.5px;
  line-height: 1.4;
}
.inventory-road .inventory-kind { color: #8d3e29; }

/* Prices: one resource per line, with the clan's stock before the required
   amount. The fixed columns keep every "/" in the same place inside a card
   and down a list, and the label column fits the longest good name. */
.cost-table {
  --cost-name-col: 90px;
  --cost-number-col: 52px;
  display: grid;
  gap: 2px;
  width: max-content;
  max-width: 100%;
  font-family: var(--font-pixel);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  line-height: 1.3;
}
.cost-row {
  display: grid;
  grid-template-columns: var(--cost-name-col) var(--cost-number-col) 10px var(--cost-number-col);
  column-gap: 4px;
  align-items: baseline;
  color: #1a1a1a;
}
.cost-row.met .cost-held { color: #2f6b33; }
.cost-row.short .cost-held { color: #a63b29; }
.cost-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
}
.cost-label .cost-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cost-label .cost-icon {
  flex: 0 0 auto;
  width: 10px;
  height: 10px;
  color: currentColor;
}
.cost-held,
.cost-required {
  text-align: right;
  white-space: nowrap;
}
.cost-sep {
  text-align: center;
}
.build-card .button { min-height: 32px; padding: 0 9px; }

.building-facts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  margin-top: 14px;
}
.building-fact {
  padding: 8px 9px;
  border: 1px solid rgba(154, 124, 74, .36);
  background: rgba(255, 247, 230, .28);
}
.building-fact span {
  display: block;
  color: #8a7654;
  font-family: var(--font-pixel);
  font-size: 12px;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.building-fact strong {
  display: block;
  margin-top: 4px;
  font-family: var(--font-pixel);
  font-size: 13px;
  font-weight: 400;
  color: #4d3b27;
}

.expansion-facts { grid-template-columns: 1fr; }
.building-fact strong.expansion-price {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
}
.expansion-price b { font-weight: 400; }
.expansion-price .cost-icon { width: 11px; height: 11px; color: #8a5d2e; }
.expansion-price .expansion-price-held.affordable { color: #2f7a43; }
.expansion-price .expansion-price-held.short { color: #a63b29; }
.expansion-price-sep { color: #9b8564; }
.expansion-price-unit { color: #8a7654; font-size: 11px; }

.level-pips {
  display: flex;
  gap: 4px;
  margin-top: 8px;
}
.level-pips i {
  width: 17px;
  height: 5px;
  background: #c5ad7e;
  border: 1px solid #a48754;
}
.level-pips i.on { background: #c94a31; border-color: #8d2e20; }

.productivity-facts { margin-top: 12px; }
.building-fact-productivity { position: relative; padding-right: 25px; }
.building-fact-productivity strong { font-size: 12px; line-height: 1.35; }
.building-fact-productivity small {
  display: block;
  margin-top: 4px;
  color: #8d3d28;
  font-family: var(--font-pixel);
  font-size: 12px;
  line-height: 1.45;
  text-transform: uppercase;
}
.fact-info-button {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(154, 124, 74, .55);
  background: rgba(255, 247, 230, .55);
  color: #8a7654;
  cursor: pointer;
}
.fact-info-button svg { width: 12px; height: 12px; }
.fact-info-button:hover { background: #f0dfb0; color: #4d3b27; }
.fact-info-button:focus-visible { outline: 2px solid #7a5a2f; outline-offset: 1px; }
.fact-info-button[aria-expanded="true"] { border-color: #8d2e20; background: #c94a31; color: #ffefd0; }

/* The expandable note under Productivity itemises the multiplier one row per
   term. Bracket rows are native details elements, so a click reveals the
   bonuses that were summed into them. */
.productivity-calc {
  grid-column: 1 / -1;
  padding: 9px 10px 10px;
  border: 1px solid rgba(154, 124, 74, .36);
  background: rgba(151, 119, 65, .08);
  color: #7d6747;
  font-family: var(--font-pixel);
  font-size: 10px;
}
.productivity-calc[hidden] { display: none; }
.productivity-calc-workers { display: grid; gap: 12px; }
.productivity-ledger {
  padding-right: 12px;
  color: #7d6747;
  font-family: var(--font-pixel);
  font-size: 10px;
}
.productivity-worker-name {
  margin: 0 0 4px;
  color: #4d3b27;
  font-family: var(--font-pixel);
  font-size: 11px;
}
.productivity-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 3px 0;
}
.productivity-row > span { color: #7d6747; }
.productivity-row > strong {
  color: #4d3b27;
  font-weight: 400;
  white-space: nowrap;
}
/* Modifier rows line up in three columns: term, bonus percentage and the
   production that bonus adds. Plain rows leave the bonus column empty so every
   figure still shares the right-hand column. */
.productivity-row-figures {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 56px 62px;
  gap: 4px;
}
.productivity-row-figures > .productivity-bonus {
  color: #927b56;
  text-align: right;
  white-space: nowrap;
}
.productivity-row-figures > .productivity-amount {
  text-align: right;
}
.productivity-rule {
  height: 6px;
  border-bottom: 1px dashed rgba(147, 115, 65, .38);
}
.productivity-bracket { border: 0; }
/* Each bracket shares the ledger's three figure columns. The caret sits in the
   ledger's right gutter so every amount ends on the same edge. */
.productivity-bracket > summary {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 56px 62px;
  gap: 4px;
  align-items: baseline;
  padding: 3px 0;
  cursor: pointer;
  list-style: none;
}
.productivity-bracket > summary::-webkit-details-marker { display: none; }
.productivity-bracket > summary:hover .productivity-bracket-label { color: #4d3b27; }
.productivity-bracket > summary:focus-visible {
  outline: 2px solid #7a5a2f;
  outline-offset: 1px;
}
.productivity-bracket-label {
  color: #7d6747;
}
.productivity-bracket-bonus {
  color: #927b56;
  text-align: right;
  white-space: nowrap;
}
.productivity-bracket-value {
  color: #4d3b27;
  font-weight: 400;
  text-align: right;
  white-space: nowrap;
}
.productivity-bracket-caret {
  position: absolute;
  top: 50%;
  right: -12px;
  width: 0;
  height: 0;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  border-left: 5px solid #8a7654;
  transform: translateY(-50%);
  transition: transform .12s ease;
}
.productivity-bracket[open] .productivity-bracket-caret { transform: translateY(-50%) rotate(90deg); }
.productivity-bracket-body {
  margin: 0 0 3px 4px;
  padding: 0 0 0 9px;
  border-left: 1px dashed rgba(147, 115, 65, .35);
}
.productivity-bracket-body .productivity-row > span { color: #927b56; }
.productivity-subkicker {
  margin: 5px 0 0;
  color: #8a7654;
  font-family: var(--font-pixel);
  font-size: 9px;
  letter-spacing: .05em;
  text-transform: uppercase;
}
.productivity-bracket-rule {
  height: 5px;
  border-bottom: 1px dashed rgba(147, 115, 65, .28);
}
.productivity-bracket-total {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 56px 62px;
  gap: 4px;
  padding: 3px 0 1px;
}
.productivity-bracket-total > span { color: #6f5a3b; }
.productivity-bracket-total > strong {
  color: #4d3b27;
  font-weight: 400;
  text-align: right;
  white-space: nowrap;
}
/* The sketch leaves breathing room between the two brackets instead of a rule. */
.productivity-bracket + .productivity-bracket { margin-top: 8px; }
.productivity-total {
  padding-top: 7px;
  color: #4d6430;
}
.productivity-total > span,
.productivity-total > strong { color: #4d6430; }
.productivity-summary { margin-top: 2px; }
.productivity-subtotal > span,
.productivity-subtotal > strong { color: #4d3b27; }
.productivity-modifiers-kicker {
  margin: 7px 0 1px;
  color: #8a7654;
  font-family: var(--font-pixel);
  font-size: 9px;
  letter-spacing: .05em;
}
.productivity-calc-empty {
  margin: 0;
  color: #806c49;
  font-size: 10px;
  line-height: 1.45;
}
.building-fact-blank {
  min-height: 52px;
  border: 0;
  background: transparent;
}
/* The second fact beside Productivity belongs to the inputs. It is deliberately
   the same box as the output fact, but it names every good the building draws
   from the Warehouse and labels the one burned as fuel. */
.building-fact-consumes {
  border-color: rgba(157, 79, 44, .42);
  background: rgba(169, 71, 43, .07);
}
.building-fact-consumes > span { color: #9b3322; }
.consumes-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 9px;
}
.consumes-good {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  color: #5a4228;
  font-family: var(--font-pixel);
  font-size: 12px;
  font-weight: 400;
}
.consumes-good i { font-style: normal; }
.consumes-good em {
  color: #9b6a3a;
  font-size: 10px;
  font-style: normal;
}
.consumes-icon {
  align-self: center;
  flex: 0 0 auto;
  width: 12px;
  height: 12px;
  color: #8a4d32;
}
.consumes-good small {
  padding: 1px 3px;
  border: 1px solid rgba(157, 79, 44, .4);
  color: #9b3322;
  font-size: 7px;
  letter-spacing: .05em;
}
.consumes-note {
  display: block;
  margin-top: 5px;
  color: #8d6a45;
  font-family: var(--font-pixel);
  font-size: 9px;
  line-height: 1.4;
}

.worker-block { margin-top: 16px; }
.worker-block-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 4px 8px;
}
.worker-block-head h3 {
  margin: 0;
  color: #7b6038;
  font-family: var(--font-pixel);
  font-size: 10px;
  font-weight: 400;
  letter-spacing: .06em;
  text-transform: uppercase;
  white-space: nowrap;
}
.worker-block-head span {
  flex: 1 1 150px;
  color: #8a7654;
  font-family: var(--font-pixel);
  font-size: 10px;
  line-height: 1.4;
  text-align: right;
}
.worker-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 5px;
  margin-top: 8px;
}
.worker-slot {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  aspect-ratio: 1 / 1;
  min-height: 62px;
  padding: 12px 3px 5px;
  border: 1px solid #b2915d;
  background: rgba(255, 247, 230, .32);
  color: #6e5836;
  cursor: pointer;
}
.worker-slot:hover:not(:disabled) {
  border-color: #9b3322;
  background: rgba(201, 74, 49, .12);
}
.worker-slot.filled {
  border-color: #8f6f3f;
  background: #e8d5a9;
}
.worker-slot.selected {
  outline: 2px solid #a93f2d;
  outline-offset: 1px;
  background: #f4dfb4;
}
.worker-slot.locked {
  border-style: dashed;
  background: transparent;
  opacity: .5;
  cursor: not-allowed;
}
.worker-slot-index {
  position: absolute;
  top: 2px;
  left: 4px;
  color: #8a7654;
  font-family: var(--font-pixel);
  font-size: 10px;
}
.worker-slot-avatar {
  width: 28px;
  height: 32px;
  overflow: hidden;
  border: 1px solid #9e7f4e;
  background: #d8c49a;
  image-rendering: pixelated;
}
.worker-slot-avatar svg { display: block; width: 100%; height: 100%; }
.worker-slot-name {
  max-width: 100%;
  overflow: hidden;
  color: #5b4730;
  font-family: var(--font-pixel);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.worker-slot-plus {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border: 1px dashed #9e7f4e;
  color: #8a6a3a;
}
.worker-slot-plus svg { width: 10px; height: 10px; }
.worker-slot-lock {
  color: #8a7654;
  font-family: var(--font-pixel);
  font-size: 12px;
}
.worker-slot.locked .worker-slot-name { font-size: 10px; }

/* The worker swap uses the same golden glow as every other tip target; the
   warmer paper simply keeps the tiny slot legible under the outline. */
.worker-slot.tip-target {
  background: linear-gradient(180deg, #f8e6c4, #f0d5a6);
  box-shadow: 0 0 24px rgba(242, 202, 105, .85), 0 0 8px rgba(242, 202, 105, .55);
}
.worker-slot.tip-target .worker-slot-name { color: #6b3f16; }

.worker-detail {
  margin-top: 10px;
  padding: 9px;
  border: 1px solid rgba(154, 124, 74, .4);
  background: rgba(255, 247, 230, .3);
}
.worker-detail-hint {
  margin: 10px 0 0;
  color: #8a7654;
  font-size: 11px;
  line-height: 1.45;
}
.worker-detail-label {
  margin: 8px 0 6px;
  color: #8a7654;
  font-family: var(--font-pixel);
  font-size: 12px;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.worker-current {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  gap: 7px;
  align-items: center;
  padding-bottom: 8px;
  border-bottom: 1px dashed rgba(148, 118, 71, .35);
}
.worker-current-avatar {
  width: 30px;
  height: 34px;
  overflow: hidden;
  border: 1px solid #9e7f4e;
  background: #d8c49a;
}
.worker-current-avatar svg { display: block; width: 100%; height: 100%; }
.worker-current-copy strong {
  display: block;
  font-family: var(--font-display);
  font-size: 15px;
  line-height: 1;
}
.worker-current-copy span {
  display: block;
  margin-top: 3px;
  color: #8a7654;
  font-family: var(--font-pixel);
  font-size: 12px;
  text-transform: uppercase;
}
.worker-current-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  flex-wrap: wrap;
}

.equip-editor-note {
  margin: 0 0 10px;
  color: #705c3e;
  font-size: 12px;
  line-height: 1.45;
}
.equip-slot {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed rgba(148, 118, 71, .35);
}
.equip-slot-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}
.equip-slot-head h3 {
  margin: 0;
  color: #7b6038;
  font-family: var(--font-pixel);
  font-size: 10px;
  font-weight: 400;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.equip-slot-head span {
  color: #8a7654;
  font-family: var(--font-pixel);
  font-size: 9px;
  letter-spacing: .04em;
}
.equip-slot-label {
  margin: 8px 0 4px;
  color: #8a7654;
  font-family: var(--font-pixel);
  font-size: 9px;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.equip-current {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px;
  border: 1px solid #c1a674;
  background: #f4e7c8;
}
.equip-current.is-empty {
  border-style: dashed;
  background: rgba(255, 252, 239, .45);
}
.equip-current.is-mismatch {
  border-style: dashed;
  background: rgba(255, 252, 239, .5);
}
.picker-item.is-suggested {
  border-color: #6e8a4a;
  background: #eaf0dc;
}
.picker-item.is-upgrade {
  border-color: #6e8a4a;
  background: #f1f5e7;
}
.picker-item.is-upgrade .picker-item-cta {
  border-color: #6e8a4a;
  color: #4f6632;
}
.equip-suggested-badge {
  padding: 1px 4px;
  border: 1px solid #6e8a4a;
  color: #4f6632;
  font-family: var(--font-pixel);
  font-size: 8px;
  letter-spacing: .04em;
}
.equip-slot-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin-top: 6px;
}
.equip-slot-empty {
  margin: 6px 0 0;
  color: #806a46;
  font-size: 11px;
  line-height: 1.4;
}
@media (max-width: 620px) {
  .equip-slot-list { grid-template-columns: 1fr; }
}
.productivity-modal .productivity-ledger { font-size: 12px; }
.productivity-modal .productivity-row { padding: 4px 0; }
.button.small { min-height: 26px; padding: 0 7px; font-size: 12px; }

.idle-workers {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 170px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #ae925f transparent;
}
.idle-worker {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) 18px;
  gap: 7px;
  align-items: center;
  padding: 5px 6px;
  border: 1px solid rgba(154, 124, 74, .36);
  background: rgba(255, 250, 238, .4);
  color: #5b4730;
  text-align: left;
}
.idle-worker:hover { border-color: #9b3322; background: #f3e2bb; }
.idle-worker-avatar {
  width: 28px;
  height: 32px;
  overflow: hidden;
  border: 1px solid #9e7f4e;
  background: #d8c49a;
}
.idle-worker-avatar svg { display: block; width: 100%; height: 100%; }
.idle-worker-copy strong {
  display: block;
  font-family: var(--font-display);
  font-size: 14px;
  line-height: 1;
}
.idle-worker-copy span {
  display: block;
  margin-top: 3px;
  color: #8a7654;
  font-family: var(--font-pixel);
  font-size: 10px;
}
/* The equip picker repeats the equipped item's rolled quality beside its name.
   The shared .inventory-rarity badge supplies the rarity ladder; this keeps the
   nested badge on the slot line instead of taking the block span's own row. */
.idle-worker-copy span .inventory-rarity {
  display: inline-block;
  margin: 0 0 0 3px;
  font-size: 9px;
  line-height: 1.4;
  vertical-align: 1px;
}
.idle-worker-add { display: grid; place-items: center; width: 16px; height: 16px; color: #9b3322; }
.idle-worker-add svg { width: 9px; height: 9px; }
.worker-empty-note { margin: 0; color: #8a7654; font-size: 11px; line-height: 1.45; }

.construction-block {
  margin-top: 14px;
  padding: 10px;
  border: 1px solid rgba(154, 124, 74, .48);
  background: rgba(195, 159, 94, .12);
}
.construction-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
.construction-head strong {
  display: block;
  margin-top: 4px;
  color: #4f3d27;
  font-family: var(--font-pixel);
  font-size: 11px;
  font-weight: 400;
}
.construction-eta {
  color: #8d3d28;
  font-family: var(--font-pixel);
  font-size: 10px;
  text-align: right;
}
.construction-bar {
  height: 8px;
  margin-top: 8px;
  overflow: hidden;
  border: 1px solid #9a7a48;
  background: #d8c49a;
}
.construction-bar i {
  display: block;
  height: 100%;
  background: #c94a31;
  transition: width .3s linear;
}
.construction-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 3px 10px;
  margin-top: 6px;
  color: #7b6038;
  font-family: var(--font-pixel);
  font-size: 10px;
}
/* The growth bar reads as one line: the clock, then the idle hands, the
   population and the beds they fill in a single parenthetical. It never wraps
   onto a second row, so the bar keeps the same height as every other tab's. */
.construction-facts.growth-facts {
  flex-wrap: nowrap;
  white-space: nowrap;
  overflow: hidden;
}
.construction-note {
  margin: 8px 0 0;
  color: #6f5e42;
  font-size: 11.5px;
  line-height: 1.45;
}
.construction-roster-head {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin-top: 10px;
  color: #7b6038;
  font-family: var(--font-pixel);
  font-size: 9px;
  letter-spacing: .03em;
  text-transform: uppercase;
}
.construction-roster-head span { padding: 0 2px; }
.construction-roster-head span:last-child { text-align: right; }
.construction-roster {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px 6px;
  margin-top: 4px;
}
.construction-slot {
  min-width: 0;
  min-height: 48px;
  padding: 5px 6px;
  border: 1px solid rgba(154, 124, 74, .42);
  background: rgba(255, 250, 238, .4);
  color: #5b4730;
  text-align: left;
}
.construction-slot.is-filled {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr) 16px;
  gap: 6px;
  align-items: center;
}
.construction-slot.is-builder { border-left: 3px solid rgba(155, 51, 34, .55); }
.construction-slot.is-planner { border-right: 3px solid rgba(62, 96, 105, .45); }
.construction-slot .idle-worker-avatar {
  width: 26px;
  height: 30px;
}
.construction-slot.is-empty {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr);
  gap: 6px;
  align-items: center;
  border-style: dashed;
  background: rgba(218, 195, 152, .18);
}
.construction-slot.is-empty:hover {
  border-color: #9b3322;
  background: #f3e2bb;
}
.construction-slot.is-empty.selected {
  border-color: #9b3322;
  background: #f3e2bb;
  box-shadow: inset 0 0 0 1px rgba(155, 51, 34, .35);
}
.construction-slot-plus {
  display: grid;
  place-items: center;
  width: 26px;
  height: 30px;
  border: 1px solid rgba(154, 124, 74, .48);
  background: rgba(255, 250, 238, .55);
  color: #9b3322;
}
.construction-slot-plus svg { width: 10px; height: 10px; }
.construction-slot-copy { min-width: 0; }
.construction-slot-copy strong {
  display: block;
  overflow: hidden;
  font-family: var(--font-display);
  font-size: 13px;
  line-height: 1.05;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.construction-slot-copy > span {
  display: block;
  margin-top: 3px;
  overflow: hidden;
  color: #8a7654;
  font-family: var(--font-pixel);
  font-size: 9px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.construction-slot.is-empty .construction-slot-copy strong { color: #8d3d28; }
.construction-slot-remove {
  display: grid;
  place-items: center;
  width: 16px;
  height: 20px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #8d3d28;
  font-family: var(--font-display);
  font-size: 16px;
  line-height: 1;
}
.construction-slot-remove:hover { background: rgba(155, 51, 34, .1); }
.construction-hint {
  margin: 8px 0 0;
  color: #8a7654;
  font-size: 11px;
  line-height: 1.4;
}
.construction-empty-note { margin-top: 6px; }
.construction-picker {
  margin-top: 9px;
  padding: 7px;
  border: 1px solid rgba(154, 124, 74, .48);
  background: rgba(255, 250, 238, .45);
}
.construction-picker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.construction-picker .worker-detail-label { margin: 0; }
.construction-picker-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 6px;
}
.construction-picker-actions .button.small { min-height: 30px; }
.construction-picker-close { flex: 0 0 auto; }
.construction-picker-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 154px;
  margin-top: 6px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #ae925f transparent;
}
.construction-idle-row {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  gap: 7px;
  align-items: center;
  padding: 5px 6px;
  border: 1px solid rgba(154, 124, 74, .36);
  background: rgba(255, 250, 238, .4);
}
.construction-idle-row .button { min-height: 26px; font-size: 11px; padding: 0 7px; }
.construction-slot-copy .construction-resolved-bonus,
.construction-idle-row .construction-resolved-bonus { color: #8d3d28; }
.build-time {
  margin-top: 4px;
  color: #8a7654;
  font-family: var(--font-pixel);
  font-size: 10px;
}

.upgrade-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 16px;
  padding: 10px;
  border: 1px solid rgba(154, 124, 74, .4);
  background: rgba(195, 159, 94, .1);
}
.upgrade-panel.is-max { border-style: dashed; }
.upgrade-panel .button { width: 100%; }
.upgrade-kicker {
  color: #92764b;
  font-family: var(--font-pixel);
  font-size: 12px;
  letter-spacing: .05em;
}
.upgrade-copy strong {
  display: block;
  margin-top: 4px;
  color: #4d3b27;
  font-family: var(--font-pixel);
  font-size: 10px;
  font-weight: 400;
  line-height: 1.45;
}
.upgrade-panel .build-cost { margin-top: 6px; }

/* Improving a road happens in the road's own inspector: a row of Inventory
   pieces, the turned preview, and one Improve button. */
.road-upgrade-panel { gap: 9px; }
.road-upgrade-picker {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(62px, 1fr));
  gap: 5px;
}
.road-upgrade-option {
  display: grid;
  gap: 1px;
  padding: 4px 3px 5px;
  border: 1px solid rgba(154, 124, 74, .46);
  background: rgba(255, 250, 238, .42);
  color: #5a482f;
  font-family: var(--font-pixel);
  text-align: center;
  cursor: pointer;
}
.road-upgrade-option:hover { border-color: #8a3a27; }
.road-upgrade-option.is-selected {
  border-color: #8a3a27;
  background: rgba(201, 74, 49, .1);
  box-shadow: inset 0 0 0 1px rgba(138, 58, 39, .36);
}
.road-upgrade-option img {
  display: block;
  width: 100%;
  height: auto;
  image-rendering: pixelated;
}
.road-upgrade-option-name {
  overflow-wrap: anywhere;
  font-size: 8px;
  line-height: 1.15;
}
.road-upgrade-option-stock { color: #85704d; font-size: 8px; }
.road-upgrade-option-fit { font-size: 7.5px; letter-spacing: .04em; color: #a0523d; }
.road-upgrade-option.is-fit .road-upgrade-option-fit { color: #3f6b4f; }

.road-upgrade-detail {
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr);
  gap: 9px;
  align-items: center;
  padding: 7px;
  border: 1px solid rgba(154, 124, 74, .38);
  background:
    radial-gradient(circle at 24% 46%, rgba(159, 177, 101, .18), transparent 64%),
    rgba(255, 250, 238, .4);
}
.road-upgrade-art {
  display: grid;
  place-items: center;
  width: 104px;
  height: 62px;
  overflow: hidden;
}
.road-upgrade-art img { width: 100%; height: 100%; object-fit: contain; image-rendering: pixelated; }
.road-upgrade-copy { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.road-upgrade-copy strong {
  color: #4d3b27;
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
}
.road-upgrade-status { font-family: var(--font-pixel); font-size: 9px; letter-spacing: .05em; }
.road-upgrade-status.is-fit { color: #3f6b4f; }
.road-upgrade-status.is-blocked { color: #a0523d; }
.road-upgrade-target { color: #6f5e42; font-size: 9.5px; line-height: 1.35; }
.road-upgrade-shape {
  color: #8a7654;
  font-family: var(--font-pixel);
  font-size: 8px;
  line-height: 1.35;
}
.road-upgrade-actions { display: flex; gap: 6px; }
.road-upgrade-panel .road-upgrade-actions .button { width: auto; flex: 1 1 0; min-height: 29px; }
.road-upgrade-panel .action-note { margin-top: 0; }

.inspector-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid #c1a674;
}
.inspector-actions .button { flex: 1 1 auto; }

.inspector-empty {
  padding: 18px 0;
  color: #8a7553;
  font-size: 12.5px;
  line-height: 1.5;
  text-align: center;
}

/* ------------------------------------------------------------------ */
/* World                                                              */
/* ------------------------------------------------------------------ */

.world-screen {
  position: relative;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #174f66;
  isolation: isolate;
}
/* The stage owns the whole band between the HUD and the dock; the atlas canvas
   keeps its own coordinate space so the top overlays and the vignette stay on
   the map. On a phone the status bar takes a docked row below it; on desktop it
   floats over the stage's foot instead. */
.world-stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}
.world-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  /* All touch gestures on the atlas belong to the map: the browser must not
     scroll, double-tap-zoom or select while a finger is panning or pinching. */
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  cursor: crosshair;
}
.world-canvas.dragging { cursor: grabbing; }

.world-stage::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  box-shadow:
    inset 0 0 120px rgba(4, 23, 31, .32),
    inset 0 20px 30px rgba(4, 23, 31, .14);
}

/* The atlas itself wears the alarm while a party is locked under attack. The
   red frame sits under the overlays so it never dims a control. */
.world-stage.is-under-attack::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  box-shadow:
    inset 0 0 0 3px rgba(214, 62, 38, .72),
    inset 0 0 88px rgba(181, 38, 20, .42);
  animation: world-attack-glow 1.35s ease-in-out infinite;
}
@keyframes world-attack-glow {
  0%, 100% { opacity: .62; }
  50% { opacity: 1; }
}

.world-attack-banner {
  position: absolute;
  z-index: 4;
  top: 104px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(92%, 520px);
  padding: 8px 14px 8px 10px;
  background: rgba(86, 20, 12, .92);
  border: 1px solid rgba(255, 124, 92, .78);
  color: #ffe4d8;
  box-shadow: 0 8px 22px rgba(24, 4, 2, .36);
  pointer-events: none;
}
.world-attack-banner[hidden] { display: none; }
.world-attack-banner-mark {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 1px solid rgba(255, 138, 108, .9);
  border-radius: 50%;
  background: rgba(46, 7, 4, .7);
  color: #ffd7c9;
  font-family: var(--font-pixel);
  font-size: 17px;
  animation: world-attack-glow 1.35s ease-in-out infinite;
}
.world-attack-banner-copy { display: grid; gap: 2px; min-width: 0; }
.world-attack-banner-copy strong {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
}
.world-attack-banner-copy span {
  color: #ffcbbd;
  font-size: 11px;
  line-height: 1.35;
}

.world-top {
  position: absolute;
  z-index: 3;
  top: 16px;
  left: 18px;
  right: 18px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  pointer-events: none;
}
.world-title-block {
  padding: 9px 13px;
  background: rgba(10, 28, 36, .75);
  border: 1px solid rgba(200, 167, 96, .38);
  color: #f4e5c4;
  box-shadow: 0 4px 16px rgba(3, 12, 16, .18);
}
.world-title-block .eyebrow { color: #d0a954; font-size: 12px; }
.world-title-block h2 {
  margin-top: 4px;
  font-family: var(--font-display);
  font-size: 25px;
  font-weight: 700;
  line-height: .9;
}
.world-title-block p {
  margin-top: 5px;
  color: #a6c2c4;
  font-family: var(--font-pixel);
  font-size: 12px;
  letter-spacing: .03em;
}

.world-top-right {
  display: flex;
  /* Keep the toolbar at its own height instead of stretching it to the tall
     coordinate panel. A stretched toolbar made the appended filter button
     centre itself far below the map buttons it belongs to. */
  align-items: flex-start;
  gap: 6px;
  pointer-events: auto;
}

/* The World tab's status bar. It uses the shared paper box so it sits
   in the same visual family as every other section, with the same centred
   column. Its two halves split the row: the selected party stays live on the
   left while the selected tile's actions open on the right instead of floating
   over the map. A phone docks it above the navbar; a desktop map lets the
   atlas run underneath it (see the media query below). */
.world-status {
  position: relative;
  z-index: 4;
  flex: 0 0 auto;
  padding: 18px 0;
  background: transparent;
  box-shadow: 0 -6px 18px rgba(4, 12, 11, .28);
}
/* On desktop the atlas owns the whole band between the HUD and the dock. The
   status bar floats over the foot of the map instead of reserving a row of its
   own, so the ground can be panned right down to the navbar and the bar reads
   as part of the map rather than a lid on it. A phone keeps the docked bar: the
   narrower screen cannot spare the overlaid strip. */
@media (min-width: 861px) {
  .world-status {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    pointer-events: none;
    /* The map runs behind the bar, so the wrapper paints no scrim, shadow or
       band: only the paper box itself separates the bar from the atlas. */
    box-shadow: none;
  }
  /* The bar's own band stays transparent so the map shows through it; only the
     paper box and its controls take the pointer. */
  .world-status > .world-status-box { pointer-events: auto; }
}
.world-status-box {
  display: grid;
  /* The two world columns live inside the shared collapsible content row. */
  grid-template-columns: minmax(0, 1fr);
  width: min(100% - 44px, 1190px);
  min-height: 118px;
  max-height: min(210px, 34vh);
  margin: 0 auto;
  padding: 14px 18px;
  overflow: visible;
}
.world-status-content {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  align-items: stretch;
  gap: 0;
}
.world-status-party {
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-width: 0;
  min-height: 0;
  padding-right: 16px;
  border-right: 1px solid rgba(145, 113, 61, .35);
}
.world-party-head {
  align-items: flex-start;
  gap: 10px;
}
.world-party-head-copy { min-width: 0; }
.world-party-head-tools {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
}
.world-party-head-tools .construction-eta {
  white-space: nowrap;
}
.world-party-deselect {
  display: grid;
  place-items: center;
  width: 21px;
  height: 21px;
  padding: 0;
  border: 1px solid #7e2a1d;
  background: #b53a2a;
  color: #fff5e4;
  font-family: var(--font-pixel);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .18), 0 1px 0 rgba(0, 0, 0, .3);
}
.world-party-deselect:hover { background: #cc4836; }
.world-party-facts { flex-wrap: wrap; }
.world-party-facts b { color: #4f3d27; font-weight: 400; }
.world-party-members {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.world-party-actions .world-party-lock,
.world-party-lock {
  flex: 1 1 100%;
  align-self: center;
  padding: 5px 9px;
  border: 1px solid rgba(164, 55, 35, .55);
  background: rgba(164, 55, 35, .1);
  color: #8f2c1a !important;
  font-family: var(--font-pixel);
  font-size: 11px;
  letter-spacing: .03em;
  text-align: center;
}
.world-party-actions .world-party-lock.is-recovering,
.world-party-lock.is-recovering {
  border-color: rgba(156, 112, 32, .55);
  background: rgba(196, 152, 54, .14);
  color: #7c5a1c !important;
}
.world-party-body.is-under-attack .construction-bar i,
.world-party-body.is-under-attack #world-party-fill {
  background: linear-gradient(90deg, #c7492f, #e5744f) !important;
}
.world-party-head .construction-eta.is-attack { color: #a93b24; }
.world-party-head .construction-eta.is-defend { color: #2f6f9e; }
.world-party-body.is-defending .construction-bar i,
.world-party-body.is-defending #world-party-fill {
  background: linear-gradient(90deg, #2f6f9e, #4a97c8) !important;
}
.world-party-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  flex: 0 0 auto;
}
.world-party-actions .button { flex: 1 1 82px; }
.world-party-empty {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px;
  margin-top: 8px;
}
.world-party-empty p {
  margin: 0;
  color: #7b6038;
  font-size: 11px;
  line-height: 1.4;
}
.world-party-empty .button { flex: 0 0 auto; }
.world-party-empty .world-party-empty-note { flex: 1 0 100%; }
/* The phone replaces the explanatory copy with the one-line selection hint
   beside Create Party, and names the selected party in the same pixel face as
   the empty-state headline. Desktop keeps the full copy and its kicker. */
.world-party-mobile-hint,
.world-status-tile-title { display: none; }
.world-party-head .world-party-selected-title { display: none; }
/* The selected party splits its half of the bar: the live order rail on the
   left and the crew's portraits on the right, with the action row pinned
   underneath both halves. Every portrait carries its own miniature health
   rail, so the crew can read each villager's condition at a glance. */
.world-party-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
  flex: 1 1 auto;
  min-height: 0;
}
.world-party-order {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  min-height: 0;
}
.world-party-crew {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  min-height: 0;
  padding-left: 10px;
  border-left: 1px solid rgba(145, 113, 61, .28);
}
.world-party-icons {
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 4px;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: thin;
}
.world-party-icons-empty {
  color: #7b6038;
  font-family: var(--font-pixel);
  font-size: 9px;
  line-height: 1.4;
}
.world-party-icon {
  position: relative;
  flex: 0 0 auto;
  width: 36px;
  height: 44px;
  overflow: hidden;
  border: 1px solid #9e7f4e;
  background: #d8c49a;
}
.world-party-icon .avatar {
  width: 100%;
  height: 100%;
  border: 0;
  image-rendering: pixelated;
}
/* Each villager's own health rail sits inside the bottom of their portrait. */
.world-party-icon-hp {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  display: block;
  height: 5px;
  overflow: hidden;
  border-top: 1px solid #3c2e1c;
  background: rgba(45, 33, 19, .72);
}
.world-party-icon-hp i {
  display: block;
  height: 100%;
  background: #6d8d45;
  transition: width .3s linear;
}
.world-party-health-bar {
  display: block;
  height: 8px;
  margin-top: 4px;
  overflow: hidden;
  border: 1px solid #9a7a48;
  background: #d8c49a;
}
.world-party-health-bar i {
  display: block;
  height: 100%;
  background: #6d8d45;
  transition: width .3s linear;
}
.world-party-body .construction-bar { margin-top: 0; }
.world-party-body .world-party-facts { margin-top: 2px; }

/* ------------------------------------------------------------------ */
/* World full-page sheets                                             */
/* ------------------------------------------------------------------ */

.world-page {
  position: fixed;
  inset: 0;
  z-index: 110;
  display: grid;
  place-items: center;
  padding: 20px;
}
.world-page[hidden] { display: none; }
.world-page-scrim {
  position: absolute;
  inset: 0;
  background: rgba(7, 16, 15, .68);
  backdrop-filter: blur(2px);
}
.world-page-panel {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: min(1060px, 100%);
  height: min(820px, calc(100dvh - 36px));
  max-height: min(820px, calc(100dvh - 36px));
  overflow: hidden;
  background:
    linear-gradient(150deg, rgba(255, 252, 241, .3), transparent 50%),
    repeating-linear-gradient(0deg, #f0e0bd 0 3px, #f7ecd2 3px 6px);
  border: 1px solid #a98752;
  box-shadow: 0 0 0 4px #1d332f, 0 0 0 5px #685032, 0 22px 60px rgba(2, 9, 9, .45);
  outline: none;
  animation: modal-in .17s ease-out;
}
.world-page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  flex: 0 0 auto;
  padding: 20px 22px 14px;
  border-bottom: 1px solid rgba(154, 124, 74, .35);
}
.world-page-head-copy { min-width: 0; }
.world-page-head h2 {
  margin: 5px 0 0;
  color: #4f3d27;
  font-family: var(--font-display);
  font-size: clamp(24px, 3vw, 38px);
  line-height: .95;
}
.world-page-subtitle {
  margin: 6px 0 0;
  color: #7b6038;
  font-size: 12px;
  line-height: 1.4;
}
.world-page-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 16px 22px;
  scrollbar-width: thin;
  scrollbar-color: #9d804f rgba(255, 250, 231, .35);
}
.world-page-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  flex: 0 0 auto;
  padding: 12px 22px;
  border-top: 1px solid rgba(154, 124, 74, .35);
  background: rgba(195, 159, 94, .1);
}
.world-page-foot-info {
  color: #7b6038;
  font-family: var(--font-pixel);
  font-size: 10px;
  line-height: 1.35;
}
.world-page-foot-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.world-page-roster-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px;
  margin: 0 0 9px;
  color: #7a6238;
  font-family: var(--font-pixel);
  font-size: 10px;
  letter-spacing: .06em;
}
.world-page-roster-head strong { color: #4f3d27; font-weight: 400; }
.world-page-order {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}
.world-order-button {
  padding: 3px 7px;
  border: 1px solid rgba(145, 113, 61, .45);
  border-radius: 4px;
  background: rgba(255, 247, 226, .55);
  color: #7a6238;
  font-family: var(--font-pixel);
  font-size: 9px;
  letter-spacing: .06em;
}
.world-order-button:hover { background: rgba(233, 193, 105, .28); }
.world-order-button[aria-pressed="true"] {
  border-color: #b58a35;
  background: rgba(233, 187, 85, .34);
  color: #4f3d27;
}
.world-page-roster-head .world-page-order + strong { margin-left: 0; }
.world-page-grid { display: grid; gap: 8px; }
.world-page-grid--pick { grid-template-columns: repeat(auto-fill, minmax(255px, 1fr)); }
.world-page-grid--parties { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.world-page-grid--details { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.world-page-empty {
  margin: 0;
  padding: 22px 12px;
  border: 1px dashed rgba(145, 113, 61, .5);
  color: #7b6038;
  font-family: var(--font-pixel);
  font-size: 11px;
  line-height: 1.5;
  text-align: center;
}

.world-pick-card {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 8px;
  border: 1px solid rgba(145, 113, 61, .4);
  background: rgba(255, 250, 231, .55);
  color: #5f4c30;
  text-align: left;
  cursor: pointer;
}
.world-pick-card:hover { background: rgba(233, 193, 105, .2); }
.world-pick-card.selected {
  border-color: #8a6b33;
  background: rgba(233, 193, 105, .28);
  box-shadow: inset 0 0 0 2px rgba(201, 74, 49, .35);
}
.world-pick-avatar.avatar {
  flex: 0 0 auto;
  width: 48px;
  height: 58px;
  overflow: hidden;
  border: 1px solid #9e7f4e;
  background: #d8c49a;
  image-rendering: pixelated;
}
.world-pick-avatar svg { width: 100%; height: 100%; }
.world-pick-copy {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.world-pick-name {
  overflow: hidden;
  color: #4f3d27;
  font-family: var(--font-display);
  font-size: 19px;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.world-pick-copy small {
  color: #8a7350;
  font-family: var(--font-pixel);
  font-size: 9px;
}
/* A pick card carries the same HP/DMG/ARM boxes as the Combat rosters, sized to
   the card copy, with RNG and SPD as plain text underneath. */
.world-pick-totals {
  width: 100%;
  gap: 3px;
}
.world-pick-totals .party-row-stat {
  flex: 1 1 0;
  width: auto;
  padding: 3px 4px;
}
.world-pick-meta {
  color: #6f5836;
  font-family: var(--font-pixel);
  font-size: 9px;
  line-height: 1.3;
}
.world-pick-hp {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #7b6038;
  font-family: var(--font-pixel);
  font-size: 9px;
}
.world-pick-hp-bar {
  flex: 1 1 auto;
  height: 6px;
  overflow: hidden;
  border: 1px solid #9a7a48;
  background: #d8c49a;
}
.world-pick-hp-bar i { display: block; height: 100%; background: #6d8d45; }
.world-pick-mark {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  border: 1px solid #8b6a3c;
  background: #f4e5c4;
  color: #5a462a;
  font-family: var(--font-pixel);
  font-size: 11px;
}
.world-pick-card.selected .world-pick-mark {
  border-color: #526536;
  background: #687d44;
  color: #fff4dd;
}

.world-party-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  border: 1px solid rgba(145, 113, 61, .4);
  background: rgba(255, 250, 231, .55);
}
.world-party-card.selected { box-shadow: inset 0 0 0 2px rgba(201, 74, 49, .35); }
.world-party-card.is-under-attack {
  border-color: rgba(176, 55, 33, .7) !important;
  box-shadow: inset 0 0 0 2px rgba(201, 74, 49, .28) !important;
}
.world-party-card.is-under-attack .world-party-card-kicker { color: #a93b24; }
.world-party-card.is-under-attack h3 { color: #7d2415; }
.world-party-card.is-recovering {
  border-color: rgba(183, 139, 52, .62) !important;
  box-shadow: inset 0 0 0 2px rgba(222, 181, 87, .26) !important;
}
.world-party-card.is-recovering .world-party-card-kicker { color: #8a641e; }
.world-party-card.is-recovering h3 { color: #5d4519; }
.world-party-card.is-defending {
  border-color: rgba(47, 111, 158, .62) !important;
  box-shadow: inset 0 0 0 2px rgba(47, 111, 158, .22) !important;
}
.world-party-card.is-defending .world-party-card-kicker { color: #2f6f9e; }
.world-party-card.is-defending h3 { color: #214c6d; }
.world-party-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
.world-party-card-kicker {
  margin: 0;
  color: #92764b;
  font-family: var(--font-pixel);
  font-size: 9px;
  letter-spacing: .06em;
}
.world-party-card h3 {
  margin: 3px 0 0;
  color: #4f3d27;
  font-family: var(--font-display);
  font-size: 21px;
  line-height: 1;
}
.world-party-card-distance {
  flex: 0 0 auto;
  color: #8d3d28;
  font-family: var(--font-pixel);
  font-size: 9px;
  text-align: right;
}
.world-party-card-icons { display: flex; flex-wrap: wrap; gap: 4px; }
.world-party-card-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 10px;
  color: #7b6038;
  font-family: var(--font-pixel);
  font-size: 10px;
}
.world-party-card-actions { display: flex; justify-content: flex-end; margin-top: auto; }

/* The Create Party sheet opens on a chooser: saved rosters first, then a
   deliberate "new party" action. */
.world-saved-party-card { gap: 7px; }
.world-saved-party-members {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  min-height: 24px;
}
.world-create-new-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 12px;
  margin-top: 12px;
  padding-top: 11px;
  border-top: 1px dashed rgba(145, 113, 61, .45);
}
.world-create-new-row span {
  color: #8a7350;
  font-size: 11px;
  line-height: 1.4;
}
.world-loaded-party {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 9px;
  padding: 8px 10px;
  border: 1px solid rgba(145, 113, 61, .5);
  background: rgba(255, 250, 231, .55);
}
.world-loaded-party strong {
  display: block;
  margin-top: 2px;
  color: #4f3d27;
  font-family: var(--font-display);
  font-size: 18px;
  line-height: 1.1;
}
.world-pull-banner {
  display: grid;
  gap: 2px;
  margin-bottom: 9px;
  padding: 8px 10px;
  border: 1px solid #b1762f;
  background: rgba(214, 156, 62, .16);
  color: #6f4b1c;
  font-size: 11px;
  line-height: 1.45;
}
.world-pull-banner strong {
  color: #8a5a24;
  font-family: var(--font-pixel);
  font-size: 9.5px;
  letter-spacing: .04em;
}
.world-pick-card.is-leaving-job {
  border-color: #b1762f;
  box-shadow: inset 0 0 0 1px rgba(177, 118, 47, .28);
}
.world-pick-copy small.is-job-warning { color: #9a5c1b; }

.world-detail-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 6px;
  margin-bottom: 12px;
}
.world-detail-stat {
  padding: 7px 9px;
  border: 1px solid rgba(145, 113, 61, .4);
  background: rgba(255, 250, 231, .55);
}
.world-detail-stat span {
  display: block;
  color: #92764b;
  font-family: var(--font-pixel);
  font-size: 9px;
  letter-spacing: .05em;
}
.world-detail-stat strong {
  display: block;
  margin-top: 3px;
  color: #4f3d27;
  font-family: var(--font-pixel);
  font-size: 12px;
  font-weight: 400;
}
.world-detail-health { margin-bottom: 14px; }
.world-detail-label {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: #7a6238;
  font-family: var(--font-pixel);
  font-size: 10px;
}
.world-detail-label b { color: #4f3d27; font-weight: 400; }
.world-detail-health .construction-bar { margin-top: 5px; }
.world-detail-eta {
  margin: 5px 0 0;
  color: #8d3d28;
  font-family: var(--font-pixel);
  font-size: 9px;
}

.world-member-card {
  display: flex;
  gap: 9px;
  padding: 10px;
  border: 1px solid rgba(145, 113, 61, .4);
  background: rgba(255, 250, 231, .55);
}
.world-member-avatar.avatar {
  flex: 0 0 auto;
  width: 52px;
  height: 64px;
  overflow: hidden;
  border: 1px solid #9e7f4e;
  background: #d8c49a;
  image-rendering: pixelated;
}
.world-member-avatar svg { width: 100%; height: 100%; }
.world-member-copy {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.world-member-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.world-member-head strong {
  overflow: hidden;
  color: #4f3d27;
  font-family: var(--font-display);
  font-size: 21px;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.world-member-head span {
  flex: 0 0 auto;
  color: #8a7350;
  font-family: var(--font-pixel);
  font-size: 9px;
}
.world-member-copy p { margin: 0; color: #7b6038; font-size: 11px; }
.world-member-stats,
.world-member-gear {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 9px;
  color: #6f5836;
  font-family: var(--font-pixel);
  font-size: 9px;
}
.world-member-stats b,
.world-member-gear b { color: #4f3d27; font-weight: 400; }
.world-member-gear { color: #8a7350; font-size: 8.5px; }
.world-member-hp {
  display: flex;
  align-items: center;
  gap: 7px;
  color: #7b6038;
  font-family: var(--font-pixel);
  font-size: 9px;
}
.world-member-hp .world-party-health-bar {
  flex: 1 1 auto;
  height: 6px;
  margin-top: 0;
}
.world-status-tile {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
  min-height: 0;
  padding-left: 16px;
  overflow: hidden;
}
.world-status-tile-head {
  display: flex;
  flex: 0 0 auto;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}
.world-status-tile-head .upgrade-kicker { margin: 0; }
.world-status-tile-name {
  overflow: hidden;
  color: #7a6238;
  font-family: var(--font-pixel);
  font-size: 10px;
  letter-spacing: .03em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.world-status-tile-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #9d804f rgba(255, 250, 231, .35);
}
.world-status-hint {
  margin: 0;
  padding: 12px 4px;
  color: #7b6038;
  font-family: var(--font-pixel);
  font-size: 11px;
  line-height: 1.55;
}
.world-coord {
  min-width: 104px;
  padding: 8px 10px;
  background: rgba(10, 28, 36, .78);
  border: 1px solid rgba(200, 167, 96, .38);
  color: #b7d1d1;
  font-family: var(--font-pixel);
  font-size: 12px;
  line-height: 1.6;
  letter-spacing: .03em;
}
.world-coord strong { color: #ffeaae; font-weight: 400; }

/* The tile card lives inside the status bar's right pane. It keeps its paper
   type and controls, but the framed box and its own scrollbar belong to the
   bar, so the card itself no longer floats or paints a second frame. */
.world-selection {
  position: relative;
  z-index: 1;
  width: 100%;
  padding: 0;
  color: var(--ink);
  background: none;
  border: 0;
  box-shadow: none;
  animation: none;
}
.world-selection-close {
  position: absolute;
  top: 6px;
  right: 6px;
  display: grid;
  place-items: center;
  width: 21px;
  height: 21px;
  padding: 0;
  border: 1px solid #7e2a1d;
  background: #b53a2a;
  color: #fff5e4;
  font-family: var(--font-pixel);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .18), 0 1px 0 rgba(0, 0, 0, .3);
}
.world-selection-close:hover { background: #cc4836; }
.world-selection .inspector-kicker { color: #92764b; }
.world-selection h3 {
  margin-top: 0;
  padding-right: 24px;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  line-height: 1;
}
/* On a phone the owner moves beside the title in parentheses. Desktop keeps
   the spelled-out caption below it. */
.world-selection-owner { display: none; }
/* The quiet owner caption under the terrain name, e.g. "Territory of Wren" or
   "Unclaimed". It is deliberately smaller than the production line. */
.world-selection-alert {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 7px;
  padding: 5px 8px;
  border: 1px solid rgba(164, 55, 35, .45);
  background: rgba(164, 55, 35, .09);
  color: #8f2c1a !important;
  font-size: 11px;
  line-height: 1.35;
}
.world-selection-alert span {
  flex: 0 0 auto;
  padding: 2px 5px;
  background: #a93b24;
  color: #ffe4d8;
  font-family: var(--font-pixel);
  font-size: 9px;
  letter-spacing: .04em;
}
.world-selection-territory {
  margin-top: 3px !important;
  color: #8a7448 !important;
  font-family: var(--font-pixel);
  font-size: 9.5px !important;
  line-height: 1.25 !important;
  letter-spacing: .04em;
}
.world-selection-territory.is-mine { color: #8a6a20 !important; }
.world-selection-territory.is-enemy { color: #a2402b !important; }
.world-selection-territory.is-open { color: #7b7f68 !important; }
.world-selection p { margin-top: 7px; color: #715e40; font-size: 12px; line-height: 1.45; }
.world-selection-production {
  margin-top: 4px !important;
  color: #5f4c30 !important;
  font-family: var(--font-pixel);
  font-size: 11.5px !important;
  line-height: 1.3 !important;
}
/* A visible enemy party names its clan and size on the tile card. The roster
   itself stays private; only the marching headcount is public. */
.world-selection-foes { display: grid; gap: 3px; margin-top: 6px; }
.world-selection-foe {
  margin: 0 !important;
  padding: 4px 6px;
  border-left: 3px solid #b0533a;
  background: rgba(207, 80, 56, .1);
  color: #6d3c2a !important;
  font-family: var(--font-pixel);
  font-size: 10px !important;
  line-height: 1.3 !important;
}
.world-selection-foe span { color: #a2402b; letter-spacing: .04em; }
.world-selection-actions { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 9px; }
.world-selection-actions .button { flex: 1 1 96px; white-space: nowrap; }
.world-selection-list,
.world-selection-roster {
  display: grid;
  gap: 4px;
  max-height: 126px;
  margin-top: 7px;
  overflow-y: auto;
}
.world-selection-roster-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: #7a6238;
  font-family: var(--font-pixel);
  font-size: 9px;
  letter-spacing: .04em;
}
.world-pick-party,
.world-selection-villager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 6px;
  border: 1px solid rgba(145, 113, 61, .4);
  background: rgba(255, 250, 231, .55);
  color: #5f4c30;
  text-align: left;
  cursor: pointer;
}
.world-pick-party:hover,
.world-selection-villager:hover { background: rgba(233, 193, 105, .2); }
.world-pick-party span,
.world-selection-villager span {
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.world-pick-party small,
.world-selection-villager small {
  color: #8a7350;
  font-family: var(--font-pixel);
  font-size: 9px;
  white-space: nowrap;
}
.world-selection-villager.selected { border-color: #b58a35; background: rgba(233, 187, 85, .26); }
.world-selection-empty {
  margin: 0 !important;
  font-style: italic;
  font-size: 11px !important;
}
.world-selection-roster .button { justify-self: stretch; margin-top: 2px; }
.world-selection .selection-actions { display: flex; gap: 5px; margin-top: 8px; }
.world-selection .selection-actions .button { flex: 1; }
.world-selection .tile-party-actions { flex-wrap: wrap; }
.world-selection .tile-party-actions .button { flex: 1 1 96px; }

/* March orders: the shortest route button sits under the tile facts in the
   inspector so the step count and the per-step cost are visible before the
   party sets off. */
.world-march-block { margin-top: 10px; }
.world-march-block .button { width: 100%; }
.world-march-block .button + .button { margin-top: 5px; }
.world-march-hint {
  margin-top: 10px;
  color: #7c6743;
  font-family: var(--font-pixel);
  font-size: 10px;
  letter-spacing: .03em;
}

.world-legend {
  position: absolute;
  z-index: 3;
  right: 18px;
  top: 80px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 10px;
  background: rgba(10, 28, 36, .63);
  border: 1px solid rgba(200, 167, 96, .24);
  color: #a9c4c3;
  font-family: var(--font-pixel);
  font-size: 12px;
  letter-spacing: .02em;
  pointer-events: none;
}
.world-legend span { display: flex; align-items: center; gap: 6px; }
.world-legend i { width: 7px; height: 7px; border-radius: 50%; background: #8fcb84; }
.world-legend i.away { background: #8c9a91; }
.world-legend i.you { background: #e9bb55; box-shadow: 0 0 0 2px rgba(233, 187, 85, .16); }
.world-legend i.party { background: #ffe09a; border-radius: 0; clip-path: polygon(0 0, 100% 0, 100% 58%, 50% 100%, 0 58%); }
.world-legend i.attack {
  background: #e4553c;
  border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(228, 85, 60, .26);
}
.world-legend i.march {
  width: 16px;
  height: 0;
  border-top: 2px dashed #e6c888;
  border-radius: 0;
  background: none;
}
.world-legend i.explored { background: #6d7d70; box-shadow: inset 0 0 0 1px rgba(200, 216, 196, .3); }
.world-legend i.remembered { background: transparent; box-shadow: inset 0 0 0 1px #93a19a; }
.world-legend i.fog { background: #24404b; box-shadow: inset 0 0 0 1px rgba(160, 196, 190, .25); }

.tile-rules {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 3px 8px;
  margin-top: 9px;
  padding: 7px 8px;
  border: 1px solid rgba(145, 113, 61, .28);
  background: rgba(255, 250, 231, .45);
  font-size: 11px;
}
.tile-rules dt { color: #92764b; font-family: var(--font-pixel); font-size: 9px; text-transform: uppercase; }
.tile-rules dd { color: #5f4c30; }
.tile-parties { margin-top: 9px; }
.tile-label { color: #92764b; font-family: var(--font-pixel); font-size: 9px; letter-spacing: .05em; }
.tile-party {
  display: block;
  margin-top: 3px;
  padding: 4px 6px;
  border: 1px solid rgba(145, 113, 61, .3);
  color: #6c5535;
  font-size: 10.5px;
}
.tile-party.mine { border-color: rgba(168, 128, 47, .6); background: rgba(241, 211, 137, .35); }
.tile-party-actions { margin-top: 7px; }

/* ------------------------------------------------------------------ */
/* Resource warehouse                                                 */
/* ------------------------------------------------------------------ */

.resource-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(260px, .55fr);
  gap: 18px;
  align-items: start;
}

.warehouse-panel { padding: 24px; }

.warehouse-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid #c1a675;
}
.warehouse-top h2 { font-family: var(--font-display); font-size: 34px; font-weight: 700; line-height: .95; }
.warehouse-top p { margin-top: 6px; color: #806c4b; font-size: 12px; line-height: 1.4; }
.capacity-stamp {
  flex: 0 0 auto;
  padding: 8px 10px;
  border: 1px solid #aa8b58;
  background: rgba(255, 246, 224, .34);
  color: #765c35;
  font-family: var(--font-pixel);
  font-size: 12px;
  line-height: 1.6;
  text-align: right;
}
.capacity-stamp strong { display: block; font-size: 15px; font-weight: 400; color: #4c3923; }

.resource-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 8px;
  margin-top: 16px;
}
.resource-row {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 10px;
  padding: 11px;
  border: 1px solid rgba(157, 126, 75, .38);
  background: rgba(255, 248, 232, .32);
}
.resource-glyph {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(139, 105, 58, .46);
  background: rgba(222, 202, 159, .54);
}
.resource-glyph svg { width: 21px; height: 21px; }
.resource-main { min-width: 0; }
.resource-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.resource-title h3 { font-family: var(--font-display); font-size: 20px; font-weight: 600; line-height: 1; }
.resource-title strong { font-family: var(--font-pixel); font-size: 15px; font-weight: 400; color: #4a3825; }
.resource-sub {
  margin-top: 3px;
  color: #85704d;
  font-family: var(--font-pixel);
  font-size: 12px;
  letter-spacing: .02em;
}
.resource-bar {
  position: relative;
  height: 7px;
  margin-top: 8px;
  overflow: hidden;
  background: #ceb98f;
  border: 1px solid #ac8e5a;
}
.resource-bar i {
  display: block;
  height: 100%;
  background:
    repeating-linear-gradient(90deg, rgba(255,255,255,.16) 0 2px, transparent 2px 5px),
    linear-gradient(90deg, #5d7a3e, #9aa74e);
  /* The live clock repaints about ten times a second; the short linear slide
     bridges those samples into continuous motion on a phone. */
  transition: width .12s linear;
}
.resource-bar.low i { background: linear-gradient(90deg, #aa5b2d, #d09747); }

.warehouse-side {
  display: flex;
  flex-direction: column;
  gap: 13px;
}
.ledger-card { padding: 19px; }
.ledger-card h3 { font-family: var(--font-display); font-size: 24px; font-weight: 700; line-height: 1; }
.ledger-card > p { margin-top: 6px; color: #806b49; font-size: 11.5px; line-height: 1.45; }
.ledger-line {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px dashed rgba(148, 117, 70, .32);
  font-size: 12px;
  color: #6e5b3e;
}
.ledger-line:last-child { border-bottom: 0; }
.ledger-line strong { font-family: var(--font-pixel); font-size: 12px; font-weight: 400; color: #4c3924; }
.gold-ledger {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 12px;
  padding: 12px;
  background: rgba(217, 187, 120, .2);
  border: 1px solid #b9995f;
}
.gold-ledger .storage-icon {
  flex: 0 0 auto;
  width: 19px;
  height: 19px;
  color: #573b1d;
}
.gold-ledger strong { font-family: var(--font-pixel); font-size: 15px; font-weight: 400; color: #573b1d; }
.gold-ledger span { margin-left: auto; color: #826a46; font-family: var(--font-pixel); font-size: 12px; }


/* ------------------------------------------------------------------ */
/* Market                                                             */
/* ------------------------------------------------------------------ */

.market-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}
.market-board { padding: 22px; }
.market-board-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid #c3a878;
}
.market-board-head h2 { font-family: var(--font-display); font-size: 30px; font-weight: 700; line-height: .95; }
.market-board-head p { margin-top: 4px; color: #816d4b; font-size: 11.5px; }
.market-filters { display: flex; flex-wrap: wrap; gap: 4px; }
.market-filters button {
  padding: 5px 7px;
  border: 1px solid #b59b6c;
  background: transparent;
  color: #7b6645;
  font-family: var(--font-pixel);
  font-size: 12px;
  text-transform: uppercase;
}
.market-filters button.active { background: #c94a31; border-color: #8d2e20; color: #fff2d9; }

.listing {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px dashed rgba(148, 116, 69, .34);
}
.listing:last-child { border-bottom: 0; }
.listing-icon { width: 36px; height: 36px; display: grid; place-items: center; border: 1px solid #b29661; background: rgba(220, 198, 153, .45); }
.listing-icon svg { width: 22px; height: 22px; }
.listing-main { min-width: 0; }
.listing-title { display: flex; align-items: baseline; gap: 7px; flex-wrap: wrap; font-family: var(--font-display); font-size: 19px; font-weight: 600; line-height: 1; }
.listing-title span { font-family: var(--font-pixel); font-size: 12px; color: #8a3a27; text-transform: uppercase; }
.listing-sub { margin-top: 4px; color: #85704c; font-size: 10.5px; line-height: 1.35; }
.listing-sub b { font-weight: 600; color: #634b2f; }
.listing-price { display: flex; align-items: center; gap: 10px; }
.price-block { text-align: right; }
.price-block strong { display: block; font-family: var(--font-pixel); font-size: 14px; font-weight: 400; color: #4f3a23; }
.price-block span { display: block; margin-top: 2px; color: #866f4b; font-family: var(--font-pixel); font-size: 12px; }
.listing .button { min-height: 32px; padding: 0 9px; }
.empty-market {
  padding: 38px 16px;
  color: #8d7858;
  font-size: 13px;
  line-height: 1.5;
  text-align: center;
}

.market-alert {
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid #b37154;
  background: rgba(182, 103, 71, .12);
  color: #7e4a33;
  font-size: 11.5px;
  line-height: 1.55;
}
.market-alert strong {
  display: inline;
  margin-right: 3px;
  color: #7e3c25;
  font-family: var(--font-pixel);
  font-weight: 400;
  letter-spacing: .03em;
  text-transform: uppercase;
}
.rate-list { display: flex; flex-direction: column; }
.market-rate {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto 154px;
  gap: 14px;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px dashed rgba(148, 116, 69, .34);
}
.market-rate:last-child { border-bottom: 0; }
.market-rate.untradeable .rate-price strong { color: #9a815a; }
.rate-icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid #b29661;
  background: rgba(220, 198, 153, .45);
}
.rate-icon svg { width: 23px; height: 23px; }
.rate-main { min-width: 0; }
.rate-title {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
  line-height: 1;
}
.rate-sub { margin-top: 4px; color: #85704c; font-size: 10.5px; line-height: 1.35; }
.market-rate .resource-bar {
  height: 10px;
  margin-top: 8px;
}
.resource-forecast-line { margin-top: 3px; }
.market-rate .forecast-window { font-size: 10px; }
.rate-numbers {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  min-width: 98px;
}
.rate-price { text-align: right; }
.rate-price strong {
  display: block;
  color: #4f3a23;
  font-family: var(--font-pixel);
  font-size: 17px;
  font-weight: 400;
  line-height: 1;
}
.rate-price span {
  display: block;
  margin-top: 3px;
  color: #866f4b;
  font-family: var(--font-pixel);
  font-size: 10px;
  white-space: nowrap;
}
.rate-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px;
}
.rate-action {
  min-height: 32px;
  padding: 4px 7px;
  border: 1px solid #b39561;
  border-radius: 0;
  background: rgba(255, 249, 234, .38);
  color: #6d5838;
  font-family: var(--font-pixel);
  font-size: 12px;
  line-height: 1.1;
  letter-spacing: .02em;
  white-space: nowrap;
  cursor: pointer;
}
.rate-action:hover:not(:disabled) {
  border-color: #8d5e3a;
  background: rgba(201, 74, 49, .12);
  color: #6b3a24;
}
.rate-action:focus-visible { outline: 2px solid #7a5a2f; outline-offset: 1px; }
/* Sell keeps the warm light-red treatment the step button used to wear; Buy
   gets the matching green so the two doors read as a pair without colouring
   either side as an error. */
.rate-action.sell {
  border-color: #a97a5e;
  background: rgba(201, 74, 49, .1);
  color: #7e3c25;
}
.rate-action.sell:hover:not(:disabled) {
  border-color: #8d5e3a;
  background: rgba(201, 74, 49, .18);
  color: #6b3a24;
}
.rate-action.buy {
  border-color: #8c9a5d;
  background: rgba(129, 145, 80, .16);
  color: #4f5d2c;
}
.rate-action.buy:hover:not(:disabled) {
  border-color: #5f6f3a;
  background: rgba(129, 145, 80, .26);
  color: #3f4c22;
}
.rate-action:disabled {
  opacity: .4;
  cursor: default;
}
/* A blocked trade still opens an overlay explaining why, so the button stays
   clickable but reads as unavailable until the pointer is on it. */
.rate-action[data-blocked="true"] {
  opacity: .55;
  cursor: help;
}
.rate-action[data-blocked="true"]:hover {
  opacity: .85;
  border-color: #8d5e3a;
}
.market-ledger-note {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed rgba(148, 116, 69, .34);
  color: #8a7555;
  font-size: 10.5px;
  line-height: 1.5;
}
/* The pre-trade quote popup: the exact value of one batch, lined up so the
   posted rate and the rate the clan actually gets can be compared at a glance. */
.market-quote {
  display: grid;
  gap: 1px;
  margin-top: 12px;
  border: 1px solid rgba(148, 116, 69, .34);
  border-radius: 6px;
  overflow: hidden;
  background: rgba(148, 116, 69, .18);
}
.market-quote > div {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 7px 10px;
  background: #fbf3e2;
  font-size: 12px;
}
.market-quote span { color: #816d4b; }
.market-quote b { font-weight: 700; color: #4a3a22; white-space: nowrap; }
.market-quote-total {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-top: 12px;
  font-size: 13px;
  color: #705c3e;
}
.market-quote-total b { font-family: var(--font-figure); font-size: 24px; color: #3f3420; }
.market-quote-total span { color: #8a7555; font-size: 11px; }
.market-quote-note {
  margin-top: 10px;
  color: #8a7555;
  font-size: 10.5px;
  line-height: 1.5;
}
/* The trade sheet: one good, one big batch readout and a slider that belongs to
   the same paper as the rest of the exchange. The rail fills from brass to
   parchment, and the right stop is always the old "all" batch. */
.market-sheet { margin-top: 4px; }
.market-sheet-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border: 1px solid rgba(148, 116, 69, .34);
  background: rgba(255, 250, 235, .5);
}
.market-sheet-icon {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid #b29661;
  background: rgba(220, 198, 153, .45);
}
.market-sheet-icon svg { width: 25px; height: 25px; }
.market-sheet-copy { min-width: 0; }
.market-sheet-kicker {
  color: #8a7049;
  font-family: var(--font-pixel);
  font-size: 10px;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.market-sheet-amount {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 9px;
  margin-top: 3px;
}
.market-sheet-amount strong {
  color: #3f3420;
  font-family: var(--font-figure);
  font-size: 32px;
  font-weight: 700;
  line-height: .9;
}
.market-sheet-amount span { color: #806a49; font-size: 11px; }
/* The trade sheet's quiet price history: a small paper strip of five-minute
   dots, with the current spot reading marked at the right edge. */
.market-chart {
  margin: 12px 0 0;
  padding: 8px 10px 6px;
  border: 1px solid rgba(148, 116, 69, .34);
  background: #fff;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .8);
}
.market-chart-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  color: #8a7049;
  font-family: var(--font-pixel);
  font-size: 9px;
  letter-spacing: .09em;
  text-transform: uppercase;
}
.market-chart-meta { color: #9a815a; letter-spacing: .04em; }
.market-chart-plot { margin-top: 5px; min-height: 92px; }
.market-chart-plot svg { display: block; width: 100%; height: auto; overflow: visible; }
.market-chart-grid {
  stroke: rgba(139, 105, 56, .20);
  stroke-width: 1;
  stroke-dasharray: 2 3;
  vector-effect: non-scaling-stroke;
}
.market-chart-grid.is-vertical { stroke: rgba(139, 105, 56, .14); }
.market-chart-axis {
  fill: #a08a63;
  font-family: var(--font-pixel);
  font-size: 8px;
  letter-spacing: .02em;
}
.market-chart-dot {
  fill: #8d6f3f;
  opacity: .58;
}
.market-chart-dot.is-current { fill: #a6412d; opacity: 1; }
.market-chart-halo { fill: #a6412d; opacity: .16; }
.market-chart-empty {
  display: block;
  padding: 28px 4px;
  color: #9a815a;
  font-family: var(--font-pixel);
  font-size: 10px;
  letter-spacing: .03em;
  text-align: center;
}
.market-sheet-slider {
  display: block;
  margin-top: 16px;
}
.market-sheet-slider input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: 100%;
  height: 26px;
  margin: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
}
.market-sheet-slider input[type="range"]::-webkit-slider-runnable-track {
  height: 10px;
  border: 1px solid #b39561;
  border-radius: 2px;
  background:
    linear-gradient(90deg, #b9872f 0%, #d9b45a var(--trade-fill, 0%),
      rgba(240, 224, 189, .92) var(--trade-fill, 0%), rgba(240, 224, 189, .92) 100%);
  box-shadow: inset 0 1px 2px rgba(88, 62, 28, .22), 0 1px 0 rgba(255, 252, 241, .7);
}
.market-sheet-slider input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  margin-top: -5px;
  border: 1px solid #6f5328;
  border-radius: 2px;
  background: linear-gradient(180deg, #f7e9c6, #c9a45a);
  box-shadow: 0 0 0 2px rgba(255, 250, 235, .6), 0 2px 3px rgba(61, 42, 18, .35);
}
.market-sheet-slider input[type="range"]::-moz-range-track {
  height: 10px;
  border: 1px solid #b39561;
  border-radius: 2px;
  background: rgba(240, 224, 189, .92);
  box-shadow: inset 0 1px 2px rgba(88, 62, 28, .22);
}
.market-sheet-slider input[type="range"]::-moz-range-progress {
  height: 10px;
  border-radius: 2px;
  background: linear-gradient(90deg, #b9872f, #d9b45a);
}
.market-sheet-slider input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border: 1px solid #6f5328;
  border-radius: 2px;
  background: linear-gradient(180deg, #f7e9c6, #c9a45a);
  box-shadow: 0 0 0 2px rgba(255, 250, 235, .6), 0 2px 3px rgba(61, 42, 18, .35);
}
.market-sheet-slider input[type="range"]:focus-visible {
  outline: 2px solid #7a5a2f;
  outline-offset: 4px;
}
.market-sheet-scale {
  display: flex;
  justify-content: space-between;
  margin-top: 5px;
  color: #8a7555;
  font-family: var(--font-pixel);
  font-size: 10px;
  letter-spacing: .03em;
}
.market-sheet .market-quote { margin-top: 14px; }
.market-sheet .market-quote-total { margin-top: 10px; }
/* The sheet's confirm wears the same side colours as the board: green for a
   purchase, the market's warm red for a sale. */
.market-trade-submit.buy {
  border-color: #4c5a2b;
  background: #6f7f45;
  color: #f7f0d4;
  box-shadow: 0 2px 0 #3f4c22;
}
.market-trade-submit.buy:hover:not(:disabled) { background: #809154; }
.market-blocked-facts {
  margin: 12px 0 0;
  padding-left: 18px;
  color: #705c3e;
  font-size: 11.5px;
  line-height: 1.55;
}
.market-blocked-facts li + li { margin-top: 3px; }
.market-history { margin-top: 18px; padding: 22px; }
.market-trades { max-height: 360px; overflow-y: auto; margin-top: 4px; }
.market-trade {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px dashed rgba(148, 116, 69, .34);
}
.market-trade:last-child { border-bottom: 0; }
.market-trade.mine { background: linear-gradient(90deg, rgba(201, 74, 49, .07), transparent 70%); }
.trade-side {
  padding: 3px 6px;
  border: 1px solid #b29564;
  color: #6f5938;
  font-family: var(--font-pixel);
  font-size: 10px;
  letter-spacing: .4px;
  text-align: center;
  text-transform: uppercase;
}
.trade-side.bought { border-color: #8c9a5d; background: rgba(129, 145, 80, .16); color: #4f5d2c; }
.trade-side.sold { border-color: #b37154; background: rgba(182, 103, 71, .14); color: #7e3c25; }
.trade-main { min-width: 0; }
.trade-main b {
  display: block;
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 600;
  line-height: 1.1;
}
.trade-main span { display: block; margin-top: 3px; color: #85704c; font-size: 10.5px; }
.trade-value { text-align: right; }
.trade-value strong {
  display: block;
  color: #4f3a23;
  font-family: var(--font-pixel);
  font-size: 13px;
  font-weight: 400;
}
.trade-value span { display: block; margin-top: 3px; color: #866f4b; font-size: 10px; }

@media (max-width: 760px) {
  .market-rate {
    position: relative;
    grid-template-columns: 34px minmax(0, 1fr);
    gap: 8px 12px;
    align-items: start;
  }
  .rate-icon {
    grid-column: 1;
    grid-row: 1;
    width: 32px;
    height: 32px;
  }
  /* The row keeps its full-width name, bar and action grid; the posted G/unit
     is lifted out of the flow into the top-right corner, level with the
     resource name. The title reserves that corner so the two never collide. */
  .rate-main { grid-column: 2; grid-row: 1; }
  .rate-title { padding-right: 96px; }
  .rate-numbers {
    position: absolute;
    top: 14px;
    right: 0;
    flex-direction: row;
    align-items: baseline;
    justify-content: flex-end;
    min-width: 0;
    margin-top: 0;
    text-align: right;
  }
  .rate-price { text-align: right; }
  .rate-price strong { display: inline; margin-right: 3px; }
  .rate-price span { display: inline; }
  .rate-actions {
    grid-column: 1 / -1;
    grid-row: 2;
    margin-top: 2px;
  }
  .market-trade { grid-template-columns: 64px minmax(0, 1fr); }
  .trade-value { grid-column: 2 / 3; text-align: left; }
  .trade-value span { margin-top: 2px; }
  .market-history { padding: 16px; }
}

/* ------------------------------------------------------------------ */
/* School, academy, tavern                                            */
/* ------------------------------------------------------------------ */

.hall-screen .panel { overflow: hidden; }
.hall-banner {
  position: relative;
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 18px;
  padding: 20px 22px;
  border: 1px solid #b2915b;
  background:
    radial-gradient(circle at 78% 10%, rgba(207, 83, 54, .2), transparent 28%),
    repeating-linear-gradient(0deg, #e9d5aa 0 3px, #f1e1bd 3px 6px);
  box-shadow: 0 0 0 3px #1f3834, 0 5px 0 rgba(7, 15, 14, .2);
}
.hall-mark {
  width: 58px;
  height: 58px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border: 1px solid #8f703f;
  background: #c94a31;
  color: #ffefd0;
  font-family: serif;
  font-size: 31px;
  box-shadow: inset 0 0 0 4px #ead8b0, inset 0 0 0 5px #a63928;
  transform: rotate(-2deg);
}
.hall-banner h2 { font-family: var(--font-display); font-size: 33px; font-weight: 700; line-height: .95; }
.hall-banner p { margin-top: 6px; max-width: 670px; color: #705c3f; font-size: 12.5px; line-height: 1.45; }
.hall-banner .hall-aside {
  margin-left: auto;
  flex: 0 0 auto;
  color: #7d6644;
  font-family: var(--font-pixel);
  font-size: 12px;
  line-height: 1.6;
  text-align: right;
}
/* The academy carries ten future scholar slots, so its board gets a full row
   under the loft copy instead of squeezing the banner text. */
.hall-banner--academy { flex-wrap: wrap; }
.hall-banner--academy > div:nth-child(2) { flex: 1 1 520px; min-width: 0; }
.hall-banner--academy .hall-aside {
  flex: 1 0 100%;
  max-width: none;
  margin: 4px 0 0;
  text-align: left;
}
.hall-banner--academy .hall-slots.hall-slots--compact { max-width: none; }
.hall-banner--academy .hall-slots--compact .hall-worker-grid {
  grid-template-columns: repeat(10, minmax(0, 1fr));
  justify-content: start;
  max-width: 790px;
}
.hall-banner--academy .hall-worker-grid .worker-slot { width: 100%; }

/* Villager slots live in the hall header, replacing the old countdown block. */
.hall-slots {
  min-width: 178px;
  max-width: 300px;
}
.hall-slots-kicker {
  margin: 0;
  color: #7d6644;
  font-family: var(--font-pixel);
  font-size: 11px;
  letter-spacing: .05em;
  text-transform: uppercase;
}
.hall-slots.is-empty {
  max-width: 150px;
  color: #8a7654;
  font-size: 11px;
  line-height: 1.45;
}
.hall-worker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, 68px);
  justify-content: end;
  gap: 6px;
  margin-top: 7px;
}
.hall-worker-grid .worker-slot {
  width: 68px;
  min-height: 70px;
  aspect-ratio: auto;
  padding: 14px 4px 6px;
}
.hall-worker-grid .worker-slot-name { font-size: 11px; }
.hall-slots-note {
  margin-top: 7px;
  max-width: 220px;
  color: #8a7654;
  font-family: var(--font-pixel);
  font-size: 10px;
  line-height: 1.45;
}
/* A plain 5x2 worker board for the tavern: no labels, locked levels disabled. */
.hall-slots.hall-slots--compact {
  min-width: 0;
  max-width: 370px;
}
.hall-slots--compact .hall-worker-grid {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  justify-content: end;
  margin-top: 0;
}
.hall-slots--compact .hall-worker-grid .worker-slot {
  width: 100%;
  min-width: 0;
}

/* Picker overlay shared by the Tavern and School villager slots. */
.modal.modal-wide { width: min(560px, 100%); }
.staff-current { margin-bottom: 4px; }
.staff-picker { max-height: min(340px, 46vh); }
.staff-picker .idle-worker-copy span { font-size: 11px; }

.hospital-ward-note {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  margin: 2px 0 8px;
  padding: 7px 10px;
  border: 1px solid #c8ad78;
  background: rgba(201, 173, 120, .14);
  color: #7c6643;
  font-family: var(--font-pixel);
  font-size: 11px;
  letter-spacing: .03em;
}
.hospital-ward-note strong { color: #47351d; }

.school-list { display: flex; flex-direction: column; gap: 8px; }
.school-row {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  align-items: center;
  gap: 11px;
  padding: 9px 0;
  border-bottom: 1px dashed rgba(147, 115, 65, .32);
}
.school-row:last-child { border-bottom: 0; }
.school-row .avatar { width: 44px; height: 52px; }
.school-name { display: flex; align-items: baseline; gap: 7px; font-family: var(--font-display); font-size: 21px; font-weight: 600; line-height: 1; }
.school-name span { color: #8c724b; font-family: var(--font-pixel); font-size: 12px; font-weight: 400; text-transform: uppercase; }
.school-edu { margin-top: 6px; display: flex; align-items: center; gap: 7px; color: #806b49; font-family: var(--font-pixel); font-size: 12px; }
.edu-track { width: 120px; height: 5px; background: #d1ba8e; border: 1px solid #b3955e; }
.edu-track i { display: block; height: 100%; background: #a27a3a; }
.school-row .button { min-height: 32px; padding: 0 9px; }
.school-row .button:disabled { opacity: .55; }
.school-status {
  margin-top: 5px;
  color: #7c6643;
  font-family: var(--font-pixel);
  font-size: 11px;
  letter-spacing: .02em;
  text-transform: uppercase;
}
.school-student.studying { background: rgba(112, 133, 76, .10); border-radius: 2px; }
.school-student.studying .edu-track i { background: #6f8147; }
.school-study-meta {
  margin-top: 4px;
  color: #8a7654;
  font-size: 11px;
  line-height: 1.35;
}
.research-card.is-queued { border-color: #8b7c4c; }
.research-queued-seal {
  position: absolute;
  right: 12px;
  top: 12px;
  padding: 3px 5px;
  border: 1px solid #9f844a;
  color: #806a49;
  background: rgba(214, 189, 139, .28);
  font-family: var(--font-pixel);
  font-size: 11px;
  text-transform: uppercase;
}
.research-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.research-card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 190px;
  padding: 15px;
  border: 1px solid #b1915b;
  background: rgba(255, 248, 231, .28);
}
.research-card.unlocked { background: rgba(112, 133, 76, .14); border-color: #87975d; }
.research-glyph {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid #b49a6a;
  color: #5a482f;
  background: rgba(214, 189, 139, .36);
}
.research-glyph svg { width: 21px; height: 21px; }
.research-card h3 { margin-top: 10px; font-family: var(--font-display); font-size: 23px; font-weight: 700; line-height: .95; }
.research-effect { margin-top: 4px; color: #8d3e29; font-family: var(--font-pixel); font-size: 12px; line-height: 1.45; }
.research-desc { margin-top: 7px; color: #7c6748; font-size: 10.5px; line-height: 1.4; }
.research-footer { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; margin-top: auto; padding-top: 13px; }
.research-cost { color: #715b3a; font-family: var(--font-pixel); font-size: 12px; line-height: 1.7; }
.research-cost b { color: #963b27; font-weight: 400; }
.research-card .button { min-height: 30px; padding: 0 8px; }
.unlocked-seal {
  position: absolute;
  right: 12px;
  top: 12px;
  padding: 3px 5px;
  border: 1px solid #798c4e;
  color: #61753e;
  font-family: var(--font-pixel);
  font-size: 12px;
  text-transform: uppercase;
  transform: rotate(2deg);
}

/* ------------------------------------------------------------------ */
/* Academy tech tree                                                  */
/* ------------------------------------------------------------------ */

.tech-tree-panel { overflow: visible; }
.tech-tree-panel .panel-head { margin-bottom: 12px; }
.tech-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px 16px;
  margin: 0 0 16px;
  padding: 8px 10px;
  border: 1px dashed rgba(148, 118, 71, .42);
  background: rgba(220, 197, 151, .2);
  color: #806d4c;
  font-family: var(--font-pixel);
  font-size: 9px;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.tech-legend > span { display: inline-flex; align-items: center; gap: 5px; }
.tech-legend-swatch { width: 15px; height: 3px; display: inline-block; background: #a98d5b; }
.tech-legend-swatch--left { background: #8a6a49; }
.tech-legend-swatch--main { height: 4px; background: #c94a31; }
.tech-legend-swatch--right { background: #6f8147; }
.tech-legend-party { margin-left: auto; color: #8d3e29; }
.tech-legend-party svg { width: 14px; height: 14px; }

.tech-tree { position: relative; padding-top: 4px; }
.tech-tier { position: relative; padding: 0 0 30px; }
.tech-tier:last-child { padding-bottom: 6px; }
.tech-tier-grid {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, .92fr) 214px minmax(0, 1.45fr);
  gap: 20px;
  align-items: stretch;
}
.tech-tier-grid::before {
  content: "";
  position: absolute;
  top: 54px;
  left: 1%;
  right: 1%;
  border-top: 1px dashed #b7a071;
  opacity: .72;
  z-index: 0;
  pointer-events: none;
}
.tech-branch { position: relative; z-index: 1; min-width: 0; }
.tech-branch-label {
  margin: 0 0 7px;
  color: #8b7652;
  font-family: var(--font-pixel);
  font-size: 9px;
  letter-spacing: .16em;
}
.tech-branch--left .tech-branch-label { text-align: right; }
.tech-branch--right .tech-branch-label { text-align: left; }
.tech-branch-cards { display: flex; flex-wrap: wrap; gap: 9px; align-items: stretch; }
.tech-branch-cards .tech-node { flex: 1 1 124px; max-width: 210px; }
.tech-branch--left .tech-branch-cards { justify-content: flex-end; }
.tech-branch--right .tech-branch-cards { justify-content: flex-start; }
.tech-branch-empty {
  width: 100%;
  padding: 12px;
  border: 1px dashed rgba(148, 118, 71, .32);
  color: #917d5a;
  font-size: 10px;
  text-align: center;
}

.tech-spine { position: relative; z-index: 2; display: flex; flex-direction: column; }
.tech-spine::before {
  content: "";
  position: absolute;
  top: -30px;
  bottom: -30px;
  left: 50%;
  width: 2px;
  margin-left: -1px;
  background: linear-gradient(180deg, rgba(169, 141, 91, .25), #a98d5b 18%, #a98d5b 82%, rgba(169, 141, 91, .25));
  z-index: 0;
  pointer-events: none;
}
.tech-tier:first-child .tech-spine::before { top: 56px; }
.tech-tier:last-child .tech-spine::before { bottom: 52px; }

.tech-main {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  min-height: 248px;
  padding: 14px 13px 12px;
  border: 1px solid #8f6c39;
  background:
    linear-gradient(155deg, rgba(255, 252, 242, .46), rgba(255, 251, 235, 0) 58%),
    repeating-linear-gradient(0deg, #ecd9b1 0 3px, #f2e2c1 3px 6px);
  box-shadow: 0 0 0 3px #d8c397, 0 4px 0 rgba(90, 64, 31, .18);
  text-align: center;
}
.tech-main.is-mastered { background: rgba(112, 133, 76, .14); border-color: #87975d; }
.tech-main.is-active { border-color: #8b6c3f; box-shadow: 0 0 0 3px #d8c397, inset 0 0 0 2px rgba(139, 108, 63, .22); }
.tech-main.is-locked { opacity: .62; border-style: dashed; }
.tech-main-medallion {
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  margin: 0 auto 9px;
  border: 2px solid #ead8b0;
  border-radius: 50%;
  background: #c94a31;
  color: #ffefd0;
  font-family: var(--font-pixel);
  font-size: 13px;
  box-shadow: 0 0 0 2px #8e2b20, 0 3px 0 rgba(50, 32, 20, .2);
}
.tech-main.is-mastered .tech-main-medallion { background: #6f8147; box-shadow: 0 0 0 2px #56683a, 0 3px 0 rgba(50, 32, 20, .2); }
.tech-main-kicker {
  color: #8b7652;
  font-family: var(--font-pixel);
  font-size: 8px;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.tech-main h4 {
  margin: 7px 0 0;
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
  line-height: .92;
}
.tech-main-effect { margin-top: 7px; color: #8d3e29; font-family: var(--font-pixel); font-size: 9.5px; line-height: 1.45; }
.tech-main-desc { margin-top: 7px; color: #7c6748; font-size: 10px; line-height: 1.4; }
/* What a tier opens, drawn as icon tiles on the centre card. Buildings and
   warehouse goods are tinted apart so a glance separates "raise this" from
   "this appears in the warehouse". */
.tech-main-unlocks {
  margin-top: 10px;
  padding-top: 9px;
  border-top: 1px dashed rgba(143, 108, 57, .38);
}
.tech-main-unlocks-label {
  display: block;
  margin-bottom: 7px;
  color: #8b7652;
  font-family: var(--font-pixel);
  font-size: 7.5px;
  letter-spacing: .14em;
  line-height: 1;
  text-transform: uppercase;
}
.tech-main-unlock-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 5px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.tech-main-unlock {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  width: 58px;
  min-width: 0;
}
.tech-main-unlock-glyph {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid #b1915b;
  background: rgba(255, 250, 238, .62);
  color: #5a482f;
  box-shadow: 0 2px 0 rgba(90, 64, 31, .12);
}
.tech-main-unlock-glyph svg { width: 19px; height: 19px; }
.tech-main-unlock--building .tech-main-unlock-glyph {
  border-color: #8f9d68;
  background: rgba(112, 133, 76, .16);
  color: #50602f;
}
.tech-main-unlock-name {
  color: #6d5838;
  font-family: var(--font-pixel);
  font-size: 6.5px;
  line-height: 1.15;
  text-align: center;
  overflow-wrap: anywhere;
}
.tech-main-foot { display: flex; flex-direction: column; gap: 7px; margin-top: auto; padding-top: 12px; }
.tech-main-meta { color: #715b3a; font-family: var(--font-pixel); font-size: 9px; line-height: 1.5; }
.tech-main .button { width: 100%; min-height: 30px; padding: 0 6px; font-size: 9px; }

.tech-node {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 158px;
  padding: 9px;
  border: 1px solid #b1915b;
  background: rgba(255, 248, 231, .38);
  transition: background .14s ease, border-color .14s ease;
}
.tech-node:hover { background: rgba(255, 250, 238, .58); }
.tech-node.is-mastered { background: rgba(112, 133, 76, .14); border-color: #87975d; }
.tech-node.is-active { border-color: #8b6c3f; box-shadow: inset 0 0 0 2px rgba(139, 108, 63, .2); }
.tech-node.is-locked { opacity: .6; border-style: dashed; background: rgba(120, 104, 74, .05); }
.tech-node-head { display: flex; align-items: flex-start; gap: 5px; min-height: 28px; }
.tech-node-glyph {
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border: 1px solid #b49a6a;
  color: #5a482f;
  background: rgba(214, 189, 139, .36);
}
.tech-node-glyph svg { width: 18px; height: 18px; }
.tech-node-badge {
  padding: 3px 4px;
  border: 1px solid #b9a273;
  background: rgba(220, 197, 151, .28);
  color: #7b5d33;
  font-family: var(--font-pixel);
  font-size: 8px;
  line-height: 1;
  white-space: nowrap;
}
.tech-node-seal {
  margin-left: auto;
  padding: 3px 4px;
  border: 1px solid #798c4e;
  color: #61753e;
  background: rgba(255, 250, 238, .5);
  font-family: var(--font-pixel);
  font-size: 7.5px;
  line-height: 1;
  text-transform: uppercase;
  white-space: nowrap;
}
.tech-node-seal.is-queued { border-color: #9f844a; color: #806a49; }
.tech-node h4 {
  margin-top: 7px;
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
  line-height: .94;
}
.tech-node-effect { margin-top: 4px; color: #8d3e29; font-family: var(--font-pixel); font-size: 8.5px; line-height: 1.4; }
.tech-node-desc {
  margin-top: 5px;
  overflow: hidden;
  color: #7c6748;
  font-size: 9px;
  line-height: 1.32;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.tech-node-requires {
  margin-top: 5px;
  color: #8a6a3c;
  font-family: var(--font-pixel);
  font-size: 7.5px;
  line-height: 1.4;
  text-transform: uppercase;
}
.tech-node-foot { display: flex; align-items: flex-end; justify-content: space-between; gap: 6px; margin-top: auto; padding-top: 9px; }
.tech-node-meta { color: #7d6847; font-family: var(--font-pixel); font-size: 8px; line-height: 1.55; }
.tech-node .button { min-height: 28px; padding: 0 7px; font-size: 8px; }
.tech-node-progress {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 3px;
  background: rgba(147, 115, 65, .18);
  overflow: hidden;
}
.tech-node-progress i { display: block; height: 100%; background: #6f8147; }

.tech-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 25px;
  padding: 0 6px;
  border: 1px solid #a98d5b;
  background: rgba(255, 249, 235, .35);
  color: #806a49;
  font-family: var(--font-pixel);
  font-size: 8px;
  line-height: 1.1;
  letter-spacing: .02em;
  text-align: center;
  text-transform: uppercase;
}
.tech-action--mastered { border-color: #87975d; color: #61753e; background: rgba(112, 133, 76, .14); }
.tech-action--active { border-color: #8b6c3f; color: #7b5b2f; background: rgba(214, 189, 139, .34); }
.tech-action--queued { border-color: #9f844a; color: #806a49; }
.tech-action--locked { border-style: dashed; color: #8a7352; }
.tech-action--capped { border-color: #7fa5bf; color: #4f7289; background: rgba(126, 170, 199, .2); }
.tech-tree-note { margin-top: 12px; border-top: 1px dashed rgba(147, 115, 65, .3); padding-top: 10px; }

/* One shared grid: three lane heads, then a row per tier. The tier rows use the
   same column template so left, centre and right always sit on the same seam. */
.tech-columns {
  --tech-gap: 20px;
  --tech-side-col: minmax(0, 1fr);
  --tech-center-col: 292px;
  display: grid;
  grid-template-columns: var(--tech-side-col) var(--tech-center-col) var(--tech-side-col);
  column-gap: var(--tech-gap);
  row-gap: 0;
  align-items: start;
  margin-top: 4px;
}
.tech-lane { min-width: 0; }
.tech-column-head {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 8px;
  margin-bottom: 14px;
  padding: 0 2px 8px;
  border-bottom: 1px solid #c3aa78;
  text-align: center;
}
.tech-column-head h4 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 21px;
  font-weight: 700;
  line-height: 1;
}
.tech-tier-row {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: var(--tech-side-col) var(--tech-center-col) var(--tech-side-col);
  column-gap: var(--tech-gap);
  align-items: stretch;
}
.tech-tier-block { position: relative; margin: 0; padding: 0; }
.tech-tier-row + .tech-tier-row {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid #c3aa78;
}
/* Every treatise joins the centre card with one line from its own mid-height. */
.tech-row::after,
.tech-veil::after {
  content: "";
  position: absolute;
  top: 50%;
  width: calc(var(--tech-gap) + 4px);
  border-top: 1px solid #a98d5b;
  opacity: .85;
  pointer-events: none;
}
.tech-lane--left .tech-row::after,
.tech-lane--left .tech-veil::after { right: calc(-1 * (var(--tech-gap) + 3px)); }
.tech-lane--right .tech-row::after,
.tech-lane--right .tech-veil::after { left: calc(-1 * (var(--tech-gap) + 3px)); }
.tech-lane--main { display: flex; flex-direction: column; }
.tech-lane--main .tech-main-stack { flex: 1 1 auto; }
.tech-main { flex: 1 1 auto; }
.tech-tier-block.is-sealed { opacity: .92; }
.tech-tier-tag {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0 0 8px;
  color: #8b7652;
  font-family: var(--font-pixel);
  font-size: 8px;
  letter-spacing: .12em;
  text-transform: uppercase;
  white-space: nowrap;
}
/* One tier label per row: it spans the three lanes instead of repeating over
   every column. */
.tech-tier-row > .tech-tier-tag {
  grid-column: 1 / -1;
  margin: 0 0 10px;
}
.tech-tier-tag span,
.tech-tier-tag b { flex: 0 0 auto; }
.tech-tier-tag i { flex: 1; height: 1px; background: rgba(147, 115, 65, .34); }
.tech-tier-tag b { color: #8d3e29; font-weight: 400; }
.tech-tier-tag.is-sealed b { color: #8a7352; }

.tech-stack {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.tech-subtag {
  margin: 5px 0 1px;
  color: #8b7652;
  font-family: var(--font-pixel);
  font-size: 7.5px;
  letter-spacing: .12em;
}
.tech-subtag:first-child { margin-top: 0; }

.tech-row {
  position: relative;
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  min-height: 128px;
  padding: 10px 10px 10px 9px;
  border: 1px solid #b1915b;
  background: rgba(255, 248, 231, .42);
  transition: background .14s ease, border-color .14s ease;
}
.tech-row:hover { background: rgba(255, 250, 238, .6); }
.tech-row.is-mastered { background: rgba(112, 133, 76, .14); border-color: #87975d; }
.tech-row.is-active { border-color: #8b6c3f; box-shadow: inset 0 0 0 2px rgba(139, 108, 63, .2); }
.tech-row.is-locked { opacity: .58; border-style: dashed; background: rgba(120, 104, 74, .05); }
/* Branch lanes track the highest centre tier: light blue once the treatise has
   reached that cap, light green while another level is affordable and its
   prerequisites are met. Both use the same translucent tint as a mastered
   centre row, so the paper below shows through. A short bill stays uncoloured. */
.tech-lane--left .tech-row.is-tier-capped,
.tech-lane--right .tech-row.is-tier-capped {
  background: rgba(106, 158, 196, .14);
  border-color: #86aec9;
}
.tech-lane--left .tech-row.is-research-ready,
.tech-lane--right .tech-row.is-research-ready {
  background: rgba(112, 133, 76, .14);
  border-color: #87975d;
}
.tech-row-glyph {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 1px solid #b49a6a;
  color: #5a482f;
  background: rgba(214, 189, 139, .36);
}
.tech-row-glyph svg { width: 20px; height: 20px; }
.tech-row-copy { min-width: 0; }
.tech-row-title { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; }
.tech-row-title h4 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 700;
  line-height: .95;
}
.tech-row-badge {
  padding: 2px 4px;
  border: 1px solid #b9a273;
  background: rgba(220, 197, 151, .28);
  color: #7b5d33;
  font-family: var(--font-pixel);
  font-size: 7.5px;
  line-height: 1;
  white-space: nowrap;
}
.tech-row-time {
  color: #7d6847;
  font-family: var(--font-pixel);
  font-size: 8px;
  line-height: 1;
  white-space: nowrap;
}
.tech-row-level {
  padding: 2px 4px;
  border: 1px solid rgba(108, 84, 48, .3);
  color: #6d5838;
  background: rgba(255, 250, 238, .55);
  font-family: var(--font-pixel);
  font-size: 7px;
  line-height: 1;
  text-transform: uppercase;
  white-space: nowrap;
}
.tech-row-seal {
  padding: 2px 4px;
  border: 1px solid #798c4e;
  color: #61753e;
  background: rgba(255, 250, 238, .5);
  font-family: var(--font-pixel);
  font-size: 7px;
  line-height: 1;
  text-transform: uppercase;
  white-space: nowrap;
}
.tech-row-seal.is-queued { border-color: #9f844a; color: #806a49; }
.tech-row-effect { margin-top: 3px; color: #8d3e29; font-family: var(--font-pixel); font-size: 8.5px; line-height: 1.4; }
/* The subtle projection under a branch treatise: the village number now and
   after one more level, so a percentage reads as something the player owns. */
.tech-row-impact,
.research-sheet-impact {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 3px 5px;
  margin-top: 4px;
  color: #6d5838;
  font-family: var(--font-pixel);
  font-size: 8px;
  line-height: 1.45;
}
.impact-kicker {
  padding: 1px 3px;
  border: 1px solid rgba(121, 140, 78, .45);
  background: rgba(112, 133, 76, .1);
  color: #61753e;
  font-size: 6px;
  letter-spacing: .06em;
  line-height: 1;
  white-space: nowrap;
}
.tech-row-impact .impact-name,
.research-sheet-impact .impact-name { color: #705c3e; }
.impact-now { color: #8a7352; white-space: nowrap; }
.impact-arrow { color: #a4895e; }
.impact-after { color: #4f6534; font-weight: 700; white-space: nowrap; }
.impact-note { color: #8a7352; font-size: 7px; white-space: nowrap; }
.tech-row-meta { margin-top: 3px; color: #7d6847; font-family: var(--font-pixel); font-size: 8px; line-height: 1.4; }
.tech-row-requires {
  margin-top: 3px;
  color: #8a6a3c;
  font-family: var(--font-pixel);
  font-size: 7.5px;
  line-height: 1.35;
  text-transform: uppercase;
}
.tech-row-side { align-self: center; }
.tech-row .button { min-height: 28px; padding: 0 7px; font-size: 8px; }
.tech-row .tech-action { min-height: 27px; }
.tech-row .cost-table {
  margin-top: 6px;
  --cost-name-col: 58px;
  --cost-number-col: 50px;
  font-size: 10px;
}
.tech-main .cost-table {
  margin: 0 auto 4px;
  --cost-name-col: 58px;
  --cost-number-col: 50px;
  font-size: 10px;
  text-align: left;
}
.tech-row-progress {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 3px;
  background: rgba(147, 115, 65, .18);
  overflow: hidden;
}
.tech-row-progress i { display: block; height: 100%; background: #6f8147; }

.tech-veil {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 96px;
  padding: 14px;
  border: 1px dashed #b1915b;
  background: rgba(120, 104, 74, .06);
}
.tech-veil-glyph {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border: 1px solid #b49a6a;
  color: #8a7352;
  background: rgba(214, 189, 139, .25);
}
.tech-veil-glyph svg { width: 22px; height: 22px; }
.tech-veil strong { font-family: var(--font-display); font-size: 19px; font-weight: 700; line-height: 1; }
.tech-veil p { margin-top: 4px; color: #7c6748; font-size: 10px; line-height: 1.4; }
.tech-veil b { color: #8d3e29; font-weight: 400; }

.tech-main-stack { position: relative; display: flex; flex-direction: column; }
.tech-main-stack::before { display: none; }
.tech-main { min-height: 400px; margin: 0; }
.tech-main--gate { border-color: #b06a42; box-shadow: 0 0 0 3px #e1c99b, 0 4px 0 rgba(90, 64, 31, .18); }
.tech-main-gate {
  margin-top: 8px;
  color: #8d3e29;
  font-family: var(--font-pixel);
  font-size: 8px;
  line-height: 1.4;
  letter-spacing: .04em;
}
.tech-main-link { position: relative; z-index: 1; height: 34px; }
.tech-main-link i {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 9px;
  height: 9px;
  margin: -4.5px 0 0 -4.5px;
  transform: rotate(45deg);
  background: #c94a31;
  border: 1px solid #8e2b20;
}
.tech-main-state {
  position: relative;
  z-index: 1;
  margin-top: 12px;
  padding: 8px 6px;
  border: 1px dashed #b1915b;
  background: rgba(120, 104, 74, .06);
  color: #8a7352;
  font-family: var(--font-pixel);
  font-size: 7.5px;
  line-height: 1.45;
  text-align: center;
  text-transform: uppercase;
}
.tech-main-state.is-open { border-color: #87975d; color: #61753e; background: rgba(112, 133, 76, .12); }
/* A short research bill names the building that makes each missing good, so a
   red "0 / 40" row comes with its next step instead of reading as a dead end. */
.tech-main-hint,
.research-sheet-hint {
  margin-top: 8px;
  padding: 6px 8px;
  border-left: 3px solid #c94a31;
  background: rgba(201, 74, 49, .06);
  color: #7c4a34;
  font-family: var(--font-pixel);
  font-size: 8px;
  line-height: 1.5;
}

.tavern-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.tavern-card {
  position: relative;
  display: grid;
  grid-template-columns: 66px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 13px;
  border: 1px solid #b2915c;
  background: rgba(255, 248, 232, .3);
}
.tavern-card .avatar { width: 66px; height: 84px; }
.tavern-card h3 { font-family: var(--font-display); font-size: 25px; font-weight: 700; line-height: .9; }
.tavern-role { margin-top: 4px; color: #8b3b29; font-family: var(--font-pixel); font-size: 12px; text-transform: uppercase; }
.tavern-stats { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 7px; color: #776342; font-family: var(--font-pixel); font-size: 12px; }
.tavern-stats span { padding: 2px 4px; border: 1px solid rgba(143, 112, 65, .33); }
.tavern-attributes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px; max-width: 252px; margin-top: 7px; }
.tavern-attributes span {
  padding: 3px 2px;
  border: 1px solid rgba(143, 112, 65, .33);
  background: rgba(255, 252, 239, .45);
  color: #8a7553;
  font-family: var(--font-pixel);
  font-size: 9.5px;
  letter-spacing: .03em;
  text-align: center;
  text-transform: uppercase;
}
.tavern-attributes strong { display: block; margin-top: 1px; color: #5b4730; font-size: 13px; font-weight: 400; }
.tavern-cost { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 10px; }
.tavern-cost strong { font-family: var(--font-pixel); font-size: 12px; font-weight: 400; color: #5d4428; }
.tavern-card.hired { opacity: .6; }
.tavern-housing-note { margin: 0 0 10px; color: #8b3b29; }

/* ------------------------------------------------------------------ */
/* Inventory and workshop                                             */
/* ------------------------------------------------------------------ */

.inventory-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.inventory-card {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 14px;
  border: 1px solid #b2915c;
  background: rgba(255, 248, 232, .3);
}

.inventory-card-top {
  display: flex;
  align-items: center;
  gap: 9px;
}

.inventory-card-title { min-width: 0; flex: 1 1 auto; }

/* The quality badge mirrors the villager rarity chips so gear and people read
   from the same ladder. Common and Poor stay quiet; the good tiers colour up. */
.inventory-rarity {
  flex: 0 0 auto;
  align-self: flex-start;
  padding: 2px 6px;
  border: 1px solid #8d7b5a;
  color: #6c573a;
  font-family: var(--font-pixel);
  font-size: 9px;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.inventory-rarity.rarity-legendary { border-color: #b8860b; background: #f7e6b4; color: #7a5406; }
.inventory-rarity.rarity-epic { border-color: #7a4f9e; background: #ead9f5; color: #5b3676; }
.inventory-rarity.rarity-rare { border-color: #3f6d9e; background: #dbe8f5; color: #2f5375; }
.inventory-rarity.rarity-uncommon { border-color: #5c7a3e; background: #e3eed4; color: #44602c; }
.inventory-rarity.rarity-common { border-color: #8d7b5a; }
.inventory-rarity.rarity-poor { border-color: #96705a; background: #efe0d3; color: #7a4a35; }

.inventory-glyph {
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border: 1px solid #b49a6a;
  color: #5a482f;
  background: rgba(214, 189, 139, .36);
}
.inventory-glyph svg { width: 22px; height: 22px; }

/* The Inventory shows the actual tile silhouette, not just the road sign. */
.road-piece-figure {
  display: grid;
  place-items: center;
  margin: -2px -2px 1px;
  padding: 7px 8px 5px;
  border: 1px solid rgba(157, 126, 75, .34);
  background:
    radial-gradient(circle at 50% 43%, rgba(255, 250, 235, .55), rgba(214, 189, 139, .16) 62%, rgba(176, 148, 102, .12));
}
.road-piece-figure img {
  display: block;
  width: 100%;
  max-width: 190px;
  height: auto;
}

/* How many standing roads this piece can improve in one of its four turns. */
.inventory-fit {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 6px 8px;
  border-left: 2px solid #b28a4c;
  background: rgba(151, 119, 65, .1);
  color: #806a49;
  font-size: 10.5px;
  line-height: 1.35;
}
.inventory-fit strong {
  color: #3f6b4f;
  font-family: var(--font-pixel);
  font-size: 15px;
  font-weight: 400;
  line-height: 1;
}
.inventory-fit.is-ready { border-left-color: #5c7d5e; }
.inventory-fit.is-blocked { border-left-color: #a0523d; }
.inventory-fit.is-blocked strong { color: #a0523d; }

.inventory-card h3 {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  line-height: .95;
}

.inventory-kind {
  margin-top: 3px;
  color: #8d3e29;
  font-family: var(--font-pixel);
  font-size: 11px;
  text-transform: uppercase;
}

.inventory-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  color: #85704d;
  font-family: var(--font-pixel);
  font-size: 11px;
}
.inventory-note {
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid rgba(157, 126, 75, .38);
  color: #806a49;
  font-size: 10.5px;
  line-height: 1.5;
}

.inventory-stack {
  display: grid;
  gap: 18px;
}

.inventory-desc {
  color: #6f5a3c;
  font-size: 11.5px;
  line-height: 1.45;
}

.inventory-worn {
  background: rgba(214, 189, 139, .22);
}

.inventory-wearer {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: auto;
  padding-top: 8px;
  border-top: 1px solid rgba(157, 126, 75, .3);
}
.inventory-wearer-avatar {
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
}
.inventory-wearer-avatar svg,
.inventory-wearer-avatar img { width: 30px; height: 30px; }
.inventory-wearer strong {
  display: block;
  color: #3e3422;
  font-family: var(--font-pixel);
  font-size: 12px;
}
.inventory-wearer small {
  display: block;
  margin-top: 2px;
  color: #806a49;
  font-family: var(--font-pixel);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .03em;
}

.inventory-holders {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  margin-top: auto;
  padding-top: 8px;
  border-top: 1px solid rgba(157, 126, 75, .28);
}

.inventory-holders-label {
  width: 100%;
  margin-bottom: 1px;
  color: #8d3e29;
  font-family: var(--font-pixel);
  font-size: 10px;
  letter-spacing: .05em;
  text-transform: uppercase;
}

.inventory-holder {
  padding: 2px 5px;
  border: 1px solid rgba(143, 112, 65, .42);
  background: rgba(214, 189, 139, .26);
  color: #5d4428;
  font-family: var(--font-pixel);
  font-size: 10px;
  line-height: 1.35;
}

.inventory-holder.muted {
  border-style: dashed;
  background: transparent;
  color: #8a7657;
}

.inventory-locked {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border: 1px dashed #b1915b;
  background: rgba(255, 248, 231, .22);
}

.inventory-locked .inventory-glyph {
  width: 42px;
  height: 42px;
}

.inventory-locked strong {
  display: block;
  font-family: var(--font-display);
  font-size: 21px;
  font-weight: 700;
  line-height: 1;
  color: #4a3825;
}

.inventory-locked p {
  max-width: 640px;
  margin-top: 4px;
  color: #7d6848;
  font-size: 11.5px;
  line-height: 1.45;
}

.inventory-lock-tag {
  flex: 0 0 auto;
  margin-left: auto;
  padding: 3px 6px;
  border: 1px solid #9d7b4b;
  color: #8d3e29;
  font-family: var(--font-pixel);
  font-size: 10px;
  letter-spacing: .06em;
}

.workshop-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.workshop-card[hidden] { display: none; }

.workshop-card {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 15px;
  border: 1px dashed #b1915b;
  background: rgba(255, 248, 231, .22);
}

/* The star in a card's top-right corner pins that recipe above the rest of the
   catalogue. It sits on the paper edge so the card keeps its one-column flow. */
.workshop-star {
  position: absolute;
  top: 7px;
  right: 7px;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid transparent;
  background: transparent;
  color: #a08a63;
  cursor: pointer;
}
.workshop-star svg { width: 19px; height: 19px; }
.workshop-star svg path { fill: none; }
.workshop-star:hover,
.workshop-star:focus-visible {
  border-color: #b1915b;
  background: rgba(214, 189, 139, .34);
  color: #8b3b29;
  outline: none;
}
.workshop-star.is-on { color: #b8862b; }
.workshop-star.is-on svg path { fill: currentColor; }
.workshop-card.is-favorite {
  border-style: solid;
  border-color: #c39b46;
  background: rgba(255, 248, 231, .42);
}

.workshop-glyph {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid #b49a6a;
  color: #5a482f;
  background: rgba(214, 189, 139, .36);
}
.workshop-glyph svg { width: 21px; height: 21px; }

.workshop-card h3 {
  margin-top: 10px;
  font-family: var(--font-display);
  font-size: 23px;
  font-weight: 700;
  line-height: .95;
}
.workshop-card p {
  margin-top: 5px;
  color: #7c6748;
  font-size: 10.5px;
  line-height: 1.45;
}

.workshop-tag {
  align-self: flex-start;
  margin-top: 13px;
  padding: 3px 5px;
  border: 1px solid #b28a4c;
  color: #806a49;
  font-family: var(--font-pixel);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .04em;
}

/* The catalogue is one list of cards, narrowed by the shared filter button in
   the section head. */
.workshop-catalogue { margin-top: 14px; }

.workshop-empty {
  grid-column: 1 / -1;
  margin: 0;
  padding: 16px;
  border: 1px dashed #b1915b;
  background: rgba(255, 248, 231, .22);
  color: #7c6748;
  font-size: 11.5px;
  line-height: 1.5;
}

/* The production floor: one wide active bench and three narrow queues. The
   cards stand directly on the tab instead of inside a surrounding panel, so
   they need their own paper surface. */
.workshop-production { margin: 14px 0; }

.production-head {
  margin-bottom: 14px;
  padding-bottom: 10px;
  color: #f6e8c9;
  border-bottom-color: rgba(214, 189, 139, .4);
}
.production-head p { color: #b7a887; }
.production-note { color: #b7c4b1; }

.workshop-line {
  display: grid;
  grid-template-columns: 3fr 1fr 1fr 1fr;
  gap: 10px;
  align-items: stretch;
}

.workshop-job {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 14px;
  border: 1px solid #b2915c;
  background:
    linear-gradient(160deg, rgba(255, 252, 242, .45), rgba(255, 251, 235, 0) 60%),
    repeating-linear-gradient(0deg, #f0e0bd 0 3px, #f4e7c9 3px 6px);
  box-shadow: 0 0 0 3px #213632, 0 8px 18px rgba(4, 12, 11, .22);
}

.workshop-job-active {
  border-style: solid;
  border-color: #8b7c4c;
  background:
    linear-gradient(160deg, rgba(255, 252, 242, .45), rgba(255, 251, 235, 0) 60%),
    repeating-linear-gradient(0deg, #efe2c2 0 3px, #f4e9cd 3px 6px);
}

.workshop-job.is-empty {
  border-style: dashed;
  background:
    linear-gradient(160deg, rgba(255, 252, 242, .35), rgba(255, 251, 235, 0) 60%),
    repeating-linear-gradient(0deg, #eee0c0 0 3px, #f2e5c7 3px 6px);
}

.workshop-job-head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.workshop-job-glyph {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border: 1px solid #b49a6a;
  color: #5a482f;
  background: rgba(214, 189, 139, .36);
}
.workshop-job-glyph svg { width: 25px; height: 25px; }

.workshop-job-title { min-width: 0; }

.workshop-job-title h3 {
  font-family: var(--font-display);
  font-size: 27px;
  font-weight: 700;
  line-height: .95;
}

.workshop-job-kicker,
.workshop-queue-kicker {
  color: #8d3e29;
  font-family: var(--font-pixel);
  font-size: 10px;
  letter-spacing: .05em;
  text-transform: uppercase;
}

.workshop-job-sub,
.workshop-queue-sub {
  margin-top: 4px;
  color: #7c6748;
  font-size: 10.5px;
  line-height: 1.4;
}

.workshop-job-percent {
  margin-left: auto;
  flex: 0 0 auto;
  color: #5f753f;
  font-family: var(--font-pixel);
  font-size: 13px;
}

.workshop-job-bar {
  height: 12px;
  margin-top: 12px;
}

.workshop-job-foot {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 7px;
  color: #776342;
  font-family: var(--font-pixel);
  font-size: 10px;
}

/* The phone bench shows this live countdown in the pinned queue strip. */
.workshop-job-countdown { display: none; }

.workshop-job-queue {
  justify-content: flex-start;
  padding: 12px;
}

.workshop-queue-glyph {
  width: 30px;
  height: 30px;
  margin-top: 8px;
  display: grid;
  place-items: center;
  border: 1px solid #b49a6a;
  color: #5a482f;
  background: rgba(214, 189, 139, .3);
}
.workshop-queue-glyph svg { width: 18px; height: 18px; }

.workshop-job-queue h3 {
  margin-top: 8px;
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 700;
  line-height: .95;
  overflow-wrap: anywhere;
}

.workshop-queue-time {
  margin-top: auto;
  padding-top: 10px;
  color: #5f753f;
  font-family: var(--font-pixel);
  font-size: 10px;
  letter-spacing: .03em;
}

.workshop-card-top {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding-right: 28px;
}

.workshop-card-title { min-width: 0; }
.workshop-card-title h3 { margin-top: 0; }

.workshop-slot {
  margin-top: 4px !important;
  color: #8b3b29 !important;
  font-family: var(--font-pixel);
  font-size: 10px !important;
  text-transform: uppercase;
  letter-spacing: .03em;
}

.workshop-desc { min-height: 44px; }

.workshop-effect {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 9px !important;
  padding: 5px 7px;
  border-left: 3px solid #6f7f3f;
  background: rgba(126, 145, 74, .12);
  color: #4f6132 !important;
  font-family: var(--font-pixel);
  font-size: 11px !important;
  line-height: 1.35 !important;
}

/* One bonus per row: the server's " · " join becomes a list of effects. */
.workshop-effect-line { display: block; }

.workshop-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 9px;
}
.workshop-stats span {
  padding: 2px 5px;
  border: 1px solid rgba(143, 112, 65, .38);
  color: #6c573a;
  font-family: var(--font-pixel);
  font-size: 10px;
  text-transform: uppercase;
}
.workshop-stats b { color: #8b3b29; font-weight: 400; }
.workshop-stats .workshop-stock {
  border-color: #7f8d4b;
  background: rgba(126, 145, 74, .16);
  color: #4f6132;
}

/* Each Workshop card lists the stacks it already holds by quality so a Rare
   piece is never hidden behind a Common one. */
/* Each Workshop card lists the stacks it already holds by quality so a Rare
   piece is never hidden behind a Common one. */
.workshop-quality-stock { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.workshop-quality-stock .inventory-rarity { padding: 2px 5px; }

.inventory-actions {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: auto;
  padding-top: 9px;
}
.inventory-actions .button.small { min-height: 29px; padding: 0 10px; font-size: 12px; }
/* A lone action (Take back) still sits on the right, directly under Equip. */
.inventory-actions .button:last-child { margin-left: auto; }

.workshop-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: auto;
  padding-top: 12px;
}
.workshop-footer > .button { margin-left: auto; }
.workshop-cost {
  flex: 1 1 auto;
  min-width: 0;
}
/* A workshop price can reach the millions. Reserve room for 9,999,999 in both
   the held and the required column so the two numbers never spill into each
   other; the card still leaves the button its own space. */
.workshop-cost .cost-table {
  margin-top: 0;
  --cost-number-col: 76px;
}
/* When the card narrows, the label gives up its width first: the two number
   columns stay wide enough for 9,999,999 and the name ellipsizes instead of
   the numbers overlapping. */
.workshop-cost .cost-row {
  grid-template-columns:
    minmax(0, var(--cost-name-col))
    var(--cost-number-col)
    10px
    var(--cost-number-col);
}

.workshop-card.short { opacity: .84; }
.workshop-card.short .workshop-effect { border-left-color: #9d7c4a; }

/* The tipped catalogue card uses the shared .tip-card treatment above. */

.workshop-rack { margin-top: 14px; }

.workshop-rack-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 14px;
}

.workshop-rack-card {
  padding: 11px;
  border: 1px solid #b2915c;
  background: rgba(255, 248, 232, .28);
}
.workshop-rack-card span {
  display: block;
  color: #806a49;
  font-family: var(--font-pixel);
  font-size: 10px;
  text-transform: uppercase;
}
.workshop-rack-card strong {
  display: block;
  margin-top: 3px;
  color: #5f753f;
  font-family: var(--font-display);
  font-size: 27px;
  line-height: 1;
}
.workshop-rack-card p {
  margin-top: 4px;
  color: #85704d;
  font-size: 10px;
  line-height: 1.35;
}

/* ------------------------------------------------------------------ */
/* Toast and modal                                                    */
/* ------------------------------------------------------------------ */

.toast {
  position: fixed;
  /* Above the guide (95 on phones) so a message is never hidden by the card. */
  z-index: 96;
  left: 50%;
  bottom: 104px;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(520px, calc(100% - 28px));
  padding: 11px 14px 11px 11px;
  transform: translateX(-50%);
  background: #f4e5c4;
  border: 1px solid #8f703f;
  box-shadow: 0 0 0 3px #1c312d, 0 10px 28px rgba(3, 10, 10, .32);
  color: #4b3924;
  animation: toast-in .22s ease-out;
}
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}
.toast-mark {
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  background: #687d44;
  color: #fff4dd;
  font-family: var(--font-pixel);
  font-size: 10px;
}
.toast.error .toast-mark { background: #a6412d; }
.toast p { font-size: 12.5px; line-height: 1.4; }

.modal-backdrop {
  position: fixed;
  /* A dialog must cover the phone tutorial card, so it sits above it. */
  z-index: 120;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(7, 16, 15, .65);
  backdrop-filter: blur(2px);
}
/* A tall editor, such as the Village's work-gear sheet, stops in the band
   between the HUD and the foot chrome instead of covering the section's status
   bar and the navbar. Both keep their own place and stay usable; moving to
   another section closes the sheet. */
#modal-backdrop.modal-backdrop-chrome {
  inset: var(--app-chrome-top, 0px) 0 var(--app-chrome-bottom, 0px);
  padding: 12px;
}
#modal-backdrop.modal-backdrop-chrome .modal {
  max-height: calc(100dvh - var(--app-chrome-top, 0px) - var(--app-chrome-bottom, 0px) - 24px);
}
body:has(#modal-backdrop.modal-backdrop-chrome:not([hidden])) .hud,
body:has(#modal-backdrop.modal-backdrop-chrome:not([hidden])) .dock,
body:has(#modal-backdrop.modal-backdrop-chrome:not([hidden])) .tab-footer,
body:has(#modal-backdrop.modal-backdrop-chrome:not([hidden])) .world-status {
  pointer-events: auto;
}
.modal {
  position: relative;
  width: min(430px, 100%);
  /* A tall dialog (the Home Screen card, a long cost report) must still fit a
     short phone; the backdrop keeps the close control reachable. */
  max-height: calc(100vh - 36px);
  max-height: calc(100dvh - 36px);
  overflow-y: auto;
  padding: 25px;
  background:
    linear-gradient(150deg, rgba(255, 252, 241, .3), transparent 50%),
    repeating-linear-gradient(0deg, #f0e0bd 0 3px, #f7ecd2 3px 6px);
  border: 1px solid #a98752;
  box-shadow: 0 0 0 4px #1d332f, 0 0 0 5px #685032, 0 22px 60px rgba(2, 9, 9, .45);
  animation: modal-in .17s ease-out;
}
@keyframes modal-in {
  from { opacity: 0; transform: translateY(8px) scale(.99); }
  to { opacity: 1; transform: none; }
}
/* One close control for every overlay: the red pixel cross box. */
.cross-close {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid #7d2f23;
  background: #c94a31;
  color: #ffefd0;
  font-family: var(--font-pixel);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
}
.cross-close:hover { border-color: #6b2418; background: #b13f29; }
.modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
}
.modal-kicker { color: #90764d; font-family: var(--font-pixel); font-size: 12px; letter-spacing: .08em; }
.modal h2 { margin-top: 7px; font-family: var(--font-display); font-size: 33px; font-weight: 700; line-height: .92; }
/* The level-up result is a centred celebration: its kicker and title sit on the
   dialog's centre line, above the seal and the stat row. */
.modal.modal-levelup .modal-kicker,
.modal.modal-levelup h2 { text-align: center; }
.modal-body { margin-top: 10px; color: #705c3e; font-size: 13px; line-height: 1.5; }
.tip-sheet {
  display: flex;
  align-items: flex-start;
  gap: 13px;
}
.tip-sheet-emblem {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid #a98752;
  background: rgba(255, 250, 235, .55);
  color: #8b5726;
  box-shadow: inset 0 0 0 2px rgba(169, 135, 82, .16);
}
.tip-sheet-emblem svg { width: 25px; height: 25px; }
.tip-sheet-copy p { margin: 0; }
.tip-sheet-copy b { color: #4d3a23; }
.tip-sheet-hint {
  margin-top: 9px !important;
  padding-top: 9px;
  border-top: 1px dashed rgba(157, 126, 75, .45);
  color: #806a49;
  font-size: 12px;
}
.tip-modal .modal-actions .button:first-child { margin-right: auto; }
@media (max-width: 520px) {
  .tip-sheet { gap: 10px; }
  .tip-sheet-emblem { width: 36px; height: 36px; }
  .tip-sheet-emblem svg { width: 21px; height: 21px; }
}
.modal-check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 13px;
  padding: 8px 10px;
  border: 1px solid rgba(157, 126, 75, .4);
  background: rgba(255, 250, 235, .45);
  cursor: pointer;
}
.modal-check input { width: 16px; height: 16px; accent-color: #a6412d; }
.modal-check-window {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 8px;
  color: #806a49;
  font-size: 12px;
}
.modal-check-window select { min-height: 30px; font-size: 12px; }
.modal-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; margin-top: 19px; }
.modal-actions .button { min-height: 36px; }

/* The Academy's treatise overlay. The phone rules live in mobile.css; this is
   the desktop sheet that a click on a tier card or a branch row opens. */
.research-sheet-head { display: flex; align-items: flex-start; gap: 12px; }
.research-sheet-glyph {
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border: 1px solid #b49a6a;
  color: #5a482f;
  background: rgba(214, 189, 139, .36);
}
.research-sheet-glyph svg { width: 28px; height: 28px; }
.research-sheet-head-copy { min-width: 0; }
.research-sheet-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.research-sheet-effect {
  margin-top: 11px;
  color: #8d3e29;
  font-family: var(--font-pixel);
  font-size: 11px;
  line-height: 1.5;
}
.research-sheet-desc { margin-top: 8px; color: #705c3e; font-size: 12px; line-height: 1.5; }
.research-sheet-requires {
  margin-top: 8px;
  color: #8a6a3c;
  font-family: var(--font-pixel);
  font-size: 9px;
  line-height: 1.4;
  text-transform: uppercase;
}
.research-sheet-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin-top: 10px;
  color: #715b3a;
  font-family: var(--font-pixel);
  font-size: 9px;
  line-height: 1.5;
}
.research-sheet-cost { margin-top: 9px; }
.research-sheet-cost .cost-table {
  --cost-name-col: 70px;
  --cost-number-col: 60px;
  font-size: 12px;
}
.research-sheet-confirm { display: block; width: 100%; min-height: 36px; margin-top: 13px; }
.research-sheet-action-note {
  margin-top: 13px;
  padding: 8px 10px;
  border: 1px dashed #b1915b;
  background: rgba(120, 104, 74, .06);
  color: #806a49;
  font-family: var(--font-pixel);
  font-size: 9px;
  line-height: 1.5;
  text-align: center;
  text-transform: uppercase;
}
/* The sheet repeats the centre card's unlock strip for warehouse goods and
   buildings, then adds the workshop recipes a treatise opens. */
.research-sheet-unlocks { margin-top: 10px; }
.research-sheet-unlocks .tech-main-unlocks {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}
.research-sheet-unlocks .tech-main-unlocks + .tech-main-unlocks {
  margin-top: 9px;
  padding-top: 9px;
  border-top: 1px dashed rgba(143, 108, 57, .38);
}
.research-sheet-unlocks .tech-main-unlock-list { justify-content: flex-start; }
.research-sheet-unlocks .tech-main-unlock { width: 64px; }
.research-sheet-unlocks .tech-main-unlock-name { font-size: 8px; }
.research-sheet-recipes .tech-main-unlock-glyph {
  border-color: #a06a45;
  background: rgba(180, 108, 62, .12);
  color: #7d4a2c;
}
/* A recipe ladder grouped by rank. The next rank still to be studied is
   outlined so a treatise with a sparse catalogue still shows its icons. */
.research-rank-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.research-rank {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  padding: 5px 6px;
  border: 1px solid rgba(143, 108, 57, .22);
  background: rgba(255, 250, 238, .32);
}
.research-rank.is-next {
  border-color: #a06a45;
  background: rgba(180, 108, 62, .1);
}
.research-rank-label {
  flex: 0 0 auto;
  width: 22px;
  padding-top: 10px;
  color: #8b7652;
  font-family: var(--font-pixel);
  font-size: 7px;
  line-height: 1;
  text-align: center;
}
.research-rank.is-next .research-rank-label { color: #8d3e29; }
.research-rank .tech-main-unlock-list { justify-content: flex-start; gap: 5px 4px; }
.research-rank .tech-main-unlock { width: 58px; }

/* The finished-work overlay: one row per villager, treatise, tool or recovery,
   using the same paper and ink as the rest of the dialogs. */
.completion-summary { display: grid; gap: 8px; margin-top: 12px; }
.completion-lead { margin: 0 0 2px; color: #806a49; font-size: 12px; line-height: 1.4; }
.completion-row {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  align-items: start;
  gap: 10px;
  padding: 9px 10px;
  border: 1px solid #c2a878;
  background: rgba(255, 252, 240, .5);
}
.completion-row .avatar { width: 42px; height: 50px; }
.completion-glyph {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid #a98752;
  background: rgba(214, 189, 139, .5);
  color: #5a482f;
}
.completion-glyph svg { width: 26px; height: 26px; }
.completion-main { min-width: 0; }
.completion-name {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 7px;
  color: #3f3324;
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 700;
  line-height: 1;
}
.completion-name span {
  color: #8c724b;
  font-family: var(--font-pixel);
  font-size: 10px;
  font-weight: 400;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.completion-detail { margin: 5px 0 0; color: #705c3e; font-size: 12.5px; line-height: 1.4; }
.completion-detail strong { color: #3f3324; }
.completion-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.completion-chip {
  padding: 2px 6px;
  border: 1px solid #af9361;
  background: rgba(255, 252, 239, .55);
  color: #6b5738;
  font-family: var(--font-pixel);
  font-size: 9px;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.completion-chip.ability { border-color: #7d2f23; background: #c94a31; color: #ffefd0; }
.completion-chip.good { border-color: #5c7a3e; background: #e3eed4; color: #44602c; }
.completion-chip.building { border-color: #8d7b5a; background: #efe0d3; color: #7a4a35; }
.completion-chip.rarity-legendary { border-color: #b8860b; background: #f7e6b4; color: #7a5406; }
.completion-chip.rarity-epic { border-color: #7a4f9e; background: #ead9f5; color: #5b3676; }
.completion-chip.rarity-rare { border-color: #3f6d9e; background: #dbe8f5; color: #2f5375; }
.completion-chip.rarity-uncommon { border-color: #5c7a3e; background: #e3eed4; color: #44602c; }
.completion-chip.rarity-common { border-color: #8d7b5a; }
.completion-chip.rarity-poor { border-color: #96705a; background: #efe0d3; color: #7a4a35; }
.completion-unlocks { margin-top: 6px; }
.completion-section-label {
  display: block;
  color: #90764d;
  font-family: var(--font-pixel);
  font-size: 9px;
  letter-spacing: .08em;
}

/* Newcomers can be turned away from the Villagers summary. The choice is a
   toggle until Continue, and a dismissed row stays in place but greys out so a
   misclick can be put right before the dialog commits it. */
.completion-villager { grid-template-columns: 44px minmax(0, 1fr) auto; }
.completion-villager-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  margin-top: 6px;
  color: #5f4b30;
  font-family: var(--font-pixel);
  font-size: 9px;
  letter-spacing: .04em;
}
.completion-villager-stats span { display: inline-flex; align-items: baseline; gap: 4px; }
.completion-villager-stats em { color: #90764d; font-style: normal; }
.completion-villager-stats strong { color: #3f3324; font-size: 11px; }
.completion-villager-actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 5px;
  min-width: 96px;
}
.completion-dismiss { min-height: 30px; padding: 0 8px; font-size: 10px; }
.completion-villager-actions [data-villager-toggle][hidden] { display: none; }
.completion-confirm { display: grid; gap: 4px; }
.completion-confirm[hidden] { display: none; }
.completion-confirm p {
  margin: 0;
  color: #8a3f2c;
  font-family: var(--font-pixel);
  font-size: 8.5px;
  line-height: 1.35;
  letter-spacing: .03em;
}
.completion-confirm .button { min-height: 28px; padding: 0 6px; font-size: 9px; }
.completion-villager.is-dismissed {
  border-style: dashed;
  border-color: #a89a83;
  background: rgba(226, 219, 203, .55);
}
.completion-villager.is-dismissed .avatar {
  filter: grayscale(1);
  opacity: .5;
}
.completion-villager.is-dismissed .completion-name,
.completion-villager.is-dismissed .completion-name span,
.completion-villager.is-dismissed .completion-villager-stats,
.completion-villager.is-dismissed .completion-chip { color: #8d8372; }
.completion-villager.is-dismissed .completion-chip {
  border-color: #b8ad99;
  background: rgba(240, 235, 224, .6);
}
.completion-lead.is-error { color: #a33d29; }

@media (max-width: 520px) {
  .completion-row { grid-template-columns: 34px minmax(0, 1fr); gap: 8px; padding: 8px; }
  .completion-row .avatar { width: 32px; height: 38px; }
  .completion-glyph { width: 34px; height: 34px; }
  .completion-glyph svg { width: 21px; height: 21px; }
  .completion-name { font-size: 17px; }
  .completion-villager-actions {
    grid-column: 2;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    min-width: 0;
  }
  .completion-confirm { grid-template-columns: auto auto; align-items: center; }
  .completion-confirm p { grid-column: 1 / -1; }
}


/* The Home Screen install card: a short recipe, with the iOS Share glyph
   inline so the step reads without a screenshot. */
.install-steps {
  display: grid;
  gap: 9px;
  margin: 13px 0 0;
  padding: 0;
  list-style: none;
  counter-reset: install-step;
}
.install-steps li {
  counter-increment: install-step;
  position: relative;
  padding: 7px 9px 7px 37px;
  border: 1px solid #c2a878;
  background: rgba(255, 252, 240, .5);
  line-height: 1.35;
}
.install-steps li::before {
  content: counter(install-step);
  position: absolute;
  top: 7px;
  left: 9px;
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border: 1px solid #8b6a3c;
  color: #5a462a;
  font-family: var(--font-pixel);
  font-size: 9px;
}
.install-steps strong { color: #4b3820; font-weight: 700; }
.install-share-glyph {
  display: inline-block;
  width: 13px;
  height: 13px;
  margin-right: 2px;
  color: #3f6f8f;
  vertical-align: -2px;
}
.install-note {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed #c4a97b;
  color: #8a7352;
  font-size: 12px;
}

.noscript {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 30px;
  background: #152421;
  color: #f1e0bc;
  text-align: center;
}

/* ------------------------------------------------------------------ */
/* Responsive                                                         */
/* ------------------------------------------------------------------ */

@media (max-width: 1100px) {
  .login-screen { grid-template-columns: minmax(0, .9fr) minmax(380px, 1.1fr); }
  .hero-title { font-size: clamp(58px, 9.4vw, 108px); }
  .hero-kanji { display: none; }
  .resource-layout { grid-template-columns: minmax(0, 1fr) 290px; }
  .villager-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .research-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tech-tier-grid { grid-template-columns: minmax(0, .9fr) 190px minmax(0, 1.35fr); gap: 16px; }
  .tech-branch-cards .tech-node { flex-basis: 120px; }
  .tech-columns { --tech-gap: 14px; --tech-center-col: 256px; }
  .tech-row-title h4 { font-size: 18px; }
  .tech-main { min-height: 400px; }
}

@media (max-width: 860px) {
  body { overflow: auto; }
  .login-screen {
    display: block;
    min-height: 100dvh;
    padding: 0;
    background: #14211f;
  }
  .login-hero {
    min-height: 36vh;
    height: 36vh;
  }
  .hero-copy {
    left: 24px;
    bottom: 36px;
    right: 24px;
  }
  .hero-kicker { font-size: 10px; margin-bottom: 8px; }
  .hero-title { font-size: clamp(58px, 14vw, 92px); }
  .hero-tagline { max-width: 420px; margin-top: 12px; font-size: 13px; }
  .hero-foot { display: none; }
  .hero-village { bottom: 0; height: 100px; width: 300px; transform: translateX(-50%) scale(.86); }
  .hero-pines { --pine-scale: .65; bottom: 2%; }
  .pines-left { left: -3%; }
  .pines-right { right: -3%; }
  .auth-panel {
    justify-content: flex-start;
    min-height: 64vh;
    padding: 30px 18px 44px;
    border-left: 0;
    border-top: 1px solid rgba(232, 185, 79, .2);
    overflow: visible;
  }
  .auth-card { padding: 28px 22px; box-shadow: 0 0 0 6px #2b2119, 0 0 0 7px #6e5536, 0 18px 46px rgba(0, 0, 0, .35); }
  .main-menu-box.panel {
    padding: 28px 22px;
    box-shadow:
      var(--ui-box-shadow),
      0 18px 46px rgba(0, 0, 0, .35);
  }
  .main-menu-servers { max-height: none; }
  .auth-mark { width: 36px; height: 36px; margin-bottom: 15px; }
  .auth-heading h2 { font-size: 35px; }
  .auth-switch { min-height: 47px; font-size: 15px; }
  .auth-credit { display: none; }

  .app { height: 100dvh; grid-template-rows: 58px minmax(0, 1fr) auto; }
  .hud { padding: 0 12px; gap: 8px; }
  .crest { width: 31px; height: 31px; }
  .crest::before { width: 12px; height: 12px; }
  .hud-clan { font-size: 17px; }
  .hud-owner { font-size: 10px; }
  .gold-purse { gap: 4px; }
  .gold-icon { width: 13px; height: 13px; }
  .gold-purse strong { font-size: 13px; }
  .gold-unit { font-size: 10px; }
  .logout-label { display: none; }
  .logout-button { padding: 0 8px; min-height: 30px; }
  .hud-actions { gap: 8px; }

  .dock { padding: 5px 7px 7px; gap: 4px; }
  .dock-head { width: 100%; }
  .dock-title { font-size: 8px; letter-spacing: .1em; }
  .nav-collapse { padding: 2px 6px; font-size: 9px; }
  .nav-window { width: 100%; gap: 3px; }
  .nav-row { gap: 2px; }
  .nav-row .nav-label { font-size: 10px; }
  .nav-button { height: 46px; }
  .nav-button .nav-icon { width: 22px; height: 22px; }
  .nav-label { font-size: 12px; }
  .dock-flourish { display: none; }

  .tab-inner { width: min(100% - 28px, 700px); padding-top: 20px; padding-bottom: 28px; }
  .screen-head { display: block; margin-bottom: 17px; }
  .screen-title { font-size: clamp(37px, 9vw, 50px); }
  .screen-subtitle { max-width: 100%; font-size: 12.5px; }
  .head-stats { justify-content: flex-start; margin-top: 13px; }
  .mini-stat { min-width: 78px; padding: 7px 9px; }
  .mini-stat strong { font-size: 12px; }

  .tech-columns { display: flex; flex-direction: column; gap: 0; }
  .tech-column-head { margin-bottom: 8px; }
  .tech-tier-row { display: contents; }
  .tech-column-head--main { order: 0; }
  .tech-lane--main { order: 1; }
  .tech-column-head--left { order: 2; margin-top: 10px; }
  .tech-lane--left { order: 3; }
  .tech-column-head--right { order: 4; margin-top: 10px; }
  .tech-lane--right { order: 5; }
  .tech-lane { width: 100%; margin-bottom: 14px; }
  .tech-lane--main { max-width: 430px; margin-left: auto; margin-right: auto; }
  .tech-tier-row:not([data-tech-tier="1"]) .tech-lane {
    padding-top: 12px;
    border-top: 1px solid #c3aa78;
  }
  .tech-column-head--main {
    flex-direction: row;
    align-items: baseline;
    justify-content: center;
    text-align: center;
  }
  .tech-lane--left .tech-row::after,
  .tech-lane--right .tech-row::after,
  .tech-lane--left .tech-veil::after,
  .tech-lane--right .tech-veil::after { display: none; }
  .tech-main-stack { width: 100%; max-width: 430px; margin: 0 auto; }
  .tech-main { min-height: 230px; padding: 12px 10px 10px; }
  .tech-main h4 { font-size: 22px; }
  .tech-row-title h4 { font-size: 18px; }
  .tech-legend-party { margin-left: 0; }
  .hall-banner--academy .hall-slots--compact .hall-worker-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    max-width: 430px;
  }

  .resource-layout { grid-template-columns: minmax(0, 1fr); }
  .warehouse-side { display: grid; grid-template-columns: 1fr 1fr; }
  .villager-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .research-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .inventory-grid,
  .workshop-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .workshop-rack-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .workshop-line { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .workshop-job-active { grid-column: 1 / -1; }
  .market-board { padding: 16px; }
  .market-board-head { align-items: flex-start; flex-direction: column; }

  .city-top { top: 10px; left: 10px; right: 10px; gap: 8px; }
  .city-stats { max-width: calc(100% - 82px); gap: 4px; }
  .city-stat { min-height: 29px; padding: 4px 7px; gap: 5px; }
  .city-stat svg { width: 12px; height: 12px; }
  .city-stat span { font-size: 10px; }
  .city-stat strong { font-size: 11px; margin-top: 1px; }
  .city-tools { gap: 3px; }
  .map-button { width: 30px; height: 30px; font-size: 11px; }
  .city-help { display: none; }
  /* On a phone the inspector is the whole middle row, not a short sheet:
     it fills the map between the header and the pinned status bar, and only
     its body scrolls once the selected building's details outgrow that space.
     The Village's bar is a sibling below the map (the tutorial card docks in
     that same bar), so the map's own foot is already the top of the bar. */
  .city-inspector {
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    height: auto;
    max-height: none;
    border-left: 0;
    border-right: 0;
    border-top: 0;
    border-bottom: 0;
    box-shadow: 0 3px 0 #1b312d, 0 4px 0 #6a5434, 0 14px 40px rgba(5, 14, 13, .35);
    animation: sheet-in .2s ease-out;
  }
  @keyframes sheet-in {
    from { transform: translateY(-20px); opacity: 0; }
    to { transform: none; opacity: 1; }
  }
  .inspector-head { padding: 13px 15px 11px; }
  .inspector-head-tile { grid-template-columns: 84px minmax(0, 1fr); gap: 9px; padding: 11px 15px 9px; }
  .inspector-tile-art { width: 84px; height: 54px; }
  .inspector-title { font-size: 25px; }
  .inspector-body { padding: 12px 15px 18px; }
  .build-card { grid-template-columns: 30px minmax(0, 1fr) auto; gap: 7px; padding: 7px 0; }
  .build-card-road { grid-template-columns: 52px minmax(0, 1fr) auto; }
  .build-icon { width: 30px; height: 30px; }
  .build-card-road .build-icon-road { width: 52px; height: 36px; }
  .build-name { font-size: 15px; }
  .road-placement {
    left: 10px;
    right: 10px;
    bottom: 10px;
    width: auto;
    max-width: none;
    transform: none;
    gap: 9px;
    padding: 8px 9px;
  }
  .road-placement-art { width: 74px; height: 48px; }
  .road-placement-copy strong { font-size: 16px; }
  .road-placement-copy p { display: none; }
  .road-placement-actions { gap: 4px; }
  .road-placement-actions .button { padding: 0 6px; }
  .build-effect { font-size: 10px; }
  .build-cost { font-size: 12px; gap: 4px 7px; }
  .build-card .button { min-height: 29px; font-size: 12px; padding: 0 7px; }
  .building-facts { margin-top: 10px; }

  .world-title-block h2 { font-size: 21px; }
  .world-coord { display: none; }
  .world-legend { display: none; }
  /* The World's bar floats over the map, so the alarm has to clear it rather
     than park behind the paper. ui.js publishes the bar's height. */
  .world-attack-banner {
    top: auto;
    bottom: calc(var(--tab-status-height, 0px) + 12px);
    max-width: calc(100% - 20px);
    padding: 7px 11px 7px 8px;
  }
  .world-attack-banner-copy span { font-size: 10px; }
  /* The World's docked bar floats over the foot of the atlas on a phone too.
     Folding it has to reveal or cover the map itself, not resize the canvas
     underneath: a stage that grows with the wrapper stretches the last drawn
     buffer until the resize settles. Kept absolute, the screen never changes
     height and only the paper box grows or shrinks. */
  .world-status {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 4;
    padding: var(--phone-gutter) 0;
    background: transparent;
    pointer-events: none;
  }
  .world-status-box {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
    width: calc(100% - var(--phone-gutter) * 2);
    max-height: none;
    padding: 12px;
    pointer-events: auto;
  }
  /* A folded bar is only the chevron: the transparent strip must let taps and
     pans reach the atlas behind it. */
  .world-status-box.is-collapsed { pointer-events: none; }
  .world-status-box.is-collapsed .status-collapse { pointer-events: auto; }
  .world-status-content {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 0;
  }
  .world-status-party { padding-right: 10px; }
  .world-status-tile { padding-left: 10px; }
  .world-party-head { gap: 5px; }
  .world-party-head-tools {
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
  }
  .world-party-head-tools .construction-eta {
    font-size: 9px;
    text-align: right;
  }
  .world-party-facts { gap: 3px 8px; }
  .world-party-members { display: none; }
  .world-party-body { gap: 8px; }
  .world-party-crew { padding-left: 8px; }
  .world-party-icon { width: 32px; height: 40px; }
  /* The phone drops the party's kicker and stat row: the order rail sits in
     the same row as the portraits, split down the middle with the crew. The
     selected party is named in the headline's own pixel face instead. */
  .world-party-title { display: none; }
  .world-party-head .world-party-selected-title {
    display: block;
    margin-top: 0;
    color: #4f3d27;
    font-family: var(--font-pixel);
    font-size: 11px;
    font-weight: 400;
  }
  .world-party-empty-copy,
  .world-party-muster,
  .world-party-select-hint { display: none; }
  .world-party-mobile-hint {
    display: block;
    flex: 1 1 0;
    min-width: 0;
    color: #7b6038;
    font-family: var(--font-pixel);
    font-size: 10px;
    line-height: 1.35;
  }
  .world-party-stats { display: none; }
  .world-party-body--party {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-items: center;
  }
  /* The tile field names its selection in the same pixel face as the party
     field, and the owner rides beside the tile title in red. */
  .world-status-tile-head { display: flex; }
  .world-status-tile-head .upgrade-kicker { display: none; }
  .world-status-tile-title {
    display: block;
    color: #4f3d27;
    font-family: var(--font-pixel);
    font-size: 11px;
    font-weight: 400;
  }
  /* The owner rides beside the tile title, while travel and terrain yield share
     one line. The route's tile count and the noun "production" are dropped. */
  .world-selection-owner {
    display: inline;
    color: #a2402b;
    font-family: var(--font-pixel);
    font-size: 11px;
    font-weight: 400;
    letter-spacing: .02em;
  }
  .world-selection-territory { display: none; }
  .world-route-count,
  .world-production-suffix { display: none; }
  .world-selection-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 2px 10px;
    margin-top: 4px;
  }
  .world-selection-meta .world-selection-production { margin: 0 !important; }
  .world-party-actions .button {
    flex: 1 1 64px;
    font-size: 10px;
    padding: 0 5px;
  }
  .world-page { padding: 10px; }
  .world-page-panel { max-height: calc(100dvh - 20px); }
  .world-status-tile-name { display: none; }
  .world-status-hint { padding: 8px 4px; }
  .world-selection h3 { font-size: 21px; }
  .world-selection p { font-size: 11px; }
  .world-status .world-selection-close { top: -2px; right: 0; }

  .toast { bottom: 138px; }
}

/* A phone cannot hold the party and its tile actions side by side without
   clipping either heading, so the same two halves stack in reading order. */
@media (max-width: 620px) {
  .world-status-content {
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
  }
  .world-status-party {
    padding-right: 0;
    padding-bottom: 8px;
    border-right: 0;
    border-bottom: 1px solid rgba(145, 113, 61, .35);
  }
  .world-status-tile {
    padding-top: 8px;
    padding-left: 0;
  }
  .world-party-head-tools {
    flex-direction: row;
    align-items: center;
  }
  .world-party-head-tools .construction-eta { font-size: 9px; }
  /* The party's order rail stays beside the portraits even on a narrow phone;
     only the messenger's longer stat row stacks. */
  .world-party-body { grid-template-columns: minmax(0, 1fr); gap: 6px; }
  .world-party-body--party {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 8px;
  }
  .world-party-crew {
    padding-top: 6px;
    padding-left: 0;
    border-top: 1px solid rgba(145, 113, 61, .28);
    border-left: 0;
  }
  .world-party-body--party .world-party-crew {
    padding-top: 0;
    padding-left: 8px;
    border-top: 0;
    border-left: 1px solid rgba(145, 113, 61, .28);
  }
  .world-party-icons { max-height: 50px; }
  /* Full-page sheets take the whole phone viewport. */
  .world-page { padding: 0; }
  .world-page-panel {
    width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    border: 0;
    box-shadow: none;
  }
  .world-page-head { padding: 14px; }
  .world-page-head h2 { font-size: 28px; }
  .world-page-body { padding: 12px; }
  .world-page-foot { padding: 10px 12px; }
  .world-page-grid--pick,
  .world-page-grid--parties,
  .world-page-grid--details { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 580px) {
  .hud { grid-template-columns: minmax(0, 1fr) auto; }
  .gold-unit { display: none; }
  .nav-button { gap: 2px; }
  .nav-button .nav-icon { width: 20px; height: 20px; }
  .nav-label { font-size: 10px; }
  .villager-grid { grid-template-columns: minmax(0, 1fr); }
  .resource-grid { grid-template-columns: minmax(0, 1fr); }
  .warehouse-side { grid-template-columns: minmax(0, 1fr); }
  .research-grid { grid-template-columns: minmax(0, 1fr); }
  .tavern-grid { grid-template-columns: minmax(0, 1fr); }
  .inventory-grid,
  .workshop-grid,
  .workshop-rack-grid { grid-template-columns: minmax(0, 1fr); }
  .workshop-line { grid-template-columns: minmax(0, 1fr); }
  .workshop-job-active { grid-column: auto; }
  .inventory-locked {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  .inventory-lock-tag { margin-left: 0; }
  .panel { padding: 16px; }
  .warehouse-panel { padding: 16px; }
  .market-board { padding: 13px; }
  .listing { grid-template-columns: 32px minmax(0, 1fr) auto; gap: 8px; }
  .listing-icon { width: 32px; height: 32px; }
  .listing-title { font-size: 17px; }
  .listing-price { flex-direction: column; gap: 4px; align-items: flex-end; }
  .listing-price .button { min-height: 28px; }
  .school-row { grid-template-columns: 40px minmax(0, 1fr) auto; gap: 8px; }
  .school-row .avatar { width: 38px; height: 46px; }
  .school-name { font-size: 18px; }
  .edu-track { width: 80px; }
  .hall-banner { display: block; padding: 16px; }
  .hall-mark { width: 40px; height: 40px; font-size: 23px; margin-bottom: 10px; }
  .hall-banner h2 { font-size: 28px; }
  .hall-banner .hall-aside { margin: 10px 0 0; text-align: left; }
  .hall-slots { max-width: none; }
  .hall-worker-grid { justify-content: start; }
  .tech-legend { gap: 6px 12px; font-size: 8px; }
  .tech-row { grid-template-columns: 28px minmax(0, 1fr) auto; gap: 7px; padding: 8px 8px 8px 7px; }
  .tech-row-glyph { width: 28px; height: 28px; }
  .tech-row-glyph svg { width: 18px; height: 18px; }
  .tech-row-title h4 { font-size: 17px; }
  .world-title-block p { display: none; }
  .city-top { flex-wrap: wrap; }
  .city-stats { max-width: 100%; }
  .city-tools { margin-left: auto; }
}

@media (max-width: 400px) {
  .hud-clan { font-size: 14px; }
  .hud-brand { gap: 8px; }
  .gold-purse strong { font-size: 12px; }
  .hero-title { font-size: clamp(44px, 14vw, 57px); }
  .hero-copy { bottom: 25px; }
  .hero-tagline { display: none; }
  .login-hero { height: 29vh; min-height: 29vh; }
  .auth-panel { min-height: 71vh; padding-top: 23px; }
  .auth-card { padding: 24px 18px; }
  .auth-heading h2 { font-size: 31px; }
  .hud-owner { display: none; }
  .nav-label { font-size: 9px; }
  .dock-title { display: none; }
  .dock-head { justify-content: flex-end; }
  .city-stat:nth-child(3) { display: none; }
}

@media (max-width: 360px) {
  .cost-table {
    --cost-name-col: 56px;
    --cost-number-col: 52px;
    column-gap: 3px;
    font-size: 11px;
  }
  .cost-row { grid-template-columns: var(--cost-name-col) var(--cost-number-col) 8px var(--cost-number-col); }
}

@media (max-height: 760px) and (min-width: 861px) {
  .login-hero { min-height: 100vh; }
  .hero-copy { bottom: 120px; }
  .hero-tagline { margin-top: 15px; }
  .auth-card { padding-top: 27px; padding-bottom: 27px; }
  .auth-form { margin-top: 21px; gap: 12px; }
  .auth-credit { margin-top: 18px; }
  .auth-mark { margin-bottom: 13px; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: .001ms !important;
  }
  /* The opening camera is part of the sign-in screen now, so it still plays
     for reduced-motion visitors; only the decorative CSS loops are stilled. */
}

/* Selectable production recipes in the building inspector. */
.recipe-block {
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid rgba(148, 118, 71, .38);
  background: rgba(255, 247, 230, .3);
}
.recipe-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}
.recipe-fuel-head { margin-top: 10px; }
.recipe-kicker {
  color: #8a7654;
  font-family: var(--font-pixel);
  font-size: 10px;
  letter-spacing: .08em;
}
.recipe-head strong { color: #4d3a24; font-size: 14px; }
.recipe-picker { display: flex; flex-wrap: wrap; gap: 6px; }
.recipe-chip {
  padding: 4px 9px;
  border: 1px solid #b2915d;
  background: rgba(255, 247, 230, .35);
  color: #6e5836;
  font-family: var(--font-pixel);
  font-size: 12px;
}
.recipe-chip:hover { border-color: #9b3322; background: rgba(201, 74, 49, .12); }
.recipe-chip:focus-visible { outline: 2px solid #7a5a2f; outline-offset: 1px; }
.recipe-chip:disabled {
  border-style: dashed;
  border-color: rgba(148, 118, 71, .45);
  background: rgba(255, 247, 230, .18);
  color: #a08b68;
  cursor: not-allowed;
}
.recipe-chip:disabled:hover { border-color: rgba(148, 118, 71, .45); background: rgba(255, 247, 230, .18); }
.recipe-chip.active {
  border-color: #8d2e20;
  background: #c94a31;
  color: #fff1d6;
}
.recipe-note {
  margin: 8px 0 0;
  color: #7b6747;
  font-size: 12px;
  line-height: 1.4;
}

/* ------------------------------------------------------------------ */
/* Phone screens                                                      */
/* ------------------------------------------------------------------ */
/* A phone dock loses four stacked rows of sections and keeps one
   swipeable shelf, so the game -- not the navigation -- owns the
   screen. The rules below sit last so they win over the older mobile
   blocks without reordering those blocks. */

@media (max-width: 860px) {
  .app {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: calc(48px + env(safe-area-inset-top, 0px)) minmax(0, 1fr) auto;
  }
  .screen { min-width: 0; }
  .tab-screen { min-width: 0; }

  .hud {
    gap: 6px;
    padding-top: env(safe-area-inset-top, 0px);
    padding-right: 10px;
    padding-bottom: 0;
    padding-left: 10px;
  }
  .crest {
    width: 27px;
    height: 27px;
    border-width: 1px;
    box-shadow: inset 0 0 0 1px #5c4527, 0 2px 0 rgba(0, 0, 0, .25);
  }
  .crest::before { width: 11px; height: 11px; box-shadow: 0 0 0 2px #2f4b41; }
  .hud-brand { gap: 8px; }
  .hud-clan { font-size: 16px; }
  .hud-owner { display: none; }

  .gold-purse { gap: 4px; }
  .gold-purse strong { font-size: 14px; }
  .gold-icon { width: 13px; height: 13px; border-width: 1px; }
  .hud-actions { gap: 6px; }
  .music-label { display: none; }
  .music-button { padding: 0 8px; min-height: 30px; }

  /* ---- Dock: one swipeable shelf, primary sections first ---- */
  .dock {
    width: 100%;
    min-width: 0;
    gap: 0;
    /* The app frame already ends at the small viewport on a phone, so this
       only pads for the home indicator. */
    padding: 3px 0 calc(4px + env(safe-area-inset-bottom, 0px));
    border-top-width: 2px;
    overflow: hidden;
    box-shadow:
      inset 16px 0 14px -12px rgba(20, 15, 12, .95),
      inset -16px 0 14px -12px rgba(20, 15, 12, .95);
  }
  .dock-head { display: none; }
  .dock-flourish { display: none; }

  .nav-window {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    flex-direction: row;
    gap: 0;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 0 4px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    scroll-snap-type: x proximity;
    /* The shelf owns its sideways drag (ui.js also arms it for a mouse), while
       a vertical gesture stays with the page. This keeps the bar slideable on
       phone WebViews that do not scroll a display:contents row natively. */
    touch-action: pan-y;
  }
  .nav-window::-webkit-scrollbar { display: none; }

  /* Both rows become one continuous shelf; the collapse control is
     desktop-only, so every section stays reachable on a phone. */
  .nav-row,
  .nav-row[hidden] { display: contents; }

  /* Every shelf button takes the Village's size, so the swipeable strip keeps
     one steady rhythm instead of a run of narrower tabs around a wide
     landmark. The Village still owns its cream palette below. The editor can
     scale this whole shape from 50% to 150%. */
  .nav-button {
    flex: 0 0 calc(92px * var(--nav-button-scale, 1));
    min-width: calc(92px * var(--nav-button-scale, 1));
    height: calc(54px * var(--nav-button-scale, 1));
    gap: calc(2px * var(--nav-button-scale, 1));
    padding: calc(5px * var(--nav-button-scale, 1)) calc(8px * var(--nav-button-scale, 1)) calc(4px * var(--nav-button-scale, 1));
    border-bottom: 0;
    border-left: 1px solid rgba(169, 123, 56, .12);
    border-right: 0;
    border-top: 0;
    scroll-snap-align: center;
  }
  /* The shelf's order comes from the player's saved layout; each button
     carries its own inline order. The first rendered button is the left edge. */
  .nav-button:first-child { border-left-color: transparent; }
  .nav-button::after { left: 18%; right: 18%; bottom: 0; }
  .nav-button.active {
    transform: none;
    background: linear-gradient(180deg, rgba(201, 74, 49, .26), rgba(201, 74, 49, .04));
  }
  .nav-button .nav-icon {
    width: calc(24px * var(--nav-button-scale, 1));
    height: calc(24px * var(--nav-button-scale, 1));
  }
  .nav-window .nav-label {
    max-width: none;
    font-size: calc(10px * var(--nav-button-scale, 1));
    letter-spacing: .01em;
  }
  /* The floating drag copy lives on <body>, outside the shelf, so it needs the
     same scaled label size in its own right. */
  .nav-drag-ghost .nav-label { font-size: calc(10px * var(--nav-button-scale, 1)); }

  /* While the editor is open the gaps between tiles are a second grab area for
     sliding the shelf, so the bar moves even when no section is picked up. */
  .nav-window.is-editing {
    gap: max(4px, calc(6px * var(--nav-button-scale, 1)));
    cursor: ew-resize;
    touch-action: none;
  }
  .nav-window.is-editing .nav-button[data-tab="city"] { cursor: ew-resize; }
  .nav-window.is-panning {
    cursor: grabbing;
    scroll-snap-type: none;
    scroll-behavior: auto;
  }

  /* One shelf, laid out by the player's saved mobile order. Desktop keeps its
     two rows; the phone treats both as a single swipeable strip. */

  /* The Village keeps the shelf's cream landmark palette; its size is the
     shared shelf size every section now uses. */
  .nav-button[data-tab="city"] {
    border: 1px solid #6f4b1b;
    border-top-color: #e3c482;
    border-bottom-color: #6f4a1a;
    background:
      linear-gradient(180deg, rgba(255, 255, 255, .44), rgba(255, 255, 255, 0) 46%),
      repeating-linear-gradient(0deg, rgba(104, 70, 26, .07) 0 1px, transparent 1px 3px),
      linear-gradient(180deg, #dcc084, #c3a25c 55%, #a98643);
    color: #2d1f0d;
    text-shadow: 0 1px 0 rgba(255, 255, 255, .26);
    box-shadow:
      inset 0 0 0 1px rgba(255, 244, 213, .34),
      inset 0 -3px 0 rgba(92, 60, 22, .32),
      0 0 0 1px rgba(35, 22, 10, .6),
      0 4px 10px rgba(0, 0, 0, .34),
      0 0 10px rgba(198, 150, 66, .12);
    transform: translateY(-1px);
  }
  .nav-button[data-tab="city"]:hover {
    color: #221607;
    background:
      linear-gradient(180deg, rgba(255, 255, 255, .58), rgba(255, 255, 255, 0) 48%),
      repeating-linear-gradient(0deg, rgba(104, 70, 26, .06) 0 1px, transparent 1px 3px),
      linear-gradient(180deg, #edd69f, #d5b470 55%, #bd9851);
  }
  .nav-button[data-tab="city"].active {
    color: #1e1408;
    background:
      linear-gradient(180deg, rgba(255, 255, 255, .84), rgba(255, 255, 255, 0) 50%),
      repeating-linear-gradient(0deg, rgba(104, 70, 26, .04) 0 1px, transparent 1px 3px),
      linear-gradient(180deg, #fff3ce, #f3dc9c 52%, #e0b45f);
    border-color: #ffe2a0;
    box-shadow:
      inset 0 0 0 1px rgba(255, 253, 240, .66),
      inset 0 -3px 0 rgba(122, 81, 30, .16),
      0 0 0 1px rgba(41, 26, 12, .5),
      0 5px 12px rgba(0, 0, 0, .34),
      0 0 22px rgba(255, 196, 88, .5);
    transform: translateY(-2px);
  }
  .nav-button[data-tab="city"].tutorial-target {
    box-shadow:
      inset 0 0 0 1px rgba(255, 253, 240, .7),
      0 0 0 2px rgba(245, 211, 111, .7),
      0 0 24px rgba(245, 211, 111, .55);
  }
  .nav-button[data-tab="city"]::after {
    left: 30%;
    right: 30%;
    bottom: 3px;
    background: rgba(120, 74, 24, .32);
  }
  .nav-button[data-tab="city"].active::after { background: #b5341f; }
  .nav-button[data-tab="city"] .nav-icon {
    filter: drop-shadow(0 1px 0 rgba(255, 255, 255, .45));
  }
  .nav-button[data-tab="city"].active .nav-icon {
    filter: drop-shadow(0 1px 0 rgba(255, 255, 255, .55));
  }
  .nav-button[data-tab="city"] .nav-label {
    font-weight: 400;
  }

  /* ---- Content: less chrome before the game ---- */
  .tab-inner {
    width: calc(100% - 20px);
    padding-top: 14px;
    padding-bottom: 20px;
  }
  .screen-head { margin-bottom: 12px; }
  .screen-head .eyebrow { margin-bottom: 5px; font-size: 9px; }
  .screen-title {
    font-size: clamp(27px, 7.4vw, 38px);
    line-height: 1;
    letter-spacing: -.02em;
  }
  .screen-subtitle {
    margin-top: 6px;
    font-size: 11.5px;
    line-height: 1.45;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  /* Stats become one compact strip instead of several stacked rows. */
  .head-stats {
    flex-wrap: nowrap;
    justify-content: flex-start;
    gap: 5px;
    margin-top: 10px;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
  }
  .head-stats::-webkit-scrollbar { display: none; }
  .mini-stat {
    flex: 0 0 auto;
    min-width: 0;
    padding: 5px 9px 6px;
  }
  .mini-stat span { font-size: 10px; letter-spacing: .04em; }
  .mini-stat strong { margin-top: 3px; font-size: 12px; }

  .panel { padding: 14px; }
  .panel-head {
    flex-wrap: wrap;
    row-gap: 2px;
    margin-bottom: 10px;
    padding-bottom: 8px;
  }
  .panel-head h3 { font-size: 21px; }
  .panel-head p { margin-left: auto; font-size: 9px; }

  .hall-banner { padding: 14px; }
  .hall-banner h2 { font-size: 24px; }
  .hall-banner p { max-width: none; font-size: 11.5px; line-height: 1.4; }
  .hall-mark { width: 36px; height: 36px; font-size: 21px; }

  /* Every phone shelf carries all sections, so the old "extra row" switch
     has no meaning here. */
  .settings-row.settings-row-navExpanded { display: none; }

  .toast { bottom: 74px; }
}

@media (max-width: 560px) {
  .tab-inner { width: calc(100% - 16px); }
  .screen-title { font-size: clamp(25px, 7.2vw, 33px); }
  .panel { padding: 13px; }
}

@media (max-width: 400px) {
  .hud-clan { font-size: 14px; }
  .hud-brand { gap: 6px; }
  .gold-purse strong { font-size: 12px; }
  .worker-slot { min-height: 54px; padding: 10px 2px 4px; }
  .worker-slot-name,
  .worker-grid .worker-slot-name,
  .hall-worker-grid .worker-slot-name,
  .worker-slot.locked .worker-slot-name,
  .hall-worker-grid .worker-slot.locked .worker-slot-name {
    font-size: 8px;
    letter-spacing: -.01em;
  }
  .worker-slot-index { font-size: 9px; }
}

/* A landscape phone keeps an even shallower bar. */
@media (max-width: 900px) and (max-height: 520px) {
  .app { grid-template-rows: calc(44px + env(safe-area-inset-top, 0px)) minmax(0, 1fr) auto; }
  .nav-button {
    flex-basis: calc(78px * var(--nav-button-scale, 1));
    min-width: calc(78px * var(--nav-button-scale, 1));
    height: calc(44px * var(--nav-button-scale, 1));
    padding: calc(3px * var(--nav-button-scale, 1)) calc(6px * var(--nav-button-scale, 1)) calc(2px * var(--nav-button-scale, 1));
  }
  .nav-button .nav-icon {
    width: calc(19px * var(--nav-button-scale, 1));
    height: calc(19px * var(--nav-button-scale, 1));
  }
  .nav-window .nav-label { font-size: calc(10px * var(--nav-button-scale, 1)); }
  .tab-inner { padding-top: 8px; padding-bottom: 14px; }
  .screen-head .eyebrow { margin-bottom: 3px; font-size: 8px; }
  .screen-title { font-size: 26px; }
  .screen-subtitle {
    margin-top: 4px;
    font-size: 10.5px;
    -webkit-line-clamp: 1;
  }
  .head-stats { margin-top: 6px; }
  .panel,
  .hall-banner { padding: 10px; }
}

/* ------------------------------------------------------------------ */
/* Messenger post (World overlay + Messages tab)                        */
/* ------------------------------------------------------------------ */

.messenger-page { z-index: 120; }
.messenger-page .world-page-panel { width: min(780px, 100%); height: auto; max-height: min(860px, calc(100dvh - 36px)); }
.messenger-target {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin: 0 0 12px;
  padding: 9px 12px;
  border: 1px solid rgba(145, 113, 61, .38);
  background: rgba(255, 249, 232, .55);
  color: #6f5a39;
  font-size: 12px;
}
.messenger-target strong { color: #4f3d27; font-family: var(--font-display); font-size: 20px; }
.messenger-target span { font-family: var(--font-pixel); font-size: 10px; letter-spacing: .05em; }
.messenger-villagers { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 7px; }
.messenger-villager {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  border: 1px solid rgba(145, 113, 61, .45);
  border-radius: 4px;
  background: rgba(255, 247, 226, .6);
  color: #5f4c31;
  text-align: left;
}
.messenger-villager:hover { background: rgba(233, 193, 105, .26); }
.messenger-villager.selected { border-color: #b58a35; background: rgba(233, 187, 85, .36); box-shadow: inset 0 0 0 1px rgba(120, 84, 28, .35); }
.messenger-villager .avatar { flex: 0 0 auto; }
.messenger-villager-copy { display: grid; gap: 2px; min-width: 0; }
.messenger-villager-copy strong { color: #4f3d27; font-size: 12px; }
.messenger-villager-copy small { color: #7b6038; font-family: var(--font-pixel); font-size: 9px; letter-spacing: .03em; }
.messenger-compose { margin-top: 14px; }
.messenger-compose-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 5px; }
.messenger-compose-head label { color: #6f5a39; font-family: var(--font-pixel); font-size: 10px; letter-spacing: .06em; }
.messenger-compose-head span { color: #7b6038; font-family: var(--font-pixel); font-size: 10px; }
.messenger-compose textarea {
  width: 100%;
  min-height: 116px;
  resize: vertical;
  padding: 10px 11px;
  border: 1px solid #a98752;
  background: rgba(255, 252, 242, .82);
  color: #4f3d27;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.45;
}
.messenger-compose textarea:focus { outline: 2px solid rgba(181, 138, 53, .55); outline-offset: 1px; }
.messenger-note { margin: 8px 0 0; color: #7b6038; font-size: 11px; line-height: 1.45; }
.messenger-empty { margin: 0; padding: 16px 10px; border: 1px dashed rgba(145, 113, 61, .5); color: #7b6038; font-family: var(--font-pixel); font-size: 11px; line-height: 1.5; text-align: center; }

.messages-summary-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) minmax(230px, 1.5fr); gap: 8px; }
.messages-stat,
.messages-guard {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid rgba(145, 113, 61, .38);
  background: rgba(255, 250, 235, .5);
}
.messages-stat span,
.messages-guard > span { color: #8a7049; font-family: var(--font-pixel); font-size: 9px; letter-spacing: .06em; }
.messages-stat strong { color: #4f3d27; font-family: var(--font-figure); font-size: 24px; line-height: 1; }
.messages-guard strong { color: #4f3d27; font-family: var(--font-figure); font-size: 18px; line-height: 1.1; }
.messages-guard small { color: #7b6038; font-size: 10.5px; line-height: 1.4; }
.messages-guard .button { justify-self: start; margin-top: 2px; }
.messages-list { display: grid; gap: 10px; }
.messages-card {
  padding: 12px 14px;
  border: 1px solid rgba(145, 113, 61, .4);
  background: rgba(255, 250, 235, .5);
}
.messages-card.unread { border-color: #b58a35; box-shadow: inset 3px 0 0 #b58a35, 0 0 0 1px rgba(181, 138, 53, .22); }
.messages-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.messages-card-head h4 { margin: 3px 0 0; color: #4f3d27; font-family: var(--font-display); font-size: 21px; font-weight: 700; line-height: 1.05; }
.messages-card-sub { margin: 4px 0 0; color: #7b6038; font-size: 11.5px; line-height: 1.4; }
.messages-status {
  flex: 0 0 auto;
  padding: 3px 7px;
  border: 1px solid rgba(145, 113, 61, .5);
  color: #7a6238;
  font-family: var(--font-pixel);
  font-size: 9px;
  letter-spacing: .05em;
  white-space: nowrap;
}
.messages-status.travelling { border-color: #8a9c6b; color: #4f6539; }
.messages-status.delivered { border-color: #4f7a53; color: #38603e; }
.messages-status.looted { border-color: #a2402b; color: #8a2f1f; }
.messages-status.returned { border-color: #9c7c46; color: #7a5a2c; }
.messages-body {
  margin: 10px 0 0;
  padding: 10px 12px;
  border-left: 3px solid rgba(181, 138, 53, .6);
  background: rgba(255, 252, 242, .7);
  color: #4a3a24;
  font-family: inherit;
  font-size: 13.5px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.messages-foot { margin: 8px 0 0; color: #7b6038; font-family: var(--font-pixel); font-size: 9px; letter-spacing: .04em; }

@media (max-width: 760px) {
  .messages-summary-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .messages-guard { grid-column: span 2; }
  .messenger-villagers { grid-template-columns: 1fr; }
}

/* Selected messenger: the left pane wears the party card's shape, with a letter
   badge instead of a roster of portraits. */
.world-messenger-avatar {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #2f4f49;
  color: #d8f3e6;
  font-size: 15px;
  line-height: 1;
  box-shadow: inset 0 0 0 2px rgba(216, 243, 230, .35);
}

/* ------------------------------------------------------------------ */
/* HUD help button and its two-door sheet                             */
/* ------------------------------------------------------------------ */

/* The control sits between Music and Main menu: same quiet chrome as its
   neighbours, with one round mark so it reads at a glance. */
.help-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 33px;
  padding: 0 11px;
  color: #cbb998;
  background: rgba(15, 18, 16, .35);
  border: 1px solid #5e4a31;
  font-family: var(--font-pixel);
  font-size: 10px;
  letter-spacing: .05em;
  text-transform: uppercase;
  transition: color .15s ease, border-color .15s ease, background .15s ease;
}
.help-button:hover {
  color: #fff0cf;
  border-color: #a97b38;
  background: rgba(85, 47, 30, .42);
}
.help-button[aria-expanded="true"] {
  color: #fff0cf;
  border-color: #c99a4a;
  background: rgba(85, 47, 30, .5);
}
.help-icon {
  display: inline-grid;
  place-items: center;
  width: 16px;
  height: 16px;
  border: 1px solid currentColor;
  border-radius: 50%;
  font-family: var(--font-pixel);
  font-size: 10px;
  line-height: 1;
}

.help-backdrop { z-index: 150; }
.help-modal { width: min(474px, 100%); }
.help-lead { color: #705c3e; }
.help-links {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
}
.help-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 13px;
  color: #3f2f1d;
  background: rgba(255, 250, 235, .55);
  border: 1px solid #b79a67;
  text-decoration: none;
  transition: background .14s ease, border-color .14s ease, transform .14s ease;
}
.help-link:hover {
  color: #3f2f1d;
  background: #fff8e6;
  border-color: #a6412d;
  transform: translateX(2px);
}
.help-link-mark {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  color: #8b5726;
  background: #f4e6c4;
  border: 1px solid #a98752;
  font-family: var(--font-pixel);
  font-size: 15px;
  line-height: 1;
  box-shadow: inset 0 0 0 2px rgba(169, 135, 82, .14);
}
.help-link-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}
.help-link-copy strong {
  color: #3c2b18;
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
  line-height: 1.12;
}
.help-link-copy small {
  color: #77603f;
  font-family: var(--font-body);
  font-size: 11.5px;
  line-height: 1.45;
}
.help-link-arrow {
  flex: 0 0 auto;
  color: #a6412d;
  font-family: var(--font-pixel);
  font-size: 15px;
}
.help-link-report .help-link-mark {
  color: #8e2b20;
  background: #f6dfd6;
  border-color: #b77d6f;
}
.help-foot {
  margin: 12px 0 0;
  color: #8a7352;
  font-size: 11px;
  line-height: 1.5;
}
body.help-open { overflow: hidden; }

/* The report door and the in-game page it opens. The sheet keeps the same
   paper card as the rest of the shell; the evidence strip previews the whole
   screen captured while the dialog is open, not a cropped map. */
button.help-link {
  width: 100%;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
}
.bug-backdrop { z-index: 152; }
.bug-modal { width: min(560px, 100%); }
.bug-lead { color: #705c3e; }
.bug-evidence {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  gap: 12px;
  margin-top: 15px;
  align-items: start;
}
.bug-shot {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  border: 1px solid #a98752;
  background: #26312c;
}
.bug-shot img {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.bug-shot img[hidden] { display: none; }
.bug-shot-empty {
  margin: 0;
  padding: 10px;
  color: #cbb998;
  font-family: var(--font-pixel);
  font-size: 9px;
  line-height: 1.5;
  letter-spacing: .02em;
  text-align: center;
}
.bug-facts {
  display: grid;
  gap: 7px;
  margin: 0;
}
.bug-facts div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 6px;
  border-bottom: 1px dashed rgba(157, 126, 75, .4);
}
.bug-facts dt {
  color: #8a7352;
  font-family: var(--font-pixel);
  font-size: 9px;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.bug-facts dd {
  margin: 0;
  min-width: 0;
  overflow: hidden;
  color: #4f3d27;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bug-message-label {
  display: block;
  margin-top: 15px;
  color: #6f5a39;
  font-family: var(--font-pixel);
  font-size: 10px;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.bug-message {
  width: 100%;
  min-height: 118px;
  margin-top: 5px;
  resize: vertical;
  padding: 10px 11px;
  border: 1px solid #a98752;
  background: rgba(255, 252, 242, .82);
  color: #4f3d27;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.45;
}
.bug-message:focus { outline: 2px solid rgba(181, 138, 53, .55); outline-offset: 1px; }
.bug-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 14px;
}
.bug-status {
  flex: 1 1 160px;
  min-height: 1.2em;
  margin: 0;
  color: #7b6038;
  font-size: 11px;
  line-height: 1.45;
}
.bug-status[data-state="error"] { color: #a6412d; }
.bug-status[data-state="ok"] { color: #3f6b4a; }
body.bug-open { overflow: hidden; }

@media (max-width: 520px) {
  .bug-modal { padding: 22px 18px; }
  .bug-evidence { grid-template-columns: minmax(0, 1fr); }
  .bug-shot { max-height: 180px; }
  .bug-actions .button { flex: 1 1 auto; }
}

/* A short landscape window (a phone held sideways, a small laptop) cannot fit
   the picture, the facts and a tall message box at once. Keep the title, the
   picture and the facts visible and let the message box be the part that
   scrolls. */
@media (max-height: 620px) and (min-width: 521px) {
  .bug-modal { padding: 20px 22px; }
  .bug-evidence { grid-template-columns: 108px minmax(0, 1fr); margin-top: 10px; }
  .bug-facts { gap: 4px; }
  .bug-facts div { padding-bottom: 3px; }
  .bug-message-label { margin-top: 10px; }
  .bug-message { min-height: 78px; }
  .bug-actions { margin-top: 10px; }
}

@media print {
  .bug-backdrop { display: none !important; }
}

@media (max-width: 520px) {
  .help-label { display: none; }
  .help-button { padding: 0 8px; min-height: 30px; }
  .help-modal { padding: 22px 18px; }
  .help-link-copy strong { font-size: 18px; }
  .help-link-mark { width: 30px; height: 30px; font-size: 13px; }
}

@media print {
  .help-button, .help-backdrop { display: none !important; }
}
