/* ── Fonts ────────────────────────────────────────────────── */
@font-face {
  font-family: "Wremena";
  src: url("/fonts/wremena/Wremena.woff2") format("woff2");
  font-weight: 400;
}
@font-face {
  font-family: "Wremena";
  src: url("/fonts/wremena/Wremena-Bold.woff2") format("woff2");
  font-weight: 700;
}
@font-face {
  font-family: "Basteleur";
  src: url("/fonts/basteleur/Basteleur-Bold.woff2") format("woff2");
  font-weight: 700;
}
@font-face {
  font-family: "Basteleur";
  src: url("/fonts/basteleur/Basteleur-Moonlight.woff2") format("woff2");
  font-weight: 400;
}
@font-face {
  font-family: "Gaeilge";
  src: url("/fonts/gaeilge/Gaeilge.woff2") format("woff2");
  font-weight: 400;
}
@font-face {
  font-family: "Distro";
  src: url("/fonts/distro/DISTROB_.woff") format("woff");
  font-weight: 700;
}
@font-face {
  font-family: "Gossip";
  src: url("/fonts/gossip/Gossip-MedSquare.woff2") format("woff2");
  font-weight: 400;
}

/* ── Reset & base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* ── Seasonal hue anchors (degrees, 0–360) ───────────────
     Change these to remap the entire palette for a season.   */
  --hue-spring: 95;   /* yellow-green */
  --hue-summer: 50;   /* golden */
  --hue-fall:   28;   /* warm orange-brown */
  --hue-winter: 210;  /* cool blue */

  /* ── Type framework ──────────────────────────────────────
     Swap these per-state to vary typography across seasons.  */
  --font-display:  "Gossip", monospace;
  --font-heading:  "Basteleur", "Wremena", sans-serif;
  --font-body:     "Wremena", system-ui, sans-serif;

  /* ── Sizing framework ────────────────────────────────────
     Adjust --size-scale per-state to vary the overall scale. */
  --size-scale: .9;
  --base-size:  calc(22px * var(--size-scale));

  /* ── Active state (driven by data-* attributes and JS) ───
     Season and rank are dials: --season-hue sets hue, --rank-sat
     scales saturation.  Day/night is not a dial but a switch
     between two palettes (ticket 082): the day palette below,
     and the night palette under [data-time="night"].  Weather
     is a dial on the day palette (ticket 083): --weather-sat,
     set by [data-sky]; at night a bright moon switches to the
     midnight palette instead ([data-moon="bright"]).        */
  --season-hue:      var(--hue-fall); /* overridden by [data-season] */
  --surface-hue:     var(--season-hue); /* the game's season, its one accent: [data-game-season] */
  --surface-sat:     18%;               /* a touch stronger in a game's season, to read as one */
  --rank-sat:        1;              /* 0.2–1; set inline by JS            */
  --weather-sat:     1;              /* < 1 under cloud, by [data-sky]     */

  /* ── Day palette ─────────────────────────────────────────
     Light on dark ink, the season's hue throughout.  To add a
     colour, add it here and to the night palette:
       hsl(<hue>, calc(--rank-sat * --weather-sat * <base-sat>%), <l>%) */
  --bark:    hsl(var(--season-hue), calc(var(--rank-sat) * var(--weather-sat) * 40%), 17%);
  --acorn:   hsl(var(--season-hue), calc(var(--rank-sat) * var(--weather-sat) * 40%), 39%);
  --leaf:    hsl(calc(var(--season-hue) + 116), calc(var(--rank-sat) * var(--weather-sat) * 26%), 38%);
  --cream:   hsl(var(--season-hue), calc(var(--rank-sat) * var(--weather-sat) * 55%), 89%);
  --sky:     hsl(calc(var(--season-hue) + 180), calc(var(--rank-sat) * var(--weather-sat) * 45%), 87%);
  --text:    hsl(var(--season-hue), calc(var(--rank-sat) * var(--weather-sat) * 50%), 7%);
  --muted:   hsl(var(--season-hue), calc(var(--rank-sat) * var(--weather-sat) * 18%), 40%);
  --border:  hsl(var(--season-hue), calc(var(--rank-sat) * var(--weather-sat) * 28%), 72%);
  --divider: hsl(var(--season-hue), calc(var(--rank-sat) * var(--weather-sat) * 22%), 87%);
  --surface: hsl(var(--surface-hue), calc(var(--rank-sat) * var(--weather-sat) * var(--surface-sat)), 97%);
  --on-accent: #fff;                 /* text on --acorn / --leaf fills    */

  /* ── Type scale — all relative to --base-size ────────── */
  --text-xs:   calc(var(--base-size) * 0.75);
  --text-sm:   calc(var(--base-size) * 0.875);
  --text-md:   calc(var(--base-size) * 1);
  --text-lg:   calc(var(--base-size) * 1.25);
  --text-xl:   calc(var(--base-size) * 1.6);

  /* every page's content column, site wide (lobby, settings, forum …) */
  --column: 42rem;

  /* ── Spacing scale ───────────────────────────────────── */
  --space-1: calc(var(--base-size) * 0.25);
  --space-2: calc(var(--base-size) * 0.5);
  --space-3: calc(var(--base-size) * 0.75);
  --space-4: calc(var(--base-size) * 1);
  --space-5: calc(var(--base-size) * 1.5);
  --space-6: calc(var(--base-size) * 2);
}

/* ── Season overrides ────────────────────────────────────────
   Each selector only needs to set --season-hue; the derived
   palette recalculates automatically.                        */
[data-season="spring"] { --season-hue: var(--hue-spring); }
[data-season="summer"] { --season-hue: var(--hue-summer); }
[data-season="fall"]   { --season-hue: var(--hue-fall); }
[data-season="winter"] { --season-hue: var(--hue-winter); }
/* SEASONS (ticket 113): the open game's season tints only the panels' background */
[data-game-season] { --surface-sat: 32%; }
[data-game-season="spring"] { --surface-hue: var(--hue-spring); }
[data-game-season="summer"] { --surface-hue: var(--hue-summer); }
[data-game-season="fall"]   { --surface-hue: var(--hue-fall); }
[data-game-season="winter"] { --surface-hue: var(--hue-winter); }

/* ── Weather dial (ticket 083) ───────────────────────────────
   The sky over your fix drains the day palette's saturation, the
   way the `overcast` and `stormy` basemaps drain natgeo's.  Starting
   values, to tune by eye against those maps.  The night palette
   doesn't use it: there the moon switches palettes instead.     */
[data-sky="cloudy"], [data-sky="rain"] { --weather-sat: 0.6; }
[data-sky="heavy"]  { --weather-sat: 0.4; }

/* ── Night palette (ticket 082) ──────────────────────────────
   Its own palette, not the day one darkened: pale ink on a dark
   ground, the same in every season.  Only the accents (acorn,
   leaf) keep the season's hue.  Roles stay the same as by day:
   --cream is the ground, --bark the strongest ink, so a --bark
   fill with --cream text inverts to pale.
   Colours are taken from the `night` basemap (ticket 084), so the
   frame and the map read as one: its charcoal land for the ground,
   its parchment labels for ink, its greys for panels and lines.
   Under a bright moon the midnight-blue palette below takes over.  */
[data-time="night"] {
  color-scheme: dark;  /* native controls (time picker icon, select arrows) draw light on the dark palette */
  --bark:    #e0d2ac;                                            /* > cityLabelText #d8c8a0   */
  --text:    #d8c8a0;                                            /* cityLabelText             */
  --muted:   #a09880;                                            /* neighbourhoodLabelText    */
  --cream:   #1a1c20;                                            /* background (land)         */
  --sky:     #162030;                                            /* water                     */
  --border:  #484440;                                            /* boundary                  */
  --divider: #2c2c32;                                            /* building ↔ outline        */
  --acorn:   hsl(var(--season-hue), calc(var(--rank-sat) * 50%), 58%);
  --leaf:    hsl(calc(var(--season-hue) + 116), calc(var(--rank-sat) * 28%), 52%);
  /* --surface in parts: the scoreboard rows (_rankBg) rebuild it with their own saturation */
  --surface-h: 225;
  --surface-s: 9%;
  --surface-l: 15%;                                              /* ≈ landUrban #22242a       */
  --surface: hsl(var(--surface-h), calc(var(--rank-sat) * var(--surface-s)), var(--surface-l));
  --on-accent: var(--cream);
}

/* ── Bright-moon night (ticket 083) ──────────────────────────
   A full or nearly full moon under a clear sky: the midnight-blue
   palette, paired with the `midnight` basemap built from these
   same tokens (ticket 084, basemaps/docs/midnight-profile-brief.md:
   change one, check the other).  Any other night is the charcoal
   palette above, with the `night` basemap.                     */
[data-time="night"][data-moon="bright"] {
  --night-hue: 226;                  /* midnight blue, every season        */
  --bark:    hsl(calc(var(--night-hue) - 4), calc(var(--rank-sat) * 45%), 88%);
  --acorn:   hsl(var(--season-hue), calc(var(--rank-sat) * 55%), 66%);
  --leaf:    hsl(calc(var(--season-hue) + 116), calc(var(--rank-sat) * 30%), 58%);
  --cream:   hsl(var(--night-hue), calc(var(--rank-sat) * 42%), 12%);
  --sky:     hsl(var(--night-hue), calc(var(--rank-sat) * 45%), 24%);
  --text:    hsl(calc(var(--night-hue) - 4), calc(var(--rank-sat) * 30%), 90%);
  --muted:   hsl(calc(var(--night-hue) - 2), calc(var(--rank-sat) * 16%), 64%);
  --border:  hsl(var(--night-hue), calc(var(--rank-sat) * 24%), 34%);
  --divider: hsl(var(--night-hue), calc(var(--rank-sat) * 28%), 23%);
  --surface-h: var(--night-hue);
  --surface-s: 36%;
  --surface-l: 17%;
}

html, body {
  height: 100%;
  width: 100%;
  overflow-x: hidden;
  font-family: var(--font-body);
  background: var(--cream);
  color: var(--text);
  font-size: var(--base-size);
  line-height: 1.5;
}

/* ── App shell ────────────────────────────────────────────── */
#app {
  display: grid;
  grid-template-rows: 1fr;
  height: 100%;
}

/* ── Typography ───────────────────────────────────────────── */
h1 { font-family: var(--font-heading); font-size: var(--text-xl); font-weight: 700; color: var(--bark); text-transform: uppercase; letter-spacing: 0.04em; }
h2 { font-family: var(--font-heading); font-size: var(--text-lg); font-weight: 700; color: var(--bark); text-transform: uppercase; letter-spacing: 0.04em; }
p  { color: var(--muted); }

/* ── Site header (js/header.js) ────────────────────────────
   "Quercus <word>" + the sun/moon, on every page but the map, the forum included */
.site-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  width: 100%; max-width: var(--column); margin: 0 auto var(--space-4);
}
/* the title's look, also worn by the lobby's Quercus Forum button; the header sets its size */
.site-title {
  font-family: var(--font-heading); font-weight: 700;
  font-variant: small-caps; text-transform: uppercase; line-height: 1;
  color: var(--bark); text-decoration: none;
}
.site-header .site-title { font-size: clamp(1.6rem, 9vw, 3.2rem); }
.site-title-word { color: var(--acorn); }
.site-header .sky-icon { flex: none; font-family: var(--font-heading); }
/* every page's column: the header's width, centred (border-box, so its padding comes on top) */
.screen:has(> .site-header) { width: 100%; max-width: calc(var(--column) + 2 * var(--space-3)); margin: 0 auto; }

/* ── Forms ────────────────────────────────────────────────── */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="datetime-local"],
input[type="time"],
input[type="number"] {
  display: block;
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: 1.5px solid var(--border);
  background: var(--surface);
  font-size: var(--text-md);
  color: var(--text);
  transition: border-color 0.15s;
}
input:focus { outline: none; border-color: var(--acorn); }

label { display: block; margin-bottom: var(--space-1); font-size: var(--text-md); color: var(--muted); }
.field { margin-bottom: var(--space-4); }

/* create form (tickets 059, 066): rules and length as cards, the timeline preview */
#create-form select {
  display: block;
  width: 100%;
  padding: var(--space-2);
  font-size: var(--text-md);
  border: 1.5px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  margin-bottom: var(--space-1);
}
.choice-group { border: none; padding: 0; margin-left: 0; margin-right: 0; }
.choice-group legend { color: var(--muted); font-size: var(--text-md); margin-bottom: var(--space-1); padding: 0; }
.choice {
  display: flex;
  gap: var(--space-2);
  align-items: flex-start;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: var(--space-2);
  margin-bottom: var(--space-1);
  color: var(--text);
  cursor: pointer;
}
.choice:has(input:checked) { border-color: var(--acorn); background: var(--cream); }
.choice input { width: auto; margin-top: 0.25rem; }
.choice span { display: grid; gap: 0.1rem; }
.inline-field { display: flex; align-items: center; gap: var(--space-2); margin-top: var(--space-1); }
.inline-field label { margin: 0; white-space: nowrap; }
.inline-field input { width: 6rem; }
.create-timeline { border: 1px solid var(--divider); border-radius: 6px; padding: var(--space-2); }
.create-subtitle { font-weight: 700; color: var(--bark); margin-bottom: var(--space-1); }
/* label and date each stay whole on one line; when both don't fit (a narrow phone, a large
   system font) the date drops below, right-aligned, instead of squeezing the label word by word */
.tl-row { display: flex; flex-wrap: wrap; justify-content: space-between; column-gap: var(--space-2); font-size: var(--text-sm); color: var(--text); }
.tl-row span { white-space: nowrap; }
.tl-row span:last-child { margin-left: auto; color: var(--muted); }
.tl-row.tl-later { opacity: 0.45; }
.create-warnings { min-height: 1.2em; font-size: var(--text-sm); color: var(--muted); }
.create-warnings p { margin: var(--space-1) 0 0; }

/* ── Buttons ──────────────────────────────────────────────── */
button {
  cursor: pointer;
  border: none;
  padding: var(--space-2) var(--space-4);
  font-family: "Distro", var(--font-heading);
  font-size: var(--text-md);
  font-weight: 600;
  transition: opacity 0.15s;
  border-radius: 4px;
}
button:active { opacity: 0.75; }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary   { background: var(--bark);  color: var(--cream); font-size: var(--text-lg); }
.btn-secondary { background: var(--acorn); color: var(--on-accent); }
.btn-ghost     { background: transparent; color: var(--bark); border: 1.5px solid var(--bark); }
/* a button that copies something (an invite link) goes nowhere: dashed, not solid */
.btn-ghost.copy-btn { border-style: dashed; }
.btn-danger    { background: #a8281c; color: #fff; }  /* can't be undone: Delete account */
.btn-full      { width: 100%; }

/* ── Card / panel ─────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  padding: var(--space-3);
  border-radius: 6px;
}
#gameover-modal h2 { font-family: "Distro", var(--font-heading); text-transform: none; letter-spacing: 0; }

/* ── Screen wrapper ───────────────────────────────────────── */
/* align-content:start keeps content anchored at top so nothing
   is clipped above the scroll origin on short viewports.      */
.screen {
  display: grid;
  align-content: start;
  padding: var(--space-3);
  overflow-y: auto;
}
.screen > .card { width: 100%; }

/* ── Map view ─────────────────────────────────────────────── */
#map-view {
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: 100svh;
  touch-action: pan-x pan-y;  /* no page pinch/double-tap zoom in the game (see _lockPageZoom) */
}
#map-wrap { position: relative; min-height: 0; } /* prevent grid blowout */
#map { position: absolute; inset: 0; }

/* ── Bottom bar ───────────────────────────────────────────── */

/* ── Notification / toast ─────────────────────────────────── */
#toast {
  position: fixed;
  top: var(--space-4);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bark);
  color: var(--cream);
  padding: var(--space-2) var(--space-4);
  font-family: "Distro", var(--font-heading);
  font-size: var(--text-lg);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
  text-align: center;
  overflow-wrap: anywhere;
  width: max-content;  /* centred via left:50%, so shrink-to-fit would cap it at half the screen */
  max-width: 90vw;
  z-index: 999;
}
#toast.show  { opacity: 1; }
#toast.error { background: #7a1a1a; }
#toast.good  { color: #b3cf8f; }  /* the map's ownership-dot green */
/* at night the toast is pale (--bark), so the green deepens and the red takes pale text */
[data-time="night"] #toast.good { color: #3d5a24; }
[data-time="night"] #toast.error, [data-time="night"] .notice.cheeks_full,
[data-time="night"] .notice:is(.spring, .summer, .fall, .winter, .grew_up) { color: var(--text); }
/* private notices (game view): toast-styled cards stacked under the toast. a touch elsewhere clears them */
#notice-stack {
  position: absolute;
  top: calc(var(--space-3) + 2.8rem);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  width: max-content;
  max-width: 90%;
  max-height: min(60%, 19.5rem);  /* a long stack scrolls, half a card peeking; the map below stays free to touch */
  overflow-y: auto;
  overscroll-behavior: contain;
  z-index: 999;
  pointer-events: none;
}
.notice {
  background: var(--bark);
  color: var(--cream);
  padding: var(--space-2) var(--space-4);
  font-family: "Distro", var(--font-heading);
  font-size: var(--text-lg);  /* = .sheet-verb */
  text-align: center;
  white-space: pre-line;  /* a message line may break: "…stash\n(Nut ×2)" */
  overflow-wrap: anywhere;
  pointer-events: auto;
  flex-shrink: 0;
  touch-action: pan-y;
  transition: opacity 0.25s;
}
.notice.gone { opacity: 0; }
#notice-stack.held { visibility: hidden; }  /* behind the quorum popup (_holdNotices) */
.handoff-qr svg { display: block; width: 10rem; height: 10rem; margin: var(--space-2) auto 0; }
.notice.cheeks_full { background: #7a1a1a; }  /* a refusal: the error toast's red */
/* SEASONS (ticket 113): each chapter's notice in its season's colour */
.notice.spring { background: #4f7a2a; }  /* fresh green */
.notice.summer { background: #8a6a12; }  /* warm gold */
.notice.fall   { background: #9a4a1c; }  /* rust */
.notice.winter { background: #3f6a88; }  /* cold blue */
.notice.grew_up { background: #4f7a2a; }  /* your planting took (ticket 118): spring's green */
/* in the game, the toast sits on the map, level with the compass */
#map-wrap #toast {
  position: absolute;
  top: calc(var(--space-3) + 1.4rem);
  transform: translate(-50%, -50%);
}


/* ── Top panel (popups, modals) ───────────────────────────── */
.top-panel {
  position: fixed;
  top: 4rem;
  left: 1rem;
  right: 1rem;
  z-index: 300;
  animation: panel-slide-in 0.25s ease forwards;
}
.top-panel.hidden { display: none !important; }
/* POPUPS flow out of the notices (Emory, 2026-11-05): one scale for every popup, the
   notices'. a heading is a notice line (Distro, text-lg, no caps), centred like one; the
   text and buttons under it are text-md. a popup's tone shows in colour, never in size.
   the dev panel is a form, not a popup */
.top-panel:not(#dev-panel) { text-align: center; }
.top-panel h2 { font-family: "Distro", var(--font-heading); font-size: var(--text-lg); text-transform: none; letter-spacing: 0; }
.top-panel:not(#dev-panel) p, .top-panel:not(#dev-panel) button { font-size: var(--text-md); }
@keyframes panel-slide-in {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Badge ────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  background: var(--leaf);
  color: var(--on-accent);
  border: 1px solid var(--leaf);
  padding: 0 var(--space-2);
  font-size: var(--text-xs);
  font-weight: 600;
}

/* ── Auth card interior grid ──────────────────────────────── */
.auth-card {
  display: grid;
  gap: var(--space-4);
}
.auth-join-code { display: grid; gap: var(--space-2); }
.auth-login     { display: grid; gap: var(--space-3); }
.auth-register  { display: grid; gap: var(--space-3); }
.auth-step.hidden { display: none; }
.auth-checkbox  { display: flex; align-items: center; gap: var(--space-2); cursor: pointer;
                  font-size: var(--text-sm); color: var(--bark); margin: var(--space-2) 0; }
/* flex: none — a long label must never squeeze the box smaller than its neighbours */
.auth-checkbox input[type="checkbox"] { flex: none; width: 18px; height: 18px; accent-color: var(--bark); }
.btn-sm         { font-size: var(--text-sm); padding: var(--space-1) var(--space-2); }
.settings-row   { display: flex; justify-content: space-between; align-items: center; gap: var(--space-3);
                  padding: var(--space-3) 0; border-bottom: 1px solid var(--divider); }
.settings-row:last-child { border-bottom: none; }
/* Settings page: one heading per section, each a row of its own */
.settings-heading { font-size: var(--text-md); margin: var(--space-4) 0 0; text-transform: none; letter-spacing: 0.02em; color: var(--acorn); }  /* as the lobby's game names */
.settings-heading:first-child { margin-top: var(--space-2); }
.settings-heading + .settings-row { padding-top: var(--space-2); }
.settings-row--bare { border-bottom: none; padding: var(--space-1) 0; }
/* a slider row: its label, then the slider taking the rest. indented to the checkbox labels'
   text (box + gap), as the setting it tunes sits just above */
.settings-slider { width: 100%; display: grid; grid-template-columns: auto 1fr; align-items: center; gap: var(--space-3);
                   padding-left: calc(18px + var(--space-2)); font-size: var(--text-sm); color: var(--bark); }
.settings-slider input[type="range"] { width: 100%; margin: 0; accent-color: var(--bark); }
.settings-slider input[type="range"]:disabled { opacity: 0.4; }
.settings-label { font-size: var(--text-sm); color: var(--bark); opacity: 0.7; }
.settings-value { font-weight: 600; }
/* value beside its label, not under it: either wraps rather than widen the panel */
.settings-row > .settings-value { min-width: 0; text-align: right; font-size: var(--text-sm); }

/* Passphrase input with overlaid toggle button */
.passphrase-wrap {
  position: relative;
}
.passphrase-wrap input {
  padding-right: var(--space-6);
}
.btn-icon {
  position: absolute;
  right: var(--space-2);
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  padding: 0;
  font-size: var(--text-md);
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
}

/* ── Lobby card interior grid ─────────────────────────────── */
.lobby-card {
  /* a column in source order; hidden rows (Create game for non-admins) leave no gap */
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}
/* the lobby's headings (greeting, game names) sit under its title: the
   title's colour and letter-spacing, at body size, so the title stays the biggest thing */
.lobby-card .lobby-greeting, .score-row--game .game-name {
  font-family: var(--font-heading); font-weight: 700; font-size: var(--text-md);
  color: var(--acorn); letter-spacing: 0.02em; text-decoration: none;
}
.lobby-card .lobby-greeting { text-transform: none; }
/* under the lobby card: server facts and the version, small and quiet */
.site-footer { display: grid; gap: var(--space-1); margin-top: var(--space-4); text-align: center; font-size: var(--text-xs); }
.site-footer p { color: var(--muted); }
.site-footer a { color: inherit; }
.site-footer-version { opacity: 0.6; }
/* the Quercus Forum button: a link dressed as the lobby's buttons, the latest post
   previewed inside it (the whole button goes to /forum/) */
a.lobby-forum {
  display: grid; gap: var(--space-2); justify-items: center; text-decoration: none;
  padding: var(--space-2) var(--space-4); border-radius: 4px;
}
a.lobby-forum .site-title { font-size: var(--text-lg); }
a.lobby-forum:active { opacity: 0.75; }
.lobby-forum-post { display: flex; gap: var(--space-3); align-items: center; width: 100%; text-align: left;
  font-family: var(--font-body); font-weight: 400; color: var(--text);
  border: 1.5px solid var(--border); border-radius: 6px; padding: var(--space-2); background: var(--cream); }
.lobby-forum-post[hidden] { display: none; }
.lobby-forum-post img { width: 3rem; height: 3rem; object-fit: cover; object-position: top; border-radius: 4px; background: #fff; flex: none; }
.lobby-forum-post span { display: grid; }
.lobby-forum-post small { color: var(--muted); font-size: var(--text-xs); }
hr                                   { border: none; border-top: 1px solid var(--divider); }
.lobby-card > .lobby-actions         { display: grid; gap: var(--space-3); }

/* ── Clickable join code ──────────────────────────────────── */
code.copy-code-btn {
  cursor: pointer;
  border-bottom: 1px dashed var(--muted);
  color: var(--acorn);
}
code.copy-code-btn:hover { color: var(--bark); border-bottom-color: var(--bark); }

/* ── Scores panel ─────────────────────────────────────────── */
/* Inside #map-wrap: covers the map only, so the top bar stays visible (and tappable to close). */
#scores-panel {
  position: absolute;
  top: 0.3rem;
  left: 0.3rem;
  right: 0.3rem;
  bottom: calc(0.3rem + env(safe-area-inset-bottom, 0px));
  z-index: 100;
  display: grid;
  grid-template-rows: auto auto 1fr;
  grid-template-columns: minmax(0, 1fr);
  overflow: hidden;
}
#scores-panel > .scores-tab-content {
  grid-row: 3;
  grid-column: 1;
}
.scores-header {
  display: grid;
  grid-template-columns: 1fr;
  align-items: baseline;
}

.scores-body {
  overflow-y: auto;
  display: grid;
  align-content: start;
  gap: var(--space-2);
}

.scores-awards {
  padding: var(--space-3) 0;
  text-align: center;
}

/* end-of-game roster (ticket 049): a slideshow, one title per slide (its name, who holds it,
   the count), arrows either side. the slides share a height */
.award-show { display: flex; align-items: center; margin-inline: calc(-1 * var(--space-2)); }  /* out to the panel's edge: the room goes to the title */
.award-arrow {
  flex: none;
  width: 1.3rem;
  padding: var(--space-3) 0;
  background: none;
  border: none;
  color: var(--bark);
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
}
.award-slides {
  flex: 1;
  min-width: 0;
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  cursor: grab;
  user-select: none;
}
.award-slides.dragging { scroll-snap-type: none; cursor: grabbing; }
.award-slides::-webkit-scrollbar { display: none; }
.award {
  flex: 0 0 100%;
  scroll-snap-align: center;
  display: grid;
  align-content: center;
  padding: calc(var(--space-4) * 2) 0;
}
.award-title { margin-bottom: var(--space-2); }
.award-count { margin-top: var(--space-2); }

/* stats page (ticket 049): trophy case, lifetime totals, past games */
.trophy-case { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-2); }
.trophy {
  display: inline-block;
  white-space: nowrap;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.15rem 0.6rem;
  background: var(--cream);
  color: var(--text);
}
.stats-totals {
  display: grid;
  gap: 0.3rem 1rem;
  margin-top: var(--space-2);
}
.past-game { padding: var(--space-2) 0; border-bottom: 1px solid var(--divider); }
.past-game:last-child { border-bottom: none; }
.past-game-head { display: flex; justify-content: space-between; gap: var(--space-2); align-items: baseline; color: var(--text); }
.past-game-head > span:last-child { white-space: nowrap; }
.past-game-sub { display: flex; justify-content: space-between; gap: var(--space-2); align-items: center; }


/* Ranked score rows — background set inline by JS; padding added here */
.score-row.score-row--ranked {
  padding-left: var(--space-3);
  padding-right: var(--space-3);
}

/* Everyone but you gets a full outline, so your own (unruled) row visibly
   shares the interface's rank colour. :last-child is listed to beat the base
   .score-row:last-child reset; stacked neighbours share one line. */
.score-row.score-row--other,
.score-row.score-row--other:last-child { border: 1px solid var(--divider); }
.score-row--other + .score-row.score-row--other { border-top: none; }
.score-row.score-row--ranked:not(.score-row--other) { border-bottom: none; }

/* a chevron under the list: reveals the players gone 7+ days, then it's gone */
.scores-more {
  display: flex;
  justify-content: center;
  width: 100%;
  padding: var(--space-3) 0;
  background: none;
  border: none;
  box-shadow: none;
  cursor: pointer;
}
.scores-more::before {
  content: "";
  width: 0.5rem;
  height: 0.5rem;
  border: solid var(--muted);
  border-width: 0 1px 1px 0;
  transform: rotate(45deg);
}

/* the You tab's folds (game details, host options): dropdowns (.chevron-btn), centred, in the
   buttons' own colour and size (no border: that's what says it folds rather than goes somewhere) */
.fold-toggle {
  display: flex; justify-content: center; align-items: center; width: 100%;
  padding: var(--space-5) 0;
  color: var(--bark);
}
.game-details { margin-bottom: var(--space-3); }  /* the You tab's details, open: a gap before the buttons */

/* Player name: truncate with ellipsis; min-width:0 lets 1fr actually shrink */
.score-row .player-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* quorum companions (ticket 128): one 🧡 per quorum you shared with that player, left of
   the score; many wrap onto more lines (right-aligned) rather than squeezing the name out */
.score-row .score-right { display: flex; align-items: center; justify-content: flex-end; gap: var(--space-2); }
.score-row .companions { max-width: 9rem; text-align: right; line-height: 1.2; overflow-wrap: anywhere; }

/* ── Activity log ─────────────────────────────────────────── */
.activity-log {
  display: grid;
  gap: var(--space-1);
  font-size: var(--text-xs);
}
.activity-log h2 { margin: 0; }
.activity-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: var(--space-2);
}

/* ── Scores panel tabs ─────────────────────────────────────── */
.scores-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-bottom: 1px solid var(--divider);
}
.scores-tab {
  background: none;
  border: none;
  padding: var(--space-2);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
}
.scores-tab.active {
  color: var(--bark);
  border-bottom-color: var(--bark);
}
.scores-tab-content {
  overflow-y: auto;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);  /* the trophy slides scroll inside, never widen the panel */
  align-content: start;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-2);
}
.scores-tab-content[data-tab="activity"] {
  display: grid;
  grid-template-rows: 1fr auto;
}
.activity-feed {
  overflow-y: auto;
  min-height: 0;
  display: grid;
  gap: var(--space-1);
  font-size: var(--text-xs);
  align-content: start;
}
.chat-input-bar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--space-1);
  padding: var(--space-1) 0;
  border-top: 1px solid var(--divider);
}
.chat-input-bar input {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  padding: var(--space-1) var(--space-2);
  border: 1px solid var(--border, var(--divider));
  border-radius: 4px;
  background: var(--surface);
  color: var(--text);
  min-width: 0;
}
.activity-chat {
  color: #c9b800;
}
[data-time="day"] .activity-chat {
  color: #c0392b;
}
.activity-chat strong {
  font-weight: 700;
  margin-right: var(--space-1);
}
/* a message from before you joined: shown as sent, never read */
.activity-chat-hidden { color: var(--muted); font-style: italic; }
[data-time="day"] .activity-chat-hidden { color: var(--muted); }

/* ── Rules page ───────────────────────────────────────────── */
.rules-body { display: grid; gap: var(--space-2); }
.rules-body h2 { margin-top: var(--space-2); }
.rules-body ul { padding-left: 1.2rem; }
.rules-toc { margin-block: var(--space-3); }
.rules-toc ol { padding-left: 1.2rem; display: grid; gap: var(--space-1); }
.rules-toc a { color: var(--bark); }
.rules-body h2 { scroll-margin-top: var(--space-3); }

/* ── Scoreboard row ───────────────────────────────────────── */
.score-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: var(--space-2) var(--space-3);
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--divider);
}
.score-row:last-child { border-bottom: none; }
.host-player { display: flex; flex-direction: column; min-width: 0; }
.host-warned:empty { display: none; }
.host-player-btns { display: flex; gap: var(--space-2); }
.score-row.gps-log { grid-template-columns: 1fr; gap: 0; }
.gps-key summary { display: flex; align-items: center; justify-content: space-between; padding: var(--space-2) 0; color: var(--muted); font-size: var(--text-sm); cursor: pointer; list-style: none; }
.gps-key details p { margin: 0 0 var(--space-2); }
/* the lobby's game list keeps its last line too, closing it off from the buttons below */
.lobby-active-games .score-row:last-child { border-bottom: 1px solid var(--divider); }

/* ── Game row (active-games-list) — responsive grid ─────── */
.score-row--game {
  grid-template-columns: 1fr auto auto;
  grid-template-areas:
    "name  enter enter"
    "meta  code  code";
}
.score-row--game .enter-game-btn { grid-area: enter; justify-self: end; }
.score-row--game .game-name  { grid-area: name; }
.score-row--game .game-meta  { grid-area: meta; font-size: var(--text-md); color: var(--muted); white-space: nowrap; }
.score-row--game .game-code  { grid-area: code; font-size: var(--text-sm); white-space: nowrap; }
/* Enter and Copy Invite Link at the size of every other button (btn-primary's own is larger) */
.score-row--game .enter-game-btn, .score-row--game .copy-invite-btn { font-size: var(--text-md); }
/* Create game styled like Enter: btn-primary at the size of every other button */
.lobby-create { font-size: var(--text-md); }
/* when the game ends, on the title line in the body's muted text */
.score-row--game .game-when { font-family: var(--font-body); font-weight: 400; color: var(--muted); letter-spacing: 0; white-space: nowrap; }
/* an open game's row: its invite button sits beside Enter, sized like it */
.score-row--game:has(.copy-invite-btn) {
  grid-template-areas:
    "name    enter   code"
    "friends friends friends"
    "panel   panel   panel";
}
.score-row--game .copy-invite-btn { grid-area: code; }
.score-row--game .invite-friends-btn { grid-area: friends; justify-self: end; font-size: var(--text-md); }
/* every dropdown, lobby and game alike: a plain label (no outline, whatever button class it
   wears) with its chevron after it, flipping when open. buttons: .chevron-btn + aria-expanded;
   <details>: the summary */
.chevron-btn, .chevron-btn.btn-ghost { border-color: transparent; background: none; box-shadow: none; }
.chevron-btn::after, summary::after { content: ""; display: inline-block; width: 0.45em; height: 0.45em; margin-left: 0.5em;
  border: solid currentColor; border-width: 0 2px 2px 0; transform: translateY(-0.15em) rotate(45deg); transition: transform 0.15s; }
.chevron-btn[aria-expanded="true"]::after, details[open] > summary::after { transform: translateY(0.1em) rotate(-135deg); }
summary { list-style: none; cursor: pointer; }
summary::-webkit-details-marker { display: none; }
/* the squirrels you've played with, opened under the row; the list scrolls, the row doesn't grow past it */
.friends-panel { grid-area: panel; min-width: 0; }
.friends-panel.hidden { display: none; }
.friends-panel .friends-search { width: 100%; margin-bottom: 0.5rem; }
.friends-list { max-height: 15rem; overflow-y: auto; }
.friend-row { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; padding: 0.3rem 0; }
.friend-row[hidden] { display: none; }
.friend-row .friend-name { min-width: 0; overflow-wrap: anywhere; }
.friend-row button { font-size: var(--text-md); flex: none; }
.friend-row .friend-status { color: var(--muted); font-size: var(--text-md); flex: none; }

/* Invite whose join is waiting on a GPS fix: the why and the last error wrap, full width */
.score-row--pending {
  grid-template-areas:
    "name  enter enter"
    "meta  meta  meta"
    "code  code  code";
}
.score-row--pending .game-meta,
.score-row--pending .game-code { white-space: normal; }
.score-row--pending .pending-error:empty { display: none; }

/* Android in-app browser (WebView): no GPS there, so send them to a real browser */
.inapp-box {
  grid-column: 1 / -1;
  margin-bottom: 1rem;
  padding: 0.75rem;
  border: 1.5px solid var(--acorn);
  border-radius: 6px;
  font-size: var(--text-md);
  white-space: normal;
}
.inapp-box p { margin: 0.4rem 0; }
.inapp-actions { display: flex; flex-direction: column; gap: 0.5rem; margin: 0.5rem 0; }
.inapp-actions button { width: 100%; }
.score-row--pending .inapp-box { margin: 0.5rem 0 0; }

@media (max-width: 480px) {
  .score-row--game {
    grid-template-columns: 1fr;
    grid-template-areas:
      "name"
      "enter"
      "meta"
      "code";
  }
  .score-row--game:has(.copy-invite-btn) { grid-template-areas: "name" "enter" "code" "friends" "panel"; }
  .score-row--game .enter-game-btn, .score-row--game .copy-invite-btn, .score-row--game .invite-friends-btn { width: 100%; }
}

/* ── Utility ──────────────────────────────────────────────── */
.mt-1 { margin-top: var(--space-2); }
.mt-2 { margin-top: var(--space-4); }
.mt-3 { margin-top: var(--space-5); }
.text-center { text-align: center; }
.text-muted { color: var(--muted); font-size: var(--text-sm); }
.gap { gap: var(--space-3); }
.hidden { display: none !important; }

/* ── v2 game view ─────────────────────────────────────────── */
/* bottom-chrome is zero-height at the screen bottom; position:relative so the tray floats above it (bottom:100%)
   without ever entering normal flow and pushing the map up. */
#bottom-chrome { position: relative; }

/* The game view runs a smaller scale than the menus: on a phone the bars, tray and
   sheet all share the screen with the map, and the map should win. The derived
   scales resolve at :root, so they're re-declared to follow the new --base-size. */
/* the You tab's Territory slots (ticket 104) are tray slots, so at the map's scale too */
#map-view, #territory-slots {
  --base-size: calc(15px * var(--size-scale));
  --text-xs: calc(var(--base-size) * 0.75);
  --text-sm: calc(var(--base-size) * 0.875);
  --text-md: var(--base-size);
  --text-lg: calc(var(--base-size) * 1.25);
  --text-xl: calc(var(--base-size) * 1.6);
  --space-1: calc(var(--base-size) * 0.25);
  --space-2: calc(var(--base-size) * 0.5);
  --space-3: calc(var(--base-size) * 0.75);
  --space-4: var(--base-size);
  font-size: var(--base-size);
}
/* The scores panel is a menu that happens to live in #map-wrap: back to the menu scale. */
#scores-panel {
  --base-size: calc(22px * var(--size-scale));
  --text-xs: calc(var(--base-size) * 0.75);
  --text-sm: calc(var(--base-size) * 0.875);
  --text-md: var(--base-size);
  --text-lg: calc(var(--base-size) * 1.25);
  --text-xl: calc(var(--base-size) * 1.6);
  --space-1: calc(var(--base-size) * 0.25);
  --space-2: calc(var(--base-size) * 0.5);
  --space-3: calc(var(--base-size) * 0.75);
  --space-4: var(--base-size);
  font-size: var(--base-size);
}

/* Top bar: day count · pediment · sky. In the grid (row 1), not floating.
   Tapping it toggles scores/activity. */
.top-bar {
  position: relative;  /* for the ruler */
  cursor: pointer;
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: start;
  gap: var(--space-2);
  padding: calc(var(--space-2) + env(safe-area-inset-top, 0px)) var(--space-3) var(--space-2);
  background: var(--surface);
  border-bottom: 1.5px solid var(--border);
  color: var(--bark);
  font-family: var(--font-heading);
}
/* the ruler (_syncRuler): ticks rising from the bar's bottom border, one every --tick px measured
   from the right edge, in the compass needle tail's faded brown. the step's length sits on the
   line at the far right, the same height as the ticks. the ticks fade fast from halfway and are gone by
   two thirds across: the step is only true near where it's measured. the left third is the
   next turn's countdown (.top-turn) */
.ruler {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--text-xs);
  pointer-events: none;
  background: linear-gradient(to left, var(--border) 1.5px, transparent 1.5px) right bottom / var(--tick, 50px) 66.7% repeat-x;
  -webkit-mask-image: linear-gradient(to left, #000 50%, rgb(0 0 0 / 0.3) 57%, transparent 66.7%);
  mask-image: linear-gradient(to left, #000 50%, rgb(0 0 0 / 0.3) 57%, transparent 66.7%);
  transition: opacity 0.3s;
}
.ruler.tilted { opacity: 0; }
/* the day count sits low in its cell, its countdown on the ruler's line (into the bar's bottom padding) */
.top-day { align-self: end; margin-bottom: calc(-1 * var(--space-2)); position: relative; z-index: 1; }
.top-turn {
  font: var(--text-sm) var(--font-body);
  line-height: 1;
  color: var(--muted);
  white-space: nowrap;
}
.ruler-label {
  position: absolute;
  right: 0;
  bottom: 0;
  padding: 0 var(--space-3) 0 var(--space-1);
  background: var(--surface);  /* the ticks stop at the number */
  font: var(--text-xs) var(--font-body);
  line-height: 1;
  color: var(--muted);
}
.top-day, .top-sky { display: grid; gap: 1px; min-width: 0; }
.top-sky { justify-items: end; text-align: right; }
/* SEASONS (ticket 113): the season's icon in the room the big turn number leaves above the "/ 60",
   its top on the number's, air above the slash, centred over it (the season follows the turn) */
.day-den { display: inline-block; margin-left: 0.25em; }  /* the " / 60" space, lost inside an inline-block */
.top-label { font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.top-day-count { font-size: var(--text-sm); color: var(--muted); white-space: nowrap; }
.top-day-count strong { font-size: calc(var(--text-xl) * 1.25); line-height: 1; color: var(--bark); }
.sky-icon { font-size: calc(var(--base-size) * 2.5); line-height: 1; color: #e2a51c;
            position: relative; display: inline-block; }
.sky-icon.night { color: #fff; }
/* the moon in its phase (theme.js): the dark disc a step lighter than its background, the lit part pure white */
.sky-icon .moon, .sky-icon .sun { display: block; width: 0.9em; height: 0.9em; margin: 0.05em; }
.sky-icon .sun { fill: currentColor; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.sky-icon .sun circle { stroke: none; }
/* the dark side: a step lighter than what's behind it, wherever the moon sits. in the lobby
   (on the page) that's the bar's colour; on the top bar (already --surface) the bar lifted by
   about the same step (page → bar is 3.5–5% lightness at night) */
.sky-icon .moon-dark { fill: var(--surface); }
.top-sky .sky-icon .moon-dark {
  fill: hsl(var(--surface-h), calc(var(--rank-sat) * var(--surface-s)), calc(var(--surface-l) + 4%)); }
.sky-icon .moon-lit { fill: currentColor; }
/* weather (ticket 083): a cloud over the lower right of the sun or moon, darker when heavy;
   its bottom on the disc's (0.05em margin + 2/24 of 0.9em), so it never hangs below the icon */
.sky-icon .cloud { position: absolute; right: -0.12em; bottom: 0.11em; width: 0.68em; height: auto;
                   fill: #eef1f4; stroke: #8f99a3; }
/* a hairline as fine as the thinnest moon sliver, the same on either cloud size: in the icon's
   em (not the cloud's viewBox), so it only scales with the icon */
.sky-icon .cloud path { vector-effect: non-scaling-stroke; stroke-width: 0.02em; }
.sky-icon.heavy .cloud { fill: #8f99a3; stroke: #59626b; }
/* rain and heavy: the same cloud, its streaks below it where its bottom would be (taller box, same width) */
.sky-icon .cloud.rain line { vector-effect: non-scaling-stroke; stroke-width: 0.075em; stroke-linecap: round;
                             stroke: #5f88aa; }
.sky-icon.night .cloud.rain line { stroke: var(--muted); }
/* heavy: bigger, pouring (four streaks), with a second cloud behind the first, up and to its
   left, shrouding the disc: raised with the front cloud's streaks, so the two still read as two */
.sky-icon.heavy .cloud { width: 0.8em; }
.sky-icon.heavy .cloud-back { right: 0.22em; bottom: 0.55em; width: 0.72em; }
/* two clouds (overcast, getClouds), heavy aside: the front one a little bigger and a second
   behind it, up and to its left, shrouding the disc (one small cloud barely hides the sun).
   over rain the second rides higher, with the front cloud lifted by its streaks */
.sky-icon.two:not(.heavy) .cloud:not(.rain):not(.cloud-back) { width: 0.74em; }
.sky-icon.two:not(.heavy) .cloud-back { right: 0.24em; bottom: 0.36em; width: 0.66em; }
.sky-icon.two:not(.heavy) .cloud.rain { width: 0.74em; }
.sky-icon.two:not(.heavy):has(.rain) .cloud-back { right: 0.24em; bottom: 0.55em; width: 0.66em; }
.sky-icon.night .cloud { fill: var(--divider); stroke: var(--muted); }
.sky-icon.night.heavy .cloud { fill: var(--border); }
/* the pediment is its own layer, centred on the bar behind the day count and the sky: it can
   be big without crowding them, its leaf tips passing behind them or a little past the bar */
.pediment {
  position: absolute; z-index: 0; pointer-events: none;
  top: calc(var(--space-2) + env(safe-area-inset-top, 0px)); left: 50%; transform: translateX(-50%);
  width: min(60vw, calc(var(--base-size) * 17.4));  /* a phone's size (≈ 60vw at 390px), capped there on tablets */
}
.top-sky { position: relative; z-index: 1; }
/* the sun/moon (and its cloud) centred between the bar's top edge and the ruler's top: the cell
   stretches past the bar's top padding to the edge and stops a ruler's height above the bottom */
.top-sky { align-self: stretch; align-content: center;
           margin: calc(-1 * var(--space-2)) 0 calc(var(--text-xs) - var(--space-2)); }
.pediment-svg { display: block; width: 100%; height: auto; overflow: visible; }
.pediment-leaves path { fill: var(--leaf); stroke: var(--bark); stroke-width: 0.6; stroke-linejoin: round; }
/* night: the acorn goes dark with the leaves, so the whole pediment is one silhouette against the sky */
[data-time="night"] .pediment-svg image { filter: brightness(0); }
[data-time="night"] .pediment-leaves path { fill: #000; stroke: #000; }
[data-time="night"] .pediment-leaves line { stroke: #000; }
.pediment-leaves line { stroke: var(--bark); stroke-width: 0.5; }

/* Landscape screens (laptops, landscape phones): everything in the top/bottom bars
   scales with viewport height, so the bars keep a roughly constant share of it and
   the map keeps the rest. Upright phones are untouched. */
@media (min-aspect-ratio: 1/1) {
  /* the derived scales resolve at :root, so they must be re-declared here to follow --base-size */
  .top-bar {
    --base-size: clamp(12px, 2.3vh, calc(22px * var(--size-scale)));
    --text-xs: calc(var(--base-size) * 0.75);
    --text-sm: calc(var(--base-size) * 0.875);
    --text-md: var(--base-size);
    --text-lg: calc(var(--base-size) * 1.25);
    --text-xl: calc(var(--base-size) * 1.6);
    --space-1: calc(var(--base-size) * 0.25);
    --space-2: calc(var(--base-size) * 0.5);
    --space-3: calc(var(--base-size) * 0.75);
    --space-4: var(--base-size);
  }
  .pediment { width: calc(var(--base-size) * 10.8); }
}

/* Wide or short screens (laptops, landscape phones): the tray is capped and centred
   instead of stretching edge to edge. Top/bottom bars keep the phone layout.
   The short-screen half needs some width too: an upright phone with its keyboard up
   is short, and must not narrow the scores panel under the chirp box. */
@media (min-width: 700px), (max-height: 560px) and (min-width: 560px) {
  .inventory-tray, .item-sheet, #scores-panel { width: min(34rem, calc(100% - 24px)); margin-inline: auto; }
}

/* Compass: needle counter-rotates with the map bearing; tap to face north */
.compass, .locate, .map-view {
  position: absolute;
  z-index: 40;
  width: 2.8rem;
  height: 2.8rem;
  padding: 0;
  border-radius: 50%;
  background: var(--surface);
  border: 1.5px solid var(--border);  /* same outline as .card (the scores panel) */
  display: grid;
  place-items: center;
}
.compass { top: var(--space-3); left: var(--space-3); }
/* 🗺️ map view (ticket 111): under the compass, one tap per view */
.map-view { top: calc(var(--space-3) + 2.8rem + var(--space-2)); left: var(--space-3); font-size: var(--text-lg); }
/* Nudges (🔔 notifications, ❗ no recovery set): top right, opposite the compass,
   until acted on or ignored */
.nudges {
  position: absolute;
  z-index: 40;
  top: var(--space-3);
  right: var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.nudge {
  width: 2.8rem;
  height: 2.8rem;
  padding: 0;
  border-radius: 50%;
  background: var(--surface);
  border: 1.5px solid var(--border);
  font-size: var(--text-lg);
  display: grid;
  place-items: center;
}
.nudge.hidden { display: none; }
/* Drop/bury placement: waits top-centre, clear of the compass */
.place-hint {
  position: absolute;
  z-index: 45;
  top: var(--space-3);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-1) var(--space-1) var(--space-4);
  background: var(--bark);
  color: var(--cream);
  font-family: "Distro", var(--font-heading);
  font-size: var(--text-lg);  /* the toasts' size ("Buried", "Tasty! +1"): one scale for map messages */
  white-space: nowrap;
}
.place-hint.hidden { display: none; }
.place-hint .btn-ghost { color: var(--cream); }
/* its cancel: a plain ✕ at the hint's own size, no outline */
.place-hint .place-cancel { border-color: transparent; font-size: inherit; line-height: 1; padding: var(--space-1) var(--space-2); }
/* Locate: bottom-right of the map; while the cheeks tray is open it rides on top of it
   (--tray-h: the tray's height, kept by game.js), so it never hides under the tray */
.locate {
  bottom: calc(var(--space-3) + max(var(--tray-h, 0px) + var(--nest-h, 0px), env(safe-area-inset-bottom, 0px)));
  right: calc(12px + var(--nest-w) / 2 - 1.4rem);  /* phones: the right-hand column (see .nest-tab) */
  transition: bottom 0.05s ease-out;  /* snappy: it travels the whole tray height, the tray only 15% */
  color: var(--bark);
}
/* the ⌖, drawn rather than a font glyph, so its lines are the same weight on every system */
/* wide or short screens: the tray is centred, away from the edge, so locate keeps the corner */
@media (min-width: 700px), (max-height: 560px) { .locate { right: var(--space-3); } }
.locate svg { width: 1.28rem; height: 1.28rem; fill: none; stroke: currentColor; stroke-width: 1.4; }
.compass-needle {
  width: 0.5rem;
  height: 2rem;
  background: linear-gradient(var(--bark) 50%, var(--border) 50%);
  clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
}

/* Cheeks tray — always absolute (see memory: never normal flow) */
.inventory-tray {
  position: absolute;
  bottom: 100%;
  left: 12px;
  right: 12px;
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-bottom: none;
  border-radius: 14px 14px 0 0;
  padding: var(--space-2) var(--space-3) calc(var(--space-2) + env(safe-area-inset-bottom, 0px));
  max-height: 33svh;  /* _lockHeight caps it at a third of #map-wrap */
  overflow-y: auto;  /* the tray scrolls as a whole (a cheek pick on top can push it past the cap) */
  animation: tray-up 0.2s ease forwards;
}
@keyframes tray-up { from { transform: translateY(15%); opacity: 0; } to { transform: none; opacity: 1; } }
.inventory-tray.hidden { display: none !important; }
.tray-header, .sheet-header { display: flex; justify-content: space-between; align-items: center; }
/* Share location (ticket 026): a small eye toggle (closed / open) opposite "Cheeks", a
   plain outline icon; while sharing, white on a round share-radar-blue button (SHARE_BLUE in game.js).
   Sized to the header text so the row doesn't grow; the header keeps that height whether it
   shows or not (games with sharing off) */
.tray-header { min-height: 1.2rem; }
/* the slots' label (Cheeks, Hollow…) centred; the eye keeps the right end */
.tray-header { display: grid; grid-template-columns: 1fr auto 1fr; }
.tray-header > :first-child { grid-column: 2; }
.tray-header > .tray-head-end { grid-column: 3; justify-self: end; display: flex; align-items: center; gap: var(--space-2); }
/* the right-hand column: the Nest tab (fixed --nest-w, flush with the tray's right edge), the
   share eye under its middle, and on phones the locate button over it. eye: tray border +
   padding + its own half-width (0.6rem) short of the tab's middle */
#map-view { --nest-w: 3.8rem; }
.tray-head-end > .share-pin { margin-right: calc(var(--nest-w) / 2 - 1.5px - var(--space-3) - 0.6rem); }
.share-pin {
  width: 1.2rem; height: 1.2rem; padding: 0;
  display: grid; place-items: center;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--bark);
}
.share-pin svg { width: 0.95rem; height: 0.95rem; fill: none; stroke: currentColor;
                 stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.share-pin .eye-open, .share-pin.on .eye-closed { display: none; }
.share-pin.on .eye-open { display: block; }
.share-pin.hidden { display: none; }
.share-pin.on { background: #3a8ee6; color: #fff; }
/* claim and Nest/Leave share the header row, beside the name */
.sheet-head-verbs { display: flex; gap: var(--space-2); flex-shrink: 0; }
/* no claim button: the spacer keeps the header's height but not its width, so a long name
   ("Nugget the Squirrel") runs on to the edge instead of wrapping early */
.sheet-head-verbs > .verb-spacer { width: 0; padding-inline: 0; border-inline-width: 0; overflow: hidden; white-space: nowrap; }
#tray-header-text, .tray-header-text {
  font-family: var(--font-heading);
  font-size: var(--text-xs);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}
.tray-close-btn {
  background: transparent;
  border: none;
  font-family: var(--font-heading);
  font-size: var(--text-xs);
  text-transform: uppercase;
  color: var(--muted);
  padding: 0;
}
/* Slots fill rows of 4, as many rows as capacity needs (squirrels grow more slots).
   in a container's sheet the grid scrolls; in the cheeks tray the whole tray does. */
#inventory-slots, .tray-slots {
  display: grid;
  grid-template-columns: repeat(4, 1fr);  /* rows of 4, filling the pane */
  max-width: 24rem;
  gap: var(--space-2);
  overflow-y: auto;
  min-height: 0;
}
/* the capped, centred panes on wide screens (see above): slots span the pane's full
   width in rows of 6 instead of a 24rem strip of 4. phones keep rows of 4. */
@media (min-width: 700px), (max-height: 560px) {
  #inventory-slots, .tray-slots { max-width: none; grid-template-columns: repeat(6, 1fr); }
}
/* the You tab's Territory row (ticket 104): a tray-slots grid that never scrolls or shrinks —
   in the scrolling tab, min-height 0 + overflow let it collapse to nothing */
#territory-slots {
  overflow: visible; min-height: auto; max-width: none; justify-content: center;
  /* slots the cheeks tray's size, centred: its inner width (12px in each side, 1.5px border,
     --space-3 padding), a strip of at most 24rem, 4 a row */
  --slot-w: calc((min(24rem, 100vw - 27px - 2 * var(--space-3)) - 3 * var(--space-2)) / 4);
  /* never wider than the panel: its padding is the menu's, wider than the tray's */
  grid-template-columns: repeat(4, min(var(--slot-w), calc((100% - 3 * var(--space-2)) / 4)));
}
@media (min-width: 700px), (max-height: 560px) {
  /* the capped tray (min(34rem, 100% - 24px)), 6 a row */
  #territory-slots { --slot-w: calc((min(34rem, 100vw - 24px) - 3px - 2 * var(--space-3) - 5 * var(--space-2)) / 6);
    grid-template-columns: repeat(6, min(var(--slot-w), calc((100% - 5 * var(--space-2)) / 6))); }
}
/* the last slot fades: more to find. only where it fits in the last row (never one alone on a
   new row): 4 a row on phones, 6 wide (the tray's columns) */
#territory-slots .territory-more { opacity: 0.35; }
#territory-slots .territory-unknown { color: var(--muted); }
#territory-slots .territory-more:nth-child(4n+1) { display: none; }
@media (min-width: 700px), (max-height: 560px) {
  #territory-slots .territory-more:nth-child(4n+1) { display: grid; }
  #territory-slots .territory-more:nth-child(6n+1) { display: none; }
}
.inventory-slot {
  aspect-ratio: 1;
  border: 1.5px dashed var(--border);
  border-radius: 10px;
  background: var(--cream);
  display: grid;
  grid-template-rows: 1fr auto;
  place-items: center;
  padding: var(--space-1);
  min-width: 0;
}
.inventory-slot:not(.filled) { grid-template-rows: 1fr; }
.slot-icon { width: 1.6em; height: 1.6em; font-size: 1.725em; line-height: 1.6em; text-align: center; }
.slot-name { font-size: 0.6rem; color: var(--muted); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inventory-slot.filled { border-color: var(--acorn); border-style: solid; cursor: pointer; }
.inventory-slot.filled:disabled { cursor: default; }
.inventory-slot.selected { background: var(--acorn); }
.inventory-slot.selected .slot-name { color: var(--cream); }


.stomach { display: grid; gap: var(--space-1); padding-top: var(--space-1); }
.stomach-head {
  display: flex;
  justify-content: center;
  font-family: var(--font-heading);
  font-size: var(--text-xs);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}
.stomach-bar { height: 0.8rem; border: 1.5px solid var(--border); border-radius: 999px; background: #c6e3f7; overflow: hidden; }  /* empty: baby blue */
.stomach-fill {
  height: 100%;
  width: 0;
  background: #c99a2e; /* earthy yellow; width = filled/capacity, left to right over the baby-blue track */
  transition: width 0.3s ease;
}

/* Stuns and active effects: a row of plain labels under the stomach, nearest expiry first.
   One line, always there (a hidden spacer when there are none, so the tray keeps its
   height). When they don't fit, the track holds them twice and slides left by one copy,
   looping (_fitChips) — a continuous banner. The gap is each label's right margin, so
   both copies are the same width. */
.status-chips { overflow: hidden; }
.chips-track { display: flex; width: max-content; }
.chips-track.sliding { animation: chips-slide linear infinite; }
/* tapped: the banner stops and the finger takes over, until the tray reopens */
.status-chips.swipe { overflow-x: auto; scrollbar-width: none; }
.status-chips.swipe::-webkit-scrollbar { display: none; }
@keyframes chips-slide { to { transform: translateX(-50%); } }
.status-chip[data-explain] { cursor: pointer; }
.status-chip {
  margin-right: var(--space-3);
  font-size: var(--text-xs);
  line-height: 1.2;
  color: var(--bark);
  white-space: nowrap;
  flex-shrink: 0;
}

/* Item sheet: hangs from the top bar, the cheeks tray's mirror image, so the world's
   items never read as yours. Always absolute inside #map-wrap (never normal flow). */
.item-sheet {
  position: absolute;
  top: 0;
  left: 12px;
  right: 12px;
  z-index: 60;
  max-height: 33.3%;  /* a third of #map-wrap (_lockHeight keeps to that) */
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-top: none;
  border-radius: 0 0 14px 14px;
  padding: var(--space-2) var(--space-3) var(--space-3);
}
.item-sheet.hidden { display: none !important; }
/* the slide-down on first open is played from JS (_openItem): a CSS animation here would
   restart whenever .morphing swaps in its own animation and back */
/* sections never squash into each other. the item sheet keeps its heading, text and
   verbs (and a picked item's) always in view; only a container's slots give way and
   scroll. the tray instead scrolls as a whole. */
.item-sheet > *, .inventory-tray > * { flex-shrink: 0; }
/* the morph line's 6px strip and the claim button's row are always reserved, so every
   item's sheet is the same height whether or not it shows them */
.item-sheet { padding-top: calc(var(--space-2) + 6px); }
.verb-spacer { visibility: hidden; }
/* both panes have a fixed height (set in _lockHeight); the slot grid takes what's left and scrolls */
.inventory-tray > #inventory-slots, .item-sheet > .sheet-slots { flex: 1 1 auto; flex-shrink: 1; min-height: 0; overflow-y: auto; }
/* a picked cheek item sits on top of the tray, rising with it */
.tray-picked {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding-bottom: var(--space-2);
  border-bottom: 1px dashed var(--border);
  height: var(--pane-h, auto);  /* action pane: fixed (see _actionPaneH), so picking never changes the pane's height */
  overflow-y: auto;
}
.tray-picked.hidden { display: none; }
.sheet-picked { border-top: 1px dashed var(--border); padding-top: calc(var(--space-2) + 5px); height: var(--pane-h, auto); overflow-y: auto; }
.sheet-subtitle { font-family: var(--font-heading); font-size: var(--text-lg); font-weight: 700; color: var(--bark); }
.sheet-title { font-family: var(--font-heading); font-size: var(--text-lg); font-weight: 700; color: var(--bark); }
/* a name never wraps (the sheet's height is fixed): one line, scrolling sideways in the room the
   claim badge leaves it, no scrollbar */
.sheet-title, .sheet-subtitle { white-space: nowrap; overflow-x: auto; min-width: 0; flex: 1 1 auto; scrollbar-width: none; }
.sheet-title::-webkit-scrollbar, .sheet-subtitle::-webkit-scrollbar { display: none; }
.sheet-header { gap: var(--space-2); }
.sheet-header > :not(.sheet-title):not(.sheet-subtitle) { flex: none; }
.sheet-meta { font-size: var(--text-sm); margin: 0; }
/* a fixed one line whatever it holds, so the sheet never resizes with it: blank when
   hidden (out of reach) or empty, scrolling sideways when longer, like the name */
.sheet-desc { font-size: var(--text-sm); font-style: italic; color: var(--bark); margin: 0 0 var(--space-1);
  height: 1lh; white-space: nowrap; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.sheet-desc::-webkit-scrollbar { display: none; }
.sheet-status { font-style: normal; }  /* the status leading the description line */
/* more to the right (_markOverflow): the line fades out at its end */
.sheet-title.more-right, .sheet-subtitle.more-right, .sheet-desc.more-right {
  -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 2.5em), transparent);
  mask-image: linear-gradient(to right, #000 calc(100% - 2.5em), transparent);
}
.sheet-verbs { display: flex; flex-wrap: wrap; gap: var(--space-2); }
/* no verbs: the status sits where they would, bottom left like a button's corner, the hidden spacer keeping the row's height */
.sheet-verbs { position: relative; }
.sheet-verbs > .verb-spacer + .sheet-meta { position: absolute; left: 0; bottom: 0; line-height: 1; }
/* "Too far" shows up on nearly every sheet: there, but barely */
.too-far { opacity: 0.55; }
/* morph progress: a slim coloured track along the top of the morphing item's own section, so a
   morphable item reads as one even at zero, filling left to right (--morph and the
   classes are set by _showMorph). the stomach's colours: baby-blue hatch for what's left,
   earthy-yellow done. the hatch drifts left to right while the morph runs and holds still
   when it's paused (same colours, just not moving). layered backgrounds, so it stays put
   while the pane scrolls */
@property --morph-d { syntax: "<length>"; inherits: false; initial-value: 0px; }
.morphing {
  --morph-fill: #c99a2e;
  /* the done part drifts with the hatch: the same 45deg stripes, in px stops (they don't
     scale with the box, which is only as wide as --morph), phase driven by --morph-d. the
     gap is opaque so the blue under it doesn't show through */
  --morph-gap: var(--surface);
  --morph-done: repeating-linear-gradient(135deg,
    var(--morph-fill) calc(var(--morph-d) * 0.7071), var(--morph-fill) calc(var(--morph-d) * 0.7071 + 2.1213px),
    var(--morph-gap) calc(var(--morph-d) * 0.7071 + 2.1213px), var(--morph-gap) calc(var(--morph-d) * 0.7071 + 4.2426px));
  /* 6px tile: the 45deg stripes repeat every 6px across, so the drift loops seamlessly */
  --morph-track: linear-gradient(135deg, #c6e3f7 25%, transparent 25% 50%, #c6e3f7 50% 75%, transparent 75%);
  animation: morph-drift 0.8s linear infinite;
}
/* the morph ends the item (starving into a corpse, a buried bug suffocating, a ward wearing out): it fills red (the hunter ring's red) */
.morphing.morph-hunger { --morph-fill: #d93f3f; }
/* paused: the same bar, holding still */
.morphing.morph-paused { animation: none; }
@keyframes morph-drift {
  from { background-position: left top, 0 top, 0 0; --morph-d: 0px; }
  to   { background-position: left top, 6px top, 0 0; --morph-d: 6px; }
}
/* reduced motion: a running morph can't drift, so its blue goes solid (the old look) and
   the hatch is left to mean paused */
@media (prefers-reduced-motion: reduce) {
  .morphing { animation: none; }
  .morphing:not(.morph-paused) { --morph-track: linear-gradient(#c6e3f7, #c6e3f7); --morph-gap: var(--morph-fill); }
}
/* the head item's line: the sheet's top edge */
.item-sheet.morphing {
  background:
    var(--morph-done) left top / var(--morph, 0%) 6px no-repeat,
    var(--morph-track) 0 top / 6px 6px repeat-x,
    var(--surface);
}
/* a picked item's line: in place of the dashed divider above it, but across the whole
   sheet, border to border (the pane reaches out over the sheet's side padding) */
.sheet-picked.morphing {
  border-top-color: transparent;
  margin-inline: calc(-1 * var(--space-3));
  padding-inline: var(--space-3);
  background:
    var(--morph-done) left top / var(--morph, 0%) 6px no-repeat,
    var(--morph-track) 0 top / 6px 6px repeat-x;
}
/* item verbs are thumb targets on a phone: a bigger label than a plain .btn-sm, and the
   button grows around it (same padding) */
.sheet-verb { font-size: var(--text-lg); }
/* claim: beside the name, in the map's ownership-dot green */
.sheet-verb.verb-claim { background: #b3cf8f; border-color: #b3cf8f; color: #2e3a1f; }
/* Claimed/Guarded are badges, not verbs: spent-looking (as disabled), but a tap explains them */
.sheet-verb.claim-badge { opacity: 0.5; cursor: default; }
/* a Gentleface icon (game.js _gf): the vendored SVG as a mask over the text's colour, at its 16 px grid */
.gf-icon { display: inline-block; width: 16px; height: 16px; vertical-align: -2px; background: currentColor;
  -webkit-mask: var(--gf) center / 16px 16px no-repeat; mask: var(--gf) center / 16px 16px no-repeat; }
.gf-flag-solid-round { --gf: url(/icons/gentleface/flag-solid-round-bold.svg); }
.gf-flag-line-round { --gf: url(/icons/gentleface/flag-line-round-bold.svg); }
.gf-shield-line-round { --gf: url(/icons/gentleface/shield-line-round-bold.svg); }
.gf-shield-solid-round { --gf: url(/icons/gentleface/shield-solid-round-bold.svg); }
/* Guarded (ticket 106): the claim button, spent and greyed red, on yours and on someone else's alike */
.sheet-verb.verb-claim.verb-guarded { background: #d9b8b2; border-color: #d9b8b2; color: #6b3a33; }
/* Nest: the open structure's verb, a tab rising from the cheeks tray's top edge (the tray's own
   surface, border and 14px corners), its right side flush with the tray's: one border running up
   the right, the tray's top-right corner squared under it. on its left, a concave 14px curve
   meets the tray's top edge, like a browser tab */
.nest-tab {
  position: absolute; z-index: 51;  /* over the tray's top border, which it hides where they meet */
  bottom: calc(100% + var(--tray-h, 0px) - 1.5px);
  right: 12px;  /* the tray's inset */
  width: var(--nest-w); display: flex; justify-content: center;  /* its middle is the column's */
  padding: var(--space-2) 0 calc(var(--space-2) + 1.5px);
  background: var(--surface);
  border: 1.5px solid var(--border); border-bottom: none;
  border-radius: 14px 14px 0 0;
}
/* the concave curve: a 14px square whose bottom and right borders form a real rounded corner
   (the same border as everywhere, so the line runs on unbroken into the tray's top edge and the
   tab's left side, which its two borders overlap), the surface filling outside the curve by a
   box-shadow (a shadow follows the rounded edge and never paints inside the box) */
.nest-tab::before {
  content: ""; position: absolute; bottom: 0; left: -14px; width: 14px; height: 14px;  /* left: from inside the tab's border, so its right border lands on the tab's */
  box-sizing: border-box;
  border: solid var(--border); border-width: 0 1.5px 1.5px 0;
  border-bottom-right-radius: 14px;
  box-shadow: 5px 5px 0 5px var(--surface);
}
#bottom-chrome:has(> .nest-tab:not(.hidden)) > .inventory-tray { border-top-right-radius: 0; }
.nest-tab.hidden { display: none; }
/* wide or short screens: the tray is capped and centred (see .inventory-tray), so is the tab's edge */
@media (min-width: 700px), (max-height: 560px) {
  .nest-tab { right: calc((100% - min(34rem, 100% - 24px)) / 2); }
}

/* Dev panel — temporary tooling, so a floating button.
   Bottom-left of the map, above the map attribution's ⓘ (24px + MapLibre's 10px margin). */
.dev-fab {
  position: absolute;
  bottom: calc(10px + 24px + var(--space-2) + env(safe-area-inset-bottom, 0px));
  left: var(--space-3);
  z-index: 40;
  width: 2.8rem;
  height: 2.8rem;
  padding: 0;
  border-radius: 50%;
  background: var(--surface);
  border: 1.5px solid var(--border);
  font-size: var(--text-lg);
  opacity: 0.8;
}
#dev-panel { max-height: 80svh; overflow-y: auto; }
.dev-row { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; margin: var(--space-2) 0; }
.dev-row select { flex: 1; min-width: 8rem; padding: var(--space-1); }
.dev-output { font-size: 0.7rem; white-space: pre-wrap; max-height: 30svh; overflow-y: auto; margin-top: var(--space-2); color: var(--bark); }

/* the quorum popup's answers: Share / Later / Ignore side by side (Later alone once answered) */
/* Share on a row of its own, Later + Ignore side by side under it: three in a row
   don't fit a phone. min-width 0 lets a label shrink instead of pushing out */
.quorum-buttons { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.quorum-buttons button { flex: 1; min-width: 0; }
