/* ---------- fonts, served from this site (faster, and visitors' addresses never go to Google) ----------
   Cinzel, Inter and JetBrains Mono are under the SIL Open Font License (see fonts/LICENSE.txt).
   Each is a variable font: one file covers every weight. The browser only downloads the
   "latin-ext" files when a page shows letters such as İ, ğ or ş. */
@font-face { font-family: "Cinzel"; font-style: normal; font-weight: 400 900; font-display: swap; src: url("fonts/cinzel-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Cinzel"; font-style: normal; font-weight: 400 900; font-display: swap; src: url("fonts/cinzel-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 100 900; font-display: swap; src: url("fonts/inter-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 100 900; font-display: swap; src: url("fonts/inter-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "JetBrains Mono"; font-style: normal; font-weight: 100 800; font-display: swap; src: url("fonts/jetbrains-mono-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  --bg: #020306;
  --bg-2: #0b0c10;
  --panel: rgba(12, 11, 9, 0.78);
  --panel-solid: #121009;
  --line: rgba(232, 184, 74, 0.22);
  --gold: #e8b84a;
  --gold-2: #ffd97a;
  --text: #f3e9d2;
  --muted: #a8997c;
  --ruler: #e8b84a;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, sans-serif;
  overflow-x: hidden;
}

/* ---------- top ---------- */
.topbar {
  position: absolute; top: 0; left: 0; right: 0; z-index: 5;
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 14px 20px; font-size: 14px; color: var(--muted);
  background: linear-gradient(180deg, rgba(2,3,6,.85), transparent);
}
.brand { font-family: Cinzel, serif; font-weight: 800; color: var(--gold); letter-spacing: .04em; }
.fallen-count b { color: var(--text); font-family: "JetBrains Mono", monospace; }

.banners { position: absolute; top: 50px; left: 0; right: 0; z-index: 6; pointer-events: none; }
.demo-banner, .notice {
  margin: 0 auto 8px; width: fit-content; max-width: calc(100% - 32px);
  padding: 8px 14px; border-radius: 10px; text-align: center; font-size: 13px; pointer-events: auto;
}
.demo-banner { background: rgba(42,34,16,.85); border: 1px dashed var(--gold); color: var(--gold-2); }
.notice { background: rgba(19,36,15,.92); border: 1px solid #3f7a2c; color: #c7f3b0; font-size: 14px; }
.notice.bad { background: rgba(42,15,13,.92); border-color: #7a2c26; color: #ffc4be; }
.banner-short { display: none; }
/* Phones: the demo/test banner shrinks to a small tag in the corner, clear of the ruler in the middle */
@media (max-width: 760px) {
  .banner-long { display: none; }
  .banner-short { display: inline; }
  .demo-banner { margin: 0 0 8px 16px; padding: 3px 9px; border-radius: 99px; font-size: 10px; font-weight: 800; letter-spacing: .08em; }
}

/* ---------- stage ---------- */
.stage {
  position: relative;
  height: 100vh; height: 100svh;
  min-height: 620px; max-height: 1000px;
  overflow: hidden;
}
#world { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: pan-y; cursor: grab; }
#world.dragging { cursor: grabbing; }
.stage-shade {
  position: absolute; inset: 0; pointer-events: none;
  background:
    linear-gradient(90deg, rgba(2,3,6,.75) 0%, rgba(2,3,6,.25) 38%, transparent 60%),
    linear-gradient(0deg, var(--bg) 0%, transparent 18%);
}
.city-label {
  position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none; white-space: nowrap;
  font: 700 13px/1 Inter, sans-serif; color: #fff;
  background: rgba(2,3,6,.72); border: 1px solid var(--ruler); border-radius: 99px; padding: 5px 10px;
  box-shadow: 0 0 14px color-mix(in srgb, var(--ruler) 45%, transparent);
}
.city-label[hidden], .name-label[hidden] { display: none; }
.name-label {
  position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  width: max-content; max-width: min(300px, 70vw); text-align: center;
  text-shadow: 0 2px 6px #000, 0 0 2px #000;
}
.name-label-name {
  font: 800 clamp(15px, 1.6vw, 20px)/1.1 Cinzel, serif; color: var(--gold-2); white-space: nowrap;
  text-shadow: 0 0 12px color-mix(in srgb, var(--ruler) 70%, transparent), 0 2px 6px #000, 0 0 2px #000;
}
.name-label-name::before { content: "👑 "; }
.name-label-msg { font: italic 500 clamp(12px, 1.1vw, 14px)/1.3 Inter, sans-serif; color: var(--text); }
.name-label-msg[hidden] { display: none; }
.stage-ui {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; justify-content: center;
  padding: 80px clamp(16px, 4vw, 56px) 48px;
  pointer-events: none;
}
.stage-ui > * { pointer-events: auto; }
/* The war report and the ruler's card travel together, docked at the foot of the map */
.stage-bottom { display: flex; flex-direction: column; }

.slogan {
  font-family: Cinzel, serif; font-weight: 800; margin: 0 0 18px;
  font-size: clamp(32px, 4.6vw, 60px); line-height: 1.02; max-width: 520px;
  color: var(--text); text-shadow: 0 4px 30px rgba(0,0,0,.8);
}
.slogan span {
  display: block;
  font-family: Inter, sans-serif; font-weight: 400;
  font-size: .42em; letter-spacing: .02em; font-weight: 500; color: rgba(243,233,210,.82);
  margin-top: 10px;
}

.ruler-card {
  width: min(430px, 100%);
  background: var(--panel);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--line);
  border-top: 3px solid var(--ruler);
  border-radius: 18px;
  padding: 18px 20px 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,.55);
}
.eyebrow {
  text-transform: uppercase; letter-spacing: .18em; font-size: 11px; color: var(--ruler); margin: 0; font-weight: 800;
}
.king-name {
  font-family: Cinzel, serif; font-weight: 800;
  font-size: clamp(28px, 3.4vw, 42px); line-height: 1.05; margin: 6px 0 4px;
  background: linear-gradient(180deg, var(--gold-2), var(--gold) 60%, #a8761e);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  overflow-wrap: anywhere;
}
.ruling-from { margin: 0; color: var(--muted); font-size: 14px; }
.ruling-from b { color: var(--text); }
.dot { opacity: .6; }
.king-message {
  font-size: 17px; font-style: italic; margin: 10px 0 14px; min-height: 1.3em; overflow-wrap: anywhere;
}

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat {
  display: flex; flex-direction: column; gap: 2px;
  background: rgba(0,0,0,.35); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px;
}
.stat-wide { grid-column: 1 / -1; flex-direction: row; justify-content: space-between; align-items: baseline; gap: 12px; }
.stat-value.territory { color: var(--gold-2); }
.stat-wide .stat-label { white-space: nowrap; }
.stat-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .18em; color: var(--muted); }
.stat-value { font-family: "JetBrains Mono", monospace; font-size: clamp(15px, 1.35vw, 19px); font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar { height: 6px; border-radius: 99px; background: rgba(255,255,255,.08); margin: 10px 0 0; overflow: hidden; }
.bar > div { height: 100%; width: 0; background: linear-gradient(90deg, var(--ruler), var(--gold-2)); border-radius: inherit; transition: width 1s linear; }
.record-line { color: var(--gold-2); font-size: 13px; min-height: 1.3em; margin: 8px 0 12px; }

.cta {
  display: inline-flex; align-items: center; justify-content: center; gap: 14px;
  font: 800 20px/1 Inter, sans-serif;
  color: #1a1206; background: linear-gradient(180deg, var(--gold-2), var(--gold));
  border: 0; border-radius: 999px; padding: 14px 26px; cursor: pointer;
  box-shadow: 0 6px 18px rgba(0,0,0,.45);
  transition: transform .12s ease, box-shadow .12s ease;
  width: 100%;
}
.cta:has(.price) { justify-content: space-between; padding-right: 14px; }
.cta:hover { transform: scale(1.01); box-shadow: 0 8px 22px rgba(232,184,74,.22); }
.cta:active { transform: scale(.98); }
.cta:disabled { opacity: .6; cursor: wait; animation: none; }
.cta .price {
  background: #1a1206; color: var(--gold-2); border-radius: 999px; padding: 9px 16px;
  font-family: "JetBrains Mono", monospace;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(232,184,74,.55), 0 10px 36px rgba(232,184,74,.3); }
  70% { box-shadow: 0 0 0 16px rgba(232,184,74,0), 0 10px 36px rgba(232,184,74,.3); }
  100% { box-shadow: 0 0 0 0 rgba(232,184,74,0), 0 10px 36px rgba(232,184,74,.3); }
}
/* What the crown costs, said plainly rather than stamped on the button */
.cta-price { color: var(--muted); font-size: 13px; margin: 9px 0 0; text-align: center; }
.cta-price b { color: var(--text); font-weight: 600; }
.fineprint { color: var(--muted); font-size: 12px; margin: 8px 0 0; text-align: center; line-height: 1.5; }

/* Reporting a ruler: a quiet link in the card, a short form in a dialog */
/* Under the ruler's own details: who is watching, and the way to report the name */
.ruler-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.ruler-meta:empty, .ruler-meta:not(:has(> :not([hidden]))) { margin-top: 0; }
.ruler-meta .watchers, .ruler-meta .report-link { margin: 0; }

.report-link {
  display: block; margin: 8px auto 0; padding: 2px 6px; border: 0; background: none; cursor: pointer;
  font: 600 11px Inter, sans-serif; color: var(--muted); text-decoration: underline; text-underline-offset: 2px;
}
.report-link:hover { color: #ff8a80; }
.report-link[hidden] { display: none; }
.report-dialog { max-width: 440px; }
.report-who { margin: 0 0 12px; padding: 10px 12px; border-radius: 10px; background: #07070a; border: 1px solid var(--line); font-weight: 700; overflow-wrap: anywhere; }
.report-reasons { border: 0; margin: 0 0 12px; padding: 0; display: grid; gap: 6px; }
.report-reasons legend { font-size: 14px; margin-bottom: 6px; }
.report-reasons label { display: flex; gap: 8px; align-items: center; font-size: 14px; cursor: pointer; }

.ruler-card.coronation { animation: crowned 1.2s ease; }
@keyframes crowned { 0% { transform: scale(.96); filter: brightness(2.2); } 100% { transform: none; filter: none; } }

/* ---------- lists ---------- */
main { max-width: 1040px; margin: 0 auto; padding: 8px 16px 48px; }
.boards { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.board, .rules {
  background: linear-gradient(180deg, var(--panel-solid), var(--bg-2));
  border: 1px solid var(--line); border-radius: 16px; padding: 18px 20px;
}
.board h2, .rules h2 { font-family: Cinzel, serif; font-size: 18px; color: var(--gold); margin: 0 0 12px; }
.list { list-style: none; margin: 0; padding: 0; }
.list li {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 10px 0;
  border-top: 1px solid rgba(232,184,74,.12);
}
.list li:first-child { border-top: 0; }
.list .n { font-weight: 600; overflow-wrap: anywhere; }
.list .rank { display: inline-block; min-width: 1.9em; }
.cup-list li { grid-template-columns: 1fr; }
.cup-list li .d { text-align: left; }
.list .swatch { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 8px; vertical-align: middle; }
.list .d { font-family: "JetBrains Mono", monospace; color: var(--gold-2); font-size: 13px; white-space: nowrap; text-align: right; }
.list .s { color: var(--muted); font-size: 12px; }
.list .m { grid-column: 1 / -1; color: var(--muted); font-size: 13px; font-style: italic; overflow-wrap: anywhere; }
.list .live { color: #ff5a4e; font-size: 10px; font-weight: 800; letter-spacing: .1em; margin-left: 6px; }
.list .empty { color: var(--muted); display: block; }

.rules { margin-top: 16px; }
.rules ol { margin: 0; padding-left: 20px; color: var(--muted); line-height: 1.8; }

.faq { margin-top: 16px; }
.faq > h2 { font-family: Cinzel, serif; font-size: 18px; color: var(--gold); margin: 0 0 10px; }
.faq details {
  background: linear-gradient(180deg, var(--panel-solid), var(--bg-2));
  border: 1px solid var(--line); border-radius: 14px; margin-top: 8px;
}
.faq summary {
  cursor: pointer; list-style: none; padding: 13px 16px;
  font-weight: 600; display: flex; justify-content: space-between; gap: 12px;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; color: var(--gold); font-weight: 400; }
.faq details[open] summary::after { content: "−"; }
.faq p { margin: 0; padding: 0 16px 15px; color: var(--muted); line-height: 1.7; }

/* ---------- the cookie bar ---------- */
/* Low, dark and narrow: it asks once and then never again. */
.consent-bar {
  position: fixed; left: 50%; bottom: 16px; z-index: 60;
  width: min(680px, calc(100vw - 24px));
  transform: translate(-50%, 140%); opacity: 0;
  transition: transform .35s ease, opacity .35s ease;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 13px 16px; border-radius: 14px;
  background: rgba(10,10,14,.94); border: 1px solid var(--line);
  box-shadow: 0 18px 40px rgba(0,0,0,.55);
  backdrop-filter: blur(6px);
  font-size: 13px; color: var(--muted); line-height: 1.5;
}
.consent-bar.in { transform: translate(-50%, 0); opacity: 1; }
.consent-bar.gone { transform: translate(-50%, 140%); opacity: 0; }
.consent-bar p { margin: 0; flex: 1 1 320px; }
.consent-bar a { color: var(--gold-2); }
.consent-buttons { display: flex; gap: 8px; margin-left: auto; }
.consent-bar button {
  font: inherit; font-weight: 600; cursor: pointer;
  padding: 8px 16px; border-radius: 99px; border: 1px solid var(--line);
  background: transparent; color: var(--muted);
}
.consent-bar button:hover { border-color: var(--gold); color: var(--gold-2); }
.consent-bar .consent-yes { background: var(--gold); border-color: var(--gold); color: #1a1408; }
.consent-bar .consent-yes:hover { background: var(--gold-2); color: #1a1408; }
@media (max-width: 560px) {
  .consent-bar { bottom: 10px; font-size: 12px; padding: 12px 14px; }
  .consent-buttons { width: 100%; margin-left: 0; }
  .consent-bar button { flex: 1; }
}

.footer { text-align: center; color: var(--muted); font-size: 13px; padding: 24px 16px 40px; }
.footer a { color: var(--muted); }

/* ---------- dialog ---------- */
.dialog {
  width: min(520px, calc(100vw - 24px)); max-height: calc(100svh - 24px);
  padding: 0; border: 1px solid var(--line); border-radius: 18px;
  background: var(--panel-solid); color: var(--text); overflow: auto;
}
.dialog::backdrop { background: rgba(0,0,0,.75); backdrop-filter: blur(3px); }
.dialog form { padding: 18px 20px 20px; }
.dialog-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.dialog h2 { font-family: Cinzel, serif; color: var(--gold); margin: 0; }
.icon-btn { background: none; border: 0; color: var(--muted); font-size: 20px; cursor: pointer; padding: 6px 8px; }

.picker { border: 0; margin: 0 0 12px; padding: 0; }
.picker legend { font-size: 14px; margin-bottom: 8px; padding: 0; }
.character-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.character-option {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: radial-gradient(circle at 50% 35%, #2a2112, #0c0b08 75%);
  border: 2px solid transparent; border-radius: 14px; padding: 6px 4px 8px;
  color: var(--text); cursor: pointer; font: 600 12px/1.2 Inter, sans-serif; text-align: center;
}
.character-option:hover { border-color: var(--line); }
.character-option[aria-checked="true"] { border-color: var(--gold); box-shadow: 0 0 20px rgba(232,184,74,.3); }
.character-option .portrait { width: 100%; aspect-ratio: 11 / 14; display: grid; place-items: center; font-size: 34px; }
.character-option img { width: 100%; height: 100%; object-fit: contain; }
.character-option small { color: var(--muted); font-weight: 400; }

.field { display: block; margin-bottom: 10px; }
.field > span { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 5px; }
.field small { color: var(--muted); }
.field input, .field select {
  width: 100%; font: 16px Inter, sans-serif; color: var(--text); background: #07070a;
  border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px;
}
.field input:focus, .field select:focus { outline: 2px solid var(--gold); border-color: transparent; }

.field-hint { display: block; margin: -1px 0 7px; font-size: 13px; line-height: 1.35; color: #d4c6a6; }

/* The capital picker: a search box with a list of matching cities under it */
.city-field { position: relative; }
.city-field > label > span { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 5px; }
.city-list {
  position: absolute; z-index: 5; left: 0; right: 0; top: calc(100% + 4px); max-height: 260px; overflow-y: auto;
  margin: 0; padding: 4px; list-style: none; background: #0d0b08; border: 1px solid var(--gold); border-radius: 10px;
  box-shadow: 0 12px 30px rgba(0,0,0,.6); overscroll-behavior: contain;
}
.city-list[hidden] { display: none; }
.city-option {
  display: flex; justify-content: space-between; align-items: baseline; gap: 10px; padding: 9px 10px; border-radius: 7px; cursor: pointer;
  font-family: "Twemoji Country Flags", Inter, sans-serif;
}
.city-option:hover, .city-option[aria-selected="true"] { background: rgba(232,184,74,.16); }
.city-name { font-size: 15px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.city-country { flex: none; font-size: 12px; color: var(--muted); }
.city-empty { padding: 10px; font-size: 13px; color: var(--muted); }

.preview {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 2px;
  padding: 10px; margin: 4px 0 12px; border-radius: 12px; background: #07070a; border: 1px dashed var(--line);
}
.preview-label { font-size: 10px; text-transform: uppercase; letter-spacing: .22em; color: var(--gold); font-weight: 800; }
.preview-name { font-family: Cinzel, serif; font-weight: 800; font-size: 22px; color: var(--gold-2); overflow-wrap: anywhere; }
.preview-city { font-size: 13px; color: var(--muted); }
.form-error { color: #ffb3ab; font-size: 14px; margin: 0 0 10px; }
.cta.wide { animation: none; }

/* ---------- responsive ---------- */
@media (max-width: 760px) {
  .stage { height: auto; min-height: 0; max-height: none; }
  #world { position: relative; height: 58svh; min-height: 360px; }
  .stage-shade { bottom: auto; height: max(58svh, 360px); background: linear-gradient(0deg, var(--bg) 0%, transparent 28%); }
  .stage-ui { position: static; display: block; padding: 0 16px 8px; }
  .slogan { position: absolute; top: 54px; left: 16px; right: 16px; font-size: 28px; text-align: center; max-width: none; }
  .slogan span { display: block; font-size: 13px; margin-top: 6px; }
  /* The report takes the card's old place over the foot of the map, so it is on screen at once */
  .war-report { position: relative; z-index: 2; margin: -44px auto 0; width: 100%; }
  .ruler-card { position: relative; z-index: 2; margin: 0 auto; width: 100%; }
  .banners { top: 96px; }
  .boards { grid-template-columns: 1fr; }
  .topbar { font-size: 12px; padding: 12px 16px; }
  .character-grid { grid-template-columns: repeat(2, 1fr); }
  .character-option .portrait { aspect-ratio: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .cta { animation: none; }
}

/* Desktop: map fills the screen, ruler info docks as a bar along the bottom */
@media (min-width: 761px) {
  .stage-shade {
    background:
      linear-gradient(180deg, rgba(2,3,6,.85) 0%, rgba(2,3,6,.45) 16%, transparent 30%),
      linear-gradient(0deg, var(--bg) 0%, rgba(2,3,6,.55) 14%, transparent 30%);
  }
  .stage-ui { justify-content: space-between; padding: 60px clamp(16px, 3vw, 40px) 20px; }
  .banners { left: auto; right: clamp(16px, 3vw, 40px); display: flex; flex-direction: column; align-items: flex-end; max-width: min(420px, 45vw); }
  .demo-banner, .notice { margin: 0 0 8px; max-width: 100%; }
  .slogan { font-size: clamp(28px, 3.2vw, 46px); margin: 0; }
  .war-report { width: min(1180px, 100%); margin: 0 auto; }
  .ruler-card {
    width: min(1180px, 100%); margin: 0 auto;
    display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr) minmax(220px, .8fr);
    gap: 24px; align-items: center; padding: 14px 22px;
  }
  .king-name { font-size: clamp(24px, 2.3vw, 34px); }
  .king-message { margin: 6px 0 0; font-size: 15px; }
  .record-line { margin: 8px 0 0; }
  .ruler-action .fineprint { margin-top: 8px; }
}
@media (min-width: 761px) and (max-width: 1080px) {
  .ruler-card { grid-template-columns: 1fr 1fr; gap: 12px 20px; }
  .ruler-action { grid-column: 1 / -1; display: flex; align-items: center; gap: 16px; }
  .ruler-action .cta { max-width: 320px; }
  .ruler-action .fineprint { margin: 0; text-align: left; }
}

/* ---------- engagement features ---------- */
body, .list, .dialog, .notice, .announce, .city-label, .ruling-from { font-family: "Twemoji Country Flags", Inter, system-ui, sans-serif; }

.topbar-right { display: flex; align-items: center; gap: 14px; }
.sound-btn, .pill-link {
  background: rgba(0,0,0,.4); border: 1px solid var(--line); color: var(--text); border-radius: 99px;
  font: 600 12px/1 Inter, sans-serif; padding: 6px 10px; cursor: pointer;
}
.pill-link { text-decoration: none; white-space: nowrap; }
.pill-link:hover { border-color: var(--gold); color: var(--gold-2); }
.sound-btn[aria-pressed="true"] { border-color: var(--gold); color: var(--gold-2); }

.ruler-titles { margin: 6px 0 0; font-size: 12px; color: var(--gold-2); min-height: 0; }
.ruler-titles:empty { display: none; }
/* ---------- the war report ---------- */
/* A newsroom band right above the ruler's card: one headline at a time, wide enough to read
   across the room, in the reigning ruler's colour. */
.war-report {
  /* Sits flush on the card, like a strip of newsprint pinned to it: shallow, so the map and the
     ruler keep as much of the screen as possible. */
  display: flex; align-items: center; gap: 12px; height: 34px; overflow: hidden;
  padding: 0 14px; border-radius: 14px 14px 0 0;
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--ruler) 22%, transparent) 0%, rgba(2,3,6,.72) 42%, rgba(2,3,6,.72) 100%),
    var(--panel);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border: 1px solid color-mix(in srgb, var(--ruler) 35%, transparent);
  border-bottom: 0; /* the card's own top edge closes it off */
  box-shadow: 0 -6px 24px rgba(0,0,0,.35), inset 0 1px 0 color-mix(in srgb, var(--ruler) 22%, transparent);
}
.war-report[hidden] { display: none; }
.war-report:not([hidden]) + .ruler-card { border-top-left-radius: 0; border-top-right-radius: 0; }
/* Phones: shallower still, and the label tightens up — every pixel here is map */


.war-live {
  display: inline-flex; align-items: center; gap: 7px; flex: none;
  padding-right: 14px; border-right: 1px solid color-mix(in srgb, var(--ruler) 30%, transparent);
  font: 800 11px/1 Inter, sans-serif; letter-spacing: .18em; color: var(--ruler);
}
.war-live i { width: 8px; height: 8px; border-radius: 50%; background: var(--ruler); animation: livePulse 1.8s infinite; }
@keyframes livePulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ruler) 70%, transparent); }
  70% { box-shadow: 0 0 0 9px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

/* Always one line: app.js shrinks a long headline instead of wrapping it */
.next-conquest {
  flex: 1; min-width: 0; margin: 0; overflow: hidden;
  white-space: nowrap; text-overflow: ellipsis;
  font: 800 16px/1.2 "Twemoji Country Flags", "JetBrains Mono", monospace; color: var(--text);
  text-shadow: 0 0 14px color-mix(in srgb, var(--ruler) 40%, transparent);
}
.next-conquest.news-in { animation: newsIn .45s ease; }
@keyframes newsIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .next-conquest.news-in { animation: none; }
  .war-live i { animation: none; }
}
.record-line { margin-top: 4px; }

.share-btn {
  display: block; width: 100%; margin-top: 8px; padding: 9px 12px; border-radius: 99px; cursor: pointer;
  background: transparent; border: 1px solid var(--line); color: var(--text); font: 700 14px/1 Inter, sans-serif;
}
.share-btn:hover { border-color: var(--gold); color: var(--gold-2); }

.list .badges { grid-column: 1 / -1; font-size: 12px; color: var(--gold-2); }
.boards { grid-template-columns: repeat(2, minmax(0, 1fr)); }

/* Big centre-screen headlines */
.announce {
  position: fixed; left: 50%; top: 22%; z-index: 50; pointer-events: none;
  display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center;
  width: min(560px, calc(100vw - 32px)); /* narrow enough to stay clear of the siege panel on the left */
  transform: translate(-50%, -10px) scale(.92); opacity: 0;
  transition: opacity .35s ease, transform .5s cubic-bezier(.2, 1.4, .4, 1);
}
.announce.show { opacity: 1; transform: translate(-50%, 0) scale(1); }
.announce-kicker {
  font: 800 11px/1 Inter, sans-serif; letter-spacing: .3em; text-transform: uppercase; color: var(--announce);
  background: rgba(2,3,6,.75); padding: 6px 12px; border-radius: 99px; border: 1px solid var(--announce);
}
.announce-headline {
  font: 800 clamp(20px, 2.8vw, 36px)/1.1 "Twemoji Country Flags", Cinzel, serif; color: #fff;
  text-shadow: 0 0 30px color-mix(in srgb, var(--announce) 80%, transparent), 0 4px 16px #000, 0 0 3px #000;
}
.confetti { position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: 49; pointer-events: none; }

/* Share dialog */
.share-dialog { width: min(640px, calc(100vw - 24px)); }
.share-body { padding: 18px 20px 20px; }
.share-subtitle { color: var(--muted); margin: 0 0 12px; font-size: 14px; }
.share-preview { border-radius: 12px; overflow: hidden; border: 1px solid var(--line); background: #07070a; aspect-ratio: 1200 / 630; }
.share-preview img { width: 100%; height: 100%; display: block; object-fit: cover; }
.share-preview img:not([src]) { visibility: hidden; }
.share-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; margin-top: 12px; }
.share-main { grid-column: 1 / -1; }
.share-link {
  display: flex; align-items: center; justify-content: center; gap: 6px; padding: 10px; border-radius: 12px;
  background: #07070a; border: 1px solid var(--line); color: var(--text); text-decoration: none;
  font: 700 14px/1 Inter, sans-serif; cursor: pointer;
}
.share-link:hover { border-color: var(--gold); color: var(--gold-2); }

@media (max-width: 760px) {
  .boards { grid-template-columns: 1fr; }
  .sound-btn { padding: 5px 8px; }
  .sound-label, #fallenWord { display: none; }
  .brand, .fallen-count { white-space: nowrap; }
  .topbar-right { gap: 8px; }
  .announce { top: 18%; }
}



@media (max-width: 760px) {
}

/* ---------- the ruler's emote bar ---------- */
.emote-bar { margin-top: 12px; max-width: 340px; }
.emote-bar[hidden] { display: none; }
.emote-label {
  display: block; font-size: 10px; letter-spacing: .18em; text-transform: uppercase;
  color: var(--ruler); font-weight: 800; margin-bottom: 6px;
}
.emote-buttons { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.emote {
  padding: 9px 6px; border-radius: 12px; cursor: pointer; white-space: nowrap;
  background: rgba(0,0,0,.35); border: 1px solid var(--ruler); color: var(--text);
  font: 700 13px/1 Inter, sans-serif;
}
.emote:hover { background: color-mix(in srgb, var(--ruler) 22%, transparent); color: #fff; }
.emote:active { transform: scale(.96); }

/* The ruler info column keeps its text at the top and the emote bar at the bottom */
@media (min-width: 761px) {
  .ruler-info { display: flex; flex-direction: column; }
  .ruler-info .emote-bar { margin-top: auto; }
  .king-message { margin-bottom: 4px; }
}

/* ---------- live watchers ---------- */
.watchers {
  margin: 8px auto 0; width: fit-content; font-size: 12px; font-weight: 700; color: var(--text);
  background: rgba(0,0,0,.35); border: 1px solid var(--line); border-radius: 99px; padding: 4px 10px;
}
.watchers[hidden] { display: none; }
.ruler-meta .watchers { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 11px; padding: 4px 9px; }


.board-link { display: inline-block; margin-top: 10px; color: var(--gold-2); font-size: 14px; font-weight: 700; text-decoration: none; }
.board-link:hover { text-decoration: underline; }

/* ---------- nation vs nation ---------- */
.announce-sub {
  margin-top: 4px; font: 700 clamp(12px, 1.05vw, 14px)/1.3 "Twemoji Country Flags", Inter, sans-serif; color: var(--gold-2);
  background: rgba(2,3,6,.8); border: 1px solid var(--announce); padding: 5px 14px; border-radius: 99px;
  box-shadow: 0 0 14px color-mix(in srgb, var(--announce) 35%, transparent);
}
.ruler-rivalry { margin: 4px 0 0; font: 700 13px/1.3 "Twemoji Country Flags", Inter, sans-serif; color: var(--gold-2); }
.ruler-rivalry[hidden] { display: none; }
.announce-sub:empty { display: none; }
.board-wide { grid-column: 1 / -1; }
.film-link { grid-column: 1 / -1; width: fit-content; font-size: 12px; font-weight: 700; color: var(--gold-2); text-decoration: none; }
.film-link:hover { text-decoration: underline; }
.notice-link { color: inherit; font-weight: 800; }

/* ---------- stream mode (/?stream) ---------- */
.stream-join { display: none; }
html.stream main, html.stream .footer, html.stream .share-btn, html.stream #claimBtn,
html.stream .ruler-action .fineprint, html.stream .cta-price,
html.stream .emote-bar, html.stream .sound-btn { display: none !important; }
html.stream .stage { height: 100vh; min-height: 0; max-height: none; }
html.stream .stream-join {
  display: flex; align-items: center; gap: 14px; padding: 10px; border-radius: 14px;
  background: rgba(0,0,0,.35); border: 1px solid var(--gold);
}
.stream-join img { width: 108px; height: 108px; border-radius: 8px; background: #fff; flex: 0 0 auto; }
.stream-join img:not([src]) { visibility: hidden; }
.stream-join p { margin: 0; }
.stream-join-title { font: 800 18px/1.2 Cinzel, serif; color: var(--gold-2); }
.stream-join-price { font: 700 16px/1.2 Inter, sans-serif; color: var(--text); margin: 6px 0 !important; }
.stream-join-url { font: 700 11px/1.2 "JetBrains Mono", monospace; color: var(--muted); white-space: nowrap; }
html.stream .ruler-info .watchers { font-size: 14px; margin: 10px 0 0; }
/* Nation-vs-nation ticker under the top bar (both modes; larger on stream) */
.stream-ticker {
  /* tucked right under the buttons in the top bar, with the smallest gap that still reads */
  position: absolute; top: 42px; left: 0; right: 0; z-index: 3; overflow: hidden; white-space: nowrap;
  font: 700 13px/1 "Twemoji Country Flags", Inter, sans-serif; color: var(--text);
  background: rgba(2,3,6,.55); border-block: 1px solid var(--line); padding: 6px 0;
}
html.stream .stream-ticker { font-size: 16px; padding: 8px 0; }
.stream-ticker > span {
  display: inline-block; padding-left: 100%;
  /* the duration is set in app.js from the width, so the speed never changes with the news */
  animation: ticker 40s linear infinite;
  will-change: transform; backface-visibility: hidden;
}
@keyframes ticker { to { transform: translate3d(-100%, 0, 0); } }
.slogan { margin-top: 30px; }
.banners { top: 88px; }
html.stream .slogan { margin-top: 36px; }
html.stream .banners { top: 96px; }
@media (max-width: 760px) {
  .stream-ticker { top: 40px; font-size: 12px; padding: 5px 0; }
  .slogan, html.stream .slogan { top: 84px; margin-top: 0; }
  .banners, html.stream .banners { top: 124px; }
}
@media (prefers-reduced-motion: reduce) { .stream-ticker > span { animation: none; padding-left: 16px; } }

/* Stream mode on and off: the entry sits beside the sound button; the exit only shows while the
   mouse moves, so it never appears on a stream (OBS has no mouse) */
.stream-exit { display: none; }
html.stream .stream-link { display: none; }
html.stream .stream-exit {
  display: inline-block; opacity: 0; pointer-events: none;
  transition: opacity .45s ease;
}
html.stream.mouse-active .stream-exit { opacity: 1; pointer-events: auto; }

/* ---------- weekly Nation Cup ---------- */
.cup { border-color: color-mix(in srgb, var(--gold) 45%, transparent); }
.cup-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 16px; }
.cup-meta { margin: 0; color: var(--muted); font-size: 13px; }
.cup-meta:empty { display: none; }
#cupLast { margin-top: 10px; color: var(--gold-2); font-weight: 700; }
@media (min-width: 761px) {
  .cup-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0 16px; }
  .cup-list li:nth-child(-n + 5) { border-top: 0; }
}

/* ---------- the Last Stand (sieges) ---------- */
.demo-attack {
  margin-left: 8px; padding: 4px 10px; border-radius: 99px; cursor: pointer;
  background: rgba(0,0,0,.4); border: 1px solid var(--gold); color: var(--gold-2); font: 700 12px/1 Inter, sans-serif;
}
.demo-attack[hidden] { display: none; }
.siege-bar {
  --held: 0%;
  position: absolute; z-index: 4; top: 200px; left: clamp(16px, 3vw, 40px); width: min(260px, calc(100% - 32px));
  padding: 9px 14px; text-align: center; border-radius: 12px;
  background: rgba(20,4,6,.82); border: 2px solid #ff3b3b; box-shadow: 0 0 30px rgba(255,59,59,.35);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  animation: siege-pulse 1.2s ease-in-out infinite;
}
.siege-bar[hidden] { display: none; }
.siege-bar p { margin: 0; }
@keyframes siege-pulse { 50% { box-shadow: 0 0 46px rgba(255,59,59,.6); } }
.siege-kicker { font: 800 10px/1 Inter, sans-serif; letter-spacing: .3em; text-transform: uppercase; color: #ff6b5e; }
.siege-who { margin-top: 4px !important; font: 600 13px/1.3 "Twemoji Country Flags", Inter, sans-serif; color: var(--text); overflow-wrap: anywhere; }
.siege-who b { color: var(--gold-2); }
.siege-clock { font: 700 32px/1.1 "JetBrains Mono", monospace; color: #fff; margin: 3px 0 !important; text-shadow: 0 0 14px rgba(255,59,59,.7); }
.siege-held { height: 5px; border-radius: 99px; background: rgba(255,255,255,.1); overflow: hidden; }
.siege-held > div { height: 100%; width: var(--held); background: linear-gradient(90deg, var(--gold), var(--gold-2)); transition: width .3s ease; }
.siege-bonus { margin-top: 4px !important; font: 700 12px/1.3 Inter, sans-serif; color: var(--gold-2); }
.siege-hint { margin-top: 3px !important; font-size: 11px; color: var(--muted); }
.siege-bar.mine .siege-hint { color: #fff; font-weight: 800; font-size: 12px; }
.siege-queue { font-size: 12px; color: #ff9d94; }
.siege-queue:empty { display: none; }

.shield-layer { position: absolute; inset: 0; z-index: 4; pointer-events: none; }
.shield {
  position: absolute; width: 64px; height: 64px; border-radius: 50%; pointer-events: auto; cursor: pointer;
  font-size: 32px; line-height: 1; display: grid; place-items: center; touch-action: manipulation;
  background: radial-gradient(circle, rgba(255,217,122,.35), rgba(2,3,6,.75) 70%);
  border: 3px solid var(--gold-2); box-shadow: 0 0 22px rgba(255,217,122,.7);
  animation: shield-in 1.3s linear forwards;
}
@keyframes shield-in {
  0% { transform: scale(.4); opacity: 0; }
  12% { transform: scale(1.08); opacity: 1; }
  20% { transform: scale(1); }
  100% { transform: scale(.85); opacity: .75; border-color: #ff3b3b; }
}
.shield.hit { animation: shield-hit .3s ease-out forwards; pointer-events: none; }
@keyframes shield-hit { to { transform: scale(1.7); opacity: 0; } }
.shield.miss { animation: shield-miss .3s ease-in forwards; pointer-events: none; }
@keyframes shield-miss { to { transform: scale(.3); opacity: 0; } }
.shield-pop {
  position: absolute; pointer-events: none; font: 800 24px/1 Inter, sans-serif; color: var(--gold-2);
  text-shadow: 0 0 12px rgba(255,217,122,.9), 0 2px 4px #000; animation: shield-pop .9s ease-out forwards;
}
@keyframes shield-pop { from { transform: translate(8px, 0); opacity: 1; } to { transform: translate(8px, -60px); opacity: 0; } }

/* Phones: a small box centred at the bottom of the map, clear of the ruler and their city */
@media (max-width: 760px) {
  .siege-bar {
    top: calc(max(58svh, 360px) - 130px); left: 50%; right: auto; transform: translateX(-50%);
    width: min(210px, calc(100% - 32px));
    display: grid; grid-template-columns: auto 1fr; column-gap: 8px; align-items: center;
    text-align: left; padding: 5px 9px; border-radius: 9px;
  }
  .siege-kicker { display: none; }
  .siege-clock { grid-column: 1; grid-row: 1 / span 4; font-size: 19px; margin: 0 !important; }
  .siege-who, .siege-held, .siege-bonus, .siege-hint, .siege-queue { grid-column: 2; }
  .siege-who { margin-top: 0 !important; font-size: 10px; }
  .siege-bonus { margin-top: 2px !important; font-size: 9px; }
  .siege-hint { margin-top: 1px !important; font-size: 9px; }
  .siege-bar.mine .siege-hint { font-size: 10px; }
}
@media (prefers-reduced-motion: reduce) { .siege-bar { animation: none; } }


/* ---------- the map is loading ---------- */
.map-loading {
  position: absolute; left: 50%; top: 45%; transform: translate(-50%, -50%); z-index: 2; pointer-events: none;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  font: 700 14px/1 Inter, sans-serif; letter-spacing: .12em; text-transform: uppercase; color: var(--gold-2);
  transition: opacity .6s ease;
}
.map-loading-globe { font-size: 44px; animation: globe-spin 2.4s ease-in-out infinite; filter: drop-shadow(0 0 18px rgba(232,184,74,.55)); }
@keyframes globe-spin { 0%, 100% { transform: scale(1) rotate(0deg); opacity: .75; } 50% { transform: scale(1.12) rotate(12deg); opacity: 1; } }
.map-loading.done { opacity: 0; }
@media (max-width: 760px) { .map-loading { top: calc(max(58svh, 360px) / 2); } }
@media (prefers-reduced-motion: reduce) { .map-loading-globe { animation: none; } }

/* ---------- leaderboard tabs ---------- */
.tabs { display: flex; gap: 8px; margin: 0 0 14px; overflow-x: auto; }
/* Centred; auto margins (not justify-content) so a too-narrow screen can still scroll to the first tab */
.tabs > :first-child { margin-left: auto; }
.tabs > :last-child { margin-right: auto; }
.tabs [role="tab"] {
  flex: 0 0 auto; padding: 9px 16px; border-radius: 99px; cursor: pointer;
  background: var(--panel-solid); border: 1px solid var(--line); color: var(--muted);
  font: 700 14px/1 Inter, sans-serif;
}
.tabs [role="tab"]:hover { color: var(--text); border-color: var(--gold); }
.tabs [role="tab"][aria-selected="true"] { background: linear-gradient(180deg, var(--gold-2), var(--gold)); color: #1a1206; border-color: transparent; }
.tabs [role="tab"]:focus-visible { outline: 2px solid var(--gold-2); outline-offset: 2px; }
.boards[hidden] { display: none; }
@media (min-width: 761px) {
  .records-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 24px; }
  .records-list li:nth-child(2) { border-top: 0; }
}
@media (max-width: 760px) {
  .tabs { gap: 6px; }
  .tabs [role="tab"] { padding: 8px 12px; font-size: 13px; }
}

/* ---------- consent, payment window, seller details ---------- */
.consent { display: flex; gap: 10px; align-items: flex-start; margin: 4px 0 12px; font-size: 13px; line-height: 1.4; color: var(--text); cursor: pointer; }
.consent input { flex: 0 0 auto; width: 18px; height: 18px; margin-top: 1px; accent-color: var(--gold); }
#claimFineprint a { color: var(--gold-2); }
.pay-dialog { width: min(880px, calc(100vw - 24px)); }
.pay-dialog::backdrop { background: rgba(2,3,6,.55); backdrop-filter: blur(2px); }
.pay-body { padding: 18px 20px 20px; }
.pay-grid { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 20px; align-items: start; }
.pay-preview { text-align: center; position: sticky; top: 0; }
.pay-preview img { width: 100%; max-width: 220px; aspect-ratio: 3 / 4; object-fit: contain; filter: drop-shadow(0 0 24px rgba(232,184,74,.45)); }
.pay-name { font: 800 22px/1.15 Cinzel, serif; color: var(--gold-2); margin: 8px 0 4px; overflow-wrap: anywhere; }
.pay-city { color: var(--muted); font-size: 13px; margin: 0; }
.pay-checkout { min-height: 420px; border-radius: 12px; overflow: hidden; background: #fff; }
.seller-info { margin: 10px 0 0; font-size: 12px; }
@media (max-width: 760px) {
  .pay-grid { grid-template-columns: 1fr; }
  .pay-preview { display: grid; grid-template-columns: 72px 1fr; gap: 12px; align-items: center; text-align: left; position: static; }
  .pay-preview img { width: 72px; }
  .pay-name { font-size: 18px; margin: 0; }
}
/* The gold diamond between the ticker's news items */
.tick-sep { display: inline-block; margin: 0 22px; color: var(--gold); font-size: .7em; vertical-align: .15em; }
@media (max-width: 760px) { .tick-sep { margin: 0 14px; } }

@media (max-width: 760px) {
  /* A narrow screen cannot hold a long headline on one line, and three seconds is too short to
     read a scrolling one — so here the band is two lines deep, and still a fixed height. */
  .war-report { height: 40px; padding: 4px 11px; gap: 9px; align-items: center; }
  .war-live { padding-right: 10px; font-size: 10px; letter-spacing: .16em; }
  .next-conquest {
    font-size: 13px; line-height: 1.2; white-space: normal;
    display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2;
  }
}
