/* Caesar IV look. Art is cropped from the game by gateway/cmd/c4assets. */
:root {
  --label: #c4ab72;        /* laurel button text, sampled from the main menu */
  --label-hover: #e8d39c;
  --ink: #e6e0cf;
  --muted: #9e9580;
  --line: rgba(196, 171, 114, .35);
  --serif: "Palatino Linotype", Palatino, "Book Antiqua", "URW Palladio L", "Pagella Web", Georgia, serif;
}

@font-face {
  font-family: "Pagella Web";
  src: local("TeX Gyre Pagella"), local("TeXGyrePagella-Regular"), url("fonts/texgyrepagella-regular.otf") format("opentype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Pagella Web";
  src: local("TeX Gyre Pagella Italic"), local("TeXGyrePagella-Italic"), url("fonts/texgyrepagella-italic.otf") format("opentype");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

* { box-sizing: border-box; }

html { background: #1f1e2b; scrollbar-gutter: stable; scrollbar-color: var(--label) #1f1e2b; }

body {
  margin: 0;
  min-height: 100vh;
  padding-block: 20px 40px;
  padding-inline: 16px;
  background: #2c2b3d url("img/marble.png") center / cover no-repeat fixed;
  color: var(--ink);
  font: 16px/1.45 var(--serif);
}

a { color: inherit; }

::selection { background: rgba(196, 171, 114, .45); color: #fff; }
input { caret-color: var(--label-hover); }
::placeholder { color: var(--muted); opacity: 1; }
:focus-visible { outline: 2px solid var(--label-hover); outline-offset: 2px; }
h1[tabindex="-1"]:focus, .panel:focus { outline: none; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.skip.dialog { position: absolute; top: 8px; left: 16px; z-index: 10; transform: translateY(-200%); }
.skip.dialog:focus-visible { transform: none; }

/* ---- Laurel button: textbutton_sm.tga, always drawn at its own 253:77 shape.
   laurel.png stacks normal / hover / pressed / disabled, so no state waits on a download. ---- */
.laurel {
  --w: 253px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: var(--w);
  max-width: 100%;
  aspect-ratio: 253 / 77;
  /* keep the label on the blue plate, clear of the laurels */
  padding: 0 calc(var(--w) * .19) calc(var(--w) * .01);
  border: 0;
  background: url("img/laurel.png") 0 0 / 100% 400% no-repeat;
  color: var(--label);
  font: max(13px, calc(var(--w) * .08)) / 1 var(--serif);
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.laurel:hover,
.laurel:focus-visible {
  background-position: 0 33.3333%;
  color: var(--label-hover);
  outline: none;
}
.laurel:focus-visible, .dialog:focus-visible { outline: 1px solid var(--label-hover); outline-offset: 3px; }
.laurel:active,
.laurel[aria-current],
.laurel[aria-pressed="true"] {
  background-position: 0 66.6667%;
  color: var(--label-hover);
}
.laurel:disabled {
  background-position: 0 100%;
  color: #8b8b8b;
  cursor: default;
}
.laurel.small { --w: 190px; }

/* Pressing a button nudges it down and right, like the game's click. */
.laurel:active:not(:disabled),
.dialog:active:not(:disabled) {
  transform: translate(2px, 2px);
}

/* ---- Dialog button: build_backgrnd_buttons.tga (OK / Cancel), blue plate with a thin gold rim.
   dialog.png stacks normal / hover / pressed / disabled at 127x40. ---- */
.dialog {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 127px;
  height: 40px;
  padding: 0 10px 1px;
  border: 0;
  background: url("img/dialog.png") 0 0 / 100% 400% no-repeat;
  color: #e9eeee;       /* sampled from the in-game OK / Cancel labels */
  font: 15px/1 var(--serif);
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.dialog:hover,
.dialog:focus-visible {
  background-position: 0 33.3333%;
  color: #fff;
}
.dialog:active,
.dialog[aria-pressed="true"],
.dialog[aria-current] {
  background-position: 0 66.6667%;
  color: #fff;
}
.dialog[aria-pressed="true"] { text-shadow: 0 0 6px rgba(255, 255, 255, .35); }
.dialog { position: relative; }
.dialog[aria-current] { color: var(--label-hover); }
.dialog[aria-current]::before { content: ""; position: absolute; left: 24%; right: 24%; bottom: 8px; height: 1px; background: var(--label-hover); }
.dialog:disabled {
  background-position: 0 100%;
  color: #9a9a9a;
  cursor: default;
}
.buttons.dialogs { gap: 6px; margin-top: 4px; }

.topbar {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  min-height: 40px;  /* reserve the row so the account buttons don't shift the page when they appear */
}
.topbar .account { margin: 0; justify-content: flex-end; }
.sound-toggle { width: 110px; height: 35px; font-size: 13px; }
.buttons.left { justify-content: flex-start; }

.account-form { max-width: 340px; margin: 6px auto 0; }
.field { margin-bottom: 12px; }
.field label { display: block; margin-bottom: 3px; color: var(--label); }
.field .hint { display: block; margin-top: 4px; color: var(--muted); font-size: 13px; line-height: 1.35; }
.field input, .find input {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid #b89c5c;
  border-radius: 3px;
  background: rgba(8, 18, 24, .85);
  color: var(--ink);
  font: 16px var(--serif);
}
.field input:focus { outline: 2px solid var(--label); outline-offset: 1px; }
.account-form[aria-busy] { cursor: progress; }
.form-error { min-height: 1.4em; margin: 0 0 6px; color: #ff9a7a; text-align: center; }
.form-footer { text-align: center; color: var(--muted); }
.form-footer a, .sub a, .setup a:not(.dialog), .note a { color: var(--label-hover); }

.note { color: var(--muted); margin: 4px 0 10px; }
.setup { margin: 8px auto 12px; max-width: 760px; }
.setup h2 { margin-top: 8px; }
.steps { padding-left: 1.4em; margin: 10px 0; line-height: 1.55; }
.steps li { margin-bottom: 18px; padding-left: 4px; }
.steps li::marker { color: var(--label); }
.steps b { color: var(--label-hover); font-weight: normal; }
.steps .buttons { margin-top: 8px; }
code { font: 14px Consolas, "Courier New", monospace; color: #e8dcb8; background: rgba(0, 0, 0, .35); padding: 1px 4px; border-radius: 2px; }
pre.lines { overflow-x: auto; padding: 10px 12px; background: rgba(0, 0, 0, .4); border: 1px solid var(--line); font: 13px/1.5 Consolas, "Courier New", monospace; color: #e8dcb8; }
.warning { margin: 8px 0 0; color: #f0c27a; }
.steps .note { margin: 8px 0 0; }
.note.small { font-size: 13px; }
details .steps { margin-top: 8px; }
.dialog.wide { width: 210px; }
.direct-link { margin: 8px 0 0; font-size: 14px; }
.direct-link a { overflow-wrap: anywhere; font-family: Consolas, "Courier New", monospace; font-size: 13px; }
.dialog.inline { width: 230px; vertical-align: middle; margin-left: 6px; }
/* A lesser alternative next to a main button: smaller and dimmed until hovered. */
.driver-downloads { align-items: center; }
.dialog.secondary { width: 96px; height: 30px; font-size: 13px; color: #b9c2c2; filter: saturate(.45) brightness(.8); }
.dialog.secondary:hover, .dialog.secondary:focus-visible { filter: none; }
details { margin-top: 6px; color: var(--muted); }
summary { cursor: pointer; color: var(--label); list-style: none; }
summary::-webkit-details-marker { display: none; }
summary::before {
  content: "";
  display: inline-block;
  margin-right: 8px;
  border-left: 6px solid currentColor;
  border-block: 4px solid transparent;
  vertical-align: 1px;
  transition: transform .15s ease-out;
}
details[open] > summary::before { transform: rotate(90deg); }

.buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 2px 8px;
}

.site {
  max-width: 1100px;
  margin: 0 auto 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
/* The game's logo, on the same marble as the page. Its width and height
   attributes reserve the space before it loads. */
.title { display: block; width: min(380px, 100%); line-height: 0; }
.title img { display: block; width: 100%; height: auto; }
/* The ornament is cut from the marble behind the page; feather its edges into it. */
.feather {
  --feather: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent), linear-gradient(transparent, #000 8%, #000 92%, transparent);
  -webkit-mask-image: var(--feather);
  -webkit-mask-composite: source-in;
  mask-image: var(--feather);
  mask-composite: intersect;
}
.find {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 4px 10px;
}
.find label { color: var(--label); text-shadow: 0 1px 2px #000; }
.find input { width: 180px; }
.find input:focus { outline: 2px solid var(--label); outline-offset: 1px; }

/* ---- Framed panel: Border_5.tga ---- */
.panel {
  max-width: 1100px;
  margin: 0 auto;
  min-height: 360px;
  --panel-pad: 12px;
  padding: 6px 12px 14px;
  border-style: solid;
  border-width: 26px;
  border-image: url("img/panel.png") 34 fill / 26px stretch;
}

h1, h2, h3 { font-weight: normal; color: var(--label); margin: 0; }
h1 { font-size: 30px; text-align: center; }
h2 { font-size: 22px; text-align: center; margin: 22px 0 4px; }
h3 { font-size: 18px; margin: 24px 0 8px; }
h2.section { font-size: 18px; text-align: left; margin: 24px 0 8px; }
.sub { text-align: center; color: var(--muted); margin: 2px 0 12px; }

.divider {
  height: 1px;
  margin: 18px 0 4px;
  background: linear-gradient(90deg, transparent, var(--line) 15%, var(--line) 85%, transparent);
}

.choice:focus-visible .frame { outline: 2px solid var(--label-hover); outline-offset: 3px; }

.scenario-head {
  display: flex;
  gap: 22px;
  align-items: flex-start;
  margin: 18px 0 14px;
}
.scenario-head .frame { flex: none; width: 220px; aspect-ratio: 1; cursor: default; }
.scenario-head h2 { text-align: left; margin: 0; }
.scenario-head .meta { margin: 2px 0 10px; color: var(--muted); }
.scenario-head .overview { margin: 0 0 8px; max-width: 68ch; color: var(--ink); line-height: 1.55; }

.table-wrap { overflow-x: auto; margin-top: 8px; }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th {
  padding: 6px 10px;
  text-align: right;
  font-weight: normal;
  color: var(--label);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
td {
  padding: 6px 10px;
  text-align: right;
  border-bottom: 1px solid rgba(196, 171, 114, .12);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
th.l, td.l { text-align: left; }
tbody tr:hover td { background: rgba(120, 20, 10, .28); }
td.rank { color: var(--muted); width: 3em; }
tr.gold td.rank { color: #e5c158; }
tr.silver td.rank { color: #cfd3d6; }
tr.bronze td.rank { color: #c88b52; }
td.sorted { color: #fff3cf; }
td a { text-decoration: none; color: var(--ink); border-bottom: 1px dotted var(--muted); }
td a:hover { color: var(--label-hover); border-bottom-color: var(--label-hover); }
td.ratings { color: var(--muted); }
/* Four narrow rating columns: tighter sides keep the table from scrolling on a laptop-width window. */
th.ratings, td.ratings { padding-inline: 4px; }

/* ---- Scroll box: uicontrols.tga's scrollbar. scroll.png holds columns up / down / knob,
   rows normal / hover / pressed, 32px each. ---- */
/* Framed like the game's list boxes (e.g. Game Screen Resolution) with listframe.png,
   the gold rules of Border_2.tga, on all four sides and again between the list and
   its scrollbar. */
.scroller {
  display: flex;
  background: rgba(8, 8, 12, .5);
  border: 4px solid transparent;
  border-image: url("img/listframe.png") 6 / 4px stretch;
}
.scroll-view {
  flex: 1;
  min-width: 0;
  max-height: 340px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
}
.scroll-view::-webkit-scrollbar { display: none; }
.scroll-view:focus-visible { outline: 1px solid var(--line); outline-offset: 2px; }
.scrollbar {
  flex: none;
  width: 42px;
  padding: 2px 4px;
  display: flex;
  flex-direction: column;
  /* just the left rule of the frame: its middle rows, stretched */
  border-style: solid;
  border-width: 0 0 0 4px;
  border-image: url("img/listframe.png") 6 0 6 6 / 0 0 0 4px stretch;
}
.scroller.fits .scrollbar { visibility: hidden; }
.scroll-arrow, .scroll-knob {
  display: block;
  flex: none;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  background: url("img/scroll.png") 0 0 / 300% 300% no-repeat;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.scroll-arrow.down { background-position-x: 50%; }
.scroll-arrow:hover { background-position-y: 50%; }
.scroll-arrow:active { background-position-y: 100%; transform: translate(1px, 1px); }
.scroll-track { position: relative; flex: 1; min-height: 40px; touch-action: none; }
.scroll-track::before { /* the rail the knob rides on */
  content: "";
  position: absolute;
  inset: 2px calc(50% - 2px);
  border-radius: 2px;
  background: linear-gradient(90deg, #6d5526, #d9bd78 50%, #6d5526);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .6);
}
.scroll-knob { position: absolute; top: 0; left: 0; background-position-x: 100%; touch-action: none; cursor: grab; }
.scroll-knob:hover, .scroll-knob.dragging { filter: brightness(1.15); }
.scroll-knob.dragging { cursor: grabbing; }

.menu-head {
  margin: -6px calc(-1 * var(--panel-pad)) 0;
  padding: 14px 0 12px;
  background: #3b3a52 url("img/marble.png") center / cover;
  text-align: center;
}
.menu-head .status {
  display: inline-block;
  min-width: 220px;
  margin: 0;
  padding: 5px 14px;
  border: 4px solid transparent;
  border-image: url("img/listframe.png") 6 / 4px stretch;
  background: rgba(8, 8, 12, .62);
  color: var(--label);
  font-size: 14px;
  position: relative;
}
.menu-head .ornament { display: block; margin: 8px auto 0; width: 234px; max-width: 100%; height: auto; }
.menu-band {
  margin: 0 calc(-1 * var(--panel-pad));
  padding: 22px 12px 18px;
  background: #2a2630 url("img/strip.jpg") center / cover;
  box-shadow: inset 0 0 0 999px rgba(20, 18, 30, .42), inset 0 14px 18px -10px #000, inset 0 -14px 18px -10px #000;
}
.choices { display: flex; justify-content: center; gap: clamp(16px, 7vw, 80px); }
.choice {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: min(220px, 38vw);
  text-align: center;
  text-decoration: none;
}
.choice .frame {
  width: 100%;
  aspect-ratio: 220 / 300;
  cursor: pointer;
  position: relative;
  box-shadow: 0 12px 28px #000;
  transition: transform .2s, filter .2s;
}
/* The paintings differ in shape; keep them from stretching the frame, and zoom in a touch
   past the sliver of dark card edge the crops carry. Only the gold outer 13px of
   panel.png's edge is used: the rest of its 34px slice is a dark inner shadow that
   showed as black bars around the paintings. */
.choice .frame { overflow: hidden; border-width: 6px; border-image: url("img/panel.png") 13 / 6px stretch; }
.choice .frame img { position: absolute; inset: 0; transform: scale(1.05); }
/* Tilted toward each other, as on the game's chooser. */
.choice.left .frame { transform: perspective(800px) rotateY(14deg); }
.choice.right .frame { transform: perspective(800px) rotateY(-14deg); }
.choice:hover .frame, .choice:focus-visible .frame { transform: perspective(800px) rotateY(0); filter: brightness(1.12); }
.choice:focus-visible { outline: none; }
.choice:focus-visible .laurel { outline: none; }
.choice .laurel { --w: min(220px, 38vw); }
.choice:hover .laurel, .choice:focus-visible .laurel { background-position: 0 33.3333%; color: var(--label-hover); }
.choice:active .laurel { background-position: 0 66.6667%; transform: translate(2px, 2px); }
.choice small { color: var(--ink); font-size: 14px; line-height: 1.3; text-shadow: 0 1px 3px #000; }
.menu-lower {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(380px, 100%), 1fr));
  gap: 8px 26px;
  margin-top: 18px;
}
.menu-lower h2 { margin: 0 0 8px; font-size: 20px; }
.inset { background: rgba(8, 8, 12, .5); border: 1px solid var(--line); padding: 6px 8px; }
.menu-lower .empty { padding: 40px 0; }
/* Half-width columns: the time moves under the name and the screenshot drops out. */
.menu-lower .plays li { grid-template-columns: 44px minmax(0, 1fr) auto; gap: 4px 10px; }
.menu-lower .plays .shot { display: none; }
.menu-lower .plays .when { grid-column: 2; grid-row: 2; margin-top: -4px; text-align: left; font-size: 12px; }
.menu-lower .plays .frame.mini { grid-row: span 2; }
.menu-lower .plays .result { grid-column: 3; grid-row: 1 / span 2; }
.leaders { margin: 0; list-style: none; }
.leaders li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0 12px;
  padding: 8px 4px;
  border-bottom: 1px solid rgba(196, 171, 114, .12);
}
.leaders li:last-child { border-bottom: 0; }
.leaders a { text-decoration: none; color: var(--ink); }
.leaders a .scen { color: var(--label); }
.leaders a:hover .scen, .leaders a:hover .who { color: var(--label-hover); }
.leaders .val { grid-row: span 2; text-align: right; color: #fff3cf; font-variant-numeric: tabular-nums; line-height: 1.2; }
.leaders .val small { display: block; color: var(--muted); font-size: 12px; }
.leaders .obj { color: var(--muted); font-size: 13px; }
.about { margin-top: 18px; }

.plays { margin: 0; padding: 0; list-style: none; }
.plays li {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 96px 7em 7.5em;
  align-items: center;
  gap: 12px;
  padding: 6px 16px;
  border-bottom: 1px solid rgba(196, 171, 114, .12);
}
/* Hover looks like the game's selected list row: deep red with a thin gold rim. */
.plays li:hover { background: #4a120c; box-shadow: inset 0 0 0 1px #c9ae6c; border-radius: 4px; }
.frame.mini { width: 44px; height: 44px; border-width: 4px; border-image-width: 4px; cursor: pointer; }
.plays .what { min-width: 0; line-height: 1.3; }
.plays .what > div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plays .what small { display: block; color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plays .what a { text-decoration: none; color: var(--ink); border-bottom: 1px dotted var(--muted); }
.plays .what a.city { color: var(--label); }
.plays .what a:hover { color: var(--label-hover); border-bottom-color: var(--label-hover); }
.plays .result { text-align: right; font-variant-numeric: tabular-nums; color: #fff3cf; line-height: 1.2; }
.plays .result small { display: block; color: var(--muted); font-size: 12px; }
.plays .when { text-align: right; color: var(--muted); font-size: 14px; white-space: nowrap; }

.frame {
  display: block;
  padding: 0;
  border-style: solid;
  border-width: 10px;
  border-image: url("img/panel.png") 34 / 10px stretch;
  background: #000;
  cursor: zoom-in;
}
.frame img { display: block; width: 100%; height: 100%; object-fit: cover; }
/* Scenario previews, the city screenshot and the city's building map fill the whole frame,
   border included, and frame.png (panel.png with its dark inside cleared) is laid over them:
   the gold rim and corner ornaments stay whole and no dark band shows between rim and picture.
   --frame-w must match the frame's border width. */
:is(.scenario-head, .city-shot, .city-head, .province-dossier) .frame, .map-frame { --frame-w: 10px; }
.frame.mini { --frame-w: 4px; }
:is(.scenario-head, .city-shot, .city-head, .province-dossier) .frame, .map-frame, .frame.mini { position: relative; }
:is(:is(.scenario-head, .city-shot, .city-head, .province-dossier) .frame, .frame.mini) > img, .map-frame > svg {
  position: absolute;
  top: calc(-1 * var(--frame-w));
  left: calc(-1 * var(--frame-w));
  width: calc(100% + 2 * var(--frame-w));
  height: calc(100% + 2 * var(--frame-w));
  max-width: none;
}
:is(.scenario-head, .city-shot, .city-head, .province-dossier) .frame::after, .map-frame::after, .frame.mini::after {
  content: "";
  position: absolute;
  inset: calc(-1 * var(--frame-w));
  border: var(--frame-w) solid transparent;
  border-image: url("img/frame.png") 34 / var(--frame-w) stretch;
  pointer-events: none;
}

td.shot { padding-block: 3px; }
.thumb {
  display: block;
  width: 96px;
  height: 40px;  /* the game uploads 800x334 panoramas */
  padding: 0;
  border: 1px solid #b89c5c;
  background: #000;
  cursor: zoom-in;
}
.thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.thumb:hover, .thumb:focus-visible { border-color: var(--label-hover); outline: none; }

.gallery {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 16px;
}
.gallery figure { margin: 0; width: min(340px, 100%); text-align: center; }
.gallery .frame { width: 100%; aspect-ratio: 800 / 334; }
.gallery figcaption { margin-top: 4px; color: var(--muted); font-size: 14px; }
.gallery figcaption a:hover { color: var(--label-hover); }

.lightbox {
  max-width: min(1100px, calc(100vw - 32px));
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  text-align: center;
}
.lightbox::backdrop { background: rgba(0, 0, 0, .8); }
.lightbox .frame { border-width: 18px; border-image-width: 18px; cursor: default; }
.lightbox .frame img { width: auto; height: auto; max-width: 100%; max-height: calc(100vh - 180px); margin: 0 auto; object-fit: contain; }
.lightbox .caption { margin: 8px 0 0; color: var(--label); font-size: 18px; text-shadow: 0 1px 2px #000; }

.city-cell { display: flex; align-items: center; gap: 10px; }
.city-shot { margin: 14px auto 0; max-width: 820px; }
.city-shot .frame { width: 100%; aspect-ratio: 800 / 334; }
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px 18px;
  margin: 18px 0 0;
  padding: 12px 0;
  border-block: 1px solid var(--line);
}
.stats dt { color: var(--muted); font-size: 13px; }
.stats dd { margin: 0; font-size: 18px; }
.stats .sorted dd { color: #fff3cf; }
.stats a { color: inherit; text-decoration: none; border-bottom: 1px dotted var(--muted); }
.stats a:hover { color: var(--label-hover); border-bottom-color: var(--label-hover); }

/* ---- Rating columns: ratings.png at 2x (240x256), five 48px columns. A capital
   (rows 0-24), the top --h of the shaft (24-228, never stretched: --h is at most 186,
   PILLAR_SHAFT in app.js) and a base (228-256). A full column (24 + 186 + 28 = 238px)
   reaches the goal line at the top of its track. The row's height is fixed so columns
   never shift what follows. ---- */
.pillars {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: clamp(10px, 5vw, 56px);
  height: 330px;
  padding: 12px 0 10px;
}
.pillar { display: flex; flex-direction: column; align-items: center; min-width: 64px; }
.pillar .goal-mark { color: var(--muted); font-size: 12px; line-height: 1.2; white-space: nowrap; }
.pillar.met .goal-mark { color: #e5c158; }
.pillar .track { position: relative; display: flex; justify-content: center; align-items: flex-end; width: 100%; height: 238px; }
.pillar .track::before { /* the goal: where a full column's capital tops out */
  content: "";
  position: absolute;
  top: 0;
  left: 4px;
  right: 4px;
  border-top: 1px dashed rgba(229, 193, 88, .6);
}
.pillar .col { position: relative; display: flex; flex-direction: column; width: 48px; }
.pillar .col b { display: block; width: 48px; background: url("img/ratings.png") calc(var(--x) * -48px) 0 / 240px 256px no-repeat; }
/* These must outrank .pillar .col b, whose background shorthand resets the position. */
.pillar .col .cap { height: 24px; }
.pillar .col .shaft { height: var(--h); background-position-y: -24px; animation: shaft-rise 1.1s cubic-bezier(.16, 1, .3, 1) both; }
.pillar:nth-child(2) .col .shaft { animation-delay: .06s; }
.pillar:nth-child(3) .col .shaft { animation-delay: .12s; }
.pillar:nth-child(4) .col .shaft { animation-delay: .18s; }
.pillar:nth-child(5) .col .shaft { animation-delay: .24s; }
@keyframes shaft-rise { from { height: 0; } }
.pillar .col .base { height: 28px; background-position-y: -228px; }
.pillar .val { margin-top: 8px; font-size: 22px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.pillar.sorted .val { color: #fff3cf; }
.pillar.met .val { color: #e5c158; }
.pillar small { color: var(--ink); font-size: 14px; }
.pillar.no-goal .track::before { content: none; }
.pillar.no-goal .goal-mark { opacity: .7; }
.roads-note { max-width: 760px; margin: -2px auto 10px; text-align: center; font-size: 14px; font-style: italic; }
.map-wrap { margin: 4px auto 14px; max-width: 760px; }
.map-frame { width: 100%; aspect-ratio: 1; cursor: grab; }
.map-frame:active { cursor: grabbing; }
.city-map { display: block; width: 100%; height: 100%; touch-action: pan-x pan-y; user-select: none; }
.map-frame.active .city-map { touch-action: none; }
.city-map:focus-visible { outline: none; }
.map-frame:has(.city-map:focus-visible) { outline: 2px solid var(--label-hover); outline-offset: 3px; }
.map-hint { margin: 6px 0 0; text-align: center; font-size: 13px; }
.map-frame.active + .map-hint { color: var(--label); }
.city-map rect { stroke: rgba(0, 0, 0, .7); stroke-width: 1px; vector-effect: non-scaling-stroke; fill-opacity: .88; }
.city-map .has-icon rect { fill-opacity: .45; }
.city-map .building:hover rect { fill-opacity: 1; stroke: #fff; }
.city-map image { pointer-events: none; }
.city-map .blank { fill: #4d5a3a; stroke: none; }
.map-wrap .buttons { margin-top: 8px; }
.legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 16px; margin: 8px 0 0; padding: 0; list-style: none; color: var(--muted); font-size: 14px; }
.legend .swatch { display: inline-block; width: 12px; height: 12px; margin-right: 6px; vertical-align: -1px; border: 1px solid rgba(0, 0, 0, .7); }
.building-groups {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 6px 28px;
  align-items: start;
}
.building-groups h3 { margin: 10px 0 2px; font-weight: normal; color: var(--label); font-size: 16px; }
.building-groups td { padding-block: 3px; }
.building-groups td.icon { width: 36px; padding: 0 4px 0 0; }
.building-groups td.icon img { display: block; }

.notice { max-width: 760px; margin: 0 auto 14px; padding: 8px 12px; border: 1px solid var(--line); background: rgba(0, 0, 0, .25); color: var(--ink); }
.notice summary { color: var(--label-hover); }
.notice p { margin: 8px 0; max-width: 72ch; line-height: 1.5; }
.notice a:not(.dialog) { color: var(--label-hover); }
.notice .steps { margin: 8px 0; }
.notice .steps li { margin-bottom: 10px; }

.empty, .error { text-align: center; color: var(--muted); padding: 48px 0; }
.error { color: #ff9a7a; padding-bottom: 16px; }

.panel > * { transition: opacity .2s ease-out; }
.panel.busy { cursor: progress; }
.panel.busy > * { opacity: .5; }


.start {
  margin: 0 calc(-1 * var(--panel-pad));
  padding: 16px 12px 18px;
  border-bottom: 1px solid var(--line);
  text-align: center;
}
.start h2 { margin: 0 0 10px; }
.start-steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px 26px;
  max-width: 900px;
  margin: 0 auto 12px;
  padding: 0;
  list-style: none;
  counter-reset: step;
  text-align: left;
}
.start-steps li { counter-increment: step; display: grid; grid-template-columns: auto 1fr; align-content: start; column-gap: 10px; color: var(--muted); line-height: 1.4; }
.start-steps li::before { content: counter(step, upper-roman); grid-row: span 2; min-width: 1.6em; color: var(--label); font-size: 26px; line-height: 1; text-align: right; }
.start-steps b { color: var(--ink); font-weight: normal; }
.start .sub { margin: 6px 0 0; }
.start .standings { max-width: 560px; margin: 0 auto 12px; padding-inline: 12px; text-align: left; }
.start .empty.inset { max-width: 560px; margin: 0 auto 12px; padding: 18px 16px; }
.welcome { max-width: 760px; margin: 4px auto 8px; padding: 8px 12px; border: 1px solid var(--line); background: rgba(0, 0, 0, .25); color: var(--label-hover); text-align: center; }

.prompt {
  width: min(460px, calc(100vw - 32px));
  padding: 6px 14px 14px;
  border-style: solid;
  border-width: 26px;
  border-image: url("img/panel.png") 34 fill / 26px stretch;
  background: transparent;
  color: var(--ink);
  text-align: center;
}
.prompt::backdrop { background: rgba(0, 0, 0, .7); }
.prompt h2 { margin: 4px 0 8px; }
.prompt p { margin: 0 0 14px; line-height: 1.5; }
.token-action { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; vertical-align: middle; }
.inline-error { min-height: 0; margin: 0; text-align: left; }
.inline-error:empty { display: none; }

@media (prefers-reduced-motion: reduce) {
  .choice.left .frame, .choice.right .frame { transform: none; }
  .choice .frame, .panel > * { transition: none; }
  .pillar .col .shaft { animation: none; }
  .laurel:active:not(:disabled), .dialog:active:not(:disabled) { transform: none; }
}

@media (max-width: 560px) {
  .panel { border-width: 18px; border-image-width: 18px; padding-inline: 4px; }
  .laurel { --w: 200px; }
  .laurel.small { --w: 160px; }
  .dialog { width: 106px; height: 34px; font-size: 14px; }
  .scenario-head { flex-direction: column; align-items: center; text-align: center; }
  .scenario-head .overview { text-align: left; }
  .scenario-head h2 { text-align: center; }
  .scenario-head .frame { width: min(260px, 100%); }
  table { font-size: 14px; }
  .hide-narrow { display: none; }
  .plays li { grid-template-columns: 44px minmax(0, 1fr) auto; gap: 8px; }
  .plays .shot { display: none; }
  .plays .when { grid-column: 2 / -1; margin-top: -8px; text-align: left; font-size: 12px; }
  .scroll-view { max-height: 300px; }
  .board .stat:not(.sorted) { display: none; }
  .buttons { row-gap: 10px; }
  .dialog { position: relative; }
  .dialog::after { content: ""; position: absolute; inset: -5px -2px; }
  .start-steps { grid-template-columns: 1fr; max-width: 420px; }
  .start { padding-inline: 8px; }
  .panel { --panel-pad: 4px; }
  .menu-head .status { min-width: 0; font-size: 13px; }
  .menu-band { padding-inline: 4px; }
  .choice small { font-size: 12px; }
  .pillars { gap: 4px; }
  .pillar { min-width: 0; flex: 1; }
  .pillar .val { font-size: 16px; }
  .pillar small { font-size: 12px; }
  .title { width: min(220px, 100%); }
  .find { flex-wrap: nowrap; gap: 8px; }
  .find label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .find input { flex: 1; width: auto; min-width: 0; }
  .find .laurel.small { --w: 112px; }
  .sort-plates { column-gap: 6px; }
  .sort-plates .dialog { width: 92px; font-size: 13px; }
}

.rank-mark {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 64px;
  color: var(--ink);
  line-height: 1;
  text-decoration: none;
}
.rank-mark b { font-weight: normal; font-size: 24px; font-variant-numeric: tabular-nums; }
.rank-mark small { margin-top: 4px; color: var(--muted); font-size: 12px; }
.rank-mark.gold b { color: #e5c158; }
.rank-mark.silver b { color: #cfd3d6; }
.rank-mark.bronze b { color: #c88b52; }
.rank-mark:hover b { color: var(--label-hover); }
.rank-mark.large {
  min-width: 136px;
  padding: 18px 14px 16px;
  border: 4px solid transparent;
  border-image: url("img/listframe.png") 6 / 4px stretch;
  background: rgba(8, 8, 12, .5);
}
.rank-mark.large b { font-size: 46px; }
.rank-mark.large small { font-size: 14px; }

.city-head {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr) auto;
  align-items: center;
  gap: 24px;
  margin: 8px 0 20px;
}
.city-head .frame { width: 200px; aspect-ratio: 1; cursor: default; }
.city-title h1 { text-align: left; font-size: 36px; line-height: 1.1; }
.city-title .meta { margin: 4px 0 0; color: var(--muted); }
.city-title .meta a { color: var(--ink); }
.city-title .meta a:hover { color: var(--label-hover); }
.city-title .buttons { margin-top: 14px; }
.ratings-screen {
  margin: 0 calc(-1 * var(--panel-pad));
  padding: 18px 12px 6px;
  background: #3b3a52 url("img/marble.png") center / cover;
  box-shadow: inset 0 0 0 999px rgba(20, 18, 30, .58), inset 0 14px 18px -10px #000, inset 0 -14px 18px -10px #000;
  text-align: center;
}
.ratings-screen h2 { margin: 0; }
.ratings-tally { margin: 2px 0 0; color: var(--muted); font-size: 14px; }
.ledger {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  margin: 0 0 6px;
  border-bottom: 1px solid var(--line);
}
.ledger > div { padding: 14px 16px 12px; border-left: 1px solid rgba(196, 171, 114, .12); }
.ledger > div:first-child { border-left: 0; }
.ledger dt { color: var(--muted); font-size: 13px; }
.ledger dd { margin: 3px 0 0; font-size: 21px; font-variant-numeric: tabular-nums; }
.ledger .sorted dd { color: #fff3cf; }

.honours {
  display: flex;
  justify-content: center;
  gap: 0;
  max-width: 640px;
  margin: 0 auto 6px;
  text-align: center;
}
.honours > div { flex: 1; padding: 6px 14px; border-left: 1px solid rgba(196, 171, 114, .18); }
.honours > div:first-child { border-left: 0; }
.honours dt { color: var(--muted); font-size: 13px; }
.honours dd { margin: 2px 0 0; color: var(--label-hover); font-size: 20px; }
.dossier-columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(420px, 100%), 1fr)); gap: 0 28px; }
.dossier { margin: 0; padding: 0; list-style: none; }
.dossier li {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) auto 76px;
  align-items: center;
  gap: 14px;
  padding: 8px 10px;
  border-bottom: 1px solid rgba(196, 171, 114, .12);
}
.dossier li:hover { background: #4a120c; box-shadow: inset 0 0 0 1px #c9ae6c; border-radius: 4px; }
.dossier .frame.mini { width: 64px; height: 64px; }
.dossier .what { min-width: 0; }
.dossier .what .city { color: var(--label); font-size: 18px; text-decoration: none; }
.dossier .what .city:hover { color: var(--label-hover); }
.dossier .what small { display: block; margin-top: 2px; color: var(--muted); font-size: 13px; }
.dossier .result { text-align: right; color: #fff3cf; font-variant-numeric: tabular-nums; line-height: 1.2; }
.dossier .result small { display: block; color: var(--muted); font-size: 12px; }

.atlas-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 230px; gap: 22px; align-items: center; margin: 0 0 10px; }
.atlas {
  position: relative;
  aspect-ratio: 1.56;
  border: 4px solid transparent;
  border-image: url("img/listframe.png") 6 / 4px stretch;
  background: #2a2838 url("img/marble.png") center / cover;
  box-shadow: inset 0 0 0 999px rgba(20, 18, 30, .5), inset 0 14px 18px -10px #000, inset 0 -14px 18px -10px #000;
}
.graticule { position: absolute; inset: 0; width: 100%; height: 100%; }
.graticule line { stroke: rgba(196, 171, 114, .2); stroke-width: 1; vector-effect: non-scaling-stroke; }
.graticule line.minor { stroke: rgba(196, 171, 114, .08); }
.graticule .coast { fill: none; stroke: rgba(196, 171, 114, .42); stroke-width: 1.25; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.sea {
  position: absolute;
  transform: translate(-50%, -50%);
  color: rgba(158, 149, 128, .5);
  font-size: 13px;
  font-style: italic;
  letter-spacing: .1em;
  white-space: nowrap;
  pointer-events: none;
}
.province { position: absolute; width: 0; height: 0; color: inherit; text-decoration: none; }
.province::before { content: ""; position: absolute; left: -12px; top: -12px; width: 24px; height: 24px; }
.province .pin {
  position: absolute;
  left: -4px;
  top: -4px;
  width: 8px;
  height: 8px;
  border: 1px solid var(--muted);
  border-radius: 50%;
  background: #1f1e2b;
  transition: transform .15s ease-out;
}
.province.settled .pin { left: -7px; top: -7px; width: 14px; height: 14px; border: 2px solid #2a2016; background: var(--label); box-shadow: 0 1px 3px #000; }
.province .label { position: absolute; color: var(--muted); font-size: 12px; line-height: 1; white-space: nowrap; text-shadow: 0 0 3px #15131d, 0 0 3px #15131d, 0 1px 2px #000; }
.province.settled .label { color: var(--label); font-size: 14px; }
.label-r .label { left: 10px; top: -6px; }
.label-l .label { right: 10px; top: -6px; }
.label-t .label { bottom: 10px; left: 0; transform: translateX(-50%); }
.label-b .label { top: 10px; left: 0; transform: translateX(-50%); }
.province:hover .pin, .province:focus-visible .pin { transform: scale(1.35); border-color: var(--label-hover); }
.province:hover .label, .province:focus-visible .label { color: var(--label-hover); }
.province:focus-visible { outline: none; }
.province:focus-visible .pin { outline: 2px solid var(--label-hover); outline-offset: 2px; }
.province-dossier { text-align: center; }
.province-dossier .frame { display: block; width: 180px; aspect-ratio: 1; margin: 0 auto 12px; cursor: pointer; }
.province-dossier h2 { margin: 0; font-size: 24px; }
.province-dossier .meta { margin: 2px 0 10px; color: var(--muted); }
.province-dossier .leader { display: flex; flex-direction: column; gap: 2px; margin: 0 0 14px; }
.province-dossier .leader small { color: var(--muted); font-size: 12px; }
.province-dossier .leader b { color: #fff3cf; font-weight: normal; font-variant-numeric: tabular-nums; }
.province-list { display: none; }
.unsettled-names { color: var(--muted); line-height: 1.7; }
.unsettled-names a { color: var(--ink); text-decoration: none; white-space: nowrap; }
.back { margin: 0 0 -6px; }

.board td.stat:not(.sorted) { color: var(--muted); }
.board th.sorted, .board td.sorted { background: rgba(196, 171, 114, .08); }
.board td.sorted a { color: #fff3cf; border-bottom: 0; }
.board td.l a { border-bottom: 0; }
.board td.l a:hover, .board td.sorted a:hover { color: var(--label-hover); text-decoration: underline; text-underline-offset: 3px; }
.board tbody tr { cursor: pointer; }

.menu-lower.single { grid-template-columns: minmax(0, 640px); justify-content: center; }
.choice .laurel { font-size: max(12px, calc(var(--w) * .072)); }

.panel:has(> .account-form), .panel:has(> .not-found) { max-width: 560px; min-height: 0; }

@media (max-width: 560px) {
  .city-head { grid-template-columns: 1fr; justify-items: center; text-align: center; gap: 14px; }
  .city-head .frame { width: 160px; }
  .city-title h1 { text-align: center; font-size: 28px; }
  .city-title .buttons { justify-content: center; }
  .ratings-screen { padding-inline: 4px; }
  .dossier-columns { grid-template-columns: 1fr; }
  .dossier li { grid-template-columns: 48px minmax(0, 1fr) auto; gap: 10px; padding-inline: 4px; }
  .dossier .frame.mini { width: 48px; height: 48px; }
  .dossier .result { display: none; }
  .atlas-wrap { grid-template-columns: 1fr; }
  .atlas .label, .atlas .sea { display: none; }
  .province-dossier { display: none; }
  .province-list { display: block; }
  .pillar .goal-mark { font-size: 12px; }
  .pillar .goal-word { display: none; }
  .ledger { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .ledger > div { padding: 10px 8px; border-left: 0; }
  .ledger dd { font-size: 17px; }
  .honours > div { padding-inline: 6px; }
  .honours dd { font-size: 16px; }
  .rank-mark.large { min-width: 120px; padding: 10px 12px; }
  .rank-mark.large b { font-size: 36px; }
}

.challenge { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 22px; align-items: start; margin-top: 4px; }
.scenario-rail { position: sticky; top: 12px; }
.scenario-rail ol { margin: 0; padding: 0; list-style: none; }
.scenario-rail li { border-bottom: 1px solid rgba(196, 171, 114, .12); }
.scenario-rail li:last-child { border-bottom: 0; }
.scenario-rail a {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  column-gap: 10px;
  align-items: center;
  padding: 7px 8px;
  border-radius: 4px;
  color: var(--ink);
  text-decoration: none;
}
.scenario-rail .frame.mini { grid-row: span 3; }
.scenario-rail .rail-name { color: var(--label); font-size: 16px; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scenario-rail small { color: var(--muted); font-size: 12px; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scenario-rail .rail-leader { color: var(--ink); font-variant-numeric: tabular-nums; }
.scenario-rail a:hover { background: rgba(120, 20, 10, .28); }
.scenario-rail a:hover .rail-name { color: var(--label-hover); }
.scenario-rail a[aria-current] { background: #4a120c; box-shadow: inset 0 0 0 1px #c9ae6c; }
.scenario-rail a[aria-current] .rail-name { color: var(--label-hover); }
.scenario-rail a:focus-visible { outline: 2px solid var(--label-hover); outline-offset: 1px; }
.challenge-main { min-width: 0; container-type: inline-size; }
.board-head { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 16px; align-items: start; margin-bottom: 10px; }
.board-head .frame { position: relative; --frame-w: 6px; width: 96px; aspect-ratio: 1; border-width: 6px; border-image-width: 6px; cursor: default; }
.board-head .frame > img { position: absolute; top: -6px; left: -6px; width: calc(100% + 12px); height: calc(100% + 12px); max-width: none; }
.board-head .frame::after { content: ""; position: absolute; inset: -6px; border: 6px solid transparent; border-image: url("img/frame.png") 34 / 6px stretch; pointer-events: none; }
.board-head h2 { margin: 0; text-align: left; font-size: 26px; }
.board-head .meta { margin: 2px 0 6px; color: var(--muted); }
.briefing { margin: 0; color: var(--ink); }
.briefing .overview { max-width: 68ch; margin: 6px 0; line-height: 1.55; }
.challenge-main .sort-plates { justify-content: flex-start; gap: 6px; margin-bottom: 4px; }
.challenge-main .sort-plates .dialog { width: 96px; height: 30px; font-size: 13px; }
@container (max-width: 880px) {
  .board .ratings { display: none; }
}
@container (max-width: 640px) {
  .board .hide-narrow { display: none; }
}

@media (max-width: 560px) {
  .challenge { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .scenario-rail { margin-inline: -4px; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none; }
  .scenario-rail::-webkit-scrollbar { display: none; }
  .scenario-rail ol { display: flex; gap: 6px; padding: 2px 4px 6px; }
  .scenario-rail li { flex: none; border: 0; }
  .scenario-rail a { width: 104px; grid-template-columns: 1fr; justify-items: center; text-align: center; padding: 6px 4px; }
  .scenario-rail .frame.mini { grid-row: auto; width: 56px; height: 56px; }
  .scenario-rail .rail-leader { display: none; }
  .board-head { grid-template-columns: minmax(0, 1fr); margin-bottom: 6px; }
  .board-head .frame { display: none; }
  .board-head h2 { font-size: 22px; }
  .board-head .meta { font-size: 14px; }
  .scenario-rail a { width: 92px; padding: 4px; }
  .scenario-rail .frame.mini { width: 48px; height: 48px; }
  .scenario-rail .rail-name { font-size: 14px; max-width: 100%; }
  .challenge-main .sort-plates .dialog { width: 88px; }
  #view > h1 { font-size: 24px; }
}
