/* Rise of Denemearc – map screen */
#app { position: fixed; inset: 0; display: flex; flex-direction: column; }

.map-header {
  position: relative;
  z-index: 8;   /* above the top menu (#tb, 6; its medals 7): the info box's world menu hangs down over it */
  display: flex;
  align-items: center;
  gap: 1.2%;
  padding: 0.7% 1.5%;
  min-height: 56px;
  background: linear-gradient(var(--wood-1), var(--wood-2));
  border-bottom: 3px solid color-mix(in srgb, var(--wood-2), #000 50%);
  box-shadow: 0 2px 0 var(--bronze) inset, 0 4px 18px rgba(0, 0, 0, 0.55);
}
.brand { display: flex; flex-direction: column; line-height: 1; white-space: nowrap; text-decoration: none; }
.brand small { font-size: clamp(11px, 0.75vw, 12px); letter-spacing: 0.35em; color: var(--gold); text-transform: uppercase; }
.brand b {
  font-size: clamp(18px, 1.8vw, 28px);
  letter-spacing: 0.06em;
  background: linear-gradient(var(--gold-hi), var(--gold) 45%, color-mix(in srgb, var(--gold), #000 30%) 55%, var(--gold) 56%, color-mix(in srgb, var(--gold), #000 55%));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 2px 0 #000);
}
/* map buttons in the header, 2 × 2: + / − in the left column, home / flat world in the right */
.ctrl {
  margin-left: auto; flex: 0 0 auto;
  display: grid; grid-auto-flow: column; grid-template-rows: repeat(2, 26px); grid-auto-columns: 26px; gap: 4px;
  /* in a small box like the info box's (.ub in game.css), but always at full strength – they are used all the time */
  padding: 3px; border-radius: 10px; border: 1px solid color-mix(in srgb, var(--gold) 35%, transparent);
  background: color-mix(in srgb, var(--wood-2) 30%, transparent);
}
.ctrl button {
  width: 26px; height: 26px; padding: 0; border: 2px solid var(--bronze); border-radius: 6px; cursor: pointer;
  background: linear-gradient(var(--wood-1), var(--wood-2)); color: var(--gold-hi); font: bold 15px/1 var(--font);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.55);
  display: flex; align-items: center; justify-content: center;
}
.ctrl button:hover { border-color: var(--gold); }
.ctrl button:focus-visible { outline: 2px solid var(--gold-hi); outline-offset: 2px; }
.rune[data-name]:focus-visible { outline: 1px dotted currentColor; outline-offset: 2px; }
/* the two switches in a third column: runes / normal letters (#ztext) on top, parish names on / off (#znames) below;
   .on = glowing gold rim, off = dimmed with a strike through the names icon */
.ctrl button.txt { font: 17px/1 var(--runes); }
.ctrl #ztext.on, .ctrl #znames.on { border-color: var(--gold); color: var(--gold-hi); box-shadow: 0 0 8px color-mix(in srgb, var(--gold) 45%, transparent), 0 2px 6px rgba(0, 0, 0, 0.55); }
.ctrl #znames:not(.on) { color: color-mix(in srgb, var(--gold-hi) 60%, transparent); }
.ctrl #znames .strike { display: none; }
.ctrl #znames:not(.on) .strike { display: inline; }
.ctrl button svg { display: block; pointer-events: none; }
/* the tech tree button (owner 2026-11-17): the 7th, as tall as the two rows, in a column of its own */
.ctrl #ztech { grid-row: 1 / span 2; height: auto; width: 30px; }
.ctrl #ztech:hover, .ctrl #ztech:focus-visible, .ctrl #ztech[aria-expanded="true"] { border-color: var(--gold); box-shadow: 0 0 8px color-mix(in srgb, var(--gold) 45%, transparent), 0 2px 6px rgba(0, 0, 0, 0.55); }

/* ---------------------------------------------------------------- the tech tree window (map.php, TechTree.php, js/tech.js) */
.tech { width: min(96vw, 60rem); max-height: 92vh; padding: 0; border: 0; background: transparent; color: var(--ink); overflow: visible; }
.tech::backdrop { background: rgba(4, 6, 10, 0.6); }
.tech [hidden] { display: none !important; }
.tech-box {
  position: relative; box-sizing: border-box; max-height: 92vh; overflow-y: auto; overscroll-behavior: contain; padding: 18px 20px 16px;
  background: var(--parch); border: 3px solid var(--wood-1); border-radius: 12px; box-shadow: 0 0 0 2px var(--bar) inset, 0 10px 28px rgba(0, 0, 0, 0.55);
}
.tech-box h2 { margin: 0 40px 6px 0; color: var(--heading); font-size: 22px; }
.tech-x { position: absolute; top: 8px; right: 10px; width: 32px; height: 32px; padding: 0; border: 0; border-radius: 8px; background: transparent; color: var(--ink-soft); font: 26px/1 var(--font); cursor: pointer; }
.tech-x:hover, .tech-x:focus-visible { color: var(--ink); background: var(--parch-2); outline: none; }
.tech-intro { margin: 0 0 12px; color: var(--ink-soft); font-size: 14px; line-height: 1.45; }
.tech-note { color: var(--ink); font-style: italic; }
.tech-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; border-bottom: 2px solid var(--line); }
.tech-tabs button { padding: 6px 14px; font: bold 14px var(--font); color: var(--ink-soft); background: var(--parch-2); border: 2px solid var(--line); border-bottom: 0; border-radius: 8px 8px 0 0; margin-bottom: -2px; cursor: pointer; }
.tech-tabs button.on { color: var(--ink); background: var(--card); border-color: var(--wood-1); }
.tt-row { display: flex; gap: 12px; margin: 0 0 10px; align-items: flex-start; }
.tt-lab { flex: 0 0 4.6rem; padding-top: 8px; color: var(--ink-soft); font-size: 12px; font-weight: bold; text-transform: uppercase; letter-spacing: 0.06em; }
.tt-cards { display: flex; flex-wrap: wrap; gap: 8px; flex: 1; min-width: 0; }
.tt-n { box-sizing: border-box; min-width: 8.4rem; max-width: 14rem; padding: 6px 10px; background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--line); border-radius: 8px; }
.tt-n b { display: inline; color: var(--ink); font-size: 14px; }
.tt-lv { margin-left: 6px; padding: 0 6px; border-radius: 9px; background: var(--gold); color: var(--wood-2); font-size: 12px; font-style: normal; font-weight: bold; }
.tt-req { display: block; margin-top: 2px; font-size: 12px; line-height: 1.4; color: var(--ink-soft); }
.tt-req i { font-style: normal; }
.tt-req i:not(:last-child)::after { content: ", "; }
.tt-req i.no { color: var(--heading); font-weight: bold; }
.tt-req i.ok { text-decoration: line-through; text-decoration-thickness: 1px; opacity: 0.8; }
.tt-core, .tt-g.tt-core i { border-left-color: var(--ink-soft); }
.tt-army, .tt-g.tt-army i { border-left-color: var(--heading); background: color-mix(in srgb, var(--heading) 11%, var(--card)); }
.tt-bonus, .tt-g.tt-bonus i { border-left-color: var(--gold); background: color-mix(in srgb, var(--gold) 20%, var(--card)); }
.tt-sea, .tt-g.tt-sea i { border-left-color: var(--link); background: color-mix(in srgb, var(--link) 16%, var(--card)); }
.tt-wall, .tt-g.tt-wall i { border-left-color: var(--bronze); background: color-mix(in srgb, var(--bronze) 22%, var(--card)); }
.tt-leg, .tt-states { display: flex; flex-wrap: wrap; gap: 14px; margin: 12px 0 0; font-size: 12px; color: var(--ink-soft); }
.tt-g i, .tt-s i { display: inline-block; width: 12px; height: 12px; margin-right: 5px; vertical-align: -2px; background: var(--card); border: 1px solid var(--line); border-left-width: 4px; border-radius: 3px; }
/* states for a signed-in player's village (js/tech.js): built, can be built now, something missing */
.tt-n.have { background: color-mix(in srgb, var(--gold) 16%, var(--card)); border-color: var(--gold); }
.tt-n.can { box-shadow: 0 0 0 2px var(--gold-hi); }
.tt-n.lock { opacity: 0.72; }
.tt-s.have i { background: color-mix(in srgb, var(--gold) 30%, var(--card)); border-color: var(--gold); }
.tt-s.can i { box-shadow: 0 0 0 2px var(--gold-hi); }
.tt-s.lock i { opacity: 0.6; }
.tt-col { margin: 0 0 12px; padding: 10px 12px; background: var(--parch-2); border: 1px solid var(--line); border-radius: 10px; }
.tt-col h3 { margin: 0 0 8px; color: var(--heading); font-size: 15px; }
.tt-steps { margin: 0; padding: 0; list-style: none; counter-reset: tt; }
.tt-steps li { position: relative; margin: 0 0 12px; padding-left: 38px; counter-increment: tt; min-height: 28px; }
.tt-steps li::before { content: counter(tt); position: absolute; left: 0; top: 0; width: 28px; height: 28px; border-radius: 50%; background: var(--gold); color: var(--wood-2); font-weight: bold; display: flex; align-items: center; justify-content: center; }
.tt-steps b { display: block; color: var(--ink); font-size: 15px; }
.tt-steps span { display: block; color: var(--ink-soft); font-size: 14px; line-height: 1.45; }
#stage { position: relative; flex: 1; overflow: hidden; touch-action: none; cursor: grab; background: #020306; }
#stage.drag { cursor: grabbing; }
#sky { position: absolute; inset: 0; width: 100%; height: 100%; display: block; pointer-events: none; }
#map { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.creature { cursor: help; }
#tip small.lore { max-width: 240px; white-space: normal; font-style: italic; letter-spacing: 0; margin-top: 2px; }

.par { stroke: #6b5434; stroke-width: 0.45; vector-effect: non-scaling-stroke; stroke-linejoin: round; transition: fill 0.25s; }
.par:hover { filter: brightness(1.12); }
.b-kom { fill: none; stroke: #7a5a32; stroke-width: 1.1; stroke-dasharray: 3 2; vector-effect: non-scaling-stroke; opacity: 0.85; pointer-events: none; }
.b-reg { fill: none; stroke: #5a1a12; stroke-width: 2.2; vector-effect: non-scaling-stroke; opacity: 0.8; pointer-events: none; stroke-linecap: round; }
.b-coast { fill: none; stroke: #24180c; stroke-width: 1.3; vector-effect: non-scaling-stroke; pointer-events: none; stroke-linejoin: round; }
.b-land { fill: none; stroke: #24180c; stroke-width: 2.4; stroke-dasharray: 7 3 1.5 3; vector-effect: non-scaling-stroke; pointer-events: none; }
.b-shallow { fill: none; stroke: #7fa6b0; stroke-width: 9; vector-effect: non-scaling-stroke; opacity: 0.28; pointer-events: none; stroke-linejoin: round; }
.b-shallow2 { fill: none; stroke: #7fa6b0; stroke-width: 20; vector-effect: non-scaling-stroke; opacity: 0.1; pointer-events: none; stroke-linejoin: round; }
.sel { fill: none; stroke: var(--gold-hi); stroke-width: 3.5; vector-effect: non-scaling-stroke; pointer-events: none; filter: drop-shadow(0 0 3px #000); }
.nb { fill: var(--gold-hi); fill-opacity: 0.22; stroke: var(--bar); stroke-width: 1.2; vector-effect: non-scaling-stroke; pointer-events: none; }
.hov { fill: #fff6d0; fill-opacity: 0.25; stroke: #3a2a12; stroke-width: 1.6; vector-effect: non-scaling-stroke; pointer-events: none; }
#labels text { pointer-events: none; paint-order: stroke; stroke: rgba(243, 232, 205, 0.8); stroke-linejoin: round; fill: #2a1c0e;   /* map art: always dark ink on the light parishes */ text-anchor: middle; font-family: var(--font); }
#labels text.reg { fill: #5a1a12; letter-spacing: 0.3em; font-weight: bold; stroke: rgba(243, 232, 205, 0.6); }
#labels text.rune { font-family: var(--runes); }
#labels text.reg.rune { font-weight: bold; fill: #4a120c; letter-spacing: 0.22em; }
#labels text.kom.rune { font-style: normal; }
/* names in runes in the parish panel – the real name shows on hover / tap */
.rune { font-family: var(--runes); letter-spacing: 0.08em; }
.rune[data-name] { position: relative; cursor: help; outline: none; }
.rune[data-name]::after {
  content: attr(data-name); position: absolute; left: 50%; top: calc(100% + 6px); z-index: 5;
  transform: translate(-50%, -4px); opacity: 0; pointer-events: none; transition: opacity 0.15s, transform 0.15s;
  padding: 4px 9px; border: 1px solid var(--bronze); border-radius: 6px; white-space: nowrap;
  background: color-mix(in srgb, var(--wood-2) 94%, transparent); color: var(--on-wood); font: 13px var(--font); letter-spacing: 0.04em;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.5);
}
.rune[data-name]:hover::after, .rune[data-name]:focus::after { opacity: 1; transform: translate(-50%, 0); }
#labels text.kom { fill: #4a3218; font-style: italic; }
.inset { fill: #f3e8cd; fill-opacity: 0.07; stroke: none; pointer-events: none; }
.inset-frame { fill: none; stroke: #d9b45a; stroke-width: 1.4; stroke-opacity: 0.7; vector-effect: non-scaling-stroke; pointer-events: none; }
.edge-text { font-family: var(--font); fill: #d9b45a; letter-spacing: 0.35em; font-weight: bold; pointer-events: none; }

#tip {
  position: absolute; z-index: 4; display: none; pointer-events: none; white-space: nowrap;
  transform: translate(14px, 14px); padding: 6px 10px; border: 1px solid var(--bronze); border-radius: 6px;
  background: color-mix(in srgb, var(--wood-2) 93%, transparent); color: var(--on-wood); font-size: 14px; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.55);
}
#tip small { display: block; color: var(--gold); font-size: 11px; letter-spacing: 0.05em; }



#panel {
  position: absolute; z-index: 3; right: 1.2%; top: 2%; bottom: calc(2% + 50px);   /* room for the language selector */
  width: clamp(260px, 26%, 400px);
  display: flex; flex-direction: column;
  background: var(--parch); border: 3px solid var(--wood-1); border-radius: 10px;
  box-shadow: 0 0 0 2px var(--bar) inset, 0 14px 40px rgba(0, 0, 0, 0.7);
  transform: translateX(calc(100% + 40px)); transition: transform 0.3s ease;
}
#panel.open { transform: none; }
#panel .hd { padding: 14px 16px 10px; border-bottom: 2px solid var(--line); background: linear-gradient(var(--parch-2), var(--parch)); border-radius: 8px 8px 0 0; }
#panel h2 { margin: 0; padding-right: 1.5em; font-size: clamp(20px, 2vw, 28px); line-height: 1.1; }
#panel .sub { margin-top: 4px; color: var(--ink-soft); font-size: 14px; }
#panel .x { position: absolute; right: 10px; top: 8px; border: 0; background: none; font-size: 24px; cursor: pointer; color: var(--ink-soft); }
#panel .bd { flex: 1; overflow: auto; padding: 12px 16px; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.stat { padding: 8px 10px; background: var(--parch-2); border: 1px solid var(--line); border-radius: 8px; }
.stat b { display: block; font-size: 18px; }
.stat span { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-soft); }
.badges { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.badge { padding: 3px 9px; border-radius: 20px; background: var(--wood-1); color: var(--on-wood); font-size: 12px; }   /* light text on dark in every theme */
.badge.sea { background: #1f4a5c; } .badge.isl { background: #2a6f6a; } .badge.land { background: #4a5a22; }
#panel h3 { margin: 14px 0 8px; padding-bottom: 4px; border-bottom: 1px solid var(--line); color: var(--ink-soft); font-size: 13px; letter-spacing: 0.15em; text-transform: uppercase; }

#loading {
  position: absolute; inset: 0; z-index: 10; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 45%, #1b3644, #05090d 70%); color: #e8d9b5; font-size: clamp(16px, 1.6vw, 22px); font-style: italic;
  transition: opacity 0.4s ease;
}
#loading.done { opacity: 0; pointer-events: none; }
#loading.err p { color: #ffb4a0; font-style: normal; max-width: 80%; text-align: center; }
.spinner { width: 54px; height: 54px; border: 4px solid color-mix(in srgb, var(--gold) 25%, transparent); border-top-color: var(--gold); border-radius: 50%; animation: spin 1s linear infinite; }
#loading.err .spinner { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* tablets and phones */
@media (max-width: 760px) {
  .map-header { gap: 8px; padding: 2% 3%; }
  #panel { left: 2%; right: 2%; top: auto; bottom: calc(1% + 50px); width: auto; max-height: 55%; transform: translateY(calc(100% + 40px)); }
}
/* narrow phones: brand, map buttons, "Report / idea" and the info box must share ~360 px – a smaller brand and tighter
   gaps keep the info box (world + player name) readable */
@media (max-width: 440px) {
  .map-header { gap: 6px; padding: 2% 2.5%; }
  .brand small { font-size: 9px; letter-spacing: 0.3em; }
  .brand b { font-size: 14px; letter-spacing: 0.04em; }
  .ctrl { padding: 2px; gap: 3px; }
  .ctrl + .ub-bar { margin-left: 0; }
}
@media (max-height: 480px) and (orientation: landscape) {
  .map-header { min-height: 0; padding: 0.5% 1.5%; }
  #panel { width: 42%; }
}

/* ---------------------------------------------------------------- the game layer (signed-in players, step 7) */
#game { pointer-events: none; }
.g-v { stroke: var(--wood-2); }
.g-v.own { fill: var(--gold-hi); stroke: var(--wood-2); }
.g-v.other { fill: var(--line-c); stroke: var(--card); }
.g-v.ally { fill: var(--link); stroke: var(--card); }
.g-v.npc { fill: color-mix(in srgb, var(--ink-soft) 70%, var(--card)); stroke: var(--wood-2); }
/* outlands: the parish itself carries its holder's (paler) colour (map.js paintRealm) – here only a dashed rim */
.g-ol { fill: none; stroke-width: 1.5; stroke-dasharray: 4 3; vector-effect: non-scaling-stroke; }
.g-ol.own { stroke: hsl(117 64% 55%); }
.g-ol.ally { stroke: var(--link); }
.g-ol.other { stroke: var(--line-c); }
.g-mv { stroke-width: 2.5; stroke-dasharray: 7 5; vector-effect: non-scaling-stroke; }
.g-mv.out { stroke: var(--gold-hi); }
.g-mv.in { stroke: var(--line-c); }
/* the army's progress figure on its line (map.js tickMoves) and the target parish that blinks softly (owner 2026-11-17) */
.g-pg polygon { stroke: var(--wood-2); stroke-width: 1.2; vector-effect: non-scaling-stroke; }
.g-pg text { font-weight: 700; paint-order: stroke; stroke: var(--wood-2); stroke-width: 3px; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.g-pg.out polygon, .g-pg.out text { fill: var(--gold-hi); }
.g-pg.in polygon, .g-pg.in text { fill: var(--line-c); }
.g-pg.back polygon, .g-pg.back text { fill: var(--link); }   /* the way home: its own colour (owner 2026-11-17) */
.g-mv.back { stroke: var(--link); }
.g-mv-end.back { fill: var(--link); }
.g-tgt { stroke: none; opacity: 0.1; animation: g-blink 1.8s ease-in-out infinite; }
.g-tgt.out { fill: var(--gold-hi); }
.g-tgt.in { fill: var(--line-c); }
/* parishes being spied on / attacked by the player: lighter red; an attack coming for an own parish: blinks red / yellow (map.js drawGame) */
.g-hit { stroke: none; fill: hsl(2 80% 62%); opacity: 0.5; pointer-events: none; }
.g-under { stroke: none; pointer-events: none; fill: hsl(0 85% 50%); opacity: 0.75; animation: g-alarm 0.9s steps(1, end) infinite; }
@keyframes g-alarm { 0% { fill: hsl(0 85% 50%); } 50% { fill: hsl(52 95% 55%); } }
@media (prefers-reduced-motion: reduce) { .g-under { animation: none; fill: hsl(26 90% 52%); } }
@keyframes g-blink { 0%, 100% { opacity: 0.04; } 50% { opacity: 0.3; } }
@media (prefers-reduced-motion: reduce) { .g-tgt { animation: none; opacity: 0.16; } }
.g-mv-end.out { fill: var(--gold-hi); }
.g-mv-end.in { fill: var(--line-c); }
#tip small.g-tip { margin-top: 3px; color: var(--gold-hi); }
#tip small.g-tip.other { color: #ffb3a8; }
.g-info { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.g-line { margin: 0; color: var(--ink); }
.g-line.other, .g-line.npc { color: var(--line-c); }
.g-btn {
  align-self: flex-start; padding: 6px 14px; border: 2px solid var(--bronze); border-radius: 8px; text-decoration: none;
  background: linear-gradient(var(--wood-1), var(--wood-2)); color: var(--gold-hi); font: bold 14px var(--font); letter-spacing: 0.05em;
}
.g-btn:hover, .g-btn:focus-visible { border-color: var(--gold); outline: none; filter: brightness(1.15); }
.g-sub { margin: 4px 0 0; color: var(--ink-soft); font-size: 13px; }
.g-moves { margin: 0; padding-left: 1.1em; font-variant-numeric: tabular-nums; }
.g-moves li.in { color: var(--line-c); font-weight: bold; }

/* the game layer (assets/js/gamelayer.js): city, army, market, reports … in a frame over the map, which stays visible
   around and behind the card (the framed page has a see-through background – account.css .in-frame) */
.gl {
  width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0;
  border: 0; background: none; overflow: hidden;
}
.gl::backdrop { background: rgba(4, 6, 10, 0.45); }
.gl-frame { display: block; width: 100%; height: 100%; border: 0; background: transparent; }
/* the copy of the header's "Report / idea" box over the open layer (gamelayer.js places it on the original) */
.gl-fb { position: fixed; margin: 0; box-sizing: border-box; opacity: 0.85; }

/* ---------------------------------------------------------------- the TOP MENU (owner 2026-11-16, spec §0 #30)
   Layout B: floor 2 (#tb) under the header – village switcher, resource ribbon, countdown signs; the four views as
   medallions hanging from it; the city's pages as a rail on the left. Phones (≤ 640 px): layout C – the ribbon in rows
   and a thumb bar (#tb-phone) at the bottom. assets/js/topbar.js fills it; the game layer lies between the menu's parts
   (--tb-top / --tb-bottom, gamelayer.js) and is not modal. Interface colours = theme tokens; the medallions' painted
   faces and the oxblood ribbon are artwork. */
.tb-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.tb [hidden], .tb-rail [hidden], .tb-phone [hidden] { display: none !important; }   /* topbar.js hides what has nothing behind it */
.tb {
  position: relative; z-index: 6; flex: 0 0 auto;
  background: linear-gradient(color-mix(in srgb, var(--wood-2) 96%, #000), var(--wood-2));
  border-bottom: 2px solid var(--gold); box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
}
/* the second floor: village switcher + rail | (the resources, when not in the header) + countdown signs in the middle
   | the map buttons at the right (owner 2026-11-17) – fixed columns, so a moved-out part leaves its column empty */
.tb-floor { display: grid; grid-template-columns: minmax(0, 1fr) auto auto minmax(max-content, 1fr); align-items: center; gap: 8px 12px; padding: 5px 1.5% 6px; }
.tb-floor > .tb-left { grid-column: 1; }
.tb-floor > .tb-res { grid-column: 2; }
.tb-floor > .tb-signs { grid-column: 3; }
.tb-floor > .tb-cslot { grid-column: 4; }
.tb-switch select {
  max-width: 100%; padding: 4px 26px 4px 10px; border-radius: 8px; cursor: pointer; font: bold 14px var(--font);
  color: var(--gold-hi); background: color-mix(in srgb, var(--wood-1) 85%, transparent); border: 1px solid color-mix(in srgb, var(--gold) 60%, transparent);
}
/* the village dropdown (owner 2026-11-18) */
.tb-dd { position: relative; }
.tb-dd-btn {
  max-width: 100%; padding: 4px 10px; border-radius: 8px; cursor: pointer; font: bold 14px var(--font); text-align: left;
  color: var(--gold-hi); background: color-mix(in srgb, var(--wood-1) 85%, transparent); border: 1px solid color-mix(in srgb, var(--gold) 60%, transparent);
}
.tb-dd-btn.many { padding-right: 26px; background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 14px) 52%, calc(100% - 9px) 52%; background-size: 5px 5px; background-repeat: no-repeat; }
.tb-dd-btn:hover, .tb-dd-btn:focus-visible { border-color: var(--gold-hi); outline: none; }
.tb-dd-list { position: absolute; z-index: 30; left: 0; top: calc(100% + 4px); min-width: 100%; max-height: 50vh; overflow: auto; margin: 0; padding: 4px; list-style: none;
  background: var(--card); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 6px 18px rgba(0, 0, 0, .35); }
.tb-dd-list[hidden] { display: none; }
.tb-dd-list button { display: block; width: 100%; padding: 6px 10px; border: 0; border-radius: 6px; background: transparent; color: var(--ink); font: 14px var(--font); text-align: left; white-space: nowrap; cursor: pointer; }
.tb-dd-list button:hover, .tb-dd-list button:focus-visible { background: var(--parch-2); outline: none; }
.tb-dd-list button.on { font-weight: bold; color: var(--heading); }
.tb-switch select:disabled { cursor: default; opacity: 1; appearance: none; padding-right: 10px; }
.tb-switch select:focus-visible { outline: 2px solid var(--gold-hi); outline-offset: 2px; }
.tb-switch option { color: var(--ink); background: var(--card); }
/* the resources: just the icons and numbers on the wood (owner 2026-11-17: no red ribbon behind them any more) –
   light text from the theme (--on-wood is light on wood in every theme) */
.tb-res {
  list-style: none; margin: 0; padding: 5px 12px; display: flex; flex-wrap: wrap; justify-content: center; gap: 2px 16px;
  color: var(--on-wood, #fff1cf); font-size: 13px; font-variant-numeric: tabular-nums; min-height: 34px; min-width: 18rem;
}
.tb-r { position: relative; display: grid; grid-template-columns: auto auto; column-gap: 5px; align-items: center; align-content: center; line-height: 1.1; cursor: default; text-align: center;
  transform: translateX(var(--fx, 0px)) scale(var(--fe, 1)); transform-origin: 50% 50%; transition: transform .12s ease-out; }
.tb-res .tb-cap { transform: translateX(var(--fx, 0px)); transition: transform .12s ease-out; }
.tb-r.fe-top { z-index: 3; }   /* the biggest one lies in front of its neighbours */
/* the ribbon in the HEADER (owner 2026-11-17; ≥ 1100 px, topbar.js moves it into #tb-hslot): at the header's bottom,
   between the brand and the map buttons; the header gets room above it for the fisheye lens, which grows UPWARDS
   (negative margin: the header's height does not change while it grows) */
/* owner 2026-11-17/18: the lens grows UP AND DOWN from the middle of the header (the ribbon is centred in it, every
   item scales round its own centre); the lines of an item are centred: value + rate (2 lines), and with the mouse over
   it the name as a third line on top – the whole block stays centred, so the header never changes height */
.hd-res { flex: 1 1 auto; min-width: 0; display: flex; justify-content: center; align-self: center; }
.hd-res:empty { display: none; }
.map-header:has(.hd-res .tb-res) { height: 74px; }   /* fixed: nothing the lens does can make the header taller and push the map down */
.hd-res .tb-res { position: relative; min-width: 0; align-items: center; }
.hd-res .tb-res.fe { z-index: 9; }
.tb-nm { display: none; grid-column: 2; grid-row: 1; font-size: 10px; white-space: nowrap; color: var(--gold-hi); }   /* column 2 = the same column as value + rate, so the 3 lines are centred together */
.tb-r.fe-top .tb-nm { display: block; }
@media (prefers-reduced-motion: reduce) { .tb-r, .tb-res { transition: none; } }
.tb-r img { grid-column: 1; grid-row: 1 / 4; align-self: center; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.6)); }   /* beside the whole text block, 2 lines or 3 */
.tb-r .tb-v { font-size: 14px; color: var(--gold-hi); text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7); }
.tb-r .tb-p { font-size: 10.5px; color: color-mix(in srgb, var(--on-wood, #f2d9a8) 80%, transparent); }
.tb-r.neg .tb-p, .tb-r.empty .tb-v { color: #ff9d8a; font-weight: bold; }
.tb-r.full .tb-v { text-decoration: underline dotted; }
.tb-cap { align-self: center; padding-left: 10px; border-left: 1px solid color-mix(in srgb, var(--gold) 40%, transparent); font-size: 12px; color: color-mix(in srgb, var(--on-wood, #f2d9a8) 80%, transparent); cursor: default; }
.tb-signs { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 6px; min-width: 0; }
/* the map buttons on the second floor (owner 2026-11-17): one row at the right, like the rail on the left */
.tb-cslot { display: flex; justify-content: flex-end; }
.tb-cslot:empty { display: none; }
.tb-cslot .ctrl { margin: 0; grid-template-rows: 30px; grid-auto-columns: 30px; padding: 0; border: 0; background: none; }
.tb-cslot .ctrl button, .tb-cslot .ctrl #ztech { width: 30px; height: 30px; grid-row: auto; border-radius: 8px; border-width: 1px; }
.tb-sign {
  display: inline-flex; gap: 6px; align-items: baseline; max-width: 100%; padding: 3px 10px; border-radius: 999px; text-decoration: none;
  font-size: 12px; font-variant-numeric: tabular-nums; color: var(--gold-hi); background: color-mix(in srgb, var(--wood-1) 85%, transparent);
  border: 1px solid color-mix(in srgb, var(--gold) 70%, transparent); white-space: nowrap;
}
.tb-sign .tb-sn { overflow: hidden; text-overflow: ellipsis; max-width: 11em; color: var(--on-wood, var(--gold-hi)); }
.tb-sign time { font-weight: bold; }
.tb-sign:hover, .tb-sign:focus-visible { border-color: var(--gold-hi); outline: none; }
.tb-sign.atk { border-color: #e56a5a; color: #ffd1c8; animation: tb-pulse 2s ease-in-out infinite; }
@keyframes tb-pulse { 50% { box-shadow: 0 0 0 3px rgba(229, 106, 90, 0.35); } }

/* the four views: medallions hanging from the menu over the map / the layer */
/* below the bar (not over the storage ribbon) and nearly see-through until pointed at (owner 2026-11-16) */
.tb-medals { position: absolute; left: 50%; top: 100%; transform: translate(-50%, 8px); display: flex; gap: 12px; align-items: flex-start; z-index: 7; pointer-events: none; }
.tb-medals .tb-md { opacity: 0.5; transition: opacity .2s; }   /* owner 2026-11-17: 0.3 was too see-through */
/* full strength while pointed at, or while the KEYBOARD is on one (a mouse click leaves focus on the medal, and
   closing the layer gives it back – that must not keep them all strong: owner 2026-11-17) */
.tb-medals .tb-md:hover, .tb-medals .tb-md:focus-visible, .tb-medals:has(.tb-md:focus-visible) .tb-md { opacity: 1; }
@media (hover: none) { .tb-medals .tb-md { opacity: 0.6; } }   /* touch screens: no pointing, so a little stronger */
.tb-md { pointer-events: auto; display: grid; justify-items: center; gap: 2px; text-decoration: none; color: var(--on-wood, var(--gold-hi)); font: 600 11px var(--font); background: none; border: 0; padding: 0; cursor: pointer; }
.tb-md span {
  width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; color: #fff6dc;
  border: 3px solid var(--gold); box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5), inset 0 0 0 2px rgba(0, 0, 0, 0.35); transition: transform .15s;
}
.tb-md svg { width: 24px; height: 24px; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.6)); }
.tb-md b { padding: 1px 8px; border-radius: 999px; background: color-mix(in srgb, var(--wood-2) 85%, transparent); white-space: nowrap; font-weight: 600; }
.tb-md-map span { background: radial-gradient(circle at 35% 30%, #7fb0c8, #2f5a7a); }
.tb-md-village span { background: radial-gradient(circle at 35% 30%, #a9c86e, #4c7a32); }
.tb-md-fields span { background: radial-gradient(circle at 35% 30%, #f0d27a, #b48a2c); }
.tb-md-centre span { background: radial-gradient(circle at 35% 30%, #d8c08e, #8a6a3e); }
.tb-md.on span { width: 66px; height: 66px; border-color: var(--gold-hi); box-shadow: 0 0 0 3px color-mix(in srgb, var(--gold-hi) 40%, transparent), 0 6px 14px rgba(0, 0, 0, 0.55); }
.tb-md.on svg { width: 32px; height: 32px; }
.tb-md.on b { color: var(--gold-hi); }
.tb-md:hover span, .tb-md:focus-visible span { transform: translateY(2px); border-color: var(--gold-hi); }
.tb-md:focus-visible { outline: none; }

/* the city's pages: small icons beside the village switcher on the second floor (owner 2026-11-16: no menu on the
   left side of the screen) */
.tb-left { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; min-width: 0; }
.tb-rail { display: flex; gap: 4px; }
.tb-rail a, .tb-rail button {
  position: relative; display: grid; place-items: center; width: 32px; height: 32px; padding: 0; border-radius: 8px; cursor: pointer;
  color: var(--on-wood, var(--gold-hi)); background: color-mix(in srgb, var(--wood-1) 85%, transparent); border: 1px solid color-mix(in srgb, var(--gold) 60%, transparent);
}
.tb-rail svg { width: 19px; height: 19px; }
.tb-rail a:hover, .tb-rail a:focus-visible { border-color: var(--gold-hi); color: var(--gold-hi); outline: none; filter: brightness(1.15); }
.tb-rail .tb-soon { opacity: 0.45; cursor: default; }
.tb-new { position: absolute; top: -6px; right: -6px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px; box-sizing: border-box; background: var(--line-c); color: #fff; font: bold 11px/18px var(--font); text-align: center; }

/* a clicked parish: a popup in the middle just under the medallions instead of a panel at the side (owner 2026-11-16) */
@media (min-width: 761px) {
  .has-tb #panel {
    left: 50%; right: auto; top: 104px; bottom: auto; width: min(400px, 92%); max-height: calc(100% - 120px);
    transform: translate(-50%, -10px); opacity: 0; visibility: hidden; transition: opacity .2s, transform .2s, visibility .2s;
  }
  .has-tb #panel.open { transform: translate(-50%, 0); opacity: 1; visibility: visible; }
}

/* the game layer below the menu: not modal, the menu stays usable */
.has-tb .gl { position: fixed; inset: var(--tb-top, 0px) 0 var(--tb-bottom, 0px) 0; width: auto; height: auto; z-index: 4; background: rgba(4, 6, 10, 0.45); }
.has-tb .gl-frame { height: 100%; }

/* phones: layout C */
.tb-phone { display: none; }
@media (max-width: 640px) {
  .tb-medals, .tb-rail { display: none; }   /* phones: the thumb bar has them */
  .tb-floor { grid-template-columns: 1fr; gap: 5px; padding: 4px 2.5% 5px; }
  .tb-floor > * { grid-column: auto !important; }   /* phones: everything in one column */
  .tb-switch { justify-self: start; }
  .tb-res { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 3px 6px; padding: 5px 6px; min-width: 0; }
  .tb-r .tb-v { font-size: 12.5px; }
  .tb-r img { width: 16px; height: 16px; }
  .tb-cap { padding-left: 0; border-left: 0; }
  .tb-signs { justify-content: flex-start; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .tb-phone {
    position: relative; z-index: 6; flex: 0 0 auto; display: grid; grid-template-columns: repeat(5, 1fr); align-items: end;
    padding-bottom: env(safe-area-inset-bottom, 0px); background: linear-gradient(var(--wood-1), var(--wood-2)); border-top: 2px solid var(--gold);
  }
  .tb-phone > a, .tb-phone > button:not(.tb-md) {
    display: grid; justify-items: center; gap: 2px; position: relative; padding: 6px 0 7px; border: 0; background: none; cursor: pointer;
    color: var(--on-wood, var(--gold-hi)); text-decoration: none; font: 11px var(--font);
  }
  .tb-phone > a svg, .tb-phone > button svg { width: 22px; height: 22px; }
  .tb-phone > a.on { color: var(--gold-hi); background: color-mix(in srgb, var(--gold) 16%, transparent); }
  .tb-phone .tb-new { top: 1px; right: calc(50% - 22px); }
  .tb-phone-md { margin-top: -26px; padding-bottom: 5px; }
  .tb-phone-md span { width: 54px; height: 54px; }
  .tb-phone-md.on span { width: 58px; height: 58px; border-color: var(--gold-hi); }
  .tb-fold, .tb-more {
    position: absolute; bottom: calc(100% + 8px); z-index: 8; display: flex; gap: 12px; padding: 10px 12px; border-radius: 14px;
    background: color-mix(in srgb, var(--wood-2) 92%, transparent); border: 1px solid var(--gold); box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5);
  }
  .tb-fold { left: 50%; transform: translateX(-50%); }
  .tb-fold[hidden], .tb-more[hidden] { display: none; }
  .tb-more { right: 6px; flex-direction: column; gap: 4px; padding: 6px; }
  .tb-more a, .tb-more button {
    display: flex; gap: 10px; align-items: center; padding: 8px 12px; border-radius: 8px; border: 0; background: none; text-decoration: none;
    color: var(--on-wood, var(--gold-hi)); font: 14px var(--font); cursor: pointer;
  }
  .tb-more svg { width: 20px; height: 20px; }
  .tb-more a:hover, .tb-more a:focus-visible { background: color-mix(in srgb, var(--gold) 18%, transparent); outline: none; }
  .tb-more button:disabled { opacity: 0.45; cursor: default; }
  .has-tb #panel { bottom: calc(var(--tb-bottom, 60px) + 1%); }
  .has-tb .copyright { bottom: calc(var(--tb-bottom, 60px) + 2px); }   /* above the thumb bar */
}
@media (prefers-reduced-motion: reduce) { .tb-sign.atk { animation: none; } .tb-md span { transition: none; } }

/* spectator mode (Admin / GM, map.php?watch=): a badge with the watched world and the way back to the staff page */
.g-watch { position: absolute; left: 12px; bottom: 36px; z-index: 6; margin: 0; max-width: calc(100% - 24px); padding: 6px 14px; border-radius: 999px;
  background: color-mix(in srgb, var(--wood-2) 90%, transparent); color: var(--on-wood); font-size: 13px; letter-spacing: 0.03em; }
.g-watch a { margin-left: 8px; color: var(--gold-hi); font-weight: bold; }
/* ---------------------------------------------------------------- the changelog (owner 2026-11-19, staff only: Changelog.php, js/changelog.js) */
.ctrl #zlog { grid-row: 1 / span 2; height: auto; width: 30px; position: relative; }
.ctrl #zlog:hover, .ctrl #zlog:focus-visible, .ctrl #zlog[aria-expanded="true"] { border-color: var(--gold); box-shadow: 0 0 8px color-mix(in srgb, var(--gold) 45%, transparent), 0 2px 6px rgba(0, 0, 0, 0.55); }
.tb-cslot .ctrl #zlog { width: 30px; height: 30px; grid-row: auto; border-radius: 8px; border-width: 1px; }
.cl { width: min(96vw, 46rem); }
.cl-sprite { position: absolute; }
.cl svg { display: block; pointer-events: none; }
.cl-list { display: grid; align-content: start; gap: 8px; max-height: 472px; overflow-y: auto; padding-right: 6px; }   /* 10 closed headlines (40 px + 8 px gap each), then the scrollbar (owner 2026-11-19) */
.cl-empty { color: var(--ink-soft); font-size: 14px; }
.cl-it { background: var(--card); border: 1px solid var(--line); border-radius: 8px; }
.cl-row, .cl-sr { display: flex; align-items: center; gap: 8px; }
.cl-row { padding: 8px 10px; cursor: pointer; }
.cl-row:hover, .cl-row:focus-visible { background: var(--parch-2); outline: none; border-radius: 8px; }
.cl-t { color: var(--ink); font-size: 14px; font-weight: bold; min-width: 0; flex: 0 1 auto; }
.cl-sr .cl-t { font-weight: normal; flex: 1; }
.cl-d { margin-left: auto; color: var(--ink-soft); font-size: 12px; white-space: nowrap; }
.cl-sr .cl-d { margin-left: 0; }
.cl-n { padding: 0 7px; border-radius: 9px; background: var(--parch-2); border: 1px solid var(--line); color: var(--ink-soft); font-size: 12px; }
.cl-ch svg { width: 16px; height: 16px; color: var(--ink-soft); transition: transform 0.15s; }
.cl-it.open .cl-ch svg { transform: rotate(90deg); }
.cl-body { padding: 2px 12px 10px 42px; border-top: 1px dashed var(--line); }
.cl-f { margin: 6px 0 0; color: var(--ink); font-size: 13px; line-height: 1.5; user-select: text; }
.cl-f b { color: var(--heading); }
.cl-meta { margin: 6px 0 0; color: var(--ink-soft); font-size: 11px; }
.cl-subs { margin: 8px 0 0 4px; padding-left: 10px; border-left: 2px solid var(--gold); display: grid; gap: 6px; }
.cl-sub .cl-f { margin-left: 28px; font-size: 12px; }
.cl-k { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; width: 22px; height: 22px; border-radius: 50%; color: var(--card); background: var(--ink-soft); }
.cl-sr .cl-k { width: 18px; height: 18px; }
.cl-k svg { width: 70%; height: 70%; }
.cl-k-new { background: var(--link); }
.cl-k-improved { background: var(--bronze); }
.cl-k-fix { background: var(--line-c); }
.cl-k-balance { background: var(--gold); color: var(--wood-2); }
.cl-k-tech { background: var(--ink-soft); }
.cl-k-removed { background: var(--heading); }
.cl-leg { display: flex; flex-wrap: wrap; gap: 14px; margin: 12px 0 0; font-size: 12px; color: var(--ink-soft); }
.cl-leg .cl-k { margin-right: 5px; width: 16px; height: 16px; }
.cl-leg span { display: inline-flex; align-items: center; }
.cl-bar { display: flex; gap: 8px; justify-content: flex-end; margin-top: 10px; }
.cl-bar.left { justify-content: flex-start; }
.cl-ib { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; padding: 0; border: 1px solid var(--line); border-radius: 7px; background: var(--parch-2); color: var(--ink); cursor: pointer; }
.cl-ib svg { width: 16px; height: 16px; }
.cl-ib:hover, .cl-ib:focus-visible { border-color: var(--gold); outline: none; }
.cl-ib.r { color: var(--heading); }
.cl-pop { width: min(92vw, 28rem); padding: 14px 16px; border: 3px solid var(--wood-1); border-radius: 12px; background: var(--parch); color: var(--ink); }
.cl-pop::backdrop { background: rgba(4, 6, 10, 0.5); }
.cl-pop label { display: block; margin: 0 0 8px; color: var(--ink-soft); font-size: 12px; font-weight: bold; }
.cl-pop input, .cl-pop select, .cl-pop textarea { display: block; box-sizing: border-box; width: 100%; margin-top: 3px; padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--card); color: var(--ink); font: 14px var(--font); user-select: text; }
.cl-pop p { margin: 0 0 6px; font-size: 14px; }
.cl-err { color: var(--heading); font-weight: bold; }
.cl-badge { position: absolute; top: -7px; right: -7px; min-width: 16px; height: 16px; padding: 0 4px; box-sizing: border-box; border-radius: 8px; background: var(--line-c); color: var(--card); font: bold 11px/16px var(--font); font-style: normal; text-align: center; pointer-events: none; box-shadow: 0 0 0 1.5px var(--wood-2); }
.cl-badge[hidden], .cl-bd[hidden] { display: none; }
.cl-bd { display: inline-block; margin-left: 6px; min-width: 16px; padding: 0 5px; box-sizing: border-box; border-radius: 8px; background: var(--line-c); color: var(--card); font: bold 11px/16px var(--font); font-style: normal; text-align: center; }
.cl-new { border-left: 3px solid var(--gold); }
.cl-nw { padding: 0 6px; border-radius: 8px; background: var(--gold); color: var(--wood-2); font-size: 11px; font-weight: bold; text-transform: uppercase; letter-spacing: 0.04em; }
