:root {
  --parchment: #f3e8d0;
  --parchment-dark: #e6d5b0;
  --ink: #3a2816;
  --ink-soft: #6b5235;
  --accent: #8e2f1c;
  --gold: #b8892f;
  --gold-text: #7d5a1c; /* gold for text: 5:1 on parchment */
  --item-h: 52px;
  --panel-w: clamp(280px, 30vw, 360px);
  --shadow: 0 10px 30px rgba(40, 25, 10, 0.35);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font-family: "EB Garamond", Georgia, serif;
  color: var(--ink);
  background: #cdbb94;
}

#map {
  position: fixed;
  inset: 0;
  background: #b9cfd6;
}

.leaflet-tile-pane {
  filter: sepia(0.5) saturate(0.75) brightness(1.04) contrast(0.95);
}

.leaflet-container {
  font-family: inherit;
}

.leaflet-interactive:focus,
.leaflet-container:focus,
:focus:not(:focus-visible) {
  outline: none;
}

/* ---------- Territories ---------- */

.realm {
  transition:
    fill-opacity 0.25s ease,
    stroke-width 0.25s ease;
  animation: realm-in 0.6s ease both;
}

/* Ink-bleed reveal (ink.js): the mask does the reveal, so no opacity fade-in. */
.ink-svg .realm:not(.fading) {
  animation: none;
}
.ink-cover {
  position: absolute;
  inset: 0;
  z-index: 1000;
  pointer-events: none;
}

.realm.fading {
  animation: realm-out 0.5s ease both;
  pointer-events: none;
}

@keyframes realm-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
@keyframes realm-out {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

.realm-flash {
  animation: flash 1.2s ease 2;
}
@keyframes flash {
  50% {
    fill-opacity: 0.9;
    stroke-width: 4;
  }
}

/* ---------- Labels ---------- */

.realm-label {
  background: none;
  border: none;
  pointer-events: none;
  animation: realm-in 0.6s ease both;
}

.realm-label.fading {
  animation: realm-out 0.4s ease both;
}

.realm-label span {
  display: block;
  transform: translate(-50%, -50%);
  width: max-content;
  max-width: 180px;
  text-align: center;
  line-height: 1.05;
  font-family: "Cinzel", serif;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #24160a;
  paint-order: stroke fill;
  -webkit-text-stroke: 3px rgba(255, 248, 230, 0.92);
  text-shadow: 0 0 6px rgba(255, 248, 230, 0.7);
  transition: opacity 0.2s ease;
}

.realm-label.xl span {
  font-size: 17px;
  max-width: 240px;
  letter-spacing: 0.08em;
}
.realm-label.lg span {
  font-size: 13.5px;
  max-width: 160px;
}
.realm-label.md span {
  font-size: 11.5px;
  max-width: 130px;
}
.realm-label.sm span {
  font-size: 10.5px;
  max-width: 110px;
  letter-spacing: 0.03em;
}

.declutter-hidden {
  opacity: 0 !important;
}
.realm-label.minor span {
  font-family: "EB Garamond", serif;
  font-style: italic;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0.02em;
  color: #5d4a33;
  font-size: 13px;
}

/* Hide the smallest labels when zoomed out, to avoid clutter. */
.zoom-low .realm-label.sm,
.zoom-low .realm-label.minor.md,
.zoom-low .realm-label.minor.sm {
  display: none;
}
.zoom-mid .realm-label.minor.sm {
  display: none;
}

/* ---------- Israelite population ---------- */

.people-path {
  animation:
    realm-in 0.6s ease both,
    dash-flow 1s linear infinite;
}
.people-path.fading {
  animation: realm-out 0.5s ease both;
}
@keyframes dash-flow {
  to {
    stroke-dashoffset: -20;
  }
}

.realm-label.people-label span {
  font-family: "EB Garamond", serif;
  font-style: italic;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0.01em;
  color: #173b80;
  font-size: 13.5px;
  max-width: 170px;
}
.realm-label.people-label.route span {
  font-size: 12.5px;
  font-weight: 500;
  color: #2a4f96;
}

.people-dot {
  display: inline-block;
  flex: none;
  width: 9px;
  height: 9px;
  margin: 0 2px;
  border-radius: 50%;
  background: #1c48a0;
  border: 1.5px solid #fffaeb;
  box-shadow: 0 0 0 3px rgba(70, 130, 230, 0.2);
  vertical-align: middle;
}

.people-note {
  margin: 0 0 6px;
  font-size: 15.5px;
  line-height: 1.35;
}

.people-groups {
  list-style: none;
  margin: 0;
  padding: 0;
}
.people-groups li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 0;
  font-size: 15px;
  font-style: italic;
  color: #173b80;
}

/* ---------- Cities ---------- */

.city-marker {
  background: none;
  border: none;
}
.city-marker .dot {
  position: absolute;
  left: -4px;
  top: -4px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #2c1c0c;
  border: 1.5px solid #fff6e0;
  box-shadow: 0 0 0 1px rgba(44, 28, 12, 0.4);
}
.city-marker .name {
  position: absolute;
  left: 7px;
  top: -9px;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 600;
  font-style: italic;
  color: #1f140a;
  paint-order: stroke fill;
  -webkit-text-stroke: 3px rgba(255, 248, 230, 0.95);
  transition: opacity 0.2s ease;
}
.zoom-low .city-marker.minor-city {
  display: none;
}

.leaflet-tooltip.realm-tip {
  background: var(--parchment);
  border: 1px solid var(--gold);
  color: var(--ink);
  font-family: "EB Garamond", serif;
  font-size: 15px;
  padding: 4px 10px;
  box-shadow: var(--shadow);
}
.realm-tip small {
  display: block;
  color: var(--ink-soft);
  font-style: italic;
}

/* ---------- Side panel ---------- */

.panel {
  position: fixed;
  top: 16px;
  left: 16px;
  bottom: 16px;
  width: var(--panel-w);
  transition: transform 0.35s ease;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(ellipse at top left, rgba(255, 255, 255, 0.5), transparent 60%),
    radial-gradient(ellipse at bottom right, rgba(160, 120, 60, 0.18), transparent 60%), var(--parchment);
  border: 1px solid rgba(120, 85, 40, 0.45);
  border-radius: 6px;
  box-shadow:
    var(--shadow),
    inset 0 0 40px rgba(150, 110, 50, 0.18);
  z-index: 1000;
  overflow: hidden;
}

.panel-header {
  position: relative;
  padding: 20px 24px 14px;
  border-bottom: 1px solid rgba(120, 85, 40, 0.3);
}

.eyebrow {
  margin: 0;
  font-family: "Cinzel", serif;
  font-size: 11px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--gold-text);
}

.panel h1 {
  margin: 4px 0 0;
  font-family: "Cinzel", serif;
  font-size: 40px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.05;
}

.panel h2 {
  margin: 2px 0 0;
  font-size: 21px;
  font-weight: 500;
  font-style: italic;
}

.panel-toggle {
  display: none;
}

body.panel-hidden .panel {
  transform: translateX(calc(-100% - 20px));
}

.panel-collapse {
  position: fixed;
  top: 28px;
  left: calc(16px + var(--panel-w));
  z-index: 1001;
  width: 26px;
  height: 52px;
  padding: 0;
  border: 1px solid rgba(120, 85, 40, 0.45);
  border-left: none;
  border-radius: 0 6px 6px 0;
  background: var(--parchment);
  box-shadow: 4px 4px 12px rgba(40, 25, 10, 0.25);
  cursor: pointer;
  transition:
    left 0.35s ease,
    background 0.2s;
}
.panel-collapse:hover {
  background: #fbf3e0;
}
.panel-collapse span {
  display: block;
  width: 9px;
  height: 9px;
  margin-left: 7px;
  border-left: 2px solid var(--ink);
  border-bottom: 2px solid var(--ink);
  transform: rotate(45deg);
  transition: transform 0.35s ease;
}
body.panel-hidden .panel-collapse {
  left: 0;
}
body.panel-hidden .panel-collapse span {
  transform: translateX(-3px) rotate(-135deg);
}

.panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px 24px 20px;
}

.summary {
  margin: 0 0 6px;
  font-size: 17px;
  line-height: 1.4;
}

.panel h3 {
  margin: 18px 0 8px;
  font-family: "Cinzel", serif;
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-soft);
  display: flex;
  align-items: center;
  gap: 10px;
}
.panel h3::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(to right, rgba(120, 85, 40, 0.4), transparent);
}

.events {
  list-style: none;
  margin: 0;
  padding: 0;
}
.events li {
  position: relative;
  padding: 0 0 10px 18px;
  font-size: 15.5px;
  line-height: 1.35;
}
.events li::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 7px;
  width: 7px;
  height: 7px;
  transform: rotate(45deg);
  background: var(--gold);
}
.events .date {
  font-weight: 600;
  color: var(--accent);
}
.events .ref {
  display: block;
  font-size: 13.5px;
  font-style: italic;
  color: var(--ink-soft);
}

.changes {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chip {
  font-size: 13.5px;
  padding: 2px 9px;
  border-radius: 999px;
  border: 1px solid;
}
.chip.added {
  color: #2f5e22;
  border-color: rgba(47, 94, 34, 0.45);
  background: rgba(90, 150, 60, 0.12);
}
.chip.removed {
  color: #7a2a1a;
  border-color: rgba(122, 42, 26, 0.4);
  background: rgba(160, 60, 40, 0.08);
  text-decoration: line-through;
}
.changes .none {
  font-style: italic;
  color: var(--ink-soft);
  font-size: 15px;
}

.realms {
  list-style: none;
  margin: 0;
  padding: 0;
}
.realms li {
  list-style: none;
}
.realms .realm-btn {
  width: calc(100% + 12px);
  font: inherit;
  color: inherit;
  text-align: left;
  background: none;
  border: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 6px;
  margin: 0 -6px;
  border-radius: 4px;
  font-size: 16px;
  cursor: pointer;
}
.realms .realm-btn:hover {
  background: rgba(160, 120, 60, 0.15);
}
.realms .swatch {
  flex: none;
  width: 14px;
  height: 14px;
  border-radius: 3px;
  border: 1px solid rgba(0, 0, 0, 0.25);
}
.realms .new-badge {
  margin-left: auto;
  font-size: 11px;
  font-family: "Cinzel", serif;
  letter-spacing: 0.1em;
  color: #2f5e22;
}
.realms.minor li {
  font-size: 14.5px;
  font-style: italic;
}

.minor-peoples summary {
  margin-top: 8px;
  cursor: pointer;
  font-size: 15px;
  color: var(--ink-soft);
}

.toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 18px;
  font-size: 15.5px;
  cursor: pointer;
}
.toggle input {
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
}

.credits {
  margin-top: 18px;
  font-size: 12.5px;
  line-height: 1.4;
  color: var(--ink-soft);
}
.credits a {
  color: var(--accent);
}

/* ---------- Books of the Bible ---------- */

.book-picker {
  position: fixed;
  top: 14px;
  left: calc(50% + (var(--panel-w) + 16px - 170px) / 2);
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px 6px 14px;
  background: var(--parchment);
  border: 1px solid rgba(120, 85, 40, 0.5);
  border-radius: 999px;
  box-shadow: 0 6px 18px rgba(40, 25, 10, 0.3);
  transition: left 0.35s ease;
}
body.panel-hidden .book-picker {
  left: 50%;
}

.book-picker label {
  font-family: "Cinzel", serif;
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--gold-text);
}

.book-picker select {
  appearance: none;
  -webkit-appearance: none;
  min-width: 230px;
  padding: 5px 30px 5px 12px;
  border: 1px solid rgba(120, 85, 40, 0.4);
  border-radius: 999px;
  background:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6'><path d='M0 0l5 6 5-6z' fill='%233a2816'/></svg>")
      no-repeat right 12px center,
    #fbf3e0;
  font-family: "EB Garamond", serif;
  font-size: 16px;
  color: var(--ink);
  cursor: pointer;
}
.book-picker select:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 1px;
}

.book-card {
  margin: 0 -8px 14px;
  padding: 10px 12px 12px;
  border: 1px solid rgba(184, 137, 47, 0.6);
  border-radius: 6px;
  background: linear-gradient(rgba(255, 246, 220, 0.9), rgba(246, 230, 190, 0.6));
  box-shadow: inset 0 0 0 3px rgba(255, 250, 235, 0.6);
}
.book-card[hidden] {
  display: none;
}
.book-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.book-clear {
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 50%;
  background: none;
  font-size: 20px;
  line-height: 1;
  color: var(--ink-soft);
  cursor: pointer;
}
.book-clear:hover {
  background: rgba(160, 120, 60, 0.15);
  color: var(--ink);
}
.panel .book-title {
  margin: 0;
  font-family: "Cinzel", serif;
  font-size: 22px;
  letter-spacing: 0.02em;
  text-transform: none;
  color: var(--accent);
  display: block;
}
.panel .book-title::after {
  display: none;
}
.book-period {
  margin: 2px 0 6px;
  font-size: 14px;
  font-style: italic;
  color: var(--ink-soft);
}
.book-summary {
  margin: 0 0 8px;
  font-size: 16px;
  line-height: 1.35;
}
.book-places {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chip.book-chip {
  font: inherit;
  font-size: 13.5px;
  color: #6b4a12;
  border-color: rgba(184, 137, 47, 0.7);
  background: rgba(212, 160, 58, 0.15);
  cursor: pointer;
}
.chip.book-chip:hover {
  background: rgba(212, 160, 58, 0.3);
}

.book-marker {
  background: none;
  border: none;
}
.book-marker .book-pin {
  position: absolute;
  left: -7px;
  top: -7px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #ffe7a3, #c8901f 70%);
  border: 2px solid #fff8e6;
  box-shadow:
    0 0 0 1.5px #7a5410,
    0 2px 6px rgba(40, 25, 10, 0.45);
}
.book-marker .book-pin::after {
  content: "";
  position: absolute;
  inset: -9px;
  border-radius: 50%;
  border: 2px solid rgba(200, 144, 31, 0.8);
  animation: book-pulse 1.8s ease-out infinite;
}
@keyframes book-pulse {
  from {
    transform: scale(0.4);
    opacity: 1;
  }
  to {
    transform: scale(1.4);
    opacity: 0;
  }
}
.book-marker .name {
  position: absolute;
  left: 11px;
  top: -11px;
  white-space: nowrap;
  font-family: "EB Garamond", serif;
  font-size: 15px;
  font-weight: 700;
  color: #4a3208;
  paint-order: stroke fill;
  -webkit-text-stroke: 3.5px rgba(255, 248, 230, 0.95);
  transition: opacity 0.2s ease;
}

/* ---------- Year wheel ---------- */

.wheel {
  position: fixed;
  right: 18px;
  top: 50%;
  transform: translateY(-50%);
  width: 150px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  z-index: 1000;
}

.wheel-window {
  position: relative;
  height: min(62vh, calc(var(--item-h) * 9));
  border-radius: 75px / 26px;
  background:
    linear-gradient(to right, rgba(0, 0, 0, 0.12), transparent 18%, transparent 82%, rgba(0, 0, 0, 0.12)),
    linear-gradient(#e9dab8, var(--parchment) 50%, #e9dab8);
  border: 1px solid rgba(120, 85, 40, 0.55);
  box-shadow:
    var(--shadow),
    inset 0 0 18px rgba(110, 75, 30, 0.35);
  overflow: hidden;
}

/* Fade the drum toward the top and bottom edges. */
.wheel-window::before,
.wheel-window::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 32%;
  z-index: 2;
  pointer-events: none;
}
.wheel-window::before {
  top: 0;
  background: linear-gradient(var(--parchment-dark), rgba(230, 213, 176, 0));
}
.wheel-window::after {
  bottom: 0;
  background: linear-gradient(rgba(230, 213, 176, 0), var(--parchment-dark));
}

.wheel-highlight {
  position: absolute;
  left: 8px;
  right: 8px;
  top: 50%;
  height: var(--item-h);
  transform: translateY(-50%);
  border-top: 2px solid var(--gold);
  border-bottom: 2px solid var(--gold);
  background: rgba(184, 137, 47, 0.12);
  pointer-events: none;
  z-index: 1;
}

.wheel-scroller {
  position: relative;
  height: 100%;
  overflow-y: scroll;
  scroll-snap-type: y mandatory;
  scrollbar-width: none;
  perspective: 600px;
  outline: none;
  cursor: grab;
  touch-action: pan-y;
}
.wheel-scroller::-webkit-scrollbar {
  display: none;
}
.wheel-scroller.dragging {
  scroll-snap-type: none;
  cursor: grabbing;
}

.wheel-pad {
  height: calc(50% - var(--item-h) / 2);
}

.wheel-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: var(--item-h);
  padding: 0;
  border: none;
  background: none;
  scroll-snap-align: center;
  font: inherit;
  color: var(--ink);
  cursor: pointer;
  transform-origin: center center;
  will-change: transform, opacity;
  user-select: none;
}
.wheel-item .y {
  font-family: "Cinzel", serif;
  font-weight: 700;
  font-size: 19px;
  line-height: 1.1;
}
.wheel-item .t {
  font-size: 12px;
  font-style: italic;
  color: var(--ink-soft);
  max-width: 130px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.wheel-item.active .y {
  color: var(--accent);
}

.wheel-step,
.wheel-play {
  border: 1px solid rgba(120, 85, 40, 0.55);
  background: var(--parchment);
  color: var(--ink);
  border-radius: 6px;
  font-family: "Cinzel", serif;
  font-size: 13px;
  padding: 5px 0;
  cursor: pointer;
  box-shadow: 0 3px 10px rgba(40, 25, 10, 0.25);
}
.wheel-step:hover,
.wheel-play:hover {
  background: #fbf3e0;
}
.wheel-play.playing {
  background: var(--accent);
  color: #fbf3e0;
  border-color: var(--accent);
}

.leaflet-control-zoom {
  margin-right: 186px !important;
}
.leaflet-control-attribution {
  font-size: 10px;
}

/* ---------- Small screens ---------- */

/* ---------- Powers: who rules, strip, cards, arrows ---------- */

.realm.sphere {
  animation:
    realm-in 0.6s ease both,
    sphere-pulse 3.5s ease-in-out 0.6s 2;
}
@keyframes sphere-pulse {
  50% {
    stroke-opacity: 0.55;
  }
}

.era-arrow {
  animation: arrow-in 0.9s ease-out both;
}
.era-arrow.arrow-exile,
.era-arrow.arrow-vassal,
.era-arrow.arrow-return,
.era-arrow.arrow-campaign {
  animation:
    arrow-in 0.9s ease-out both,
    dash-flow 1.6s linear infinite;
}
.era-arrow.fading {
  animation: realm-out 0.4s ease both;
}
@keyframes arrow-in {
  from {
    opacity: 0;
    stroke-width: 0;
  }
}
.realm-label.arrow-label span {
  font-family: "EB Garamond", serif;
  font-style: italic;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  color: #4a1a0c;
  white-space: nowrap;
}
.realm-label.arrow-label-exile span {
  color: #1d255a;
}
.realm-label.arrow-label-return span {
  color: #24521f;
}

.who-rules {
  position: fixed;
  top: 66px;
  left: calc(50% + (var(--panel-w) + 16px - 170px) / 2);
  transform: translateX(-50%);
  z-index: 999;
  max-width: min(560px, calc(100vw - var(--panel-w) - 240px));
  transition: left 0.35s ease;
}
body.panel-hidden .who-rules {
  left: 50%;
}
.who-rules[hidden] {
  display: none;
}
.wr-main {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
  gap: 2px 10px;
  width: 100%;
  padding: 6px 16px;
  font: inherit;
  color: var(--ink);
  text-align: center;
  background: rgba(243, 232, 208, 0.96);
  border: 1px solid rgba(120, 85, 40, 0.5);
  border-radius: 14px;
  box-shadow: 0 6px 18px rgba(40, 25, 10, 0.28);
  cursor: pointer;
}
.wr-main:hover,
.wr-main[aria-expanded="true"] {
  background: #f8f0dc;
}
.wr-main:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.wr-q {
  font-family: "Cinzel", serif;
  font-size: 10.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.wr-now {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 16px;
  font-weight: 600;
}
.wr-swatches {
  display: inline-flex;
  gap: 2px;
}
.wr-swatches .swatch,
.pc-power .swatch {
  display: inline-block;
  width: 11px;
  height: 11px;
  border-radius: 2px;
  border: 1px solid rgba(58, 40, 22, 0.5);
}
.wr-status {
  font-size: 12px;
  padding: 1px 8px;
  border-radius: 999px;
  background: #e9dcc0;
  color: #4a3519;
  border: 1px solid rgba(120, 85, 40, 0.35);
}
.wr-status.st-independent {
  background: #dfe9cf;
  color: #2c4a18;
}
.wr-status.st-vassal {
  background: #f3dcc1;
  color: #6b3410;
}
.wr-status.st-province {
  background: #ecd2cc;
  color: #6e1f16;
}
.wr-detail {
  margin-top: 6px;
  padding: 10px 14px;
  font-size: 15px;
  line-height: 1.4;
  background: var(--parchment);
  border: 1px solid rgba(120, 85, 40, 0.45);
  border-radius: 10px;
  box-shadow: 0 6px 18px rgba(40, 25, 10, 0.28);
}
.wr-detail p {
  margin: 0;
}
.wr-detail p + p {
  margin-top: 6px;
}
.who-rules.changed .wr-main {
  animation: ruler-change 1.4s ease;
}
@keyframes ruler-change {
  0% {
    box-shadow: 0 0 0 0 rgba(142, 47, 28, 0.7);
    transform: scale(1);
  }
  25% {
    transform: scale(1.04);
  }
  100% {
    box-shadow: 0 0 0 14px rgba(142, 47, 28, 0);
    transform: scale(1);
  }
}

.contested {
  display: inline-block;
  margin-left: 4px;
  padding: 0 6px;
  font-family: "Cinzel", serif;
  font-size: 9.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #6b2a10;
  background: #f4dfc6;
  border: 1px dashed #a4532c;
  border-radius: 3px;
  vertical-align: 1px;
}
.contested-text {
  display: block;
  margin-top: 2px;
  font-size: 13.5px;
  font-style: italic;
  color: var(--ink-soft);
}

.power-strip {
  position: fixed;
  left: calc(var(--panel-w) + 48px);
  right: 190px;
  bottom: 24px;
  z-index: 998;
  padding: 6px 12px 4px;
  background: rgba(243, 232, 208, 0.94);
  border: 1px solid rgba(120, 85, 40, 0.45);
  border-radius: 8px;
  box-shadow: 0 6px 18px rgba(40, 25, 10, 0.25);
  transition: left 0.35s ease;
}
body.panel-hidden .power-strip {
  left: 20px;
}
.ps-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 3px;
}
.ps-title {
  font-family: "Cinzel", serif;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
}
.ps-hint {
  font-size: 12px;
  font-style: italic;
  color: var(--ink-soft);
}
.ps-chart {
  position: relative;
  padding-bottom: 16px;
}
.ps-row {
  position: relative;
  height: 17px;
  margin-bottom: 2px;
}
.ps-bar {
  position: absolute;
  top: 0;
  height: 100%;
  min-width: 6px;
  padding: 0 4px;
  overflow: hidden;
  font:
    600 11.5px/17px "EB Garamond",
    serif;
  color: #241606;
  text-align: left;
  white-space: nowrap;
  background: color-mix(in srgb, var(--c) 55%, #f3e8d0);
  border: 1px solid color-mix(in srgb, var(--c) 70%, #000);
  border-radius: 3px;
  cursor: pointer;
  opacity: 0.75;
  transition:
    opacity 0.3s,
    background 0.3s,
    box-shadow 0.3s;
}
.ps-bar.on {
  opacity: 1;
  background: color-mix(in srgb, var(--c) 80%, #fff);
  color: var(--fg-on, #241606);
  box-shadow: 0 0 0 1.5px #3a2816;
}
.ps-bar:hover,
.ps-bar:focus-visible {
  opacity: 1;
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  z-index: 2;
}
.ps-eras {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 12px;
  height: 0;
}
.ps-era {
  position: absolute;
  top: -4px;
  width: 9px;
  height: 9px;
  margin-left: -4.5px;
  padding: 0;
  border-radius: 50%;
  background: #f3e8d0;
  border: 1.5px solid #6b5235;
  cursor: pointer;
}
.ps-era.active {
  background: var(--accent);
  border-color: var(--accent);
}
.ps-era:hover,
.ps-era:focus-visible {
  transform: scale(1.4);
  outline: none;
  background: var(--gold);
}
.ps-cursor {
  position: absolute;
  top: -2px;
  bottom: 12px;
  width: 2px;
  margin-left: -1px;
  background: var(--accent);
  pointer-events: none;
  transition: left 0.45s ease;
}
.ps-axis {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -2px;
  height: 12px;
  font-size: 11px;
  color: var(--ink-soft);
}
.ps-axis span {
  position: absolute;
  transform: translateX(-50%);
  white-space: nowrap;
}

.leaflet-popup.power-popup .leaflet-popup-content-wrapper {
  background: var(--parchment);
  color: var(--ink);
  border: 1px solid rgba(120, 85, 40, 0.5);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.leaflet-popup.power-popup .leaflet-popup-tip {
  background: var(--parchment);
}
.leaflet-popup.power-popup .leaflet-popup-content {
  margin: 12px 16px;
  font-family: "EB Garamond", serif;
  font-size: 15px;
  line-height: 1.38;
}
.power-card {
  border-left: 4px solid var(--pc, #8f7a5a);
  padding-left: 10px;
}
.power-card h4 {
  margin: 0 0 2px;
  font-family: "Cinzel", serif;
  font-size: 16px;
  color: var(--accent);
}
.power-card p {
  margin: 4px 0;
}
.pc-power {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
}
.pc-status {
  font-style: italic;
  color: #6b3410;
}
.power-card dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 1px 10px;
  margin: 6px 0;
}
.power-card dt {
  font-family: "Cinzel", serif;
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
  padding-top: 3px;
}
.power-card dd {
  margin: 0;
}
.pc-conf {
  font-size: 13.5px;
  color: var(--ink-soft);
  border-top: 1px dashed rgba(120, 85, 40, 0.4);
  padding-top: 5px;
}
.pc-conf span {
  font-family: "Cinzel", serif;
  font-size: 9.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0 5px;
  border-radius: 3px;
  background: #efe2c8;
  color: #6b2a10;
}

.cause-effect {
  list-style: none;
  margin: 0 0 8px;
  padding: 0;
}
.cause-effect li {
  display: block;
  padding: 6px 0;
  font-size: 14.5px;
  line-height: 1.3;
  border-bottom: 1px dotted rgba(120, 85, 40, 0.35);
}
.cause-effect .cause {
  display: block;
  color: var(--ink-soft);
}
.cause-effect .arrow {
  color: var(--accent);
  font-weight: 700;
  margin-right: 4px;
}
.cause-effect .effect {
  font-weight: 600;
}

.scholar-note {
  margin: 6px 0;
  padding: 6px 10px;
  font-size: 14.5px;
  background: rgba(255, 250, 238, 0.6);
  border-left: 3px solid var(--gold);
  border-radius: 0 4px 4px 0;
}
.scholar-note summary {
  cursor: pointer;
  font-weight: 600;
}
.scholar-note p {
  margin: 6px 0 2px;
  line-height: 1.4;
}
.sn-tag {
  font-family: "Cinzel", serif;
  font-size: 9.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #6b4a12;
}

.map-key {
  margin: 10px 0;
}
.map-key summary {
  cursor: pointer;
  font-family: "Cinzel", serif;
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}
.legend {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  font-size: 14px;
}
.legend li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 0;
}
.lg-box {
  display: inline-block;
  width: 22px;
  height: 14px;
}
.lg-box.sphere {
  background: rgba(226, 118, 47, 0.15);
  border: 2px dashed #b05a20;
}
.strip-slot:empty {
  display: none;
}

@media (max-width: 760px) {
  .who-rules,
  body.panel-hidden .who-rules {
    top: 60px;
    left: 8px;
    transform: none;
    max-width: calc(100vw - 136px);
  }
  .wr-main {
    justify-content: flex-start;
    text-align: left;
    padding: 5px 10px;
    gap: 1px 6px;
  }
  .wr-q {
    font-size: 9.5px;
    width: 100%;
  }
  .wr-now {
    font-size: 14px;
  }
  .wr-status {
    font-size: 11px;
  }
  .strip-slot .power-strip {
    position: static;
    margin: 4px 0 10px;
    padding: 6px 4px 2px;
    box-shadow: none;
    background: rgba(255, 250, 238, 0.5);
  }
  .ps-hint {
    font-size: 11px;
  }

  :root {
    --item-h: 44px;
  }

  .panel {
    top: auto;
    left: 8px;
    right: 8px;
    bottom: 8px;
    width: auto;
    max-height: 45vh;
  }
  .panel.collapsed .panel-body {
    display: none;
  }
  .panel-collapse {
    display: none;
  }
  .book-picker,
  body.panel-hidden .book-picker {
    left: 8px;
    transform: none;
    top: 12px;
    padding: 4px 6px 4px 10px;
  }
  .book-picker select {
    min-width: 0;
    width: 46vw;
    font-size: 15px;
  }
  body.panel-hidden .panel {
    transform: none;
  }
  .panel-header {
    padding: 12px 56px 10px 16px;
  }
  .panel h1 {
    font-size: 28px;
  }
  .panel h2 {
    font-size: 17px;
  }
  .panel-body {
    padding: 10px 16px 16px;
  }
  .panel-toggle {
    display: block;
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid rgba(120, 85, 40, 0.5);
    background: var(--parchment-dark);
    cursor: pointer;
  }
  .panel-toggle span {
    display: block;
    width: 10px;
    height: 10px;
    margin: 0 auto;
    border-right: 2px solid var(--ink);
    border-bottom: 2px solid var(--ink);
    transform: translateY(-2px) rotate(45deg);
    transition: transform 0.2s;
  }
  .panel.collapsed .panel-toggle span {
    transform: translateY(2px) rotate(-135deg);
  }

  .wheel {
    top: 12px;
    right: 8px;
    transform: none;
    width: 112px;
  }
  .wheel-window {
    height: calc(var(--item-h) * 5);
  }
  .wheel-item .y {
    font-size: 16px;
  }
  .wheel-item .t {
    display: none;
  }
  .leaflet-control-zoom {
    display: none;
  }
}

/* ---------- Book context ---------- */

.book-context {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(120, 85, 40, 0.3);
}
.bc-head {
  margin: 0 0 6px;
  font-family: "Cinzel", serif;
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
}
.bc-facts {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 10px;
  margin: 0 0 8px;
  font-size: 15px;
  line-height: 1.35;
}
.bc-facts dt {
  font-family: "Cinzel", serif;
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
  padding-top: 3px;
}
.bc-facts dd {
  margin: 0;
}
.bc-fact-note,
.bc-note {
  display: block;
  margin-top: 2px;
  font-size: 13.5px;
  font-style: italic;
  color: var(--ink-soft);
}
.bc-label {
  margin: 8px 0 4px;
  font-family: "Cinzel", serif;
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.bc-empires,
.bc-eras {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.bc-power .swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 5px;
  border-radius: 2px;
  border: 1px solid rgba(58, 40, 22, 0.5);
}
.bc-politics {
  margin: 8px 0;
  font-size: 15px;
  line-height: 1.4;
}
.bc-era {
  text-align: left;
}
.bc-era strong {
  color: var(--accent);
}
.bc-era.on {
  background: #f3dcc1;
  border-color: var(--accent);
}
.bc-chapters {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}
.bc-chapters .bc-label {
  margin: 0;
}
.bc-chapters select {
  font: inherit;
  font-size: 15px;
  padding: 3px 6px;
  color: var(--ink);
  background: #fffaf0;
  border: 1px solid rgba(120, 85, 40, 0.5);
  border-radius: 6px;
}
.bc-sections {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
}
.bc-sec {
  display: flex;
  gap: 8px;
  width: 100%;
  padding: 4px 6px;
  font: inherit;
  font-size: 15px;
  text-align: left;
  color: var(--ink);
  background: none;
  border: 0;
  border-radius: 4px;
  cursor: pointer;
}
.bc-sec:hover,
.bc-sec:focus-visible {
  background: rgba(255, 250, 238, 0.8);
  outline: 1px solid rgba(120, 85, 40, 0.4);
}
.bc-sec.on {
  background: #f3dcc1;
  font-weight: 600;
}
.bc-sec-ch {
  flex: 0 0 48px;
  font-family: "Cinzel", serif;
  font-size: 12px;
  padding-top: 2px;
  color: var(--accent);
}
.bc-coverage {
  margin: 4px 0;
  font-size: 13px;
  font-style: italic;
  color: var(--ink-soft);
}
.bc-section {
  margin: 8px 0;
  padding: 8px 12px;
  background: rgba(255, 250, 238, 0.7);
  border-left: 3px solid var(--accent);
  border-radius: 0 6px 6px 0;
  animation: realm-in 0.4s ease both;
}
.bc-section h4 {
  margin: 0 0 4px;
  font-size: 17px;
}
.bc-section p {
  margin: 0 0 4px;
  font-size: 15px;
  line-height: 1.4;
}
.bc-sec-range {
  font-family: "Cinzel", serif;
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.bc-ew {
  margin: 10px 0 0;
  padding-top: 8px;
  font-size: 14.5px;
  border-top: 1px dotted rgba(120, 85, 40, 0.4);
}
.bc-ew .ew-ch {
  display: block;
  font-size: 13px;
  color: var(--ink-soft);
}
.bc-ew a {
  font-weight: 600;
  color: var(--accent);
}
.bc-ew small {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  color: var(--ink-soft);
}
.chip.bc-power,
.chip.bc-era {
  font: inherit;
  font-size: 13.5px;
  color: var(--ink);
  border-color: rgba(120, 85, 40, 0.45);
  background: rgba(255, 250, 238, 0.7);
  cursor: pointer;
}
.chip.bc-power {
  border-color: color-mix(in srgb, var(--c) 70%, #000);
}
.chip.bc-power:hover,
.chip.bc-era:hover,
.chip.bc-power:focus-visible,
.chip.bc-era:focus-visible {
  background: #fff6e4;
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.bc-section .bc-sec-range {
  margin: 0 0 2px;
  font-size: 10.5px;
}

/* ---------- Journeys ---------- */
.journey-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.chip.journey-chip,
.chip.bc-journey {
  cursor: pointer;
  font: inherit;
  font-size: 13.5px;
  color: var(--ink);
  background: #fbf4e4;
  border: 1px solid rgba(122, 46, 28, 0.35);
}
.chip.journey-chip span {
  color: var(--ink-soft);
  font-size: 12px;
}
.chip.journey-chip[aria-pressed="true"] {
  background: #7a2e1c;
  border-color: #7a2e1c;
  color: #fff8ea;
}
.chip.journey-chip[aria-pressed="true"] span {
  color: #f3dcc4;
}
.chip.journey-chip:hover,
.chip.bc-journey:hover {
  border-color: #7a2e1c;
}
.chip.journey-chip:focus-visible,
.chip.bc-journey:focus-visible,
.js-stop:focus-visible,
.cc-link:focus-visible,
.realms .realm-btn:focus-visible,
.leaflet-marker-icon:focus-visible {
  outline: 2px solid #7a2e1c;
  outline-offset: 2px;
}
.journey-card {
  margin: 0 0 10px;
  padding: 10px 12px;
  background: #fffaf0;
  border: 1px solid rgba(122, 46, 28, 0.3);
  border-left: 4px solid #7a2e1c;
  border-radius: 6px;
}
.jc-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}
.journey-card h4 {
  margin: 0;
  font-family: "Cinzel", serif;
  font-size: 15px;
  color: #7a2e1c;
}
.journey-card p {
  margin: 4px 0;
  font-size: 14.5px;
  line-height: 1.4;
}
.jc-meta {
  font-style: italic;
  color: var(--ink-soft);
  font-size: 13px !important;
}
.jc-stops {
  list-style: none;
  margin: 8px 0 4px;
  padding: 0;
}
.js-stop {
  display: block;
  width: 100%;
  text-align: left;
  font: inherit;
  font-size: 14px;
  line-height: 1.35;
  color: var(--ink);
  background: none;
  border: 0;
  border-radius: 4px;
  padding: 3px 4px;
  cursor: pointer;
}
.js-stop:hover,
.js-stop.on {
  background: #f4e4c8;
}
.js-stop .n {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  margin-right: 2px;
  border-radius: 50%;
  background: #7a2e1c;
  color: #fff;
  font-size: 11px;
  font-family: "Cinzel", serif;
}
.js-stop.uncertain .n {
  background: #fff;
  color: #7a2e1c;
  border: 1.5px dashed #7a2e1c;
}
.jc-key {
  font-size: 12.5px !important;
  color: var(--ink-soft);
}
.jk-solid,
.jk-dash {
  display: inline-block;
  width: 22px;
  margin: 0 2px 3px 6px;
  border-top: 3px solid #7a2e1c;
}
.jk-dash {
  border-top-style: dotted;
}

.journey-casing {
  animation: realm-in 0.4s ease both;
}
.journey-seg:not(.uncertain) {
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  animation: journey-draw 0.45s ease-out forwards;
}
.journey-seg.uncertain {
  animation: realm-in 0.45s ease both;
}
@keyframes journey-draw {
  to {
    stroke-dashoffset: 0;
  }
}
.journey-stop span {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #7a2e1c;
  color: #fff;
  font:
    700 11px "Cinzel",
    serif;
  border: 2px solid #fff8e8;
  box-shadow: 0 1px 4px rgba(40, 20, 5, 0.45);
  animation: stop-pop 0.35s ease-out both;
}
.journey-stop.uncertain span {
  background: #fffaf0;
  color: #7a2e1c;
  border: 2px dashed #7a2e1c;
}
@keyframes stop-pop {
  from {
    transform: scale(0);
  }
  to {
    transform: scale(1);
  }
}

/* ---------- City card ---------- */
.city-card .cc-alias {
  margin: -2px 0 4px;
  font-style: italic;
  color: var(--ink-soft);
  font-size: 13px;
}
.cc-holder {
  margin: 4px 0;
  font-size: 13.5px;
}
.cc-holder .swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 5px;
  border-radius: 2px;
  vertical-align: -1px;
}
.cc-refs {
  margin: 4px 0;
  font-size: 12.5px;
  color: var(--ink-soft);
}
.cc-label {
  margin: 8px 0 3px;
  font-family: "Cinzel", serif;
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.cc-links {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.chip.cc-link {
  font: inherit;
  font-size: 12.5px;
  padding: 1px 8px;
  color: var(--ink);
  text-decoration: none;
  background: #fbf4e4;
  border: 1px solid rgba(120, 85, 40, 0.4);
  cursor: pointer;
}
.city-marker {
  cursor: pointer;
}

/* ---------- Bottom sheet (phones) ---------- */
@media (max-width: 760px) {
  .panel {
    transition: max-height 0.25s ease;
  }
  .panel.expanded {
    max-height: 86vh;
  }
  .panel-header {
    touch-action: none;
  }
  .panel-header::before {
    content: "";
    position: absolute;
    top: 5px;
    left: 50%;
    width: 38px;
    height: 4px;
    margin-left: -19px;
    border-radius: 2px;
    background: rgba(120, 85, 40, 0.35);
  }
}

@media (prefers-reduced-motion: reduce) {
  .journey-seg:not(.uncertain),
  .journey-seg.uncertain,
  .journey-casing,
  .journey-stop span {
    animation: none;
    stroke-dashoffset: 0;
  }
}
.journey-on .era-arrow {
  opacity: 0.22 !important;
}
.journey-on .arrow-label {
  display: none;
}
.cc-more {
  margin: 4px 0 0;
  font-size: 12px;
  font-style: italic;
  color: var(--ink-soft);
}
@media (max-width: 760px) {
  .panel-header {
    user-select: none;
  }
}
@media (max-width: 760px) {
  .panel.expanded {
    z-index: 1002;
  }
}
.era-books {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chip.era-book {
  cursor: pointer;
  font: inherit;
  font-size: 13.5px;
  color: var(--ink);
  background: #fbf4e4;
  border: 1px solid rgba(122, 46, 28, 0.35);
}
.chip.era-book:hover {
  border-color: #7a2e1c;
}
.chip.era-book.active {
  background: #7a2e1c;
  border-color: #7a2e1c;
  color: #fff8ea;
}
.chip.era-book:focus-visible {
  outline: 2px solid #7a2e1c;
  outline-offset: 2px;
}
.chip.journey-chip.this-era {
  border-color: #7a2e1c;
  border-width: 1.5px;
  font-weight: 600;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.skip-link {
  position: absolute;
  left: 8px;
  top: -60px;
  z-index: 3000;
  padding: 8px 12px;
  background: #7a2e1c;
  color: #fff8ea;
  border-radius: 6px;
}
.skip-link:focus {
  top: 8px;
}
.skip-link {
  border: 0;
  font: inherit;
  cursor: pointer;
}
.panel:focus {
  outline: none;
}
.panel:focus-visible {
  outline: 2px solid #7a2e1c;
}
