:root {
  --bg: #130e0b;
  --bg-deep: #090706;
  --surface: rgba(45, 20, 24, 0.9);
  --surface-solid: #2b1519;
  --surface-high: #421d25;
  --line: rgba(239, 213, 161, 0.18);
  --line-strong: rgba(239, 213, 161, 0.38);
  --text: #f8efd9;
  --muted: #b8a991;
  --accent: #d7ad60;
  --accent-bright: #f1cd82;
  --accent-dark: #6f202b;
  --rival: #a85d4b;
  --crimson: #741f28;
  --crimson-bright: #b83b43;
  --royal-blue: #182e56;
  --royal-blue-bright: #315a91;
  --marble: #eadfc9;
  --success: #75b28b;
  --danger: #d86b5d;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
  --serif: "Palatino Linotype", "Book Antiqua", Palatino, Georgia, serif;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body[data-theme="greece"],
body[data-arena="greece"] {
  --bg: #09131c;
  --bg-deep: #050a10;
  --surface: rgba(18, 39, 54, 0.9);
  --surface-solid: #122736;
  --surface-high: #19394f;
  --line: rgba(190, 222, 236, 0.2);
  --line-strong: rgba(190, 222, 236, 0.42);
  --text: #f2f5ed;
  --muted: #aebfca;
  --accent: #74b5d4;
  --accent-bright: #b6ddeb;
  --accent-dark: #315f79;
}

body[data-theme="carthage"],
body[data-arena="carthage"] {
  --bg: #100d18;
  --bg-deep: #07060b;
  --surface: rgba(36, 27, 51, 0.91);
  --surface-solid: #241b33;
  --surface-high: #39284e;
  --line: rgba(224, 170, 112, 0.2);
  --line-strong: rgba(224, 170, 112, 0.43);
  --text: #fbf0de;
  --muted: #bcaec7;
  --accent: #d58f5a;
  --accent-bright: #efbb79;
  --accent-dark: #563557;
}

body[data-theme="egypt"],
body[data-arena="egypt"] {
  --bg: #111613;
  --bg-deep: #070b09;
  --surface: rgba(27, 43, 36, 0.91);
  --surface-solid: #1b2b24;
  --surface-high: #274239;
  --line: rgba(231, 197, 106, 0.2);
  --line-strong: rgba(231, 197, 106, 0.42);
  --text: #faf2d9;
  --muted: #b9b9a0;
  --accent: #d9b557;
  --accent-bright: #f2d67d;
  --accent-dark: #776326;
}

body[data-theme="persia"],
body[data-arena="persia"] {
  --bg: #130d17;
  --bg-deep: #08060a;
  --surface: rgba(46, 25, 50, 0.9);
  --surface-solid: #2e1932;
  --surface-high: #48234a;
  --line: rgba(111, 206, 193, 0.2);
  --line-strong: rgba(111, 206, 193, 0.42);
  --text: #fbf0e5;
  --muted: #c3aec3;
  --accent: #5fc3b8;
  --accent-bright: #94ddd2;
  --accent-dark: #286b67;
}

body[data-theme="china"],
body[data-arena="china"] {
  --bg: #160b0b;
  --bg-deep: #090505;
  --surface: rgba(53, 21, 20, 0.9);
  --surface-solid: #351514;
  --surface-high: #51201d;
  --line: rgba(229, 183, 92, 0.2);
  --line-strong: rgba(229, 183, 92, 0.42);
  --text: #fff2d8;
  --muted: #c6a9a0;
  --accent: #d8a94e;
  --accent-bright: #f1cd75;
  --accent-dark: #7a5424;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg-deep);
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--text);
  background:
    radial-gradient(circle at 70% 15%, color-mix(in srgb, var(--accent-dark) 32%, transparent), transparent 30%),
    linear-gradient(135deg, var(--bg), var(--bg-deep) 70%);
  font-family: var(--sans);
  transition: background 450ms ease;
}

body[data-theme="rome"] {
  background:
    radial-gradient(circle at 77% 11%, rgba(184, 59, 67, 0.17), transparent 25%),
    radial-gradient(circle at 18% 92%, rgba(24, 46, 86, 0.22), transparent 31%),
    linear-gradient(135deg, #21100f, var(--bg-deep) 70%);
}

button,
dialog {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 80%, white);
  outline-offset: 3px;
}

.ambient {
  position: fixed;
  z-index: -1;
  width: 34rem;
  height: 34rem;
  border-radius: 999px;
  filter: blur(100px);
  opacity: 0.08;
  pointer-events: none;
}

.ambient-one {
  top: -18rem;
  right: -8rem;
  background: var(--accent);
}

.ambient-two {
  bottom: -22rem;
  left: -12rem;
  background: var(--rival);
}

.topbar {
  position: relative;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(1480px, calc(100% - 48px));
  height: 88px;
  margin: 0 auto;
  border-bottom: 1px solid var(--line);
}

body[data-theme="rome"] .topbar::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: -2px;
  left: 0;
  height: 3px;
  background: repeating-linear-gradient(90deg, var(--crimson) 0 18px, var(--accent) 18px 22px, var(--royal-blue) 22px 40px, var(--accent) 40px 44px);
  opacity: 0.72;
}

.brand-button {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px;
  border: 0;
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.brand-button strong,
.brand-button small {
  display: block;
}

.brand-button strong {
  font-family: var(--serif);
  font-size: 15px;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.brand-button small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.brand-mark {
  position: relative;
  display: grid;
  grid-template-columns: repeat(2, 5px);
  place-content: center;
  gap: 5px;
  width: 37px;
  height: 37px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  transform: rotate(8deg);
  background: linear-gradient(145deg, var(--surface-high), var(--surface-solid));
  box-shadow: 0 5px 16px rgba(0, 0, 0, 0.3);
}

body[data-theme="rome"] .brand-mark {
  border-color: rgba(241, 205, 130, 0.58);
  background: linear-gradient(145deg, var(--crimson-bright), #381319 58%, var(--royal-blue));
  box-shadow: 0 5px 20px rgba(116, 31, 40, 0.38), inset 0 0 0 2px rgba(215, 173, 96, 0.12);
}

.brand-mark i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent-bright);
}

.brand-mark i:last-child {
  grid-column: 1 / 3;
  justify-self: center;
}

.topbar-actions {
  display: flex;
  gap: 8px;
}

.icon-button,
.back-button {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.025);
  color: var(--muted);
  cursor: pointer;
  transition: 180ms ease;
}

.icon-button:hover,
.back-button:hover {
  border-color: var(--line-strong);
  color: var(--accent-bright);
  transform: translateY(-1px);
}

.audio-button span {
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .06em;
}

.audio-button.is-off {
  opacity: .48;
}

#app {
  position: relative;
  width: min(1480px, calc(100% - 48px));
  min-height: calc(100vh - 88px);
  margin: 0 auto;
}

.screen {
  display: none;
  width: 100%;
  min-height: calc(100vh - 88px);
  padding: 42px 0 56px;
  animation: screen-in 420ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.screen.is-active {
  display: block;
}

@keyframes screen-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.menu-screen.is-active {
  display: grid;
  grid-template-columns: minmax(380px, 0.9fr) minmax(440px, 1.1fr);
  align-items: center;
  gap: 40px;
}

.menu-copy {
  position: relative;
  z-index: 4;
  max-width: 720px;
  padding-left: clamp(0px, 4vw, 72px);
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 18px;
  color: var(--accent-bright);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.eyebrow > span {
  width: 32px;
  height: 1px;
  background: var(--accent);
}

.eyebrow.centered {
  justify-content: center;
}

.menu-copy h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(58px, 6.8vw, 96px);
  font-weight: 600;
  line-height: 0.82;
  letter-spacing: -0.055em;
  text-transform: uppercase;
  text-shadow: 0 10px 45px rgba(0, 0, 0, 0.35);
}

.menu-copy h1 em {
  color: transparent;
  font-style: normal;
  -webkit-text-stroke: 1.4px var(--accent);
  text-shadow: none;
}

.menu-lead {
  max-width: 520px;
  margin: 24px 0;
  color: var(--muted);
  font-size: clamp(16px, 1.3vw, 20px);
  line-height: 1.7;
}

.menu-actions {
  display: flex;
  align-items: center;
  gap: 22px;
  flex-wrap: wrap;
}

.menu-new-button[hidden] { display: none; }

.home-commander {
  width: min(690px, 100%);
  margin: 0 0 20px;
  padding: 14px;
  border: 1px solid var(--line-strong);
  border-radius: 15px;
  background:
    linear-gradient(115deg, rgba(116, 31, 40, .34), transparent 45%, rgba(24, 46, 86, .28)),
    rgba(18, 12, 11, .74);
  box-shadow: inset 0 0 35px rgba(215, 173, 96, .035), 0 16px 44px rgba(0, 0, 0, .24);
  backdrop-filter: blur(12px);
}

.home-commander-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin: 0 2px 11px;
}

.home-commander-heading small,
.home-commander-heading h2,
.home-commander-heading > span { display: block; margin: 0; }
.home-commander-heading small { color: var(--accent-bright); font-size: 8px; font-weight: 900; letter-spacing: .16em; text-transform: uppercase; }
.home-commander-heading h2 { margin-top: 3px; font-family: var(--serif); font-size: 20px; font-weight: 600; }
.home-commander-heading > span { color: var(--muted); font-size: 9px; letter-spacing: .08em; text-transform: uppercase; }

.primary-button,
.secondary-button,
.bank-button,
.danger-button {
  min-height: 52px;
  padding: 0 22px;
  border-radius: 9px;
  cursor: pointer;
  font-weight: 700;
  letter-spacing: 0.02em;
  transition: 180ms ease;
}

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  min-width: 210px;
  border: 1px solid var(--accent-bright);
  background: linear-gradient(135deg, var(--accent-bright), var(--accent));
  color: #20150c;
  box-shadow: 0 12px 32px color-mix(in srgb, var(--accent-dark) 45%, transparent);
}

.primary-button:hover:not(:disabled) {
  transform: translateY(-2px);
  filter: brightness(1.07);
}

.primary-button.full {
  width: 100%;
  justify-content: center;
}

.secondary-button {
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.035);
  color: var(--text);
}

.secondary-button:hover:not(:disabled) {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}

.secondary-button.small {
  min-height: 42px;
  padding: 0 16px;
  font-size: 12px;
}

.bank-button {
  border: 1px solid color-mix(in srgb, var(--success) 80%, white);
  background: color-mix(in srgb, var(--success) 18%, transparent);
  color: #d8f4df;
}

.bank-button:hover:not(:disabled) {
  background: color-mix(in srgb, var(--success) 30%, transparent);
  transform: translateY(-2px);
}

.danger-button {
  min-height: 52px;
  padding: 0 22px;
  border: 1px solid #d87567;
  border-radius: 9px;
  background: linear-gradient(135deg, #9b332f, #6f211f);
  color: #fff4ea;
  cursor: pointer;
  font-weight: 800;
}

.danger-button:hover { filter: brightness(1.1); transform: translateY(-1px); }
.danger-button.full { width: 100%; }

button:disabled {
  cursor: not-allowed;
  filter: grayscale(0.5);
  opacity: 0.38;
}

.text-button {
  padding: 8px 2px;
  border: 0;
  border-bottom: 1px solid var(--line-strong);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
}

.text-button:hover {
  border-color: var(--accent);
  color: var(--text);
}

.campaign-summary {
  display: flex;
  gap: clamp(25px, 4vw, 54px);
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.campaign-summary strong,
.campaign-summary span {
  display: block;
}

.campaign-summary strong {
  margin-bottom: 2px;
  color: var(--accent-bright);
  font-family: var(--serif);
  font-size: 24px;
}

.campaign-summary span {
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.menu-art {
  position: relative;
  height: min(700px, calc(100vh - 130px));
  min-height: 500px;
  overflow: hidden;
  isolation: isolate;
}

.menu-art::before {
  content: "";
  position: absolute;
  z-index: 1;
  top: 4%;
  left: 50%;
  width: min(29vw, 390px);
  aspect-ratio: 1;
  border: 1px solid rgba(241, 205, 130, .32);
  border-radius: 30px;
  transform: translateX(-50%);
  background: url("assets/faction-standards-atlas.webp") 0 0 / 300% 200% no-repeat;
  box-shadow: 0 30px 95px rgba(0,0,0,.48), 0 0 70px rgba(215,173,96,.12);
  opacity: .58;
  mask-image: linear-gradient(to bottom, black 0 72%, transparent 100%);
}

.sun-disc {
  position: absolute;
  top: 8%;
  left: 50%;
  width: min(34vw, 460px);
  height: min(34vw, 460px);
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  transform: translateX(-50%);
  background:
    repeating-conic-gradient(from 0deg, transparent 0 8deg, rgba(215, 173, 96, 0.055) 8deg 9deg),
    radial-gradient(circle, color-mix(in srgb, var(--accent) 13%, transparent), transparent 68%);
  box-shadow: inset 0 0 80px rgba(215, 173, 96, 0.06);
}

.sun-disc::after {
  content: "";
  position: absolute;
  inset: 11%;
  border: 1px solid var(--line);
  border-radius: 50%;
}

.arch {
  position: absolute;
  left: 50%;
  bottom: -21%;
  border: 1px solid var(--line-strong);
  border-bottom: 0;
  border-radius: 48% 48% 0 0;
  transform: translateX(-50%);
  background: linear-gradient(110deg, rgba(255, 255, 255, 0.025), transparent 46%);
}

.arch-back {
  width: 72%;
  height: 90%;
  opacity: 0.45;
}

.arch-front {
  width: 52%;
  height: 76%;
  border-width: 16px;
  border-color: color-mix(in srgb, var(--surface-high) 92%, var(--accent));
  box-shadow: var(--shadow), inset 0 0 0 1px var(--line-strong);
}

.hero-die {
  position: absolute;
  z-index: 2;
  width: clamp(105px, 12vw, 170px);
  aspect-ratio: 1;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 24%;
  background:
    radial-gradient(circle at 28% 26%, rgba(255, 255, 255, 0.22), transparent 18%),
    linear-gradient(145deg, #d9c7a5, #92775a);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.52), inset -8px -10px 20px rgba(61, 42, 24, 0.35);
}

.hero-die::before {
  content: "";
  position: absolute;
  inset: 0;
  background-repeat: no-repeat;
  filter: drop-shadow(0 2px 1px rgba(255,255,255,.15));
}

.hero-die[data-face="5"]::before {
  background-image: radial-gradient(circle, #302219 0 11%, transparent 12%), radial-gradient(circle, #302219 0 11%, transparent 12%), radial-gradient(circle, #302219 0 11%, transparent 12%), radial-gradient(circle, #302219 0 11%, transparent 12%), radial-gradient(circle, #302219 0 11%, transparent 12%);
  background-position: 24% 24%, 76% 24%, 50% 50%, 24% 76%, 76% 76%;
  background-size: 25% 25%;
}

.hero-die[data-face="1"]::before {
  background-image: radial-gradient(circle, #302219 0 12%, transparent 13%);
  background-position: 50% 50%;
  background-size: 32% 32%;
}

.hero-die-one {
  left: 33%;
  bottom: 18%;
  transform: rotate(-13deg);
  animation: float-one 5.5s ease-in-out infinite;
}

.hero-die-two {
  right: 19%;
  bottom: 33%;
  width: clamp(85px, 10vw, 140px);
  transform: rotate(17deg);
  animation: float-two 6.5s ease-in-out infinite;
}

@keyframes float-one { 50% { transform: rotate(-10deg) translateY(-10px); } }
@keyframes float-two { 50% { transform: rotate(13deg) translateY(9px); } }

.laurel {
  position: absolute;
  z-index: 1;
  bottom: 18%;
  color: var(--accent-dark);
  font-family: Georgia, serif;
  font-size: clamp(150px, 20vw, 290px);
  line-height: 1;
  opacity: 0.55;
}

.laurel-left { left: 3%; transform: rotate(49deg); }
.laurel-right { right: -2%; transform: scaleX(-1) rotate(49deg); }

.section-heading,
.map-header,
.arena-header {
  display: flex;
  align-items: center;
  gap: 22px;
}

.section-heading {
  margin-bottom: 38px;
}

.section-heading h2,
.map-header h2,
.arena-header h2,
.game-dialog h2 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 600;
  letter-spacing: -0.025em;
}

.section-heading h2,
.map-header h2 {
  font-size: clamp(34px, 4vw, 54px);
}

.section-heading p:last-child {
  max-width: 650px;
  margin: 8px 0 0;
  color: var(--muted);
}

.commander-picker {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin: -12px 0 24px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background:
    linear-gradient(110deg, color-mix(in srgb, var(--accent-dark) 18%, transparent), transparent 45%),
    rgba(255, 255, 255, 0.022);
}

.commander-copy p,
.commander-copy h3,
.commander-copy span { margin: 0; }
.commander-copy p { color: var(--accent-bright); font-size: 8px; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
.commander-copy h3 { margin-top: 4px; font-family: var(--serif); font-size: 19px; }
.commander-copy span { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; }

.portrait-options {
  display: flex;
  align-items: stretch;
  gap: 8px;
}

.portrait-choice {
  display: grid;
  grid-template-columns: 46px minmax(0, auto);
  align-items: center;
  gap: 9px;
  min-width: 154px;
  padding: 6px 10px 6px 6px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(0, 0, 0, .16);
  color: var(--muted);
  cursor: pointer;
  text-align: left;
  transition: 180ms ease;
}

.portrait-choice img,
.portrait-standard {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  object-fit: cover;
  background: color-mix(in srgb, var(--accent-dark) 20%, var(--surface-solid));
}

.portrait-choice > span:last-child { min-width: 0; }
.portrait-choice strong,
.portrait-choice small { display: block; }
.portrait-choice strong { color: var(--text); font-family: var(--serif); font-size: 13px; }
.portrait-choice small { margin-top: 2px; overflow: hidden; color: var(--muted); font-size: 7px; letter-spacing: .06em; text-overflow: ellipsis; text-transform: uppercase; white-space: nowrap; }

.portrait-choice:hover,
.portrait-choice.active {
  border-color: var(--accent-bright);
  color: var(--text);
  background: color-mix(in srgb, var(--accent) 10%, rgba(0, 0, 0, .2));
}

.portrait-choice.active {
  box-shadow: inset 0 0 0 1px var(--accent), 0 0 22px color-mix(in srgb, var(--accent) 12%, transparent);
}

.faction-standard,
.portrait-standard,
.chip-standard,
.avatar-standard,
.mini-standard,
.node-standard,
.marching-standard,
.territory-standard {
  background-image: url("assets/faction-standards-atlas.webp");
  background-repeat: no-repeat;
  background-size: 300% 200%;
}

.standard-rome { background-position: 0 0; }
.standard-carthage { background-position: 50% 0; }
.standard-greece { background-position: 100% 0; }
.standard-egypt { background-position: 0 100%; }
.standard-persia { background-position: 50% 100%; }
.standard-china { background-position: 100% 100%; }

.territory-standard {
  border-radius: 18px;
  font-size: 0;
}

.faction-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(220px, 1fr));
  gap: 16px;
}

.faction-card {
  position: relative;
  min-height: 330px;
  overflow: hidden;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background:
    linear-gradient(180deg, transparent 35%, rgba(0,0,0,.7)),
    radial-gradient(circle at 50% 20%, var(--card-accent, var(--accent-dark)), var(--surface-solid) 58%);
  cursor: pointer;
  text-align: left;
  transition: 220ms ease;
}

.faction-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background-repeat: no-repeat;
  opacity: .3;
  filter: saturate(.88) contrast(1.08);
  mask-image: linear-gradient(to bottom, black 0 62%, transparent 94%);
}

.faction-card[data-faction="rome"]::before {
  background-image: url("assets/roman-arena-background.webp");
  background-position: center;
  background-size: cover;
}

.faction-card[data-faction="carthage"]::before {
  background-image: url("assets/faction-standards-atlas.webp");
  background-position: 50% 0;
  background-size: 300% 200%;
}

.faction-card[data-faction="greece"]::before,
.faction-card[data-faction="egypt"]::before,
.faction-card[data-faction="persia"]::before,
.faction-card[data-faction="china"]::before {
  background-image: url("assets/civilization-arena-atlas.webp");
  background-size: 200% 200%;
}

.faction-card[data-faction="greece"]::before { background-position: 0 0; }
.faction-card[data-faction="egypt"]::before { background-position: 100% 0; }
.faction-card[data-faction="persia"]::before { background-position: 0 100%; }
.faction-card[data-faction="china"]::before { background-position: 100% 100%; }

.faction-card:hover:not(.locked) {
  border-color: var(--accent);
  transform: translateY(-5px);
  box-shadow: var(--shadow);
}

.faction-card.locked {
  cursor: not-allowed;
  filter: none;
  opacity: 0.78;
}

.faction-card.locked::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(6, 5, 5, .12), rgba(6, 5, 5, .5));
  pointer-events: none;
}

.faction-card.active {
  border-color: var(--accent-bright);
  box-shadow: inset 0 0 0 1px var(--accent), 0 18px 60px rgba(0,0,0,.32);
}

.faction-card .card-pattern {
  position: absolute;
  inset: 0;
  opacity: 0.16;
  background-image: repeating-linear-gradient(45deg, transparent 0 18px, rgba(255,255,255,.15) 19px 20px);
  mask-image: linear-gradient(to bottom, black, transparent 72%);
}

.faction-card .faction-standard {
  position: relative;
  display: block;
  width: 116px;
  height: 116px;
  margin: 5px auto 43px;
  border: 1px solid color-mix(in srgb, var(--faction-accent) 60%, white);
  border-radius: 18px;
  box-shadow: 0 18px 40px rgba(0,0,0,.4), 0 0 30px color-mix(in srgb, var(--faction-accent) 16%, transparent);
}

.faction-card small,
.faction-card strong,
.faction-card span {
  position: relative;
  z-index: 2;
  display: block;
}

.faction-card small {
  color: var(--accent-bright);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.faction-card strong {
  margin: 6px 0;
  font-family: var(--serif);
  font-size: 23px;
}

.faction-card span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.faction-card .lock-mark {
  position: absolute;
  top: 17px;
  right: 17px;
  z-index: 4;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 8px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: rgba(8,6,6,.76);
  color: var(--accent-bright);
  text-align: center;
}

.faction-card .lock-mark svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }

.map-screen {
  position: relative;
  isolation: isolate;
}

.map-screen::before {
  content: "";
  position: absolute;
  z-index: 0;
  inset: -42px calc(50% - 50vw) -70px;
  background:
    linear-gradient(180deg, rgba(10,7,6,.68), rgba(7,6,6,.9)),
    url("assets/ancient-world-map.webp") center / cover no-repeat;
  filter: saturate(.64) contrast(1.08);
  opacity: .24;
  pointer-events: none;
}

.map-screen > * { position: relative; z-index: 1; }

.map-header {
  justify-content: space-between;
  margin-bottom: 24px;
}

.map-header .eyebrow,
.arena-header .eyebrow {
  margin-bottom: 4px;
}

.map-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.faction-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 150px;
  padding: 6px 12px 6px 7px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(255,255,255,.025);
  cursor: pointer;
  text-align: left;
}

.faction-chip > span:first-child {
  display: grid;
  place-items: center;
  width: 39px;
  height: 39px;
  border-radius: 8px;
  box-shadow: inset 0 0 0 1px var(--line-strong);
}

.faction-chip small,
.faction-chip strong {
  display: block;
}

.faction-chip small { color: var(--muted); font-size: 8px; text-transform: uppercase; letter-spacing: .12em; }
.faction-chip strong { margin-top: 1px; font-family: var(--serif); font-size: 13px; }

.campaign-alert {
  position: relative;
  z-index: 4;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
  margin: 0 0 14px;
  padding: 12px 14px;
  border: 1px solid rgba(210, 92, 76, .64);
  border-radius: 12px;
  background:
    linear-gradient(100deg, rgba(111, 29, 31, .92), rgba(39, 17, 18, .94) 58%, rgba(20, 28, 37, .94));
  box-shadow: 0 14px 40px rgba(0,0,0,.34), inset 0 0 28px rgba(214, 80, 63, .06);
  animation: campaign-alert-arrive 460ms cubic-bezier(.2,.8,.25,1);
}

.campaign-alert[hidden] { display: none; }
.campaign-alert-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(255, 176, 145, .45);
  border-radius: 50%;
  background: rgba(0,0,0,.24);
  color: #ffc2a5;
  font-size: 19px;
  box-shadow: 0 0 24px rgba(202, 63, 47, .18);
}
.campaign-alert small,
.campaign-alert strong { display: block; }
.campaign-alert small { color: #f2a187; font-size: 8px; font-weight: 900; letter-spacing: .18em; text-transform: uppercase; }
.campaign-alert strong { margin-top: 3px; color: #fff0df; font-family: var(--serif); font-size: 14px; font-weight: 600; }
.campaign-alert .danger-button { min-height: 42px; padding-inline: 16px; font-size: 11px; }

@keyframes campaign-alert-arrive {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.world-map {
  position: relative;
  min-height: min(590px, calc(100vh - 260px));
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(7, 7, 6, .34), rgba(8, 5, 4, .58)),
    radial-gradient(circle at 34% 48%, color-mix(in srgb, var(--accent-dark) 16%, transparent), transparent 39%),
    url("assets/ancient-world-map.webp") center / cover no-repeat,
    var(--bg-deep);
  box-shadow: var(--shadow), inset 0 0 130px rgba(0,0,0,.6), 0 0 0 1px rgba(210, 169, 91, .035);
}

.world-map::before {
  content: "";
  position: absolute;
  inset: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  z-index: 1;
  pointer-events: none;
}

.world-map::after {
  content: "✦";
  position: absolute;
  top: 28px;
  right: 31px;
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  color: var(--accent);
  font-family: var(--serif);
  font-size: 26px;
  opacity: 0.34;
  box-shadow: inset 0 0 0 8px rgba(255,255,255,.018);
  pointer-events: none;
}

.map-routes,
.map-nodes {
  position: absolute;
  z-index: 2;
  inset: 0;
  width: 100%;
  height: 100%;
}

.map-routes line {
  vector-effect: non-scaling-stroke;
  stroke: var(--line-strong);
  stroke-width: 1.5;
  stroke-dasharray: 4 6;
}

.map-routes line.claimed {
  stroke: var(--accent);
  stroke-dasharray: 0;
  filter: drop-shadow(0 0 6px color-mix(in srgb, var(--accent) 50%, transparent));
}

.map-routes line.awaiting-victory { stroke-dasharray: 4 7; }
.map-routes line.route-threatened {
  stroke: #d65a4c;
  stroke-width: 3;
  stroke-dasharray: 8 7;
  filter: drop-shadow(0 0 6px rgba(216, 76, 59, .72));
  animation: counter-route-warning 1.1s linear infinite;
}
.map-routes line.counterattack-march {
  stroke-width: 5;
  stroke-dasharray: 15 8;
  filter: drop-shadow(0 0 10px rgba(237, 92, 68, .9));
  animation-duration: .5s;
}
.map-routes line.route-victory {
  stroke: var(--accent-bright);
  stroke-width: 4;
  stroke-dasharray: 13 9;
  filter: drop-shadow(0 0 8px var(--accent));
  animation: route-march .62s linear infinite;
}

@keyframes route-march { to { stroke-dashoffset: -22; } }
@keyframes counter-route-warning { to { stroke-dashoffset: 30; } }

.map-node {
  position: absolute;
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: var(--surface-solid);
  box-shadow: 0 12px 24px rgba(0,0,0,.38), inset 0 0 0 6px rgba(255,255,255,.025);
  cursor: pointer;
  transition: 200ms ease;
}

.map-node::before {
  content: "";
  position: absolute;
  inset: -7px;
  border: 1px solid transparent;
  border-radius: inherit;
}

.map-node:hover:not(.locked) {
  z-index: 5;
  transform: translate(-50%, -50%) scale(1.08);
}

.map-node.available {
  border-color: var(--accent-bright);
  animation: node-pulse 2.2s ease-in-out infinite;
}

.map-node.available::before { border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.map-node.claimed { border-color: var(--success); background: color-mix(in srgb, var(--success) 16%, var(--surface-solid)); }
.map-node.locked { cursor: not-allowed; opacity: .44; filter: grayscale(.7); }
.map-node.threatened {
  z-index: 7;
  border-color: #ef8068;
  background: linear-gradient(145deg, #641f25, #181316);
  box-shadow: 0 12px 28px rgba(0,0,0,.5), inset 0 0 0 6px rgba(255,255,255,.025), 0 0 32px rgba(218, 65, 53, .56);
  animation: threatened-node-pulse 1.2s ease-in-out infinite;
}
.map-node.threatened::before { border-color: rgba(255, 129, 101, .7); }

.map-node[data-civilization="rome"] { --node-color: #c74b4e; --node-deep: #5a1820; }
.map-node[data-civilization="carthage"] { --node-color: #d58f5a; --node-deep: #443052; }
.map-node[data-civilization="greece"] { --node-color: #75c6ea; --node-deep: #183f61; }
.map-node[data-civilization="egypt"] { --node-color: #e6bd52; --node-deep: #4d5324; }
.map-node[data-civilization="persia"] { --node-color: #62d0c0; --node-deep: #482750; }
.map-node[data-civilization="china"] { --node-color: #e04d41; --node-deep: #681b1c; }

.map-node[data-civilization] {
  border-color: color-mix(in srgb, var(--node-color) 68%, var(--line));
  background:
    radial-gradient(circle at 35% 27%, color-mix(in srgb, var(--node-color) 24%, transparent), transparent 29%),
    linear-gradient(145deg, color-mix(in srgb, var(--node-deep) 84%, var(--surface-solid)), var(--surface-solid));
}

.map-node[data-civilization].available {
  border-color: color-mix(in srgb, var(--node-color) 82%, white);
  box-shadow: 0 12px 24px rgba(0,0,0,.38), inset 0 0 0 6px color-mix(in srgb, var(--node-color) 7%, transparent), 0 0 24px color-mix(in srgb, var(--node-color) 22%, transparent);
}

.map-node[data-civilization].claimed {
  border-color: var(--node-color);
  background:
    radial-gradient(circle at 35% 27%, color-mix(in srgb, var(--node-color) 31%, transparent), transparent 32%),
    linear-gradient(145deg, color-mix(in srgb, var(--node-deep) 72%, var(--surface-solid)), var(--surface-solid));
}

.map-node[data-civilization].threatened {
  border-color: #ff9478;
  background:
    radial-gradient(circle at 35% 27%, color-mix(in srgb, var(--node-color) 22%, transparent), transparent 32%),
    linear-gradient(145deg, #6d2227, #171215 72%);
}

@keyframes node-pulse {
  50% { box-shadow: 0 12px 24px rgba(0,0,0,.38), 0 0 0 8px color-mix(in srgb, var(--accent) 7%, transparent); }
}

@keyframes threatened-node-pulse {
  50% { transform: translate(-50%, -50%) scale(1.08); box-shadow: 0 12px 28px rgba(0,0,0,.5), 0 0 0 10px rgba(216, 67, 52, .1), 0 0 44px rgba(230, 77, 58, .68); }
}

.map-node .node-standard {
  display: block;
  width: 46px;
  height: 46px;
  border: 1px solid color-mix(in srgb, var(--node-color) 65%, white);
  border-radius: 50%;
  box-shadow: 0 0 18px color-mix(in srgb, var(--node-color) 18%, transparent);
}

.map-node.awaiting-capture { opacity: .55; }
.map-node.captured-flash {
  z-index: 8;
  animation: territory-captured 1.9s cubic-bezier(.18,.8,.22,1);
}

.map-node.counterattack-impact { animation: counterattack-impact 700ms cubic-bezier(.18,.8,.22,1), threatened-node-pulse 1.2s 700ms ease-in-out infinite; }

@keyframes counterattack-impact {
  0% { transform: translate(-50%, -50%) scale(.8); filter: brightness(2.2); }
  38% { transform: translate(-50%, -50%) scale(1.34); box-shadow: 0 0 0 18px rgba(223, 71, 55, .14), 0 0 70px #df4737; }
  100% { transform: translate(-50%, -50%) scale(1); }
}

@keyframes territory-captured {
  0% { transform: translate(-50%, -50%) scale(.62); filter: brightness(2); }
  24% { transform: translate(-50%, -50%) scale(1.32); box-shadow: 0 0 0 14px color-mix(in srgb, var(--node-color) 15%, transparent), 0 0 58px var(--node-color); }
  55% { transform: translate(-50%, -50%) scale(.96); }
  100% { transform: translate(-50%, -50%) scale(1); }
}

.marching-standard {
  position: absolute;
  z-index: 12;
  display: block;
  width: 74px;
  height: 74px;
  border: 2px solid var(--accent-bright);
  border-radius: 16px;
  box-shadow: 0 12px 36px rgba(0,0,0,.58), 0 0 35px var(--accent);
  pointer-events: none;
}

.marching-rival {
  position: absolute;
  z-index: 13;
  display: block;
  width: 76px;
  height: 76px;
  border: 3px solid #ef8068;
  border-radius: 50%;
  background-image: url("assets/rival-commanders-atlas.webp");
  background-repeat: no-repeat;
  background-size: 300% 200%;
  box-shadow: 0 14px 38px rgba(0,0,0,.66), 0 0 34px rgba(225, 68, 53, .7), inset 0 0 0 5px rgba(0,0,0,.25);
  pointer-events: none;
}

.map-victory-callout {
  position: absolute;
  z-index: 14;
  top: 24px;
  left: 50%;
  min-width: min(390px, calc(100% - 130px));
  padding: 12px 20px;
  border: 1px solid var(--accent-bright);
  border-radius: 12px;
  transform: translate(-50%, -18px);
  background: linear-gradient(135deg, rgba(92,28,31,.94), rgba(17,31,57,.94));
  box-shadow: 0 18px 55px rgba(0,0,0,.58), 0 0 28px color-mix(in srgb, var(--accent) 18%, transparent);
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: 280ms ease;
}

.map-victory-callout.show { transform: translate(-50%, 0); opacity: 1; }
.map-victory-callout.counterattack {
  border-color: #ef8068;
  background: linear-gradient(135deg, rgba(108, 26, 30, .97), rgba(28, 12, 14, .97) 58%, rgba(32, 28, 35, .97));
  box-shadow: 0 18px 60px rgba(0,0,0,.66), 0 0 34px rgba(220, 69, 52, .33);
}
.map-victory-callout.counterattack small { color: #f5a389; }
.map-victory-callout.counterattack strong { color: #fff0df; }
.map-victory-callout small,
.map-victory-callout strong,
.map-victory-callout span { display: block; }
.map-victory-callout small { color: var(--accent-bright); font-size: 8px; font-weight: 900; letter-spacing: .17em; text-transform: uppercase; }
.map-victory-callout strong { margin: 3px 0; font-family: var(--serif); font-size: 25px; }
.map-victory-callout span { color: var(--muted); font-size: 9px; }

.map-node .node-check {
  position: absolute;
  top: -3px;
  right: -3px;
  display: grid;
  place-items: center;
  width: 23px;
  height: 23px;
  border: 2px solid var(--surface-solid);
  border-radius: 50%;
  background: var(--success);
  color: #0d2515;
  font-size: 12px;
  font-weight: 900;
}

.map-node .node-threat {
  position: absolute;
  top: -7px;
  right: -7px;
  display: grid;
  place-items: center;
  width: 27px;
  height: 27px;
  border: 2px solid #ffd0b8;
  border-radius: 50%;
  background: #a82f31;
  color: #fff5e8;
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 900;
  box-shadow: 0 5px 16px rgba(0,0,0,.55), 0 0 18px rgba(231, 77, 59, .68);
}

.map-node .node-label {
  position: absolute;
  top: calc(100% + 9px);
  left: 50%;
  width: max-content;
  max-width: 120px;
  transform: translateX(-50%);
  color: var(--text);
  font-family: var(--serif);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .05em;
  text-shadow: 0 2px 6px #000;
}

.map-node .node-label small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 7px;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.map-legend {
  position: absolute;
  right: 26px;
  bottom: 22px;
  display: flex;
  gap: 15px;
  padding: 10px 13px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(0,0,0,.25);
  color: var(--muted);
  font-size: 9px;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.map-legend span { display: flex; align-items: center; gap: 6px; }
.legend-dot { width: 7px; height: 7px; border-radius: 50%; background: #555; }
.legend-dot.claimed { background: var(--success); }
.legend-dot.available { background: var(--accent-bright); }
.legend-dot.threatened { background: #e76551; box-shadow: 0 0 7px rgba(231, 101, 81, .75); }
.legend-dot.locked { background: #69645d; }

.map-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 25px;
  padding: 20px 4px 0;
  color: var(--muted);
}

.map-footer > div { flex: 1; max-width: 520px; }
.map-progress-label { display: block; margin-bottom: 7px; font-size: 9px; letter-spacing: .14em; text-transform: uppercase; }
.map-defense-rule { display: block; margin-top: 8px; color: color-mix(in srgb, var(--muted) 82%, var(--accent-bright)); font-size: 8px; letter-spacing: .05em; }
.progress-track, .mini-progress { overflow: hidden; height: 5px; border-radius: 999px; background: rgba(255,255,255,.08); }
.progress-track i, .mini-progress i { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--accent-dark), var(--accent-bright)); transition: width 450ms ease; }
.map-footer strong { font-size: 12px; }

.game-screen {
  position: relative;
  isolation: isolate;
  padding-top: 24px;
}

.game-screen.is-active::before,
.game-screen.is-active::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 100vw;
  transform: translateX(-50%);
  pointer-events: none;
}

.game-screen.is-active::before {
  z-index: -2;
  opacity: 0.46;
  filter: saturate(1.08) contrast(1.04);
}

body[data-theme="rome"] .game-screen.is-active::before {
  background: url("assets/roman-arena-background.webp") center top / cover no-repeat;
}

body[data-theme="carthage"] .game-screen.is-active::before {
  background-image: url("assets/faction-standards-atlas.webp");
  background-position: 50% 0;
  background-repeat: no-repeat;
  background-size: 300% 200%;
}

body[data-theme="greece"] .game-screen.is-active::before,
body[data-theme="egypt"] .game-screen.is-active::before,
body[data-theme="persia"] .game-screen.is-active::before,
body[data-theme="china"] .game-screen.is-active::before {
  background-image: url("assets/civilization-arena-atlas.webp");
  background-repeat: no-repeat;
  background-size: 200% 200%;
}

body[data-theme="greece"] .game-screen.is-active::before { background-position: 0 0; }
body[data-theme="egypt"] .game-screen.is-active::before { background-position: 100% 0; }
body[data-theme="persia"] .game-screen.is-active::before { background-position: 0 100%; }
body[data-theme="china"] .game-screen.is-active::before { background-position: 100% 100%; }

.game-screen.is-active::after {
  z-index: -1;
  background:
    linear-gradient(90deg, rgba(9, 7, 6, 0.82), rgba(22, 11, 11, 0.48) 28%, rgba(9, 7, 6, 0.48) 72%, rgba(9, 7, 6, 0.84)),
    linear-gradient(180deg, rgba(9, 7, 6, 0.24), rgba(9, 7, 6, 0.88));
}

.arena-header {
  display: grid;
  grid-template-columns: 48px minmax(240px, 1fr) minmax(230px, .75fr) auto;
  align-items: center;
  gap: 14px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

body[data-theme="rome"] .game-screen .arena-header {
  position: relative;
  overflow: hidden;
  padding: 15px 18px 17px;
  border: 1px solid rgba(215, 173, 96, 0.35);
  border-radius: 14px;
  background:
    linear-gradient(90deg, rgba(116, 31, 40, 0.68), rgba(39, 18, 18, 0.88) 38%, rgba(24, 46, 86, 0.64)),
    rgba(15, 10, 9, 0.88);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.28), inset 0 0 35px rgba(215, 173, 96, 0.04);
}

body:not([data-theme="rome"]) .game-screen .arena-header {
  position: relative;
  overflow: hidden;
  padding: 15px 18px 17px;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--accent-dark) 45%, rgba(8, 9, 12, .9)), rgba(8, 9, 12, .82) 48%, color-mix(in srgb, var(--accent-dark) 35%, rgba(8, 9, 12, .88))),
    var(--surface);
  box-shadow: 0 18px 50px rgba(0, 0, 0, .3), inset 0 0 35px color-mix(in srgb, var(--accent) 4%, transparent);
}

.arena-motto {
  overflow: hidden;
  color: rgba(241, 205, 130, 0.22);
  font-family: var(--serif);
  font-size: clamp(15px, 1.5vw, 24px);
  letter-spacing: 0.12em;
  text-align: center;
  white-space: nowrap;
}

.arena-motto i { color: var(--accent); font-style: normal; font-size: .48em; vertical-align: middle; }

.arena-location small {
  color: var(--accent-bright);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .15em;
  text-transform: uppercase;
}

.arena-location h2 { margin-top: 3px; font-size: 26px; }

.series-score {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

.series-score span { padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; }
.series-score b { color: var(--text); font-size: 16px; }
.series-goal { min-width: 88px; text-align: center; }
.series-goal i,
.series-goal small { display: block; }
.series-goal i { color: var(--accent); font-style: normal; font-size: 8px; font-weight: 800; letter-spacing: .12em; }
.series-goal small { margin-top: 3px; color: var(--muted); font-size: 7px; letter-spacing: .08em; }

.game-layout {
  display: grid;
  grid-template-columns: minmax(160px, 220px) minmax(560px, 1fr) minmax(160px, 220px);
  align-items: stretch;
  gap: 18px;
  margin-top: 18px;
}

.score-card,
.dice-arena {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 18px 60px rgba(0,0,0,.23);
  backdrop-filter: blur(16px);
}

.score-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 540px;
  padding: 25px 18px;
  text-align: center;
}

body[data-theme="rome"] .score-card {
  overflow: hidden;
  border-color: rgba(215, 173, 96, 0.28);
}

body[data-theme="rome"] .player-card {
  background:
    radial-gradient(circle at 50% 18%, rgba(241, 205, 130, 0.16), transparent 29%),
    linear-gradient(180deg, rgba(116, 31, 40, 0.92), rgba(37, 15, 16, 0.93) 55%, rgba(16, 12, 11, 0.94));
}

body[data-theme="rome"] .rival-card {
  background:
    radial-gradient(circle at 50% 18%, rgba(89, 128, 180, 0.18), transparent 29%),
    linear-gradient(180deg, rgba(24, 46, 86, 0.94), rgba(17, 27, 48, 0.94) 55%, rgba(12, 12, 17, 0.95));
}

body[data-theme="rome"] .score-card::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 7px;
  background: repeating-linear-gradient(90deg, transparent 0 8px, var(--accent) 8px 12px, transparent 12px 20px);
  opacity: 0.55;
}

.score-card::before {
  content: "";
  width: 1px;
  height: 46px;
  margin-bottom: 18px;
  background: linear-gradient(transparent, var(--line-strong));
}

body[data-theme="rome"] .score-card::before {
  content: "❦";
  width: auto;
  height: auto;
  margin-bottom: 13px;
  background: none;
  color: rgba(241, 205, 130, 0.72);
  font-family: var(--serif);
  font-size: 30px;
  line-height: 1;
}

.score-avatar {
  position: relative;
  display: grid;
  place-items: center;
  width: 76px;
  height: 76px;
  margin-bottom: 18px;
  border: 1px solid var(--accent);
  border-radius: 50%;
  background:
    repeating-conic-gradient(from 0deg, transparent 0 14deg, rgba(255,255,255,.035) 15deg 16deg),
    color-mix(in srgb, var(--accent-dark) 30%, var(--surface-solid));
  color: var(--accent-bright);
  font-family: var(--serif);
  font-size: 28px;
  box-shadow: inset 0 0 0 7px rgba(0,0,0,.14);
}

.score-avatar.has-portrait {
  border-width: 2px;
  background: #160d0e;
  box-shadow: 0 10px 28px rgba(0, 0, 0, .42), 0 0 0 5px color-mix(in srgb, var(--accent) 9%, transparent);
}

.score-avatar.has-standard {
  overflow: hidden;
  border-width: 2px;
  background: #120c0b;
}

.score-avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.avatar-standard {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
}

.atlas-portrait {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background-image: url("assets/rival-commanders-atlas.webp");
  background-repeat: no-repeat;
  background-size: 300% 200%;
}

.portrait-0 { background-position: 0 0; }
.portrait-1 { background-position: 50% 0; }
.portrait-2 { background-position: 100% 0; }
.portrait-3 { background-position: 0 100%; }
.portrait-4 { background-position: 50% 100%; }
.portrait-5 { background-position: 100% 100%; }

.avatar-badge {
  position: absolute;
  right: -5px;
  bottom: -4px;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 2px solid var(--surface-solid);
  border-radius: 50%;
  background: var(--accent-dark);
  color: var(--accent-bright);
  font-family: var(--serif);
  font-size: 10px;
  font-weight: 800;
  box-shadow: 0 4px 12px rgba(0, 0, 0, .42);
  overflow: hidden;
}

.mini-standard { display: block; width: 100%; height: 100%; border-radius: 50%; }

.score-avatar.rival {
  border-color: var(--rival);
  background-color: color-mix(in srgb, var(--rival) 24%, var(--surface-solid));
  color: #e6a99a;
}

.score-avatar.rival .avatar-badge { background: #263f69; color: #d6e7ff; }

.score-card small {
  color: var(--muted);
  font-size: 8px;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.score-card h3 { margin: 5px 0 24px; font-family: var(--serif); font-size: 18px; }
.banked-score { font-family: var(--serif); font-size: clamp(40px, 4vw, 60px); font-weight: 500; line-height: 1; }
.score-target { margin-top: 7px; color: var(--muted); font-size: 10px; text-transform: uppercase; }
.score-target b { color: var(--muted); }
.score-card .mini-progress { width: 100%; margin-top: 22px; }
.rival-card .mini-progress i { background: linear-gradient(90deg, color-mix(in srgb, var(--rival) 50%, #222), var(--rival)); }

.dice-arena {
  position: relative;
  overflow: hidden;
  min-height: 540px;
  padding: 20px;
}

body[data-theme="rome"] .dice-arena {
  border-color: rgba(215, 173, 96, 0.42);
  background:
    linear-gradient(135deg, rgba(116, 31, 40, 0.33), transparent 38%),
    linear-gradient(225deg, rgba(24, 46, 86, 0.36), transparent 42%),
    rgba(24, 16, 14, 0.92);
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.4), inset 0 0 50px rgba(215, 173, 96, 0.045);
}

body[data-theme="rome"] .dice-arena::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  height: 6px;
  background: repeating-linear-gradient(90deg, var(--crimson-bright) 0 22px, var(--accent-bright) 22px 27px, var(--royal-blue-bright) 27px 49px, var(--accent-bright) 49px 54px);
  opacity: 0.82;
}

.turn-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px 14px;
  color: var(--muted);
  font-size: 11px;
}

.turn-banner > span {
  color: var(--accent-bright);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.turn-banner strong { font-weight: 500; }
.turn-banner b { color: var(--text); font-family: var(--serif); font-size: 17px; }

.dice-stage {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 250px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 13px;
  background:
    radial-gradient(circle at 50% 50%, color-mix(in srgb, var(--accent-dark) 18%, transparent), transparent 50%),
    repeating-radial-gradient(circle at 50% 100%, transparent 0 44px, rgba(255,255,255,.018) 45px 46px),
    rgba(0,0,0,.18);
  box-shadow: inset 0 20px 60px rgba(0,0,0,.2);
}

body[data-theme="rome"] .dice-stage {
  border-color: rgba(215, 173, 96, 0.38);
  background:
    radial-gradient(circle at 50% 50%, rgba(116, 31, 40, 0.24), transparent 49%),
    repeating-radial-gradient(circle at 50% 110%, transparent 0 42px, rgba(241, 205, 130, 0.035) 43px 45px),
    linear-gradient(145deg, rgba(17, 11, 10, 0.92), rgba(24, 31, 49, 0.72));
  box-shadow: inset 0 22px 70px rgba(0, 0, 0, 0.42), 0 0 0 1px rgba(116, 31, 40, 0.42);
}

body[data-theme="rome"] .dice-stage::before {
  content: "";
  position: absolute;
  z-index: 1;
  inset: 9px;
  border: 1px solid rgba(215, 173, 96, 0.14);
  border-radius: 9px;
  pointer-events: none;
}

body[data-theme="rome"] .dice-stage::after {
  content: "SENATVS  ·  POPVLVSQVE  ·  ROMANVS";
  position: absolute;
  z-index: 1;
  right: 0;
  bottom: 14px;
  left: 0;
  color: rgba(241, 205, 130, 0.2);
  font-family: var(--serif);
  font-size: 9px;
  letter-spacing: 0.24em;
  text-align: center;
  pointer-events: none;
}

.arena-seal {
  position: absolute;
  display: grid;
  place-items: center;
  width: 190px;
  height: 190px;
  border: 1px solid var(--line);
  border-radius: 50%;
  opacity: .26;
}

.arena-seal::before,
.arena-seal::after {
  content: "";
  position: absolute;
  inset: 15px;
  border: 1px dotted var(--line-strong);
  border-radius: 50%;
}

.arena-seal::after { inset: 45px; border-style: solid; }
.arena-seal span { font-family: var(--serif); font-size: 24px; color: var(--accent); }

.dice-row {
  position: relative;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: clamp(8px, 1.2vw, 14px);
  width: 100%;
  padding: 24px 12px;
}

.die {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  flex: 0 0 auto;
  width: clamp(56px, 6vw, 78px);
  aspect-ratio: 1;
  padding: clamp(7px, 0.75vw, 11px);
  gap: 1px;
  border: 2px solid transparent;
  border-radius: 18%;
  background: linear-gradient(145deg, #fff9e9, #cdbd9e);
  box-shadow: 0 9px 15px rgba(0,0,0,.38), inset -5px -7px 12px rgba(76,59,37,.22), inset 3px 3px 8px rgba(255,255,255,.55);
  cursor: pointer;
  transition: transform 150ms ease, box-shadow 150ms ease, opacity 150ms ease;
}

.die:hover:not(:disabled) { transform: translateY(-5px); }
.die:disabled { cursor: default; opacity: 1; filter: none; }
.die.selected {
  z-index: 4;
  border: 4px solid #f4cc68;
  outline: 3px solid rgba(255, 236, 160, .55);
  outline-offset: 3px;
  transform: translateY(-12px) scale(1.07);
  box-shadow:
    0 0 0 6px rgba(215, 173, 96, .18),
    0 13px 32px rgba(0, 0, 0, .58),
    0 0 28px rgba(241, 205, 130, .52),
    inset -5px -7px 12px rgba(76,59,37,.22);
}
.die.ai-selected { border-color: #e69b87; transform: translateY(-6px); box-shadow: 0 10px 22px rgba(168,93,75,.34); }
.die.rolling { animation: dice-roll 500ms cubic-bezier(.2,.75,.35,1); }

@keyframes dice-roll {
  0% { transform: translateY(-34px) rotate(-28deg) scale(.82); opacity: .2; }
  45% { transform: translateY(7px) rotate(19deg) scale(1.05); }
  72% { transform: translateY(-4px) rotate(-5deg); }
  100% { transform: translateY(0) rotate(0) scale(1); opacity: 1; }
}

.pip {
  display: block;
  align-self: center;
  justify-self: center;
  width: 53%;
  min-width: 5px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #35271f;
  box-shadow: inset 0 1px 2px rgba(0,0,0,.55), 0 1px 0 rgba(255,255,255,.3);
}

.pip.p1 { grid-area: 1 / 1; }
.pip.p2 { grid-area: 1 / 2; }
.pip.p3 { grid-area: 1 / 3; }
.pip.p4 { grid-area: 2 / 1; }
.pip.p5 { grid-area: 2 / 2; }
.pip.p6 { grid-area: 2 / 3; }
.pip.p7 { grid-area: 3 / 1; }
.pip.p8 { grid-area: 3 / 2; }
.pip.p9 { grid-area: 3 / 3; }

.stage-message {
  position: absolute;
  z-index: 6;
  display: grid;
  place-items: center;
  inset: 0;
  padding: 20px;
  background: rgba(8,6,5,.8);
  font-family: var(--serif);
  font-size: clamp(27px, 4vw, 50px);
  letter-spacing: .04em;
  text-align: center;
  text-transform: uppercase;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

.stage-message.show { opacity: 1; }
.stage-message.bust { color: var(--danger); }
.stage-message.hot { color: var(--accent-bright); text-shadow: 0 0 30px color-mix(in srgb, var(--accent) 60%, transparent); }
.stage-message.bank { color: var(--success); }

.selection-panel,
.held-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 4px;
  border-bottom: 1px solid var(--line);
}

.selection-panel small { display: block; color: var(--muted); font-size: 8px; letter-spacing: .12em; text-transform: uppercase; }
.selection-panel strong { display: block; margin-top: 4px; font-size: 12px; font-weight: 600; }
.selection-panel > span { color: var(--accent-bright); font-family: var(--serif); font-size: 24px; }

.held-panel { justify-content: flex-start; min-height: 49px; padding-block: 9px; color: var(--muted); font-size: 9px; letter-spacing: .1em; text-transform: uppercase; }
.held-dice { display: flex; flex: 1; gap: 5px; min-width: 0; }
.held-dice em { color: color-mix(in srgb, var(--muted) 65%, transparent); font-style: normal; text-transform: none; letter-spacing: 0; }
.mini-die { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 6px; background: #d7c7a8; color: #33251c; font-family: var(--serif); font-size: 12px; font-weight: 700; }
.remaining-count { white-space: nowrap; }
.remaining-count b { color: var(--text); font-size: 13px; }

.game-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding-top: 16px;
}

.game-actions button { min-width: 0; }
.game-actions .secondary-button { grid-column: 1; grid-row: 1; }
.game-actions .bank-button { grid-column: 2; grid-row: 1; }
#continueRollButton:not(:disabled) {
  border-color: #e3ad50;
  background: linear-gradient(135deg, #8c4523, #bd7d2d 56%, #d19d48);
  color: #fff4d5;
  box-shadow: 0 10px 25px rgba(126, 60, 29, .34), inset 0 1px 0 rgba(255,255,255,.14);
  text-shadow: 0 1px 2px rgba(0,0,0,.38);
}
#continueRollButton:hover:not(:disabled) {
  border-color: #f4cd78;
  background: linear-gradient(135deg, #9d4d27, #ce8b35 56%, #dfad5b);
  box-shadow: 0 12px 30px rgba(166, 85, 34, .42), 0 0 18px rgba(218, 157, 67, .15);
}
.roll-button {
  z-index: 2;
  grid-column: 1 / -1;
  grid-row: 1;
  justify-content: center;
  opacity: 1;
  visibility: visible;
}
.roll-button.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.action-hint { min-height: 16px; margin: 10px 0 0; color: var(--muted); font-size: 10px; text-align: center; }

.turn-log {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  overflow-x: auto;
  scrollbar-width: thin;
}

.log-item {
  flex: 0 0 auto;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255,255,255,.02);
  color: var(--muted);
  font-size: 9px;
}

.log-item b { margin-right: 5px; color: var(--text); }
.log-item.bust b { color: var(--danger); }
.log-item.bank b { color: var(--success); }

.game-dialog {
  position: relative;
  width: min(520px, calc(100% - 30px));
  padding: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  background:
    radial-gradient(circle at 50% 0%, color-mix(in srgb, var(--accent-dark) 25%, transparent), transparent 38%),
    var(--surface-solid);
  color: var(--text);
  box-shadow: 0 30px 100px rgba(0,0,0,.72);
  text-align: center;
}

.game-dialog::backdrop {
  background: rgba(4,3,3,.78);
  backdrop-filter: blur(7px);
}

.dialog-close {
  position: absolute;
  top: 13px;
  right: 13px;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 20px;
}

.dialog-sigil,
.result-emblem {
  display: grid;
  place-items: center;
  width: 82px;
  height: 82px;
  margin: 0 auto 20px;
  border: 1px solid var(--accent);
  border-radius: 50%;
  background-color: color-mix(in srgb, var(--accent) 10%, transparent);
  color: var(--accent-bright);
  font-family: var(--serif);
  font-size: 28px;
  box-shadow: inset 0 0 0 7px rgba(255,255,255,.025);
}

.result-visual {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
}

.result-art {
  display: none;
  width: 210px;
  height: 210px;
  margin: -4px auto 12px;
  border: 1px solid rgba(241, 205, 130, 0.64);
  border-radius: 50%;
  object-fit: cover;
  filter: drop-shadow(0 18px 30px rgba(0, 0, 0, 0.48));
  box-shadow: 0 0 0 8px rgba(215, 173, 96, 0.075), 0 0 55px rgba(215, 173, 96, 0.22);
}

.result-rival-portrait,
.result-rival-standard { display: none; }

.result-dialog.defeat-mode {
  width: min(650px, calc(100% - 30px));
  overflow: hidden;
  padding: 28px 46px 38px;
  border-color: rgba(223, 91, 75, .72);
  background:
    radial-gradient(circle at 50% 13%, rgba(164, 48, 45, .26), transparent 32%),
    linear-gradient(148deg, rgba(66, 17, 20, .99), rgba(18, 15, 18, .99) 52%, rgba(20, 29, 39, .99));
  box-shadow: 0 36px 135px rgba(0,0,0,.88), 0 0 58px rgba(172, 45, 38, .22), inset 0 0 0 4px rgba(217, 88, 69, .045);
  animation: defeat-result-arrive 620ms cubic-bezier(.16,.78,.24,1);
}

.result-dialog.defeat-mode > * { position: relative; z-index: 2; }
.result-dialog.defeat-mode::before {
  content: "";
  position: absolute;
  z-index: 0;
  top: -250px;
  left: 50%;
  width: 680px;
  height: 680px;
  border-radius: 50%;
  transform: translateX(-50%) rotate(8deg);
  background:
    repeating-conic-gradient(from 8deg, rgba(230, 101, 78, .095) 0 2deg, transparent 2deg 13deg),
    radial-gradient(circle, rgba(110, 31, 32, .18), transparent 61%);
  animation: defeat-rays 16s linear infinite reverse;
}
.result-dialog.defeat-mode::after {
  content: "DEFEAT";
  position: absolute;
  z-index: 1;
  right: 0;
  bottom: 72px;
  left: 0;
  color: rgba(232, 104, 83, .055);
  font-family: var(--serif);
  font-size: clamp(58px, 11vw, 100px);
  letter-spacing: .12em;
  text-indent: .12em;
  pointer-events: none;
}
.result-dialog.defeat-mode .result-visual { min-height: 218px; margin-bottom: 5px; }
.result-dialog.defeat-mode .result-art,
.result-dialog.defeat-mode .result-emblem { display: none; }
.result-dialog.defeat-mode .result-rival-portrait {
  display: block;
  width: 205px;
  height: 205px;
  border: 2px solid #dc6f5d;
  border-radius: 50%;
  background-image: url("assets/rival-commanders-atlas.webp");
  background-repeat: no-repeat;
  background-size: 300% 200%;
  filter: saturate(.82) contrast(1.08);
  box-shadow: 0 0 0 9px rgba(153, 45, 42, .14), 0 22px 50px rgba(0,0,0,.58), 0 0 54px rgba(203, 64, 50, .3);
  animation: rival-defeat-reveal 740ms cubic-bezier(.16,.78,.24,1);
}
.result-dialog.defeat-mode .result-rival-standard {
  position: absolute;
  right: calc(50% - 122px);
  bottom: 7px;
  display: block;
  width: 58px;
  height: 58px;
  border: 2px solid rgba(245, 172, 133, .78);
  border-radius: 14px;
  background-image: url("assets/faction-standards-atlas.webp");
  background-repeat: no-repeat;
  background-size: 300% 200%;
  box-shadow: 0 10px 28px rgba(0,0,0,.58), 0 0 25px rgba(219, 78, 57, .34);
  animation: rival-standard-strike 780ms cubic-bezier(.16,.8,.22,1);
}
.result-dialog.defeat-mode .eyebrow { color: #ef9a7f; }
.result-dialog.defeat-mode h2 {
  color: #fff0df;
  font-size: clamp(38px, 6vw, 54px);
  text-shadow: 0 6px 28px rgba(0,0,0,.6), 0 0 24px rgba(201, 62, 50, .2);
}
.result-dialog.defeat-mode > p:not(.eyebrow) { max-width: 500px; color: #cdbdb2; }
.result-dialog.defeat-mode .result-scoreline { gap: 10px; }
.result-dialog.defeat-mode .result-scoreline div {
  min-width: 118px;
  padding: 12px 20px;
  border: 1px solid rgba(218, 104, 83, .2);
  border-radius: 9px;
  background: rgba(0,0,0,.22);
}
.result-dialog.defeat-mode .result-scoreline strong { color: #fff0df; }
.result-dialog.defeat-mode .primary-button {
  border-color: #e27a65;
  background: linear-gradient(135deg, #a64037, #d06d53);
  color: #fff7eb;
  box-shadow: 0 12px 34px rgba(139, 42, 36, .42);
}

@keyframes defeat-result-arrive {
  0% { opacity: 0; transform: translateY(18px) scale(.92); filter: brightness(.55); }
  62% { transform: translateY(-3px) scale(1.015); }
  100% { opacity: 1; transform: translateY(0) scale(1); filter: brightness(1); }
}
@keyframes defeat-rays { to { transform: translateX(-50%) rotate(-352deg); } }
@keyframes rival-defeat-reveal {
  from { opacity: 0; transform: translateY(-20px) scale(.74); filter: saturate(.3) brightness(.5); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes rival-standard-strike {
  0% { opacity: 0; transform: translate(35px, -55px) rotate(18deg) scale(1.4); }
  70% { opacity: 1; transform: translate(-3px, 2px) rotate(-4deg) scale(.96); }
  100% { transform: translate(0) rotate(0) scale(1); }
}

.result-dialog.round-victory {
  overflow: hidden;
  border-color: rgba(241, 205, 130, .64);
  background:
    radial-gradient(circle at 50% 8%, rgba(215, 173, 96, .2), transparent 35%),
    linear-gradient(145deg, #3f171b, #182f47 78%);
  box-shadow: 0 32px 115px rgba(0,0,0,.78), 0 0 46px rgba(215, 173, 96, .15);
  animation: round-result-arrive 520ms cubic-bezier(.18,.82,.26,1);
}

.result-dialog.round-victory .result-emblem {
  border-width: 2px;
  border-color: #f1cd82;
  background:
    repeating-conic-gradient(from 0deg, rgba(255,255,255,.06) 0 9deg, transparent 9deg 18deg),
    rgba(215, 173, 96, .15);
  color: #fff0bd;
  box-shadow: inset 0 0 0 7px rgba(255,255,255,.035), 0 0 0 7px rgba(215, 173, 96, .06), 0 0 38px rgba(241, 205, 130, .32);
  animation: round-emblem-pulse 1.8s ease-in-out infinite;
}

.result-dialog.round-victory h2 { color: #fff2d3; text-shadow: 0 5px 22px rgba(0,0,0,.44); }

@keyframes round-result-arrive {
  from { opacity: 0; transform: translateY(18px) scale(.94); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes round-emblem-pulse {
  50% { transform: scale(1.06); box-shadow: inset 0 0 0 7px rgba(255,255,255,.05), 0 0 0 11px rgba(215, 173, 96, .04), 0 0 48px rgba(241, 205, 130, .42); }
}

.result-dialog.victory-mode {
  width: min(650px, calc(100% - 30px));
  overflow: hidden;
  padding: 30px 46px 38px;
  border-color: rgba(241, 205, 130, 0.76);
  background:
    radial-gradient(circle at 50% 12%, rgba(215, 173, 96, 0.2), transparent 31%),
    linear-gradient(145deg, rgba(99, 24, 31, 0.97), rgba(29, 13, 14, 0.98) 47%, rgba(17, 31, 57, 0.98));
  box-shadow: 0 36px 130px rgba(0,0,0,.82), 0 0 55px rgba(215, 173, 96, 0.16), inset 0 0 0 4px rgba(215, 173, 96, 0.055);
}

.result-dialog.victory-mode > * {
  position: relative;
  z-index: 2;
}

.result-dialog.victory-mode::before {
  content: "";
  position: absolute;
  z-index: 0;
  top: -215px;
  left: 50%;
  width: 640px;
  height: 640px;
  border-radius: 50%;
  transform: translateX(-50%);
  background: repeating-conic-gradient(from 3deg, rgba(241, 205, 130, 0.09) 0 3deg, transparent 3deg 11deg);
  animation: triumph-rays 18s linear infinite;
}

.result-dialog.victory-mode::after {
  content: "VICTORIA";
  position: absolute;
  z-index: 1;
  right: 0;
  bottom: 75px;
  left: 0;
  color: rgba(241, 205, 130, 0.055);
  font-family: var(--serif);
  font-size: clamp(54px, 10vw, 95px);
  letter-spacing: 0.1em;
  text-indent: 0.1em;
  pointer-events: none;
}

.result-dialog.victory-mode .result-art { display: block; }
.result-dialog.victory-mode .result-emblem { display: none; }
.result-dialog.victory-mode .eyebrow { color: var(--accent-bright); }
.result-dialog.victory-mode h2 {
  color: #fff1cb;
  font-size: clamp(38px, 6vw, 55px);
  text-shadow: 0 5px 28px rgba(0, 0, 0, 0.52), 0 0 22px rgba(215, 173, 96, 0.16);
}

.result-dialog.victory-mode > p:not(.eyebrow) {
  max-width: 490px;
  color: #d8c9ae;
}

.result-dialog.grand-victory {
  border-width: 2px;
  box-shadow: 0 36px 140px rgba(0,0,0,.86), 0 0 80px rgba(241, 205, 130, 0.24), inset 0 0 80px rgba(215, 173, 96, 0.075);
}

.result-dialog.grand-victory .result-art {
  width: 235px;
  height: 235px;
  box-shadow: 0 0 0 9px rgba(215, 173, 96, 0.09), 0 0 78px rgba(241, 205, 130, 0.3);
}

@keyframes triumph-rays {
  to { transform: translateX(-50%) rotate(360deg); }
}

.game-dialog h2 { font-size: 34px; }
.game-dialog > p:not(.eyebrow) { margin: 10px auto 24px; color: var(--muted); line-height: 1.6; }

.challenge-facts {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 24px;
}

.challenge-facts div {
  padding: 13px 8px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(0,0,0,.13);
}

.challenge-facts small,
.challenge-facts strong { display: block; }
.challenge-facts small { color: var(--muted); font-size: 8px; text-transform: uppercase; letter-spacing: .12em; }
.challenge-facts strong { margin-top: 5px; font-size: 12px; }

.challenge-facts .opponent-fact {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding-block: 7px;
  text-align: left;
}

.territory-portrait {
  display: block;
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background-image: url("assets/rival-commanders-atlas.webp");
  background-repeat: no-repeat;
  background-size: 300% 200%;
  box-shadow: 0 5px 14px rgba(0,0,0,.38);
}

.challenge-facts select {
  width: 100%;
  margin-top: 4px;
  padding: 4px 24px 4px 6px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--surface-high);
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
  text-align: center;
  cursor: pointer;
}

.challenge-facts select:focus-visible { outline: 2px solid var(--accent-bright); outline-offset: 2px; }

.rules-dialog { width: min(680px, calc(100% - 30px)); }
.reset-dialog { width: min(500px, calc(100% - 30px)); }
.rules-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; text-align: left; }
.rules-grid article { display: flex; gap: 12px; padding: 13px; border: 1px solid var(--line); border-radius: 10px; background: rgba(0,0,0,.12); }
.rules-grid .campaign-rule { grid-column: 1 / -1; }
.rules-grid article > b { display: grid; place-items: center; flex: 0 0 30px; height: 30px; border-radius: 50%; background: color-mix(in srgb, var(--accent) 15%, transparent); color: var(--accent-bright); }
.rules-grid strong { font-family: var(--serif); }
.rules-grid p { margin: 3px 0 0; color: var(--muted); font-size: 11px; line-height: 1.45; }
.score-table { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; margin-top: 14px; overflow: hidden; border: 1px solid var(--line); border-radius: 10px; background: var(--line); text-align: left; }
.score-table span { display: flex; justify-content: space-between; padding: 9px 11px; background: var(--surface-solid); color: var(--muted); font-size: 10px; }
.score-table b { color: var(--text); }

.result-scoreline {
  display: flex;
  justify-content: center;
  gap: 22px;
  margin: 20px 0 24px;
  font-family: var(--serif);
  font-size: 27px;
}

.result-scoreline strong,
.result-scoreline span { display: block; }
.result-scoreline span { margin-top: 3px; color: var(--muted); font-family: var(--sans); font-size: 10px; letter-spacing: .1em; text-transform: uppercase; }
.victory-mode .result-scoreline { gap: 10px; }
.victory-mode .result-scoreline div {
  min-width: 118px;
  padding: 12px 20px;
  border: 1px solid rgba(215, 173, 96, 0.22);
  border-radius: 9px;
  background: rgba(0, 0, 0, 0.19);
}
.victory-mode .result-scoreline strong { display: block; color: #fff1cb; }
.victory-mode .result-scoreline span { display: block; margin-top: 3px; color: #b9a98c; letter-spacing: .14em; }
.result-dialog .text-button { margin-top: 15px; }

.toast {
  position: fixed;
  z-index: 80;
  left: 50%;
  bottom: 28px;
  max-width: calc(100% - 30px);
  padding: 12px 17px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  transform: translate(-50%, 30px);
  background: var(--surface-high);
  box-shadow: var(--shadow);
  color: var(--text);
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transition: 240ms ease;
}

.toast.show { transform: translate(-50%, 0); opacity: 1; }

.confetti {
  position: fixed;
  z-index: 90;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.confetti i {
  position: absolute;
  top: -20px;
  width: 8px;
  height: 14px;
  background: var(--confetti-color);
  animation: confetti-fall var(--duration) cubic-bezier(.16,.72,.28,1) forwards;
}

.confetti i.coin {
  width: 13px;
  height: 13px;
  border: 2px solid rgba(255, 244, 188, 0.64);
  border-radius: 50%;
  background: #c88b2f;
  box-shadow: inset 0 0 0 2px #f1cd82, 0 0 10px rgba(241, 205, 130, 0.3);
}

.confetti i.debris {
  width: 7px;
  height: 19px;
  border-radius: 2px;
  box-shadow: 0 2px 5px rgba(0,0,0,.4);
  filter: saturate(.8);
}

.confetti.triumph::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 45%, rgba(255, 234, 171, 0.34), transparent 47%);
  animation: victory-flash 1.2s ease-out forwards;
}

@keyframes victory-flash {
  from { opacity: 0; transform: scale(.72); }
  28% { opacity: 1; }
  to { opacity: 0; transform: scale(1.12); }
}

@keyframes confetti-fall {
  to { transform: translate(var(--drift), 110vh) rotate(var(--spin)); opacity: .2; }
}

@media (max-width: 1120px) {
  .faction-grid { grid-template-columns: repeat(3, 1fr); }
  .arena-header { grid-template-columns: 48px 1fr auto; }
  .arena-motto { display: none; }
  .game-layout { grid-template-columns: 145px minmax(500px, 1fr) 145px; }
  .score-card { padding-inline: 10px; }
  .score-avatar { width: 62px; height: 62px; }
  .banked-score { font-size: 38px; }
}

@media (max-width: 900px) {
  .menu-screen.is-active { grid-template-columns: 1fr; padding-top: 55px; }
  .menu-copy { position: relative; z-index: 3; padding: 0 7vw; }
  .menu-art { position: absolute; z-index: 0; inset: 0 -10% auto 34%; height: 76vh; opacity: .48; }
  .menu-lead { max-width: 470px; }
  .portrait-options { width: 100%; }
  .portrait-choice { flex: 1; }
  .game-layout { grid-template-columns: 1fr 1fr; }
  .dice-arena { grid-column: 1 / -1; grid-row: 2; }
  .score-card { min-height: auto; flex-direction: row; justify-content: flex-start; gap: 12px; padding: 13px 16px; text-align: left; }
  .score-card::before, .score-target { display: none; }
  .score-avatar { flex: 0 0 48px; width: 48px; height: 48px; margin: 0; font-size: 18px; }
  .score-card small { display: none; }
  .score-card h3 { flex: 1; margin: 0; font-size: 14px; }
  .banked-score { font-size: 30px; }
  .score-card .mini-progress { position: absolute; right: 15px; bottom: 8px; width: calc(100% - 80px); max-width: 170px; }
  .score-card { position: relative; }
  .rival-card { grid-column: 2; }
  .player-card { grid-column: 1; }
}

@media (max-width: 720px) {
  .topbar, #app { width: min(100% - 28px, 1480px); }
  .topbar { height: 72px; }
  #app, .screen { min-height: calc(100vh - 72px); }
  .screen { padding-top: 28px; }
  .brand-button small { display: none; }
  .menu-screen.is-active { padding-top: 44px; }
  .menu-copy { padding: 0 4px; }
  .menu-art { left: 25%; right: -35%; }
  .menu-actions { align-items: stretch; flex-direction: column; max-width: 310px; gap: 8px; }
  .menu-actions .primary-button,
  .menu-actions .secondary-button { width: 100%; }
  .text-button { align-self: flex-start; }
  .campaign-summary { gap: 25px; }
  .faction-grid { grid-template-columns: 1fr 1fr; }
  .faction-card { min-height: 280px; padding: 18px; }
  .faction-card .faction-standard { width: 88px; height: 88px; margin-bottom: 40px; }
  .map-header { align-items: flex-start; }
  .map-header-actions { align-items: flex-end; flex-direction: column; }
  .campaign-alert { grid-template-columns: auto 1fr; }
  .campaign-alert .danger-button { grid-column: 1 / -1; width: 100%; }
  .world-map { min-height: 530px; }
  .map-node { width: 60px; height: 60px; }
  .map-node .node-label { font-size: 9px; }
  .map-legend { right: 18px; bottom: 16px; gap: 9px; }
  .arena-header { grid-template-columns: 42px 1fr; }
  .series-score { grid-column: 1 / -1; justify-content: center; margin-top: 8px; }
  .game-layout { gap: 8px; }
  .dice-arena { padding: 12px; }
  .dice-stage { min-height: 220px; }
  .game-actions { grid-template-columns: 1fr 1fr; }
  .game-actions .bank-button { grid-column: 2; grid-row: 1; }
  .game-actions .secondary-button { grid-column: 1; grid-row: 1; }
  .game-actions .roll-button { grid-column: 1 / -1; grid-row: 1; }
}

@media (max-width: 520px) {
  .brand-button strong { font-size: 12px; }
  .menu-copy h1 { font-size: clamp(54px, 19vw, 82px); }
  .menu-lead { font-size: 15px; }
  .home-commander { padding: 11px; }
  .home-commander-heading { align-items: flex-start; flex-direction: column; gap: 5px; }
  .campaign-summary span { font-size: 8px; }
  .section-heading { align-items: flex-start; }
  .section-heading h2, .map-header h2 { font-size: 31px; }
  .faction-grid { grid-template-columns: 1fr; }
  .portrait-options { display: grid; grid-template-columns: 1fr 1fr; }
  .portrait-choice { min-width: 0; }
  .portrait-choice:last-child { grid-column: 1 / -1; }
  .faction-card { min-height: 230px; }
  .faction-card .faction-standard { margin: 2px auto 26px; }
  .map-header { display: block; }
  .map-header-actions { flex-direction: row; justify-content: space-between; margin-top: 14px; }
  .campaign-alert { gap: 10px; margin-top: 14px; padding: 10px; }
  .campaign-alert-icon { width: 37px; height: 37px; }
  .campaign-alert strong { font-size: 12px; }
  .world-map { min-height: 510px; }
  .map-node { width: 54px; height: 54px; }
  .map-node .node-standard { width: 39px; height: 39px; }
  .map-victory-callout { top: 17px; min-width: calc(100% - 36px); }
  .map-legend { left: 18px; right: auto; font-size: 7px; }
  .map-footer { align-items: flex-start; flex-direction: column; gap: 8px; }
  .map-footer > div { width: 100%; }
  .arena-location h2 { font-size: 20px; }
  .score-card { gap: 7px; padding: 9px; }
  .score-avatar { flex-basis: 39px; width: 39px; height: 39px; }
  .score-card h3 { font-size: 11px; }
  .banked-score { font-size: 23px; }
  .dice-arena { min-height: 500px; }
  .dice-stage { min-height: 205px; }
  .die { width: clamp(45px, 14vw, 61px); }
  .selection-panel { padding-inline: 0; }
  .selection-panel strong { max-width: 210px; }
  .held-panel { flex-wrap: wrap; }
  .held-dice { order: 3; flex-basis: 100%; }
  .remaining-count { margin-left: auto; }
  .game-actions button { min-height: 48px; padding-inline: 9px; font-size: 11px; }
  .game-dialog { padding: 29px 20px 24px; }
  .game-dialog h2 { font-size: 28px; }
  .result-dialog.victory-mode { padding: 24px 20px 28px; }
  .result-dialog.defeat-mode { padding: 22px 20px 28px; }
  .result-dialog.victory-mode .result-art { width: 170px; height: 170px; }
  .result-dialog.defeat-mode .result-visual { min-height: 174px; }
  .result-dialog.defeat-mode .result-rival-portrait { width: 164px; height: 164px; }
  .result-dialog.defeat-mode .result-rival-standard { right: calc(50% - 99px); width: 49px; height: 49px; }
  .result-dialog.grand-victory .result-art { width: 188px; height: 188px; }
  .result-dialog.victory-mode h2,
  .result-dialog.defeat-mode h2 { font-size: 34px; }
  .challenge-facts { grid-template-columns: 1fr; }
  .rules-grid, .score-table { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }
}

/* v6: expanded civilizations, campaign gates, and battle momentum */
.build-version {
  color: var(--accent-bright);
  font-family: var(--sans);
  font-size: 7px;
  letter-spacing: .08em;
  vertical-align: super;
}

body[data-theme="macedon"] {
  --bg: #091323; --bg-deep: #050912; --surface: rgba(25, 43, 72, .92);
  --surface-solid: #192b48; --surface-high: #27436d; --line: rgba(228, 188, 98, .22);
  --line-strong: rgba(228, 188, 98, .46); --text: #fff3d6; --muted: #b8c0cf;
  --accent: #e4bc62; --accent-bright: #f7d985; --accent-dark: #284b7d;
}

body[data-theme="phoenicia"] {
  --bg: #190b18; --bg-deep: #0b050a; --surface: rgba(70, 27, 59, .92);
  --surface-solid: #461b3b; --surface-high: #682754; --line: rgba(220, 146, 205, .22);
  --line-strong: rgba(220, 146, 205, .46); --text: #fff0e4; --muted: #c9aec2;
  --accent: #ce7ed0; --accent-bright: #eda8e2; --accent-dark: #61284f;
}

body[data-theme="babylon"] {
  --bg: #071327; --bg-deep: #030812; --surface: rgba(20, 49, 89, .92);
  --surface-solid: #143159; --surface-high: #204b80; --line: rgba(225, 185, 86, .22);
  --line-strong: rgba(225, 185, 86, .48); --text: #fff1cf; --muted: #afbdd3;
  --accent: #e1b956; --accent-bright: #f7d77b; --accent-dark: #204579;
}

body[data-theme="maurya"] {
  --bg: #0c1710; --bg-deep: #050a07; --surface: rgba(35, 65, 43, .92);
  --surface-solid: #23412b; --surface-high: #315d3d; --line: rgba(228, 160, 77, .22);
  --line-strong: rgba(228, 160, 77, .46); --text: #fff0d7; --muted: #b5c1ad;
  --accent: #e4a04d; --accent-bright: #f6c06d; --accent-dark: #315c3d;
}

.standard-macedon,
.standard-phoenicia,
.standard-babylon,
.standard-maurya {
  background-image: url("assets/new-civilizations-atlas.webp") !important;
  background-repeat: no-repeat !important;
  background-size: 400% 200% !important;
}

.standard-macedon { background-position: 0 100% !important; }
.standard-phoenicia { background-position: 33.333% 100% !important; }
.standard-babylon { background-position: 66.667% 100% !important; }
.standard-maurya { background-position: 100% 100% !important; }

.portrait-6,
.portrait-7,
.portrait-8,
.portrait-9 {
  background-image: url("assets/new-civilizations-atlas.webp") !important;
  background-repeat: no-repeat !important;
  background-size: 400% 200% !important;
}

.portrait-6 { background-position: 0 0 !important; }
.portrait-7 { background-position: 33.333% 0 !important; }
.portrait-8 { background-position: 66.667% 0 !important; }
.portrait-9 { background-position: 100% 0 !important; }

.faction-card[data-faction="macedon"]::before,
.faction-card[data-faction="phoenicia"]::before,
.faction-card[data-faction="babylon"]::before,
.faction-card[data-faction="maurya"]::before {
  background-image: url("assets/new-civilizations-atlas.webp");
  background-repeat: no-repeat;
  background-size: 400% 200%;
}

.faction-card[data-faction="macedon"]::before { background-position: 0 100%; }
.faction-card[data-faction="phoenicia"]::before { background-position: 33.333% 100%; }
.faction-card[data-faction="babylon"]::before { background-position: 66.667% 100%; }
.faction-card[data-faction="maurya"]::before { background-position: 100% 100%; }

body[data-theme="macedon"] .game-screen.is-active::before,
body[data-theme="phoenicia"] .game-screen.is-active::before,
body[data-theme="babylon"] .game-screen.is-active::before,
body[data-theme="maurya"] .game-screen.is-active::before {
  background-image: url("assets/new-civilizations-atlas.webp");
  background-repeat: no-repeat;
  background-size: 400% 200%;
}

body[data-theme="macedon"] .game-screen.is-active::before { background-position: 0 100%; }
body[data-theme="phoenicia"] .game-screen.is-active::before { background-position: 33.333% 100%; }
body[data-theme="babylon"] .game-screen.is-active::before { background-position: 66.667% 100%; }
body[data-theme="maurya"] .game-screen.is-active::before { background-position: 100% 100%; }

.map-node[data-civilization="macedon"] { --node-color: #e4bc62; --node-deep: #284b7d; }
.map-node[data-civilization="phoenicia"] { --node-color: #ce7ed0; --node-deep: #61284f; }
.map-node[data-civilization="babylon"] { --node-color: #e1b956; --node-deep: #204579; }
.map-node[data-civilization="maurya"] { --node-color: #e4a04d; --node-deep: #315c3d; }

.map-node {
  width: 50px;
  height: 50px;
}

.map-node.node-capital { width: 64px; height: 64px; }
.map-node.node-home,
.map-node.node-final { width: 70px; height: 70px; }
.map-node.node-minor .node-standard { width: 33px; height: 33px; }
.map-node.node-capital .node-standard { width: 44px; height: 44px; }
.map-node.node-home .node-standard,
.map-node.node-final .node-standard { width: 49px; height: 49px; }
.map-node.node-minor .node-label { top: calc(100% + 6px); font-size: 9px; }
.map-node.node-minor .node-label small { font-size: 6px; }
.map-node.node-minor .node-check { top: -4px; right: -4px; width: 18px; height: 18px; font-size: 9px; }

.map-routes line.route-open {
  stroke: color-mix(in srgb, var(--accent-bright) 72%, transparent);
  stroke-width: 2.2;
  stroke-dasharray: 6 5;
}

.map-routes line.route-ready {
  stroke: #d7ad60;
  stroke-width: 2.4;
  stroke-dasharray: 0;
  filter: drop-shadow(0 0 5px rgba(215, 173, 96, .32));
}

.map-routes line.route-missing {
  stroke: #8f5d57;
  stroke-width: 2;
  stroke-dasharray: 3 7;
  opacity: .72;
}

.map-routes line.route-defense {
  stroke: #83c69a;
  stroke-width: 4;
  stroke-dasharray: 1 7;
  stroke-linecap: round;
  filter: drop-shadow(0 0 9px rgba(117, 178, 139, .78));
  animation: defense-route 680ms linear infinite;
}

.frontier-advice {
  display: block;
  margin-top: 7px;
  padding-left: 11px;
  border-left: 2px solid #d7ad60;
  color: #e7c77f;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: .035em;
}

.frontier-advice[hidden] { display: none; }

.map-victory-callout.defense {
  border-color: #83c69a;
  background: linear-gradient(135deg, rgba(24, 74, 46, .97), rgba(13, 28, 23, .97) 62%, rgba(71, 52, 22, .96));
  box-shadow: 0 18px 60px rgba(0,0,0,.66), 0 0 36px rgba(117, 178, 139, .36);
}

.map-victory-callout.defense small { color: #aee3bd; }
.map-node.defended-flash { z-index: 9; animation: defended-node 1.9s cubic-bezier(.18,.8,.22,1); }

.defense-shield {
  position: absolute;
  z-index: 18;
  width: 82px;
  height: 96px;
  transform: translate(-50%, -50%);
  clip-path: polygon(50% 0, 92% 14%, 86% 66%, 50% 100%, 14% 66%, 8% 14%);
  background:
    linear-gradient(90deg, transparent 45%, rgba(255,255,255,.42) 48% 52%, transparent 55%),
    linear-gradient(145deg, #f4d279, #6aa77e 58%, #1f5135);
  box-shadow: 0 0 45px rgba(128, 204, 151, .78);
  pointer-events: none;
  animation: shield-defense 2.1s cubic-bezier(.2,.75,.2,1) forwards;
}

.defense-shield::after {
  content: "✦";
  position: absolute;
  inset: 9px;
  display: grid;
  place-items: center;
  clip-path: inherit;
  border: 2px solid rgba(255, 245, 197, .72);
  color: #fff0b5;
  font-family: var(--serif);
  font-size: 30px;
}

@keyframes defense-route { to { stroke-dashoffset: -16; } }
@keyframes defended-node {
  0% { transform: translate(-50%, -50%) scale(.72); filter: brightness(2); }
  32% { transform: translate(-50%, -50%) scale(1.25); box-shadow: 0 0 0 18px rgba(117,178,139,.14), 0 0 66px #75b28b; }
  100% { transform: translate(-50%, -50%) scale(1); }
}
@keyframes shield-defense {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(.28) rotate(-13deg); }
  24% { opacity: 1; transform: translate(-50%, -50%) scale(1.28) rotate(4deg); }
  48% { transform: translate(-50%, -50%) scale(.96) rotate(0); }
  78% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -55%) scale(1.08); }
}

.game-screen {
  --player-battle-color: #d7ad60;
  --player-battle-deep: #78513a;
  --rival-battle-color: #74b5d4;
  --rival-battle-deep: #28607f;
  --battle-control: 50%;
}

body .game-screen .score-card {
  overflow: hidden;
  border-color: color-mix(in srgb, var(--card-faction-color) 48%, var(--line));
  background:
    radial-gradient(circle at 50% 17%, color-mix(in srgb, var(--card-faction-color) 24%, transparent), transparent 31%),
    linear-gradient(180deg, color-mix(in srgb, var(--card-faction-deep) 88%, #111318), color-mix(in srgb, var(--card-faction-deep) 56%, #0b0c0e) 58%, #09090a 100%);
  box-shadow: 0 18px 60px rgba(0,0,0,.34), inset 0 0 45px color-mix(in srgb, var(--card-faction-color) 5%, transparent);
}

body .game-screen .score-card::before {
  content: "❦";
  width: auto;
  height: auto;
  margin-bottom: 13px;
  background: none;
  color: color-mix(in srgb, var(--card-faction-color) 76%, #fff0c4);
  font-family: var(--serif);
  font-size: 30px;
  line-height: 1;
}

body .game-screen .score-card::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 7px;
  background: repeating-linear-gradient(90deg, transparent 0 8px, var(--card-faction-color) 8px 12px, transparent 12px 20px);
  opacity: .72;
}

.game-screen .score-avatar { border-color: var(--card-faction-color); }
.game-screen .score-avatar.has-portrait { box-shadow: 0 10px 28px rgba(0,0,0,.48), 0 0 0 5px color-mix(in srgb, var(--card-faction-color) 14%, transparent); }
.game-screen .player-card .mini-progress i { background: linear-gradient(90deg, var(--player-battle-deep), var(--player-battle-color)); }
.game-screen .rival-card .mini-progress i { background: linear-gradient(90deg, var(--rival-battle-deep), var(--rival-battle-color)); }

.dice-arena::after {
  content: "";
  position: absolute;
  z-index: 0;
  inset: 0;
  background: linear-gradient(90deg,
    color-mix(in srgb, var(--player-battle-deep) 46%, transparent) 0 var(--battle-control),
    color-mix(in srgb, var(--rival-battle-deep) 46%, transparent) var(--battle-control) 100%);
  opacity: .54;
  pointer-events: none;
  transition: background 420ms ease;
}

.dice-arena > * { position: relative; z-index: 1; }

.battle-front {
  display: grid;
  grid-template-columns: minmax(70px, auto) minmax(170px, 1fr) minmax(70px, auto);
  align-items: center;
  gap: 10px;
  margin: -2px 4px 14px;
}

.front-side {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 7px;
  font-weight: 850;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.front-side.rival { justify-content: flex-end; text-align: right; }
.front-side i { width: 7px; height: 7px; border-radius: 50%; background: var(--player-battle-color); box-shadow: 0 0 9px var(--player-battle-color); }
.front-side.rival i { background: var(--rival-battle-color); box-shadow: 0 0 9px var(--rival-battle-color); }
.front-track { position: relative; height: 11px; border: 1px solid rgba(255,255,255,.16); border-radius: 999px; background: linear-gradient(90deg, var(--rival-battle-deep), var(--rival-battle-color)); box-shadow: inset 0 2px 5px rgba(0,0,0,.52); }
.front-control { position: absolute; inset: 0 auto 0 0; width: 50%; border-radius: inherit; background: linear-gradient(90deg, var(--player-battle-deep), var(--player-battle-color)); box-shadow: 3px 0 12px color-mix(in srgb, var(--player-battle-color) 72%, transparent); transition: width 480ms cubic-bezier(.2,.72,.2,1); }
.front-clash { position: absolute; top: 50%; left: 50%; display: grid; place-items: center; width: 25px; height: 25px; border: 1px solid rgba(255,238,191,.45); border-radius: 50%; transform: translate(-50%, -50%); background: #171311; color: #f4d27c; font-style: normal; font-size: 11px; box-shadow: 0 4px 13px rgba(0,0,0,.55); transition: left 480ms cubic-bezier(.2,.72,.2,1), box-shadow 300ms ease; }
.battle-front.player-leading .front-clash { box-shadow: 0 0 17px color-mix(in srgb, var(--player-battle-color) 76%, transparent); }
.battle-front.rival-leading .front-clash { box-shadow: 0 0 17px color-mix(in srgb, var(--rival-battle-color) 76%, transparent); }

.die.ai-selected {
  z-index: 4;
  border: 4px solid color-mix(in srgb, var(--rival-battle-color) 82%, #fff1d1);
  outline: 3px solid color-mix(in srgb, var(--rival-battle-color) 48%, transparent);
  outline-offset: 3px;
  transform: translateY(-12px) scale(1.07);
  box-shadow:
    0 0 0 6px color-mix(in srgb, var(--rival-battle-color) 18%, transparent),
    0 13px 32px rgba(0,0,0,.58),
    0 0 28px color-mix(in srgb, var(--rival-battle-color) 55%, transparent),
    inset -5px -7px 12px rgba(76,59,37,.22);
}

#continueRollButton:not(:disabled) {
  border-color: color-mix(in srgb, var(--player-battle-color) 72%, #fff0ba);
  background: linear-gradient(135deg, color-mix(in srgb, var(--player-battle-deep) 78%, #181311), color-mix(in srgb, var(--player-battle-color) 22%, #201a14));
  box-shadow: 0 8px 24px color-mix(in srgb, var(--player-battle-color) 13%, transparent);
}

.game-screen.hot-dice-player .player-card,
.game-screen.hot-dice-rival .rival-card { animation: hot-card-surge 1.25s cubic-bezier(.16,.78,.2,1); }
.game-screen.hot-dice-player .dice-stage { animation: hot-field-player 1.25s ease-out; }
.game-screen.hot-dice-rival .dice-stage { animation: hot-field-rival 1.25s ease-out; }
.game-screen.hot-dice-player .battle-front .front-clash,
.game-screen.hot-dice-rival .battle-front .front-clash { animation: hot-clash 1.05s ease-out; }

@keyframes hot-card-surge {
  0% { transform: translateY(0); }
  22% { transform: translateY(-8px) scale(1.025); filter: brightness(1.45); }
  55% { transform: translateY(2px) scale(.995); }
  100% { transform: translateY(0); filter: brightness(1); }
}
@keyframes hot-field-player {
  18% { border-color: var(--player-battle-color); box-shadow: inset 0 0 90px color-mix(in srgb, var(--player-battle-color) 35%, transparent), 0 0 52px color-mix(in srgb, var(--player-battle-color) 42%, transparent); }
}
@keyframes hot-field-rival {
  18% { border-color: var(--rival-battle-color); box-shadow: inset 0 0 90px color-mix(in srgb, var(--rival-battle-color) 38%, transparent), 0 0 58px color-mix(in srgb, var(--rival-battle-color) 48%, transparent); }
}
@keyframes hot-clash { 28% { transform: translate(-50%, -50%) scale(1.55) rotate(20deg); filter: brightness(1.8); } }

.confetti i.ritual-particle { border-radius: 1px; background: var(--confetti-color); }
.confetti i.ritual-particle.coin { width: 14px; height: 14px; }
.confetti i.ritual-particle.laurel { width: auto; height: auto; background: transparent; color: var(--confetti-color); font-family: Georgia, serif; font-size: 25px; font-style: normal; line-height: 1; text-shadow: 0 0 8px color-mix(in srgb, var(--confetti-color) 55%, transparent); }
.confetti i.ritual-particle.shield-shard { width: 13px; height: 17px; clip-path: polygon(50% 0, 92% 17%, 82% 70%, 50% 100%, 18% 70%, 8% 17%); box-shadow: 0 0 8px color-mix(in srgb, var(--confetti-color) 45%, transparent); }
.confetti i.ritual-particle.ember { width: 7px; height: 7px; border-radius: 50%; box-shadow: 0 0 12px var(--confetti-color); }
.confetti i.player-hot,
.confetti i.rival-hot { top: 88%; animation-name: ritual-surge; animation-timing-function: cubic-bezier(.16,.72,.28,1); }

.confetti.defeat-shock::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 50% 44%, transparent 0 20%, rgba(145, 35, 31, .3) 55%, rgba(18, 4, 4, .72) 100%),
    linear-gradient(115deg, transparent 44%, rgba(255, 133, 91, .22) 49% 51%, transparent 56%);
  animation: defeat-shock 1.3s ease-out forwards;
}

@keyframes ritual-surge {
  0% { opacity: 0; transform: translate(0, 10vh) scale(.35) rotate(0); }
  18% { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--drift), -92vh) scale(1.08) rotate(var(--spin)); }
}

@keyframes defeat-shock {
  0% { opacity: 0; transform: scale(.88); }
  22% { opacity: 1; transform: scale(1.03); }
  100% { opacity: 0; transform: scale(1.1); }
}

@media (max-width: 720px) {
  .map-node { width: 39px; height: 39px; }
  .map-node.node-capital { width: 50px; height: 50px; }
  .map-node.node-home,
  .map-node.node-final { width: 56px; height: 56px; }
  .map-node.node-minor .node-standard { width: 27px; height: 27px; }
  .map-node.node-capital .node-standard { width: 36px; height: 36px; }
  .map-node.node-home .node-standard,
  .map-node.node-final .node-standard { width: 41px; height: 41px; }
  .map-node .node-label { max-width: 88px; font-size: 8px; }
  .map-node .node-label small { max-width: 86px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .battle-front { grid-template-columns: 58px minmax(120px, 1fr) 58px; gap: 7px; }
  .front-side { font-size: 6px; }
}

@media (max-width: 520px) {
  .world-map { min-height: 535px; }
  .battle-front { grid-template-columns: 42px minmax(105px, 1fr) 42px; margin-inline: 0; }
  .front-side b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .front-side i { display: none; }
  .front-track { height: 9px; }
  .front-clash { width: 21px; height: 21px; font-size: 9px; }
}

/* v7: roomier presentation, Roman crimson ownership, and cinematic Hot Dice */
.dice-arena::after {
  content: none;
  display: none;
}

.map-node.conquered {
  box-shadow:
    0 12px 26px rgba(0,0,0,.46),
    inset 0 0 0 5px color-mix(in srgb, var(--node-color) 9%, transparent),
    0 0 22px color-mix(in srgb, var(--node-color) 20%, transparent);
}

.map-node.conquered .node-standard {
  filter: saturate(1.12) contrast(1.04);
}

.map-node.claimed .node-check {
  background: var(--node-color);
  color: #fff8e5;
}

.hot-dice-cinematic {
  --hot-color: var(--player-battle-color);
  --hot-deep: var(--player-battle-deep);
  position: absolute;
  z-index: 14;
  inset: 0;
  display: grid;
  grid-template-rows: auto auto auto auto;
  place-content: center;
  justify-items: center;
  overflow: hidden;
  border-radius: inherit;
  background:
    radial-gradient(circle at 50% 48%, color-mix(in srgb, var(--hot-color) 26%, transparent), transparent 34%),
    radial-gradient(circle at 50% 50%, color-mix(in srgb, var(--hot-deep) 42%, rgba(5,6,8,.92)), rgba(5,6,8,.95) 72%);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.hot-dice-cinematic.rival-hot {
  --hot-color: var(--rival-battle-color);
  --hot-deep: var(--rival-battle-deep);
}

.hot-dice-cinematic.is-active {
  visibility: visible;
  animation: hot-cinematic-stage 2.6s cubic-bezier(.2,.72,.2,1) both;
}

.hot-dice-halo {
  position: absolute;
  top: 50%;
  left: 50%;
  width: min(52%, 410px);
  aspect-ratio: 1;
  border: 1px solid color-mix(in srgb, var(--hot-color) 55%, transparent);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  box-shadow:
    0 0 0 22px color-mix(in srgb, var(--hot-color) 4%, transparent),
    0 0 0 54px color-mix(in srgb, var(--hot-color) 3%, transparent),
    inset 0 0 55px color-mix(in srgb, var(--hot-color) 11%, transparent),
    0 0 75px color-mix(in srgb, var(--hot-color) 22%, transparent);
  animation: hot-halo-breathe 2.6s ease-out both;
}

.hot-dice-halo::before,
.hot-dice-halo::after {
  content: "";
  position: absolute;
  border: 1px solid color-mix(in srgb, var(--hot-color) 35%, transparent);
  border-radius: 50%;
}

.hot-dice-halo::before { inset: 15%; }
.hot-dice-halo::after { inset: 33%; border-style: dashed; animation: hot-orbit 7s linear infinite; }

.hot-dice-medallion {
  position: relative;
  display: grid;
  place-items: center;
  width: 76px;
  height: 76px;
  margin-bottom: 13px;
  border: 1px solid color-mix(in srgb, var(--hot-color) 74%, white);
  border-radius: 50%;
  background:
    repeating-conic-gradient(from 0deg, transparent 0 14deg, rgba(255,255,255,.11) 15deg 16deg),
    radial-gradient(circle at 35% 27%, color-mix(in srgb, var(--hot-color) 58%, white), var(--hot-deep) 68%);
  box-shadow: inset 0 0 0 7px rgba(0,0,0,.2), 0 0 38px color-mix(in srgb, var(--hot-color) 45%, transparent);
  color: #fff2c9;
  font-family: var(--serif);
  font-size: 27px;
  letter-spacing: .04em;
  animation: hot-medallion-arrive 2.6s cubic-bezier(.18,.8,.2,1) both;
}

.hot-dice-cinematic strong {
  position: relative;
  color: #fff5db;
  font-family: var(--serif);
  font-size: clamp(37px, 4vw, 62px);
  font-weight: 600;
  letter-spacing: .08em;
  line-height: .95;
  text-align: center;
  text-shadow: 0 0 24px color-mix(in srgb, var(--hot-color) 48%, transparent), 0 8px 25px rgba(0,0,0,.68);
  animation: hot-title-arrive 2.6s cubic-bezier(.18,.8,.2,1) both;
}

.hot-dice-cinematic small {
  position: relative;
  margin-top: 12px;
  color: color-mix(in srgb, var(--hot-color) 55%, #fff4dc);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .15em;
  text-align: center;
  text-transform: uppercase;
  animation: hot-subtitle-arrive 2.6s ease-out both;
}

.hot-dice-count {
  position: relative;
  display: flex;
  gap: 7px;
  margin-top: 18px;
}

.hot-dice-count i {
  width: 7px;
  height: 7px;
  border-radius: 2px;
  transform: rotate(45deg);
  background: var(--hot-color);
  box-shadow: 0 0 12px color-mix(in srgb, var(--hot-color) 70%, transparent);
  animation: hot-count-pulse 1.15s ease-in-out infinite alternate;
}

.hot-dice-count i:nth-child(2) { animation-delay: .08s; }
.hot-dice-count i:nth-child(3) { animation-delay: .16s; }
.hot-dice-count i:nth-child(4) { animation-delay: .24s; }
.hot-dice-count i:nth-child(5) { animation-delay: .32s; }
.hot-dice-count i:nth-child(6) { animation-delay: .4s; }

.confetti i.hot-spark {
  position: absolute;
  width: 5px;
  height: 18px;
  border-radius: 999px;
  transform: translate(-50%, -50%) scale(.15);
  background: linear-gradient(180deg, #fff8db, var(--spark-color), transparent);
  box-shadow: 0 0 12px var(--spark-color);
  animation: hot-spark-out var(--duration) cubic-bezier(.15,.72,.18,1) both;
}

.game-screen.hot-dice-player .player-card,
.game-screen.hot-dice-rival .rival-card {
  animation: hot-card-cinematic 2.6s cubic-bezier(.16,.78,.2,1);
}

.game-screen.hot-dice-player .dice-stage { animation: hot-stage-cinematic-player 2.6s ease-out; }
.game-screen.hot-dice-rival .dice-stage { animation: hot-stage-cinematic-rival 2.6s ease-out; }
.game-screen.hot-dice-player .battle-front .front-clash,
.game-screen.hot-dice-rival .battle-front .front-clash { animation: hot-clash-cinematic 2.1s ease-out; }

@keyframes hot-cinematic-stage {
  0% { opacity: 0; backdrop-filter: blur(0); }
  9% { opacity: 1; backdrop-filter: blur(3px); }
  76% { opacity: 1; backdrop-filter: blur(3px); }
  100% { opacity: 0; backdrop-filter: blur(0); }
}

@keyframes hot-medallion-arrive {
  0% { opacity: 0; transform: scale(.25) rotate(-18deg); }
  18% { opacity: 1; transform: scale(1.18) rotate(4deg); }
  34%, 78% { opacity: 1; transform: scale(1) rotate(0); }
  100% { opacity: 0; transform: scale(.92); }
}

@keyframes hot-title-arrive {
  0%, 10% { opacity: 0; transform: translateY(18px); letter-spacing: .18em; }
  29%, 78% { opacity: 1; transform: translateY(0); letter-spacing: .08em; }
  100% { opacity: 0; transform: translateY(-7px); }
}

@keyframes hot-subtitle-arrive {
  0%, 21% { opacity: 0; transform: translateY(8px); }
  37%, 79% { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; }
}

@keyframes hot-halo-breathe {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(.48); }
  25% { opacity: 1; transform: translate(-50%, -50%) scale(1.04); }
  72% { opacity: .86; transform: translate(-50%, -50%) scale(.98); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.18); }
}

@keyframes hot-orbit { to { transform: rotate(360deg); } }
@keyframes hot-count-pulse { to { opacity: .42; transform: rotate(45deg) scale(.72); } }
@keyframes hot-spark-out {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(.15); }
  16% { opacity: 1; }
  100% { opacity: 0; transform: translate(calc(-50% + var(--spark-x)), calc(-50% + var(--spark-y))) scale(1); }
}

@keyframes hot-card-cinematic {
  0%, 100% { transform: translateY(0); filter: brightness(1); }
  18% { transform: translateY(-7px) scale(1.018); filter: brightness(1.4); }
  56% { transform: translateY(0) scale(1.006); filter: brightness(1.14); }
}

@keyframes hot-stage-cinematic-player {
  13%, 62% { border-color: var(--player-battle-color); box-shadow: inset 0 0 110px color-mix(in srgb, var(--player-battle-color) 30%, transparent), 0 0 55px color-mix(in srgb, var(--player-battle-color) 35%, transparent); }
}

@keyframes hot-stage-cinematic-rival {
  13%, 62% { border-color: var(--rival-battle-color); box-shadow: inset 0 0 110px color-mix(in srgb, var(--rival-battle-color) 32%, transparent), 0 0 55px color-mix(in srgb, var(--rival-battle-color) 38%, transparent); }
}

@keyframes hot-clash-cinematic {
  16% { transform: translate(-50%, -50%) scale(1.6) rotate(22deg); filter: brightness(1.8); }
  52% { transform: translate(-50%, -50%) scale(1.12) rotate(0); }
}

@media (min-width: 901px) {
  .topbar,
  #app {
    width: min(2560px, calc(100% - clamp(40px, 4vw, 96px)));
  }

  .topbar { height: 96px; }
  #app,
  .screen { min-height: calc(100vh - 96px); }
  .screen { padding-top: 34px; }
  .brand-mark { width: 43px; height: 43px; }
  .brand-button strong { font-size: 17px; }
  .brand-button small { font-size: 10px; }
  .icon-button,
  .back-button { width: 48px; height: 48px; }
  .section-heading h2,
  .map-header h2 { font-size: clamp(46px, 3.5vw, 66px); }
  .world-map { min-height: clamp(650px, 64vh, 1080px); }
}

@media (min-width: 1200px) {
  .game-layout {
    grid-template-columns: minmax(220px, 285px) minmax(720px, 1fr) minmax(220px, 285px);
    gap: 22px;
  }

  .score-card,
  .dice-arena { min-height: clamp(620px, 64vh, 1000px); }
  .score-card { padding: 30px 22px; }
  .score-avatar { width: 90px; height: 90px; }
  .score-card h3 { font-size: 21px; }
  .banked-score { font-size: clamp(54px, 4vw, 76px); }
  .dice-arena { padding: 24px; }
  .dice-stage { min-height: clamp(300px, 36vh, 560px); }
  .die { width: clamp(64px, 5vw, 94px); }
  .turn-banner { font-size: 12px; }
  .turn-banner > span { font-size: 10px; }
  .turn-banner b { font-size: 20px; }
  .selection-panel { min-height: 74px; }
  .game-actions button { min-height: 58px; font-size: 14px; }
}

@media (min-width: 1700px) {
  .faction-grid { grid-template-columns: repeat(5, minmax(240px, 1fr)); }
  .faction-card { min-height: 360px; }
}

@media (max-width: 520px) {
  .hot-dice-medallion { width: 62px; height: 62px; font-size: 22px; }
  .hot-dice-cinematic strong { font-size: 32px; }
  .hot-dice-cinematic small { max-width: 260px; padding-inline: 12px; font-size: 8px; line-height: 1.5; }
  .hot-dice-halo { width: 78%; }
}

/* v9 foundation: full-scale arena, explicit Hot Dice roll, and true Sudden Death duels */
.sudden-death-banner[hidden] { display: none; }

.sudden-death-banner {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  margin: 0 4px 15px;
  padding: 12px 15px;
  border: 1px solid rgba(226, 77, 64, .62);
  border-radius: 12px;
  background:
    linear-gradient(90deg, rgba(123, 23, 29, .92), rgba(34, 14, 17, .96) 48%, rgba(103, 65, 21, .92)),
    #1b1012;
  box-shadow: 0 12px 30px rgba(0,0,0,.34), inset 0 0 24px rgba(226, 77, 64, .08);
  animation: sudden-banner-arrive 620ms cubic-bezier(.16,.78,.2,1) both;
}

.sudden-death-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(244, 199, 101, .72);
  border-radius: 50%;
  background: rgba(11, 8, 8, .4);
  box-shadow: 0 0 22px rgba(205, 55, 46, .34), inset 0 0 0 5px rgba(244, 199, 101, .045);
}

.sudden-death-icon svg { width: 24px; height: 24px; fill: #f4c765; }
.sudden-death-copy small,
.sudden-death-copy strong { display: block; }
.sudden-death-copy small { color: #f3a18d; font-size: 9px; font-weight: 900; letter-spacing: .17em; text-transform: uppercase; }
.sudden-death-copy strong { margin-top: 3px; color: #fff2d4; font-family: var(--serif); font-size: 16px; font-weight: 600; }
.sudden-death-tally { display: flex; align-items: center; gap: 10px; }
.sudden-death-tally b { min-width: 64px; color: #fff4d8; font-family: var(--serif); font-size: 23px; font-weight: 600; text-align: center; }
.sudden-death-tally b:first-child { color: var(--player-battle-color); }
.sudden-death-tally b:last-child { color: var(--rival-battle-color); }
.sudden-death-tally i { color: rgba(255,255,255,.42); font-size: 8px; font-style: normal; letter-spacing: .12em; text-transform: uppercase; }
.game-screen.sudden-death .dice-arena { border-color: rgba(226, 77, 64, .55); box-shadow: 0 22px 70px rgba(0,0,0,.4), inset 0 0 65px rgba(145, 28, 35, .09); }
.game-screen.sudden-death .front-track { box-shadow: inset 0 2px 5px rgba(0,0,0,.52), 0 0 17px rgba(218, 66, 54, .28); }
.stage-message.sudden { color: #ffd57f; background: radial-gradient(circle, rgba(117, 23, 29, .92), rgba(8,6,5,.94) 68%); text-shadow: 0 0 32px rgba(235, 78, 54, .64); }
.log-item.sudden { border-color: rgba(215, 86, 62, .42); background: rgba(105, 25, 29, .18); }
.log-item.sudden b { color: #f4b168; }
.log-item.hot { border-color: color-mix(in srgb, var(--accent) 52%, var(--line)); background: color-mix(in srgb, var(--accent-dark) 19%, rgba(255,255,255,.02)); }
.log-item.hot b { color: var(--accent-bright); }

@keyframes sudden-banner-arrive {
  0% { opacity: 0; transform: translateY(-10px) scale(.985); }
  62% { opacity: 1; transform: translateY(2px) scale(1.004); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

.hot-dice-cinematic {
  grid-template-rows: auto auto auto auto;
  row-gap: 0;
}

.hot-dice-cinematic.is-active { animation-duration: 3.2s; }
.hot-dice-halo,
.hot-dice-cinematic strong,
.hot-dice-cinematic small { animation-duration: 3.2s; }
.game-screen.hot-dice-player .player-card,
.game-screen.hot-dice-rival .rival-card,
.game-screen.hot-dice-player .dice-stage,
.game-screen.hot-dice-rival .dice-stage { animation-duration: 3.2s; }

.hot-dice-status {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 17px;
  padding: 8px 13px;
  border: 1px solid color-mix(in srgb, var(--hot-color) 62%, transparent);
  border-radius: 999px;
  background: rgba(7, 7, 8, .58);
  box-shadow: 0 0 24px color-mix(in srgb, var(--hot-color) 15%, transparent);
  color: #fff2d3;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .15em;
  text-transform: uppercase;
  animation: hot-status-arrive 3.2s ease-out both;
}

.hot-dice-status svg { width: 18px; height: 18px; fill: var(--hot-color); filter: drop-shadow(0 0 6px var(--hot-color)); }

.hot-dice-roll {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(7px, .8vw, 13px);
  min-height: 80px;
  margin-bottom: 16px;
  perspective: 700px;
}

.hot-roll-die {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  width: clamp(49px, 4.4vw, 68px);
  aspect-ratio: 1;
  padding: clamp(6px, .55vw, 9px);
  border: 2px solid color-mix(in srgb, var(--hot-color) 48%, #fff6dd);
  border-radius: 16%;
  background: linear-gradient(145deg, #fff9e9, #cdbd9e);
  box-shadow: 0 12px 22px rgba(0,0,0,.52), 0 0 18px color-mix(in srgb, var(--hot-color) 28%, transparent), inset -5px -7px 12px rgba(76,59,37,.22);
  opacity: 0;
  animation: hot-die-return 3.2s cubic-bezier(.16,.76,.18,1) both;
  animation-delay: calc(var(--hot-die-index) * 70ms);
}

.hot-roll-die .pip { min-width: 3px; }
.hot-roll-die:nth-child(1) { --hot-x: -118px; }
.hot-roll-die:nth-child(2) { --hot-x: -72px; }
.hot-roll-die:nth-child(3) { --hot-x: -27px; }
.hot-roll-die:nth-child(4) { --hot-x: 27px; }
.hot-roll-die:nth-child(5) { --hot-x: 72px; }
.hot-roll-die:nth-child(6) { --hot-x: 118px; }
.hot-dice-cinematic strong { font-size: clamp(41px, 4.2vw, 68px); }
.hot-dice-cinematic small { margin-top: 10px; font-size: 11px; }

@keyframes hot-status-arrive {
  0%, 8% { opacity: 0; transform: translateY(-10px); }
  20%, 79% { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(-5px); }
}

@keyframes hot-die-return {
  0%, 8% { opacity: 0; transform: translate3d(var(--hot-x), -74px, -120px) rotateX(85deg) rotateY(-75deg) rotateZ(-26deg) scale(.48); }
  27% { opacity: 1; transform: translate3d(0, 8px, 0) rotateX(-12deg) rotateY(14deg) rotateZ(7deg) scale(1.08); }
  39%, 79% { opacity: 1; transform: translate3d(0, 0, 0) rotateX(0) rotateY(0) rotateZ(0) scale(1); }
  100% { opacity: 0; transform: translate3d(0, -8px, 0) scale(.94); }
}

@media (min-width: 901px) {
  .topbar,
  #app { width: min(3400px, calc(100% - clamp(28px, 2.5vw, 72px))); }
  .topbar { height: 102px; }
  #app,
  .screen { min-height: calc(100vh - 102px); }
  .screen { padding-top: 28px; }
  .brand-mark { width: 48px; height: 48px; }
  .brand-button strong { font-size: 19px; }
  .brand-button small { font-size: 11px; }
  .arena-header { grid-template-columns: 54px minmax(290px, 1fr) minmax(300px, .85fr) auto; gap: 20px; }
  body .game-screen .arena-header { padding: 20px 22px; }
  .arena-location small { font-size: 11px; }
  .arena-location h2 { font-size: 33px; }
  .arena-motto { font-size: clamp(20px, 1.7vw, 31px); }
  .series-score { gap: 14px; font-size: 13px; }
  .series-score span { padding: 9px 12px; }
  .series-score b { font-size: 20px; }
  .series-goal { min-width: 112px; }
  .series-goal i { font-size: 10px; }
  .series-goal small { font-size: 9px; }
}

@media (min-width: 1200px) {
  .game-layout {
    grid-template-columns: minmax(270px, 340px) minmax(720px, 1fr) minmax(270px, 340px);
    gap: 26px;
    margin-top: 24px;
  }
  .score-card,
  .dice-arena { min-height: clamp(660px, 68vh, 1050px); }
  .score-card { padding: 40px 28px; }
  body .game-screen .score-card::before { margin-bottom: 20px; font-size: 40px; }
  .score-avatar { width: 126px; height: 126px; margin-bottom: 25px; }
  .avatar-badge { right: -7px; bottom: -5px; width: 32px; height: 32px; }
  .score-card small { font-size: 11px; line-height: 1.5; }
  .score-card h3 { margin: 8px 0 30px; font-size: 28px; }
  .banked-score { font-size: clamp(72px, 4.6vw, 92px); }
  .score-target { margin-top: 11px; font-size: 13px; }
  .score-card .mini-progress { margin-top: 30px; }
  .dice-arena { padding: 31px; }
  .turn-banner { padding: 0 7px 18px; font-size: 15px; }
  .turn-banner > span { font-size: 12px; }
  .turn-banner b { font-size: 26px; }
  .battle-front { grid-template-columns: minmax(95px, auto) minmax(220px, 1fr) minmax(95px, auto); gap: 15px; margin: -1px 7px 18px; }
  .front-side { gap: 8px; font-size: 10px; }
  .front-side i { width: 9px; height: 9px; }
  .front-track { height: 14px; }
  .front-clash { width: 31px; height: 31px; font-size: 14px; }
  .dice-stage { min-height: clamp(365px, 39vh, 630px); }
  .dice-row { gap: clamp(13px, 1.2vw, 21px); padding: 32px 16px; }
  .die { width: clamp(82px, 5.5vw, 124px); padding: clamp(10px, .8vw, 15px); }
  .selection-panel { min-height: 88px; padding: 17px 7px; }
  .selection-panel small { font-size: 10px; }
  .selection-panel strong { margin-top: 6px; font-size: 16px; }
  .selection-panel > span { font-size: 31px; }
  .held-panel { min-height: 62px; padding: 12px 7px; font-size: 11px; }
  .held-dice { gap: 8px; }
  .mini-die { width: 34px; height: 34px; border-radius: 8px; font-size: 15px; }
  .remaining-count b { font-size: 17px; }
  .game-actions { gap: 14px; padding-top: 21px; }
  .game-actions button { min-height: 66px; font-size: 16px; }
  .action-hint { min-height: 20px; margin-top: 13px; font-size: 12px; }
  .turn-log { gap: 10px; margin-top: 15px; }
  .log-item { padding: 10px 14px; font-size: 11px; }
  .sudden-death-banner { padding: 14px 17px; }
  .sudden-death-copy small { font-size: 10px; }
  .sudden-death-copy strong { font-size: 19px; }
}

@media (min-width: 1800px) {
  .game-layout {
    grid-template-columns: minmax(330px, 390px) minmax(900px, 1fr) minmax(330px, 390px);
    gap: 32px;
  }
  .score-card,
  .dice-arena { min-height: clamp(700px, 70vh, 1120px); }
  .score-card { padding-inline: 34px; }
  .score-avatar { width: 150px; height: 150px; }
  .score-card small { font-size: 12px; }
  .score-card h3 { font-size: 32px; }
  .banked-score { font-size: clamp(86px, 4.8vw, 106px); }
  .score-target { font-size: 14px; }
  .dice-stage { min-height: clamp(400px, 42vh, 720px); }
  .die { width: clamp(96px, 5.2vw, 136px); }
  .selection-panel strong { font-size: 18px; }
  .game-actions button { min-height: 72px; font-size: 18px; }
  .action-hint { font-size: 13px; }
}

@media (max-width: 720px) {
  .sudden-death-banner { grid-template-columns: auto 1fr; margin-inline: 0; padding: 10px; }
  .sudden-death-icon { width: 36px; height: 36px; }
  .sudden-death-copy small { font-size: 7px; }
  .sudden-death-copy strong { font-size: 13px; }
  .sudden-death-tally { grid-column: 1 / -1; justify-content: center; padding-top: 7px; border-top: 1px solid rgba(255,255,255,.08); }
  .sudden-death-tally b { min-width: 52px; font-size: 19px; }
  .hot-dice-status { margin-bottom: 12px; padding: 6px 10px; font-size: 8px; }
  .hot-dice-roll { flex-wrap: wrap; max-width: 250px; min-height: 102px; margin-bottom: 11px; gap: 6px; }
  .hot-roll-die { width: 42px; padding: 5px; }
  .hot-dice-cinematic strong { font-size: 31px; }
  .hot-dice-cinematic small { max-width: 270px; font-size: 8px; line-height: 1.5; }
}

/* v9: rival-colored defeat, readable Hot Dice command, and historical dispatches */
.historical-dispatch {
  position: relative;
  align-self: stretch;
  min-height: 132px;
  margin-top: clamp(20px, 2.5vh, 34px);
  padding: 15px 16px 14px;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--card-faction-color) 28%, rgba(255,255,255,.08));
  border-radius: 12px;
  background:
    linear-gradient(145deg, color-mix(in srgb, var(--card-faction-deep) 34%, rgba(5,6,8,.62)), rgba(5,6,8,.52)),
    rgba(5,6,8,.52);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.035), 0 14px 30px rgba(0,0,0,.2);
  text-align: left;
}

.historical-dispatch::after {
  content: "✦";
  position: absolute;
  right: 11px;
  bottom: -11px;
  color: color-mix(in srgb, var(--card-faction-color) 10%, transparent);
  font-family: var(--serif);
  font-size: 64px;
  line-height: 1;
  pointer-events: none;
}

.historical-dispatch header {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-bottom: 9px;
  border-bottom: 1px solid rgba(255,255,255,.075);
}

.historical-dispatch header span,
.historical-dispatch header b {
  font-size: 8px;
  font-weight: 900;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.historical-dispatch header span { color: color-mix(in srgb, var(--card-faction-color) 76%, #fff1d3); }
.historical-dispatch header b {
  padding: 3px 6px;
  border: 1px solid color-mix(in srgb, var(--card-faction-color) 30%, transparent);
  border-radius: 999px;
  color: color-mix(in srgb, var(--card-faction-color) 65%, #fff5dc);
  letter-spacing: .1em;
}

.historical-dispatch p {
  position: relative;
  z-index: 1;
  margin: 11px 0 9px;
  color: #eee2cb;
  font-family: var(--serif);
  font-size: 13px;
  line-height: 1.42;
}

.historical-dispatch.is-quotation p { font-style: italic; }
.historical-dispatch cite {
  position: relative;
  z-index: 1;
  display: block;
  color: color-mix(in srgb, var(--card-faction-color) 52%, #9e9a91);
  font-size: 8px;
  font-style: normal;
  font-weight: 700;
  letter-spacing: .075em;
  line-height: 1.35;
}

.historical-dispatch.is-changing { animation: dispatch-turn 520ms cubic-bezier(.18,.76,.22,1) both; }

@keyframes dispatch-turn {
  0% { opacity: .35; transform: translateY(5px); filter: brightness(.7); }
  58% { opacity: 1; transform: translateY(-1px); filter: brightness(1.12); }
  100% { opacity: 1; transform: translateY(0); filter: brightness(1); }
}

.result-dialog.defeat-mode {
  --result-faction-color: #74b5d4;
  --result-faction-deep: #28607f;
  border-color: color-mix(in srgb, var(--result-faction-color) 72%, transparent);
  background:
    radial-gradient(circle at 50% 13%, color-mix(in srgb, var(--result-faction-color) 27%, transparent), transparent 33%),
    linear-gradient(148deg, color-mix(in srgb, var(--result-faction-deep) 77%, #171318), rgba(16,16,21,.99) 53%, color-mix(in srgb, var(--result-faction-deep) 31%, #121820));
  box-shadow:
    0 36px 135px rgba(0,0,0,.88),
    0 0 58px color-mix(in srgb, var(--result-faction-color) 25%, transparent),
    inset 0 0 0 4px color-mix(in srgb, var(--result-faction-color) 5%, transparent);
}

.result-dialog.defeat-mode::before {
  background:
    repeating-conic-gradient(from 8deg, color-mix(in srgb, var(--result-faction-color) 11%, transparent) 0 2deg, transparent 2deg 13deg),
    radial-gradient(circle, color-mix(in srgb, var(--result-faction-deep) 24%, transparent), transparent 61%);
}

.result-dialog.defeat-mode::after { color: color-mix(in srgb, var(--result-faction-color) 6%, transparent); }
.result-dialog.defeat-mode .result-rival-portrait {
  border-color: color-mix(in srgb, var(--result-faction-color) 86%, white);
  box-shadow:
    0 0 0 9px color-mix(in srgb, var(--result-faction-deep) 18%, transparent),
    0 22px 50px rgba(0,0,0,.58),
    0 0 54px color-mix(in srgb, var(--result-faction-color) 35%, transparent);
}
.result-dialog.defeat-mode .result-rival-standard {
  border-color: color-mix(in srgb, var(--result-faction-color) 78%, #fff0cf);
  box-shadow: 0 10px 28px rgba(0,0,0,.58), 0 0 25px color-mix(in srgb, var(--result-faction-color) 38%, transparent);
}
.result-dialog.defeat-mode .eyebrow { color: color-mix(in srgb, var(--result-faction-color) 75%, #fff0d9); }
.result-dialog.defeat-mode h2 {
  color: color-mix(in srgb, var(--result-faction-color) 18%, #fff2df);
  text-shadow: 0 6px 28px rgba(0,0,0,.6), 0 0 24px color-mix(in srgb, var(--result-faction-color) 24%, transparent);
}
.result-dialog.defeat-mode > p:not(.eyebrow) { color: color-mix(in srgb, var(--result-faction-color) 12%, #cdbdb2); }
.result-dialog.defeat-mode .result-scoreline div { border-color: color-mix(in srgb, var(--result-faction-color) 22%, transparent); }
.result-dialog.defeat-mode .result-scoreline strong { color: color-mix(in srgb, var(--result-faction-color) 14%, #fff0df); }
.result-dialog.defeat-mode .primary-button {
  border-color: color-mix(in srgb, var(--result-faction-color) 78%, white);
  background: linear-gradient(135deg, color-mix(in srgb, var(--result-faction-deep) 88%, #16151a), color-mix(in srgb, var(--result-faction-color) 58%, var(--result-faction-deep)));
  color: #fff8e9;
  box-shadow: 0 12px 34px color-mix(in srgb, var(--result-faction-deep) 48%, transparent);
}

.hot-dice-cinematic.is-active,
.hot-dice-halo,
.hot-dice-cinematic strong,
.hot-dice-cinematic small,
.hot-dice-status,
.hot-roll-die,
.game-screen.hot-dice-player .player-card,
.game-screen.hot-dice-rival .rival-card,
.game-screen.hot-dice-player .dice-stage,
.game-screen.hot-dice-rival .dice-stage { animation-duration: 3.8s; }

.hot-dice-status { z-index: 2; }
.hot-dice-cinematic strong {
  z-index: 2;
  max-width: min(92%, 780px);
  padding: 11px 24px 12px;
  border-top: 1px solid color-mix(in srgb, var(--hot-color) 44%, transparent);
  border-bottom: 1px solid color-mix(in srgb, var(--hot-color) 44%, transparent);
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--hot-deep) 62%, rgba(5,6,8,.84)) 18% 82%, transparent);
  font-size: clamp(31px, 3.2vw, 54px);
  line-height: 1.1;
}
.hot-dice-cinematic small { z-index: 2; font-size: 11px; }

#musicButton:not(.is-off) {
  border-color: color-mix(in srgb, var(--accent) 54%, var(--line));
  background: color-mix(in srgb, var(--accent-dark) 18%, rgba(255,255,255,.025));
  box-shadow: 0 0 18px color-mix(in srgb, var(--accent) 10%, transparent);
}

@keyframes hot-status-arrive {
  0%, 7% { opacity: 0; transform: translateY(-10px); }
  18%, 88% { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(-5px); }
}

@keyframes hot-title-arrive {
  0%, 18% { opacity: 0; transform: translateY(18px); letter-spacing: .14em; }
  34%, 91% { opacity: 1; transform: translateY(0); letter-spacing: .06em; }
  100% { opacity: 0; transform: translateY(-7px); }
}

@keyframes hot-subtitle-arrive {
  0%, 26% { opacity: 0; transform: translateY(8px); }
  42%, 92% { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; }
}

@media (min-width: 1800px) {
  .historical-dispatch { min-height: 144px; padding: 17px 18px 15px; }
  .historical-dispatch header span,
  .historical-dispatch header b,
  .historical-dispatch cite { font-size: 9px; }
  .historical-dispatch p { font-size: 14px; }
}

@media (max-width: 1199px) {
  .historical-dispatch { display: none; }
}

@media (max-width: 720px) {
  .hot-dice-cinematic strong { max-width: 285px; padding: 9px 12px; font-size: 27px; line-height: 1.12; }
}

/* v10: immutable campaign identities and the western frontier */
body[data-theme="gaul"] {
  --bg: #0a1715; --bg-deep: #040a09; --surface: rgba(24, 55, 50, .92);
  --surface-solid: #183732; --surface-high: #27534b; --line: rgba(159, 196, 120, .22);
  --line-strong: rgba(159, 196, 120, .47); --text: #f3eedb; --muted: #b3c2ad;
  --accent: #9fc478; --accent-bright: #cbe59f; --accent-dark: #1f4c47;
}

body[data-theme="iberia"] {
  --bg: #1b0d0a; --bg-deep: #0b0605; --surface: rgba(82, 34, 28, .92);
  --surface-solid: #52221c; --surface-high: #75382d; --line: rgba(224, 173, 89, .22);
  --line-strong: rgba(224, 173, 89, .48); --text: #fff0d7; --muted: #c9b09b;
  --accent: #e0ad59; --accent-bright: #f3cf82; --accent-dark: #7a3029;
}

.standard-gaul,
.standard-iberia {
  background-image: url("assets/western-civilizations-atlas.webp") !important;
  background-repeat: no-repeat !important;
  background-size: 200% 200% !important;
}

.standard-gaul { background-position: 0 100% !important; }
.standard-iberia { background-position: 100% 100% !important; }

.portrait-10,
.portrait-11 {
  background-image: url("assets/western-civilizations-atlas.webp") !important;
  background-repeat: no-repeat !important;
  background-size: 200% 200% !important;
}

.portrait-10 { background-position: 0 0 !important; }
.portrait-11 { background-position: 100% 0 !important; }
.portrait-12 {
  background-image: url("assets/roman-general-female.webp") !important;
  background-position: center !important;
  background-repeat: no-repeat !important;
  background-size: cover !important;
}

.menu-faction-standard,
.commander-standard,
.campaign-standard {
  background-image: url("assets/faction-standards-atlas.webp");
  background-repeat: no-repeat;
  background-size: 300% 200%;
}

.menu-art::before { display: none; }
.menu-faction-standard {
  position: absolute;
  z-index: 1;
  top: 4%;
  left: 50%;
  display: block;
  width: min(29vw, 390px);
  aspect-ratio: 1;
  border: 1px solid color-mix(in srgb, var(--accent) 52%, transparent);
  border-radius: 30px;
  transform: translateX(-50%);
  box-shadow: 0 30px 95px rgba(0,0,0,.48), 0 0 70px color-mix(in srgb, var(--accent) 16%, transparent);
  opacity: .62;
  mask-image: linear-gradient(to bottom, black 0 72%, transparent 100%);
}

.commander-option-visual {
  display: block;
  width: 46px;
  height: 46px;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  object-fit: cover;
  background-color: color-mix(in srgb, var(--accent-dark) 20%, var(--surface-solid));
}

.commander-option-visual.atlas-portrait { border-radius: 11px; }
.player-commander-visual {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.portrait-options.is-locked .portrait-choice { cursor: default; }
.portrait-options.is-locked .portrait-choice:not(.active) { opacity: .45; }
.portrait-choice:disabled { cursor: default; }

.faction-card .faction-action {
  position: relative;
  z-index: 3;
  display: block;
  margin-top: 16px;
  color: var(--faction-accent);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.faction-card[data-faction="gaul"]::before,
.faction-card[data-faction="iberia"]::before,
body[data-theme="gaul"] .game-screen.is-active::before,
body[data-theme="iberia"] .game-screen.is-active::before {
  background-image: url("assets/western-civilizations-atlas.webp");
  background-repeat: no-repeat;
  background-size: 200% 200%;
}

.faction-card[data-faction="gaul"]::before,
body[data-theme="gaul"] .game-screen.is-active::before { background-position: 0 100%; }
.faction-card[data-faction="iberia"]::before,
body[data-theme="iberia"] .game-screen.is-active::before { background-position: 100% 100%; }

.map-node[data-civilization="gaul"] { --node-color: #9fc478; --node-deep: #1f4c47; }
.map-node[data-civilization="iberia"] { --node-color: #e0ad59; --node-deep: #7a3029; }

.reset-dialog .campaign-standard {
  border-color: var(--line-strong);
  border-radius: 14px;
  font-size: 0;
  box-shadow: 0 12px 34px rgba(0,0,0,.4), 0 0 24px color-mix(in srgb, var(--accent) 14%, transparent);
}

@media (max-width: 720px) {
  .menu-faction-standard { width: min(58vw, 290px); opacity: .42; }
}
