:root {
  --bg: #0e0a11;
  --panel: #191320;
  --panel-alt: #22182c;
  --line: #3a2948;
  --text: #f7f1ff;
  --muted: #beaccf;
  --pink: #ff4db8;
  --gold: #ffd166;
  --danger: #ff7b7b;
  --success: #74d99f;
  --warning: #ffd166;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: radial-gradient(circle at top, #251530 0%, var(--bg) 55%);
  color: var(--text);
}

a { color: var(--text); text-decoration: none; }
a:hover { color: var(--pink); }

h1, h2, h3, p { margin-top: 0; }

.wrap {
  width: min(1180px, calc(100% - 2rem));
  margin: 0 auto;
}

.site-header {
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
  background: rgba(8, 4, 12, 0.85);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 0;
}

.brand {
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--pink);
}

.nav,
.account-actions,
.pill-row {
  display: flex;
  gap: 0.9rem;
  align-items: center;
  flex-wrap: wrap;
}

.page-shell {
  padding: 2rem 0 4rem;
}

.panel,
.hero-card,
.subpanel,
.pod-card,
.match-card {
  background: linear-gradient(180deg, rgba(255,255,255,0.03), rgba(255,255,255,0.01));
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 1.2rem;
  box-shadow: 0 18px 50px rgba(0,0,0,0.25);
  margin-bottom: 1.25rem;
}

.subpanel,
.pod-card,
.match-card {
  background: rgba(255,255,255,0.02);
  box-shadow: none;
}

.hero-card {
  padding: 1.6rem;
}

.narrow { max-width: 760px; }
.hero h2, .auth-card h2 { margin-top: 0.25rem; }

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gold);
  font-size: 0.8rem;
  margin: 0 0 0.35rem;
}

.muted { color: var(--muted); }

.card-grid,
.stats-grid,
.two-column-grid,
.form-grid,
.confirmation-grid {
  display: grid;
  gap: 1rem;
}

.card-grid,
.stats-grid.three-up,
.form-grid.three-up { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.card-grid.two-up,
.two-column-grid,
.form-grid.two-up { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.form-grid.four-up,
.confirmation-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.form-grid.five-up,
.stats-grid.five-up { grid-template-columns: repeat(5, minmax(0, 1fr)); }

.tight-grid { gap: 0.75rem; }

.stat-card {
  text-align: center;
}

.stat-label {
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  margin: 0;
}

.stack-form {
  display: grid;
  gap: 0.9rem;
}

label span {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--muted);
}

input,
select,
textarea,
button {
  width: 100%;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel-alt);
  color: var(--text);
  padding: 0.8rem 0.9rem;
}

button {
  cursor: pointer;
  background: linear-gradient(135deg, #ff4db8, #b541ff);
  border: none;
  font-weight: 700;
}

button:hover { filter: brightness(1.06); }

.link-button,
.secondary-link-button,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  border-radius: 12px;
}

.link-button,
.secondary-link-button {
  background: transparent;
  border: 1px solid var(--line);
  padding: 0.55rem 0.9rem;
}

.secondary-link-button {
  background: rgba(255,255,255,0.04);
}

.secondary-button {
  min-height: 42px;
  padding: 0.7rem 1rem;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.03);
  color: var(--text);
}

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

.flash-stack {
  display: grid;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.flash {
  border-radius: 12px;
  padding: 0.85rem 1rem;
  border: 1px solid var(--line);
}

.flash-success { background: rgba(116, 217, 159, 0.12); }
.flash-danger { background: rgba(255, 123, 123, 0.12); }
.flash-warning { background: rgba(255, 209, 102, 0.12); }

.list-stack {
  display: grid;
  gap: 0.75rem;
}

.list-row,
.admin-row,
.split {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.list-row,
.admin-row {
  padding: 0.85rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.02);
}

.list-row form,
.admin-row form { margin: 0; }

.list-row button,
.admin-row button { width: auto; }

.simple-list,
.compact-list,
.bullet-list {
  margin: 0;
  padding-left: 1.15rem;
  display: grid;
  gap: 0.45rem;
}

.color-row {
  display: flex;
  gap: 0.75rem;
  margin: 0.85rem 0;
}

.swatch {
  width: 42px;
  height: 42px;
  border-radius: 999px;
  border: 2px solid rgba(255,255,255,0.15);
}

.account-pill,
.status-pill,
.type-pill,
.map-status-pill {
  padding: 0.45rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255,255,255,0.04);
  font-size: 0.82rem;
}

.type-pill { color: var(--gold); }
.status-confirmed { color: var(--success); }
.status-disputed { color: var(--danger); }
.status-pending-confirmation { color: var(--warning); }

.map-status-pill {
  margin-bottom: 0.8rem;
}

.map-status-pill.error {
  color: var(--danger);
  border-color: rgba(255, 123, 123, 0.35);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  border-bottom: 1px solid var(--line);
  padding: 0.75rem;
  text-align: left;
}

.data-table th { color: var(--muted); }

.confirmation-form {
  display: grid;
  gap: 0.5rem;
  padding: 0.85rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.02);
}

.compact-form { max-width: 420px; }
.top-gap-sm { margin-top: 0.9rem; }

.button-row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.feed-scroll {
  max-height: 540px;
  overflow: auto;
  padding-right: 0.2rem;
}

.collapsible-card {
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(255,255,255,0.035), rgba(255,255,255,0.015));
  overflow: hidden;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.collapsible-card:hover,
.collapsible-card[open] {
  border-color: rgba(255, 209, 102, 0.35);
  background: linear-gradient(180deg, rgba(255,255,255,0.05), rgba(255,255,255,0.02));
}

.collapsible-card summary {
  list-style: none;
  cursor: pointer;
  padding: 1rem 1rem 0.95rem;
}

.collapsible-card summary::-webkit-details-marker { display: none; }

.collapsible-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1rem;
  align-items: start;
}

.collapsible-title {
  font-size: 1.02rem;
  font-weight: 700;
  margin: 0.2rem 0 0;
}

.collapsible-meta {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
  margin-bottom: 0.35rem;
}

.collapsible-preview,
.preview-clamp,
.story-card-preview {
  color: var(--muted);
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.collapsible-card[open] .collapsible-preview,
.collapsible-card[open] .preview-clamp,
.collapsible-card[open] .story-card-preview {
  display: block;
  overflow: visible;
}

.collapsible-time,
.activity-time {
  color: var(--muted);
  font-size: 0.9rem;
  white-space: nowrap;
}

.collapsible-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--gold);
  font-size: 0.84rem;
  margin-top: 0.7rem;
}

.collapsible-toggle::after {
  content: 'Expand';
}

.collapsible-card[open] .collapsible-toggle::after {
  content: 'Collapse';
}

.collapsible-body {
  border-top: 1px solid rgba(255,255,255,0.06);
  padding: 0.95rem 1rem 1rem;
  display: grid;
  gap: 0.75rem;
}

.story-card-grid {
  display: grid;
  gap: 1rem;
}

.story-card {
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 18px;
  padding: 1rem;
  background: linear-gradient(180deg, rgba(255,255,255,0.035), rgba(255,255,255,0.015));
}

.story-card-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1rem;
  align-items: start;
}

.story-card-title {
  font-size: 1.08rem;
  font-weight: 700;
  margin: 0.35rem 0 0.35rem;
}

.story-card-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.story-card-thumb {
  margin-top: 0.9rem;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.02);
}

.story-card-thumb img {
  display: block;
  width: 100%;
  max-height: 220px;
  object-fit: cover;
}

.story-layout {
  display: grid;
  gap: 1rem;
}

.story-surface {
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.015));
  padding: 1.2rem;
}

.story-media,
.story-video,
.story-html-block,
.story-text-block {
  margin-top: 1rem;
}

.story-media img {
  display: block;
  width: 100%;
  max-width: 100%;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.08);
}

.story-video {
  position: relative;
  width: 100%;
  overflow: hidden;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.08);
  background: #000;
}

.story-video.story-video-embed {
  padding-top: 56.25%;
}

.story-video.story-video-embed iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.story-video video {
  display: block;
  width: 100%;
  max-height: 70vh;
}

.story-html-block {
  padding: 1rem;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.025);
  overflow-wrap: anywhere;
}

.story-text-block,
.prose-block {
  white-space: pre-wrap;
  line-height: 1.75;
}

.map-caption {
  max-width: 64ch;
}

/* Kingdom region map */
.region-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.45rem;
}

.tile {
  position: relative;
  min-height: 88px;
  border-radius: 14px;
  border: 1px solid var(--line);
  padding: 0.55rem;
  background: rgba(255,255,255,0.03);
  display: grid;
  gap: 0.25rem;
}

.tile-neutral { opacity: 0.75; }
.tile-frontier { border-style: dashed; border-color: var(--gold); }
.tile-owned { background: linear-gradient(180deg, rgba(255,77,184,0.18), rgba(255,255,255,0.03)); }
.tile-capital { box-shadow: inset 0 0 0 1px rgba(255,209,102,0.65); }

.tile-coord,
.tile-terrain {
  font-size: 0.72rem;
  color: var(--muted);
}

.tile-marker,
.tile-building {
  position: absolute;
  right: 0.45rem;
  width: 1.45rem;
  height: 1.45rem;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-size: 0.75rem;
  font-weight: 700;
}

.tile-marker {
  top: 0.45rem;
  background: rgba(255,209,102,0.16);
  color: var(--gold);
}

.tile-building {
  bottom: 0.45rem;
  background: rgba(116,217,159,0.16);
  color: var(--success);
}

/* Admin world map workspace */
.zoom-button {
  min-width: 5rem;
}

.zoom-button.is-active {
  border-color: rgba(255, 209, 102, 0.6);
  box-shadow: inset 0 0 0 1px rgba(255, 209, 102, 0.35);
}

.map-workspace-grid {
  display: grid;
  gap: 1rem;
  align-items: start;
  grid-template-columns: minmax(0, 2fr) minmax(320px, 0.9fr);
}

.map-stage-panel,
.map-sidebar-panel {
  min-height: 100%;
  min-width: 0;
}

.world-map-shell {
  --map-stage-width: 100%;
  --map-stage-height: 640px;
  position: relative;
  overflow: auto;
  max-width: 100%;
  max-height: 70vh;
  min-height: 420px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0.01)),
    #100b16;
  cursor: grab;
}

.world-map-shell.is-dragging {
  cursor: grabbing;
}

.world-map-stage {
  position: relative;
  width: var(--map-stage-width);
  height: var(--map-stage-height);
}

.world-map-image {
  display: block;
  max-width: none;
}

.world-map-image.interactive {
  display: block;
  width: 100%;
  height: 100%;
  user-select: none;
  -webkit-user-drag: none;
  image-rendering: pixelated;
}

.world-map-selection,
.world-map-hover {
  position: absolute;
  pointer-events: none;
  box-sizing: border-box;
}

.world-map-selection {
  border: 2px solid var(--gold);
  box-shadow:
    inset 0 0 0 1px rgba(14, 10, 17, 0.85),
    0 0 0 1px rgba(255, 209, 102, 0.3);
  background: rgba(255, 209, 102, 0.12);
}

.world-map-hover {
  border: 1px solid rgba(255,255,255,0.55);
  background: rgba(255,255,255,0.05);
  display: grid;
  place-items: center;
  font-size: 0.64rem;
  color: var(--text);
  text-shadow: 0 1px 2px rgba(0,0,0,0.9);
}

.map-mini-stats .stat-card.compact {
  padding: 0.8rem;
}

.stat-value-sm {
  font-size: 1rem;
  line-height: 1.25;
  word-break: break-word;
}

.map-detail-list .list-row {
  align-items: center;
}

.legend-selected {
  background: rgba(255, 209, 102, 0.7);
}

@media (max-width: 1100px) {
  .stats-grid.five-up,
  .form-grid.five-up {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .map-workspace-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .card-grid,
  .card-grid.two-up,
  .stats-grid,
  .two-column-grid,
  .form-grid,
  .confirmation-grid {
    grid-template-columns: 1fr;
  }

  .split,
  .story-card-top,
  .collapsible-header {
    align-items: flex-start;
  }

  .story-card-actions {
    justify-content: flex-start;
  }

  .region-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .world-map-shell {
    max-height: 60vh;
    min-height: 340px;
  }
}

@media (max-width: 600px) {
  .region-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .wrap {
    width: min(100%, calc(100% - 1rem));
  }

  .panel,
  .hero-card {
    padding: 1rem;
  }
}

.button-row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: center;
}

.top-gap-sm { margin-top: 0.75rem; }
.check-stack {
  display: grid;
  gap: 0.45rem;
  align-content: end;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--text);
}

.checkbox-row input {
  width: auto;
  margin: 0;
}

.checkbox-row span {
  margin: 0;
  color: var(--text);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.04);
  font-size: 0.85rem;
}

.live-logger-shell {
  display: grid;
  gap: 1.1rem;
}

.live-logger-header,
.live-confirm-panel {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.live-logger-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.live-seat-list {
  width: min(620px, 100%);
  margin: 0 auto;
  display: grid;
  gap: 0.85rem;
}

.live-seat-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.85rem;
  align-items: center;
  min-height: 76px;
  padding: 1rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.03);
}

.live-seat-row.is-ready {
  border-color: rgba(116, 217, 159, 0.55);
}

.live-seat-row.is-winner {
  border-color: rgba(255, 209, 102, 0.75);
}

.live-seat-row.is-empty {
  opacity: 0.72;
}

.live-seat-status strong {
  display: block;
  font-size: 1.05rem;
  line-height: 1.3;
}

.live-seat-status p {
  margin: 0.2rem 0 0;
}

.live-seat-form {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.75rem;
  align-items: end;
  padding-top: 0.2rem;
}

.live-seat-form label {
  min-width: 0;
}

.live-winner-check {
  min-height: 46px;
  padding: 0.7rem 0.85rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.03);
  white-space: nowrap;
}

.live-save-hint {
  grid-column: 1 / -1;
  margin: 0;
  font-size: 0.9rem;
}

.live-finalize-form {
  margin: 0;
}

.live-finalize-form button {
  width: auto;
  min-width: 180px;
}

.live-finalize-form button:disabled {
  cursor: not-allowed;
  filter: grayscale(0.65);
  opacity: 0.58;
}

.memory-ledger-image {
  max-width: 100%;
  border-radius: 8px;
  border: 1px solid var(--line);
}

.ai-output {
  white-space: pre-wrap;
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1.5;
}

.field-help {
  display: block;
  margin-top: 0.35rem;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.4;
}

.field-help code {
  color: var(--gold);
}

.inline-check-stack {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  align-items: center;
}

.compact-top-gap {
  margin-bottom: 0.25rem;
}

.preview-card-shell {
  display: grid;
  gap: 1rem;
}

.preview-card-head,
.preview-output-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
}

.preview-card-head h2 {
  margin-bottom: 0.25rem;
}

.preview-actions-inline {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.preview-actions-inline button,
.preview-actions-inline .secondary-button {
  width: auto;
}

.align-start {
  align-items: flex-start;
}

.inline-form {
  display: inline-flex;
  gap: 0.75rem;
  align-items: center;
  margin: 0;
}

.inline-form button {
  width: auto;
}

.button-stack {
  display: grid;
  gap: 0.75rem;
}

.fixed-action-stack {
  min-width: 240px;
}

.stat-value-sm {
  font-size: 1.15rem;
}

.world-atlas-layout {
  align-items: start;
}

.world-atlas-panel,
.atlas-sidebar {
  overflow: hidden;
}

.atlas-caption {
  margin-bottom: 1rem;
}

.world-atlas-shell {
  margin-top: 0.5rem;
}

.world-atlas-frame {
  position: relative;
  overflow: hidden;
  border-radius: 28px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: radial-gradient(circle at top, rgba(35, 24, 50, 0.95) 0%, rgba(10, 7, 15, 0.98) 72%);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.04), 0 22px 40px rgba(0,0,0,0.28);
}

.world-atlas-image {
  display: block;
  width: 100%;
  height: auto;
  image-rendering: pixelated;
}

.world-atlas-overlay,
.world-atlas-selection {
  position: absolute;
  inset: 0;
}

.world-atlas-overlay {
  pointer-events: none;
}

.world-atlas-selection {
  border: 2px solid rgba(255, 209, 102, 0.95);
  box-shadow: 0 0 0 1px rgba(0,0,0,0.5), 0 0 18px rgba(255, 209, 102, 0.35);
  border-radius: 3px;
  pointer-events: none;
}

.atlas-mini-stats {
  margin-top: 1rem;
}

.atlas-detail-list {
  margin-top: 1rem;
}

.atlas-legend {
  display: grid;
  gap: 0.7rem;
  margin-top: 1.2rem;
}

.atlas-legend-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  color: var(--muted);
}

.atlas-legend-swatch {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  display: inline-block;
}

.atlas-legend-owned {
  background: rgba(95, 156, 100, 0.75);
}

.atlas-legend-capital {
  background: linear-gradient(135deg, rgba(255,255,255,0.92), rgba(255,209,102,0.92));
}

.atlas-legend-self {
  background: rgba(121, 186, 116, 0.9);
}

@media (max-width: 840px) {
  .world-atlas-layout {
    grid-template-columns: 1fr;
  }
}

.kingdom-local-building-overlay { position:absolute; inset:0; width:100%; height:100%; image-rendering:pixelated; object-fit:fill; z-index:2; pointer-events:none; }

.world-globe-stage {
  display: grid;
}

.globe-panel-wide {
  width: 100%;
}

.globe-panel-header {
  gap: 1rem;
}

.globe-panel-header-wide {
  align-items: start;
}

.globe-top-pills {
  justify-content: flex-end;
}

.world-globe-shell {
  margin-top: 0.75rem;
}

.world-globe-shell-wide {
  width: 100%;
}

.world-globe-frame {
  position: relative;
  min-height: 420px;
  border-radius: 32px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background:
    radial-gradient(circle at 30% 25%, rgba(255,255,255,0.1) 0%, rgba(255,255,255,0.02) 12%, rgba(8,6,14,0) 20%),
    radial-gradient(circle at 50% 50%, rgba(33, 24, 48, 0.98) 0%, rgba(11, 8, 18, 1) 72%);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.04), 0 24px 48px rgba(0,0,0,0.34);
  overflow: hidden;
}

.world-globe-frame-wide {
  min-height: 640px;
}

.world-globe-frame::before,
.world-globe-frame::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.world-globe-frame::before {
  background-image:
    radial-gradient(circle at 14% 24%, rgba(255,255,255,0.25) 0 1px, transparent 1px),
    radial-gradient(circle at 72% 18%, rgba(255,255,255,0.18) 0 1px, transparent 1px),
    radial-gradient(circle at 84% 60%, rgba(255,255,255,0.22) 0 1px, transparent 1px),
    radial-gradient(circle at 28% 72%, rgba(255,255,255,0.16) 0 1px, transparent 1px),
    radial-gradient(circle at 60% 78%, rgba(255,255,255,0.2) 0 1px, transparent 1px),
    radial-gradient(circle at 18% 52%, rgba(255,255,255,0.14) 0 1px, transparent 1px),
    radial-gradient(circle at 90% 34%, rgba(255,255,255,0.16) 0 1px, transparent 1px);
  background-size: 100% 100%;
  opacity: 0.75;
}

.world-globe-frame::after {
  background: radial-gradient(circle at 50% 100%, rgba(255,255,255,0.05), transparent 48%);
}

.world-globe-canvas {
  display: block;
  width: min(100%, 760px);
  aspect-ratio: 1 / 1;
  margin: 0 auto;
  touch-action: none;
  cursor: grab;
}

.world-globe-canvas-wide {
  width: min(100%, 1040px);
}

.world-globe-canvas:active {
  cursor: grabbing;
}

.world-globe-hud {
  position: absolute;
  left: 1rem;
  bottom: 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  pointer-events: none;
}
.world-globe-hud-controls {
  right: 1rem;
  left: auto;
  bottom: 1rem;
  pointer-events: auto;
}

.world-globe-hud .ghost-btn {
  pointer-events: auto;
  min-width: auto;
  padding: 0.5rem 0.75rem;
}


.world-globe-hud-minimal {
  opacity: 0.92;
}

.globe-caption-wide {
  max-width: 960px;
}
@media (max-width: 840px) {
  .world-atlas-layout {
    grid-template-columns: 1fr;
  }
}

.kingdom-local-building-overlay { position:absolute; inset:0; width:100%; height:100%; image-rendering:pixelated; object-fit:fill; z-index:2; pointer-events:none; }

.globe-layout {
  align-items: start;
}

.globe-panel-header {
  gap: 1rem;
}

.world-globe-shell {
  margin-top: 0.75rem;
}

.world-globe-frame {
  position: relative;
  min-height: 420px;
  border-radius: 32px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background:
    radial-gradient(circle at 30% 25%, rgba(255,255,255,0.1) 0%, rgba(255,255,255,0.02) 12%, rgba(8,6,14,0) 20%),
    radial-gradient(circle at 50% 50%, rgba(33, 24, 48, 0.98) 0%, rgba(11, 8, 18, 1) 72%);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.04), 0 24px 48px rgba(0,0,0,0.34);
  overflow: hidden;
}

.world-globe-frame::before,
.world-globe-frame::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.world-globe-frame::before {
  background-image:
    radial-gradient(circle at 14% 24%, rgba(255,255,255,0.25) 0 1px, transparent 1px),
    radial-gradient(circle at 72% 18%, rgba(255,255,255,0.18) 0 1px, transparent 1px),
    radial-gradient(circle at 84% 60%, rgba(255,255,255,0.22) 0 1px, transparent 1px),
    radial-gradient(circle at 28% 72%, rgba(255,255,255,0.16) 0 1px, transparent 1px),
    radial-gradient(circle at 60% 78%, rgba(255,255,255,0.2) 0 1px, transparent 1px),
    radial-gradient(circle at 18% 52%, rgba(255,255,255,0.14) 0 1px, transparent 1px),
    radial-gradient(circle at 90% 34%, rgba(255,255,255,0.16) 0 1px, transparent 1px);
  background-size: 100% 100%;
  opacity: 0.75;
}

.world-globe-frame::after {
  background: radial-gradient(circle at 50% 100%, rgba(255,255,255,0.05), transparent 48%);
}

.world-globe-canvas {
  display: block;
  width: min(100%, 760px);
  aspect-ratio: 1 / 1;
  margin: 0 auto;
  touch-action: none;
  cursor: grab;
}

.world-globe-canvas:active {
  cursor: grabbing;
}

.world-globe-hud {
  position: absolute;
  left: 1rem;
  bottom: 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  pointer-events: none;
}
.world-globe-hud-controls {
  right: 1rem;
  left: auto;
  bottom: 1rem;
  pointer-events: auto;
}

.world-globe-hud .ghost-btn {
  pointer-events: auto;
  min-width: auto;
  padding: 0.5rem 0.75rem;
}


.globe-sidebar {
  display: grid;
  gap: 1rem;
}

.globe-mini-stats {
  margin-top: 0.25rem;
}

.atlas-legend-sigil {
  background: linear-gradient(135deg, rgba(255, 77, 184, 0.46), rgba(255, 209, 102, 0.46));
}

.atlas-legend-building {
  background: linear-gradient(135deg, rgba(255,255,255,0.88), rgba(116, 217, 159, 0.85));
}

.globe-kingdom-list {
  display: grid;
  gap: 0.6rem;
}

.globe-kingdom-row {
  align-items: center;
  gap: 0.75rem;
}

.globe-kingdom-row.is-self {
  background: rgba(255, 209, 102, 0.06);
  border-radius: 14px;
}

.globe-kingdom-color {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--kingdom-color, rgba(255,255,255,0.7));
  box-shadow: 0 0 0 2px rgba(255,255,255,0.08);
  flex: 0 0 auto;
}

.globe-kingdom-copy {
  display: grid;
  gap: 0.15rem;
}

@media (max-width: 840px) {
  .world-globe-frame {
    min-height: 340px;
  }

  .world-globe-canvas {
    width: 100%;
  }
}

.world-globe-stage-leaderboard {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 1.25rem;
  align-items: start;
}

.globe-panel-main {
  min-width: 0;
}

.globe-kingdom-panel {
  display: grid;
  gap: 1rem;
  align-self: stretch;
}

.globe-kingdom-panel-header {
  align-items: start;
  gap: 1rem;
}

.globe-kingdom-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.globe-kingdom-list {
  display: grid;
  gap: 0.75rem;
  max-height: 720px;
  overflow: auto;
  padding-right: 0.25rem;
}

.globe-kingdom-item {
  display: grid;
  grid-template-columns: auto 52px minmax(0, 1fr);
  gap: 0.85rem;
  align-items: center;
  padding: 0.9rem 1rem;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.015));
}

.globe-kingdom-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
}

.globe-kingdom-sigil {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  overflow: hidden;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  display: grid;
  place-items: center;
}

.globe-kingdom-sigil img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.globe-kingdom-swatch {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.2);
  display: inline-block;
  margin-right: 0.5rem;
  vertical-align: middle;
}

.globe-kingdom-name {
  font-weight: 700;
}

.globe-kingdom-meta {
  color: var(--muted);
  font-size: 0.94rem;
}

.globe-kingdom-tag {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.12);
  font-size: 0.78rem;
  color: var(--gold);
  margin-left: 0.5rem;
}

@media (max-width: 1180px) {
  .world-globe-stage-leaderboard {
    grid-template-columns: 1fr;
  }

  .globe-kingdom-list {
    max-height: none;
  }
}


/* Wave 20.5 — standings + globe integration */
.standings-hero {
  margin-bottom: 1.25rem;
}

.standings-globe-stage {
  margin-bottom: 1.25rem;
}

.standings-globe-header {
  align-items: start;
}

.standings-globe-caption {
  max-width: 920px;
}

.standings-globe-sidebar {
  min-width: 0;
}

.standings-panel {
  display: grid;
  gap: 1rem;
}

.standings-panel-header {
  align-items: start;
  gap: 1rem;
}

.standings-panel-copy {
  margin-top: -0.35rem;
}

.standings-list {
  display: grid;
  gap: 0.85rem;
}

.standings-card {
  display: grid;
  grid-template-columns: 72px 72px minmax(0, 1fr) 130px 130px;
  gap: 0.9rem;
  align-items: center;
  padding: 1rem 1.1rem;
  border-radius: 22px;
  border: 1px solid rgba(255,255,255,0.1);
  background: linear-gradient(180deg, rgba(255,255,255,0.045), rgba(255,255,255,0.018));
}

.standings-card.is-self {
  border-color: rgba(255, 209, 102, 0.3);
  box-shadow: inset 0 0 0 1px rgba(255, 209, 102, 0.08);
}

.standings-rank {
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--gold);
}

.standings-sigil-wrap {
  display: grid;
  place-items: center;
}

.standings-sigil {
  width: 62px;
  height: 62px;
  border-radius: 18px;
  overflow: hidden;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255,255,255,0.12);
  background: radial-gradient(circle at 30% 25%, rgba(255,255,255,0.12), rgba(255,255,255,0.03) 45%, rgba(16,12,24,0.96));
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.04), 0 10px 24px rgba(0,0,0,0.2);
}

.standings-sigil img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.standings-sigil span {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
}

.standings-identity {
  min-width: 0;
  display: grid;
  gap: 0.25rem;
}

.standings-name-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.standings-name-row h3 {
  margin: 0;
}

.standings-stat-block {
  display: grid;
  gap: 0.18rem;
  justify-items: start;
}

.standings-stat-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.standings-stat-block strong {
  font-size: 1.2rem;
}

@media (max-width: 960px) {
  .standings-card {
    grid-template-columns: 64px 64px minmax(0, 1fr);
  }

  .standings-stat-block {
    grid-column: span 1;
  }
}

@media (max-width: 720px) {
  .standings-card {
    grid-template-columns: 56px 56px minmax(0, 1fr);
    padding: 0.9rem;
  }

  .standings-rank {
    font-size: 1.2rem;
  }

  .standings-sigil {
    width: 52px;
    height: 52px;
    border-radius: 14px;
  }

  .standings-stat-block {
    grid-column: 2 / span 2;
    justify-items: start;
  }
}


/* === Patch 3 + 4 + 5 compatibility additions === */

/* Loading overlay */
.loading-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(8, 4, 14, 0.62);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
  z-index: 9999;
}

.loading-overlay.is-active {
  opacity: 1;
  pointer-events: auto;
}

.loading-overlay-card {
  min-width: 180px;
  max-width: min(92vw, 320px);
  padding: 1rem 1.1rem;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(25, 19, 32, 0.95);
  box-shadow: 0 20px 50px rgba(0,0,0,0.35);
  text-align: center;
}

.loading-spinner {
  width: 42px;
  height: 42px;
  margin: 0 auto 0.75rem;
  border-radius: 999px;
  border: 4px solid rgba(255,255,255,0.14);
  border-top-color: var(--pink);
  animation: rml-spin 0.9s linear infinite;
}

.loading-overlay-title {
  font-weight: 700;
  margin-bottom: 0.2rem;
}

.loading-overlay-copy {
  color: var(--muted);
  font-size: 0.95rem;
}

body.is-loading {
  overflow: hidden;
}

@keyframes rml-spin {
  to { transform: rotate(360deg); }
}

/* Mobile responsive tightening */
.page-shell,
.wrap {
  max-width: 100%;
}

img,
video,
canvas {
  max-width: 100%;
}

button,
input,
select,
textarea {
  max-width: 100%;
}

.button-row,
.button-stack,
.pill-row {
  flex-wrap: wrap;
}

@media (max-width: 900px) {
  .topbar {
    gap: 0.75rem;
  }

  .nav {
    gap: 0.55rem;
    flex-wrap: wrap;
  }

  .account-actions {
    gap: 0.5rem;
    flex-wrap: wrap;
  }
}

@media (max-width: 720px) {
  .page-shell {
    padding-inline: 0.15rem;
  }

  .panel,
  .hero-card,
  .subpanel,
  .stat-card,
  .standings-card,
  .general-card,
  .general-stat-panel {
    padding: 0.9rem;
  }

  .split,
  .button-row,
  .button-stack,
  .pill-row,
  .live-logger-header,
  .live-confirm-panel,
  .form-grid,
  .stats-grid,
  .card-grid {
    gap: 0.75rem;
  }

  .live-logger-header,
  .live-confirm-panel {
    flex-direction: column;
  }

  .live-logger-actions {
    justify-content: flex-start;
  }

  .live-seat-form {
    grid-template-columns: 1fr;
  }

  .live-winner-check {
    white-space: normal;
  }

  input,
  select,
  textarea,
  button {
    font-size: 16px;
  }

  .button-row > *,
  .button-stack > *,
  .button-row button,
  .button-row a,
  .button-stack button,
  .button-stack a {
    width: 100%;
  }

  .site-header .wrap {
    padding-inline: 0.75rem;
  }
}

/* Generals card containment */
.generals-card-grid {
  display: grid;
  gap: 1rem;
}

.general-card {
  overflow: hidden;
}

.general-card-summary {
  display: grid;
  grid-template-columns: minmax(0, 140px) minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

.general-art-shell {
  position: relative;
  width: 100%;
  min-width: 0;
  aspect-ratio: 63 / 88;
  border-radius: 18px;
  overflow: hidden;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
}

.general-art,
.general-art-fallback {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

.general-art-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: 700;
  color: var(--text);
  background: linear-gradient(180deg, rgba(255,77,184,0.18), rgba(255,209,102,0.14));
}

.general-mode-chip {
  position: absolute;
  right: 0.5rem;
  bottom: 0.5rem;
  max-width: calc(100% - 1rem);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.general-card-copy {
  min-width: 0;
}

.general-card-copy h4 {
  margin-bottom: 0.35rem;
  overflow-wrap: anywhere;
}

.general-bucket-chips {
  gap: 0.4rem;
}

.general-detail-body {
  min-width: 0;
}

.general-detail-footer {
  gap: 0.75rem;
  align-items: start;
}

.general-detail-footer .general-action-form {
  flex-shrink: 0;
}

.general-search-item img,
.general-variant-option img {
  width: 100%;
  height: auto;
  object-fit: cover;
}

.general-search-item,
.general-variant-option {
  min-width: 0;
}

@media (max-width: 720px) {
  .general-card-summary {
    grid-template-columns: 96px minmax(0, 1fr);
    gap: 0.75rem;
  }

  .general-art-shell {
    border-radius: 14px;
  }

  .general-card-copy h4 {
    font-size: 1rem;
    line-height: 1.2;
  }

  .general-card-copy .muted {
    font-size: 0.92rem;
  }

  .general-detail-footer {
    flex-direction: column;
  }

  .general-detail-footer .general-action-form,
  .general-detail-footer .link-button,
  .general-detail-footer button {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .general-card-summary {
    grid-template-columns: 82px minmax(0, 1fr);
    gap: 0.65rem;
  }

  .general-mode-chip {
    right: 0.35rem;
    bottom: 0.35rem;
    font-size: 0.68rem;
  }
}

/* Wave 20.5R — standings war map + globe controls split */
.standings-war-panel { overflow: hidden; }
.standings-war-header { align-items: flex-start; gap: 1rem; }
.standings-war-caption { max-width: 920px; }
.war-map-toolbar { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; margin: 0.9rem 0; }
.standings-war-map-shell {
  position: relative;
  width: 100%;
  height: min(72vh, 760px);
  min-height: 440px;
  overflow: hidden;
  border-radius: 22px;
  border: 1px solid rgba(255,255,255,0.1);
  background: radial-gradient(circle at center, rgba(255,255,255,0.05), rgba(0,0,0,0.35));
  cursor: grab;
  touch-action: none;
}
.standings-war-map-shell:active { cursor: grabbing; }
.standings-war-map-stage { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; }
.standings-war-map-image { position: absolute; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; user-select: none; }
.standings-war-map-overlays { position: absolute; inset: 0; pointer-events: none; }
.war-map-sigil {
  position: absolute;
  display: grid;
  place-items: center;
  border-radius: 50%;
  overflow: hidden;
  color: #f7f1ff;
  font-weight: 800;
  font-size: 11px;
  background: color-mix(in srgb, var(--kingdom-color, #5b9b65) 62%, rgba(0,0,0,0.25));
  box-shadow: 0 0 0 1px rgba(255,255,255,0.18), 0 0 14px color-mix(in srgb, var(--kingdom-color, #5b9b65) 60%, transparent);
}
.war-map-sigil img { width: 100%; height: 100%; object-fit: cover; }
.war-map-sigil.is-self { opacity: 0.34; filter: saturate(0.92) contrast(0.9); }
.war-map-sigil.is-rival { opacity: 0.82; filter: saturate(1.08) contrast(1.03); }
.globe-sigil-scale-control {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.45rem 0.75rem;
  align-items: center;
  margin: 0.8rem 0 1rem;
  padding: 0.75rem;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.035);
}
.globe-sigil-scale-control label { font-weight: 700; }
.globe-sigil-scale-control input { grid-column: 1 / -1; width: 100%; accent-color: var(--pink); }
@media (max-width: 760px) {
  .standings-war-map-shell { min-height: 360px; height: 66vh; border-radius: 16px; }
  .war-map-toolbar { gap: 0.45rem; }
}
