/* ==========================================================================
   WORLD REMIX (yannis.website) - Production Stylesheet
   Aesthetic Direction: Tactile Cartographic Studio & Atlas Atelier
   ========================================================================== */

:root {
  color-scheme: light;
  /* Light Theme: Vellum & Brass Atlas */
  --bg-primary: #F5F0E6;
  --bg-secondary: #EAE2D1;
  --bg-surface: #FAF7F0;
  --bg-elevated: #FFFFFF;
  --bg-ocean: #D2E3E9;
  --bg-ocean-deep: #BED5DE;
  --graticule-line: rgba(23, 102, 110, 0.16);
  --land-default: #EDE8DC;
  --land-hover: #DFD5C0;
  --land-stroke: #726856;
  --ink-primary: #161411;
  --ink-secondary: #433D33;
  --ink-muted: #665E50;
  --border-ink: #26221C;
  --border-subtle: #C9BFA9;
  /* High-contrast interactive accents (always paired with crisp white #FFFFFF text) */
  --accent-vermilion: #C93B22;
  --accent-teal: #14656D;
  --btn-vermilion-bg: #C93B22;
  --btn-vermilion-hover: #A92E18;
  --btn-teal-bg: #15656D;
  --btn-teal-hover: #0F4E55;
  --accent-ochre: #C88A2B;
  --accent-indigo: #5A4A8C;
  --accent-emerald: #1F7A4C;
  --text-accent-vermilion: #C93B22;
  --text-accent-teal: #15656D;
  --shadow-hard: 3px 3px 0px #26221C;
  --shadow-hard-sm: 2px 2px 0px #26221C;
  --font-serif: 'Fraunces', 'Playfair Display', 'Georgia', Cambria, serif;
  --font-sans: 'Space Grotesk', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
  --header-h: 64px;
}

[data-theme="dark"] {
  color-scheme: dark;
  /* Dark Theme: Nocturnal Observatory */
  --bg-primary: #0B1118;
  --bg-secondary: #131D28;
  --bg-surface: #172331;
  --bg-elevated: #1E2E40;
  --bg-ocean: #080E14;
  --bg-ocean-deep: #05090E;
  --graticule-line: rgba(56, 228, 206, 0.13);
  --land-default: #1B2938;
  --land-hover: #283C52;
  --land-stroke: #46607A;
  --ink-primary: #F7F5F0;
  --ink-secondary: #C6D2DF;
  --ink-muted: #93A5B8;
  --border-ink: #4F6882;
  --border-subtle: #2C3F54;
  /* Saturated dark-mode button fills that preserve high-contrast #FFFFFF text */
  --accent-vermilion: #FF8269;
  --accent-teal: #3CEAD2;
  --btn-vermilion-bg: #D6452B;
  --btn-vermilion-hover: #E8563C;
  --btn-teal-bg: #157982;
  --btn-teal-hover: #1C929C;
  --accent-ochre: #F6B93B;
  --accent-indigo: #A57CFF;
  --accent-emerald: #34D399;
  /* Bright text accents for labels on dark surfaces */
  --text-accent-vermilion: #FF8269;
  --text-accent-teal: #3CEAD2;
  --shadow-hard: 3px 3px 0px #04070A;
  --shadow-hard-sm: 2px 2px 0px #04070A;
}

/* Base Reset & Explicit Inheritance for Form / Button Elements */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
}

body {
  background-color: var(--bg-primary);
  color: var(--ink-primary);
  font-family: var(--font-sans);
  line-height: 1.55;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  transition: background-color 0.18s ease, color 0.18s ease;
}

/* Guarantee buttons, inputs, selects, and options never fall back to black UA text in dark mode */
button,
input,
select,
textarea,
option {
  font-family: inherit;
  font-size: inherit;
  color: var(--ink-primary);
  background-color: transparent;
}

input::placeholder,
textarea::placeholder {
  color: var(--ink-muted);
  opacity: 1;
}

select option {
  background-color: var(--bg-elevated);
  color: var(--ink-primary);
}

code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  background-color: var(--bg-secondary);
  color: var(--ink-primary);
  padding: 2px 6px;
  border: 1px solid var(--border-subtle);
}

/* Skip Link for Keyboard Accessibility */
.skip-link {
  position: absolute;
  top: -100px;
  left: 16px;
  background: var(--accent-vermilion);
  color: #FFFFFF !important;
  padding: 10px 18px;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.875rem;
  z-index: 9999;
  text-decoration: none;
  border: 2px solid var(--border-ink);
}
.skip-link:focus {
  top: 12px;
}

/* Typography */
h1, h2, h3, h4, .serif-heading {
  font-family: var(--font-serif);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.02em;
  color: var(--ink-primary);
}

.mono-label {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-secondary);
}

.text-vermilion {
  color: var(--text-accent-vermilion) !important;
}
.text-teal {
  color: var(--text-accent-teal) !important;
}

a {
  color: var(--text-accent-vermilion);
  text-decoration: underline;
  text-underline-offset: 3px;
}
a:hover {
  color: var(--text-accent-teal);
}

/* Custom Vector Icon Utilities & Flag Badges */
.icon-svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
  vertical-align: middle;
}
.btn-flag-pair {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.btn-flag-img {
  width: 18px;
  height: 13px;
  object-fit: contain;
  border: 1px solid var(--border-subtle);
  display: inline-block;
  background: #fff;
}

/* ==========================================================================
   ARCHITECTURAL TOP NAVIGATION BAR
   ========================================================================== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 200;
  background: var(--bg-surface);
  border-bottom: 2px solid var(--border-ink);
  min-height: var(--header-h);
}

.header-inner {
  max-width: 1440px;
  margin: 0 auto;
  padding: 6px 16px;
  min-height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.brand-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--ink-primary) !important;
  background: transparent;
  border: none;
  cursor: pointer;
  flex-shrink: 1;
  min-width: 0;
}
.brand-link:hover,
.brand-link:focus,
.brand-link:active {
  color: var(--ink-primary) !important;
}
.brand-link svg {
  height: 40px;
  width: auto;
  max-width: 235px;
  display: block;
}
.brand-link .logo-title-text {
  fill: var(--ink-primary) !important;
}
.brand-link .logo-sub-text {
  fill: var(--text-accent-vermilion) !important;
}

.main-nav {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Navigation Links & Canvas Tab Buttons: High-contrast in all states */
.nav-link,
button.nav-link,
a.nav-link {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-primary) !important;
  background-color: transparent;
  text-decoration: none;
  padding: 8px 12px;
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: background-color 0.14s ease, color 0.14s ease, border-color 0.14s ease;
  white-space: nowrap;
}

.nav-link:hover,
button.nav-link:hover,
a.nav-link:hover,
.nav-link:focus-visible {
  background-color: var(--bg-secondary) !important;
  border-color: var(--border-ink) !important;
  color: var(--ink-primary) !important;
  outline: none;
}

.nav-link.active,
button.nav-link.active,
a.nav-link.active,
.nav-link[aria-current="page"],
.nav-link:active {
  background-color: var(--btn-vermilion-bg) !important;
  border-color: var(--border-ink) !important;
  color: #FFFFFF !important;
  box-shadow: var(--shadow-hard-sm);
}

.header-utilities {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

/* ==========================================================================
   TACTILE BUTTON SYSTEM (High-Contrast in Default, Hover, Focus, Active, Pressed, Disabled)
   ========================================================================== */
.btn,
a.btn,
button.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-family: var(--font-mono);
  font-size: 0.79rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 9px 13px;
  min-height: 40px;
  background-color: var(--bg-elevated);
  color: var(--ink-primary) !important;
  border: 1.5px solid var(--border-ink);
  box-shadow: var(--shadow-hard-sm);
  cursor: pointer;
  text-decoration: none !important;
  transition: transform 0.1s ease, box-shadow 0.1s ease, background-color 0.14s ease, color 0.14s ease;
  user-select: none;
  text-align: center;
}

.btn span,
.btn svg {
  color: inherit !important;
}

.btn:hover,
a.btn:hover,
button.btn:hover {
  background-color: var(--bg-secondary);
  color: var(--ink-primary) !important;
  transform: translate(-1px, -1px);
  box-shadow: var(--shadow-hard);
}

.btn:active,
a.btn:active,
button.btn:active,
.btn.active,
.btn[aria-pressed="true"] {
  background-color: var(--btn-teal-bg) !important;
  color: #FFFFFF !important;
  border-color: var(--border-ink) !important;
  transform: translate(1px, 1px);
  box-shadow: none;
}

.btn:focus-visible {
  outline: 2px solid var(--text-accent-vermilion);
  outline-offset: 2px;
}

/* Disabled Button State: Readable muted text instead of invisible low opacity */
.btn[disabled],
.btn:disabled {
  background-color: var(--bg-secondary) !important;
  color: var(--ink-muted) !important;
  border-color: var(--border-subtle) !important;
  box-shadow: none !important;
  cursor: not-allowed;
  pointer-events: none;
  opacity: 0.85;
}

/* Primary Action Button (Vermilion with Crisp White Text in ALL states & themes) */
.btn-primary,
a.btn-primary,
button.btn-primary {
  background-color: var(--btn-vermilion-bg) !important;
  color: #FFFFFF !important;
  border-color: var(--border-ink);
}
.btn-primary:hover,
a.btn-primary:hover,
button.btn-primary:hover,
.btn-primary:focus-visible {
  background-color: var(--btn-vermilion-hover) !important;
  color: #FFFFFF !important;
}
.btn-primary:active,
a.btn-primary:active,
button.btn-primary:active,
.btn-primary.active {
  background-color: #9E2A15 !important;
  color: #FFFFFF !important;
  transform: translate(1px, 1px);
  box-shadow: none;
}

/* Secondary Action Button (Teal with Crisp White Text in ALL states & themes) */
.btn-teal,
a.btn-teal,
button.btn-teal {
  background-color: var(--btn-teal-bg) !important;
  color: #FFFFFF !important;
  border-color: var(--border-ink);
}
.btn-teal:hover,
a.btn-teal:hover,
button.btn-teal:hover,
.btn-teal:focus-visible {
  background-color: var(--btn-teal-hover) !important;
  color: #FFFFFF !important;
}
.btn-teal:active,
a.btn-teal:active,
button.btn-teal:active,
.btn-teal.active {
  background-color: #0D4B52 !important;
  color: #FFFFFF !important;
  transform: translate(1px, 1px);
  box-shadow: none;
}

.btn-icon {
  padding: 8px 10px;
  min-width: 40px;
}

.mobile-menu-btn,
button.mobile-menu-btn {
  display: none !important;
}

/* ==========================================================================
   HERO & DAILY CHALLENGE LAUNCHPAD
   ========================================================================== */
.hero-atlas {
  max-width: 1440px;
  margin: 0 auto;
  padding: 16px 16px 6px;
}
.hero-strip {
  background: var(--bg-surface);
  border: 2px solid var(--border-ink);
  box-shadow: var(--shadow-hard);
  padding: 20px 22px;
  display: grid;
  grid-template-columns: 1.35fr 0.65fr;
  gap: 20px;
  align-items: center;
}
.hero-title {
  font-size: clamp(1.75rem, 3.4vw, 2.85rem);
  margin: 6px 0 10px;
  color: var(--ink-primary);
}
.hero-tagline {
  font-size: 1.02rem;
  color: var(--ink-secondary);
  max-width: 64ch;
  margin-bottom: 14px;
}
.hero-cta-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}
.preset-recipes-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}
.preset-recipes-label {
  width: 100%;
  margin-bottom: 2px;
}

/* ==========================================================================
   GAME WORKSPACE LAYOUT (Country Fusion Studio)
   ========================================================================== */
.studio-shell {
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
  padding: 12px 16px;
  display: grid;
  grid-template-columns: minmax(0, 1.42fr) minmax(360px, 0.98fr);
  gap: 16px;
  align-items: start;
}

@media (min-width: 1081px) {
  .map-deck {
    position: sticky;
    top: calc(var(--header-h) + 12px);
  }
}

/* Left Column: Interactive Cartographic Viewport */
.map-deck {
  background: var(--bg-surface);
  border: 2px solid var(--border-ink);
  box-shadow: var(--shadow-hard);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.map-toolbar {
  padding: 12px;
  background: var(--bg-secondary);
  border-bottom: 1.5px solid var(--border-ink);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.search-box-wrap {
  position: relative;
  width: 100%;
}

.map-toolbar-actions {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  width: 100%;
}
.map-toolbar-actions .btn {
  width: 100%;
  padding: 8px 6px;
  font-size: 0.75rem;
}

.country-search-input {
  width: 100%;
  min-height: 42px;
  padding: 8px 14px;
  font-family: var(--font-sans);
  font-size: 0.92rem;
  background-color: var(--bg-elevated);
  color: var(--ink-primary);
  border: 1.5px solid var(--border-ink);
}
.country-search-input:focus {
  outline: 2px solid var(--text-accent-vermilion);
  outline-offset: -1px;
}

.search-results-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 280px;
  overflow-y: auto;
  background-color: var(--bg-elevated);
  color: var(--ink-primary);
  border: 2px solid var(--border-ink);
  box-shadow: var(--shadow-hard);
  z-index: 150;
  list-style: none;
}
.search-results-dropdown[hidden] {
  display: none !important;
}

.search-result-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--ink-primary);
  background-color: var(--bg-elevated);
}
.search-result-item:hover,
.search-result-item:focus,
.search-result-item.highlighted {
  background-color: var(--accent-teal);
  color: #FFFFFF !important;
  outline: none;
}
.search-result-item:hover .mono-label,
.search-result-item.highlighted .mono-label {
  color: #FFFFFF !important;
}
.search-result-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.search-result-flag {
  width: 24px;
  height: 18px;
  object-fit: contain;
  border: 1px solid var(--border-subtle);
  background: #fff;
  flex-shrink: 0;
}

/* Interactive Map Canvas Container */
.map-viewport {
  position: relative;
  width: 100%;
  aspect-ratio: 2 / 1;
  min-height: 320px;
  max-height: 490px;
  background: radial-gradient(circle at 50% 45%, var(--bg-ocean) 0%, var(--bg-ocean-deep) 100%);
  overflow: hidden;
  touch-action: none;
  user-select: none;
}

.world-map-svg {
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
}
.world-map-svg:active {
  cursor: grabbing;
}

.graticule-path {
  fill: none;
  stroke: var(--graticule-line);
  stroke-width: 0.6;
  vector-effect: non-scaling-stroke;
}

.country-path {
  fill: var(--land-default);
  stroke: var(--land-stroke);
  stroke-width: 0.65;
  vector-effect: non-scaling-stroke;
  cursor: pointer;
  transition: fill 0.14s ease;
}
.country-path:hover,
.country-path:focus {
  fill: var(--land-hover);
  stroke: var(--ink-primary);
  stroke-width: 1.3;
  outline: none;
}

/* Selected Slots on Map */
.country-path.selected-slot-0 {
  fill: #E04F35 !important;
  stroke: #FFFFFF !important;
  stroke-width: 1.5;
}
.country-path.selected-slot-1 {
  fill: #24B8A8 !important;
  stroke: #FFFFFF !important;
  stroke-width: 1.5;
}
.country-path.selected-slot-2 {
  fill: var(--accent-ochre) !important;
  stroke: #FFFFFF !important;
  stroke-width: 1.5;
}
.country-path.selected-slot-n {
  fill: var(--accent-indigo) !important;
  stroke: #FFFFFF !important;
  stroke-width: 1.5;
}

/* Microstate / Island Nation Selectable Beacons */
.microstate-marker {
  fill: var(--bg-surface);
  stroke: var(--border-ink);
  stroke-width: 1.1;
  vector-effect: non-scaling-stroke;
  cursor: pointer;
}
.microstate-marker:hover {
  fill: var(--accent-ochre);
  r: 4.5px;
}
.microstate-marker.selected-slot-0 { fill: #E04F35; }
.microstate-marker.selected-slot-1 { fill: #24B8A8; }
.microstate-marker.selected-slot-2 { fill: var(--accent-ochre); }
.microstate-marker.selected-slot-n { fill: var(--accent-indigo); }

.capital-city-dot {
  fill: var(--accent-ochre);
  stroke: var(--ink-primary);
  stroke-width: 0.9;
  vector-effect: non-scaling-stroke;
  pointer-events: none;
}

.fusion-geodesic-arc {
  fill: none;
  stroke: #FF785A;
  stroke-width: 2.2;
  stroke-dasharray: 6 4;
  vector-effect: non-scaling-stroke;
  pointer-events: none;
}

/* Floating Map Controls Overlay */
.map-hud-controls {
  position: absolute;
  bottom: 12px;
  right: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 25;
}

.map-coords-readout {
  position: absolute;
  bottom: 12px;
  left: 12px;
  background-color: var(--bg-surface);
  color: var(--ink-primary);
  border: 1.5px solid var(--border-ink);
  padding: 5px 10px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  pointer-events: none;
  z-index: 25;
}

/* Floating Hover Tooltip */
.map-tooltip {
  position: absolute;
  pointer-events: none;
  background-color: var(--bg-elevated);
  color: var(--ink-primary);
  border: 2px solid var(--border-ink);
  box-shadow: var(--shadow-hard-sm);
  padding: 8px 10px;
  z-index: 90;
  min-width: 170px;
  max-width: 240px;
  font-size: 0.8rem;
}
.map-tooltip[hidden] {
  display: none !important;
}
.tooltip-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  font-weight: 700;
  color: var(--ink-primary);
}
.tooltip-flag {
  width: 26px;
  height: 19px;
  object-fit: contain;
  border: 1px solid var(--border-subtle);
  background: #fff;
}
.tooltip-meta {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--ink-secondary);
}

/* Selected Constituent Strip below Map */
.selection-tray {
  padding: 12px;
  background: var(--bg-surface);
  border-top: 1.5px solid var(--border-ink);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.selected-chips-list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.country-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 10px;
  background-color: var(--bg-elevated);
  color: var(--ink-primary);
  border: 1.5px solid var(--border-ink);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 700;
}
.country-chip img {
  width: 22px;
  height: 16px;
  object-fit: contain;
  border: 1px solid var(--border-subtle);
  background: #fff;
}
.chip-remove-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid transparent;
  color: var(--ink-secondary) !important;
  cursor: pointer;
  padding: 2px;
  border-radius: 2px;
}
.chip-remove-btn:hover,
.chip-remove-btn:focus,
.chip-remove-btn:active {
  background-color: var(--accent-vermilion);
  color: #FFFFFF !important;
}

/* ==========================================================================
   RIGHT COLUMN: FUSION CHARTER & SYNTHESIS PANEL
   ========================================================================== */
.fusion-charter {
  background: var(--bg-surface);
  border: 2px solid var(--border-ink);
  box-shadow: var(--shadow-hard);
  display: flex;
  flex-direction: column;
}

.charter-header {
  padding: 12px 16px;
  background: var(--bg-secondary);
  border-bottom: 2px solid var(--border-ink);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.charter-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.fused-identity-banner {
  border: 1.5px solid var(--border-ink);
  background: var(--bg-elevated);
  padding: 14px;
  position: relative;
}

.fused-nation-name {
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  color: var(--ink-primary);
  word-break: break-word;
  margin: 4px 0;
}

.fused-subtitle {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-accent-teal);
  font-weight: 700;
}

.visual-synthesis-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.synthesis-frame {
  border: 1.5px solid var(--border-ink);
  background: var(--bg-elevated);
  display: flex;
  flex-direction: column;
}

.frame-top-bar {
  padding: 7px 10px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-ink);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.frame-stage {
  padding: 12px;
  min-height: 150px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: repeating-linear-gradient(
    45deg,
    transparent,
    transparent 8px,
    rgba(120, 112, 98, 0.06) 8px,
    rgba(120, 112, 98, 0.06) 16px
  );
}

.generated-flag-wrap svg,
.silhouette-stage-wrap svg {
  width: 100%;
  max-width: 210px;
  height: auto;
  display: block;
  border: 1.5px solid var(--border-ink);
  box-shadow: var(--shadow-hard-sm);
}

.silhouette-stage-wrap svg {
  background: var(--bg-ocean);
}

.frame-footnote {
  padding: 6px 10px;
  border-top: 1px solid var(--border-subtle);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--ink-secondary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

/* Architectural Statistics Ledger Table */
.stats-ledger {
  width: 100%;
  border-collapse: collapse;
  border: 1.5px solid var(--border-ink);
  background: var(--bg-elevated);
  font-size: 0.85rem;
}
.stats-ledger th,
.stats-ledger td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border-subtle);
  text-align: left;
  vertical-align: top;
  word-break: break-word;
}
.stats-ledger th {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--ink-primary);
  background: var(--bg-secondary);
  width: 38%;
}
.stats-ledger td {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--ink-primary);
}
.stat-source-note {
  display: block;
  font-size: 0.7rem;
  font-weight: 400;
  color: var(--ink-secondary);
  margin-top: 2px;
}

/* Constituent Breakdown Cards */
.constituents-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.constituent-row {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background-color: var(--bg-elevated);
  color: var(--ink-primary);
  border: 1.5px solid var(--border-ink);
}
.constituent-row strong {
  color: var(--ink-primary);
}
.constituent-row img {
  width: 36px;
  height: 27px;
  object-fit: contain;
  border: 1px solid var(--border-subtle);
  background: #fff;
}

/* Action Bar (Share, Export PNG, Export SVG, Save) */
.charter-actions-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
.charter-actions-grid .btn {
  width: 100%;
}

/* Saved Creations Shelf */
.saved-shelf {
  margin-top: 6px;
  border-top: 1.5px solid var(--border-ink);
  padding-top: 12px;
}
.saved-items-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
  margin-top: 8px;
}
.saved-item-card {
  padding: 9px 11px;
  background-color: var(--bg-elevated);
  color: var(--ink-primary) !important;
  border: 1.5px solid var(--border-ink);
  box-shadow: var(--shadow-hard-sm);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: left;
  transition: background-color 0.14s ease, transform 0.1s ease;
}
.saved-item-card strong {
  color: inherit !important;
  font-size: 0.9rem;
}
.saved-item-card .mono-label {
  color: var(--ink-secondary) !important;
}
.saved-item-card:hover,
.saved-item-card:focus-visible {
  background-color: var(--bg-secondary);
  transform: translate(-1px, -1px);
  outline: none;
}
.saved-item-card:active {
  background-color: var(--btn-teal-bg) !important;
  color: #FFFFFF !important;
}
.saved-item-card:active .mono-label {
  color: #FFFFFF !important;
}

/* ==========================================================================
   DAILY WORLD CHALLENGE ARENA
   ========================================================================== */
.challenge-banner {
  max-width: 1440px;
  margin: 12px auto 0;
  padding: 0 16px;
}
.challenge-card {
  background: var(--bg-surface);
  border: 2px solid var(--border-ink);
  box-shadow: var(--shadow-hard);
  padding: 16px 20px;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 16px;
}
.score-meter-wrap {
  background: var(--bg-elevated);
  border: 1.5px solid var(--border-ink);
  padding: 12px 16px;
  text-align: center;
  min-width: 180px;
}
.score-big-num {
  font-family: var(--font-serif);
  font-size: 2.1rem;
  font-weight: 800;
  color: var(--text-accent-vermilion);
  line-height: 1.1;
}

/* ==========================================================================
   EDITORIAL & INFORMATION PAGES
   ========================================================================== */
.page-container {
  max-width: 1080px;
  width: 100%;
  margin: 0 auto;
  padding: 24px 16px 40px;
}

.editorial-sheet {
  background: var(--bg-surface);
  border: 2px solid var(--border-ink);
  box-shadow: var(--shadow-hard);
  padding: clamp(18px, 3.5vw, 36px);
}

.editorial-sheet h1 {
  font-size: clamp(1.75rem, 3.4vw, 2.6rem);
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--border-ink);
  color: var(--ink-primary);
}
.editorial-sheet h2 {
  font-size: 1.35rem;
  margin: 24px 0 10px;
  color: var(--text-accent-teal);
}
.editorial-sheet h3 {
  font-size: 1.08rem;
  margin: 16px 0 8px;
  color: var(--ink-primary);
}
.editorial-sheet p,
.editorial-sheet li {
  color: var(--ink-secondary);
  margin-bottom: 12px;
  font-size: 0.96rem;
}
.editorial-sheet strong {
  color: var(--ink-primary);
}
.editorial-sheet ul,
.editorial-sheet ol {
  padding-left: 22px;
  margin-bottom: 16px;
}

.breadcrumb-nav {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  margin-bottom: 12px;
  color: var(--ink-muted);
}
.breadcrumb-nav a {
  color: var(--ink-secondary);
}

/* ==========================================================================
   MONETIZATION READINESS: CLS-SAFE AD SLOTS & COMPACT PRIVACY BAR
   ========================================================================== */
.ad-slot-wrapper {
  max-width: 1440px;
  width: 100%;
  margin: 16px auto;
  padding: 0 16px;
}
.ad-slot-box {
  width: 100%;
  min-height: 92px;
  background: var(--bg-secondary);
  border: 1.5px dashed var(--border-subtle);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 12px;
  text-align: center;
  color: var(--ink-secondary);
  font-family: var(--font-mono);
  font-size: 0.72rem;
}
.ad-slot-label {
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 4px;
  color: var(--ink-muted);
}

/* Compact Non-Blocking Cookie Consent Bar */
.cookie-consent-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 850;
  background: var(--bg-surface);
  border-top: 2px solid var(--border-ink);
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.22);
  padding: 10px 14px;
}
.cookie-consent-bar[hidden] {
  display: none !important;
}
.cookie-consent-inner {
  max-width: 1440px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.8rem;
  color: var(--ink-primary);
}

/* ==========================================================================
   TOAST NOTIFICATION & ANIMATION
   ========================================================================== */
.toast-container {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 900;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  width: max-content;
  max-width: calc(100vw - 24px);
}
.toast-msg {
  background-color: var(--bg-elevated);
  color: var(--ink-primary);
  border: 2px solid var(--accent-vermilion);
  box-shadow: var(--shadow-hard);
  padding: 10px 16px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 700;
  pointer-events: auto;
  text-align: center;
}

@keyframes fusionPulse {
  0% { transform: scale(0.98); opacity: 0.75; }
  50% { transform: scale(1.01); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}
.fusion-animate {
  animation: fusionPulse 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}

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

/* ==========================================================================
   FOOTER
   ========================================================================== */
.site-footer {
  margin-top: auto;
  background: var(--bg-surface);
  border-top: 2px solid var(--border-ink);
  padding: 28px 16px;
}
.footer-inner {
  max-width: 1440px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr 1fr;
  gap: 24px;
}
.footer-col h3 {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 10px;
  color: var(--ink-primary);
}
.footer-links {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.footer-links a {
  color: var(--ink-secondary);
  text-decoration: none;
  font-size: 0.86rem;
}
.footer-links a:hover {
  color: var(--text-accent-vermilion);
  text-decoration: underline;
}
.footer-bottom {
  max-width: 1440px;
  margin: 20px auto 0;
  padding-top: 16px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--ink-muted);
}

/* ==========================================================================
   RESPONSIVE & MOBILE-FIRST ORGANIZED ALIGNMENT (1080px, 768px, 480px, 375px, 320px)
   ========================================================================== */
@media (max-width: 1080px) {
  .studio-shell {
    grid-template-columns: 1fr;
  }
  .hero-strip {
    grid-template-columns: 1fr;
  }
  .footer-inner {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 820px) {
  .header-inner {
    padding: 6px 10px;
    gap: 6px;
  }
  .brand-link svg {
    height: 32px;
    max-width: 168px;
  }
  .mobile-menu-btn,
  button.mobile-menu-btn {
    display: inline-flex !important;
    order: 3;
  }
  .header-utilities {
    gap: 5px;
    margin-left: auto;
  }
  .header-utilities .btn,
  .mobile-menu-btn {
    padding: 6px 8px;
    min-height: 34px;
    min-width: 34px;
    font-size: 0.7rem;
  }
  /* Compact utility labels on narrow screens so header never overflows */
  #btn-sound-toggle span,
  #btn-theme-toggle span {
    display: none;
  }
  .main-nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-surface);
    border-bottom: 2px solid var(--border-ink);
    box-shadow: var(--shadow-hard);
    padding: 12px;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
  .main-nav.open {
    display: grid;
  }
  .main-nav .nav-link {
    width: 100%;
    text-align: center;
    border: 1.5px solid var(--border-subtle);
    padding: 10px 8px;
  }

  /* Organized Hero & Presets on Mobile */
  .hero-atlas {
    padding: 10px 10px 4px;
  }
  .hero-strip {
    padding: 14px;
    gap: 14px;
  }
  .hero-title {
    font-size: 1.65rem;
  }
  .hero-tagline {
    font-size: 0.92rem;
    margin-bottom: 12px;
  }
  .hero-cta-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .hero-cta-group > :first-child {
    grid-column: 1 / -1;
  }
  .hero-cta-group .btn {
    width: 100%;
  }

  /* Symmetrical 2-Column Preset Grid on Mobile */
  .preset-recipes-bar {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
  .preset-recipes-bar > .mono-label {
    grid-column: 1 / -1;
  }
  .preset-recipes-bar > .btn {
    width: 100%;
    padding: 8px 8px;
    font-size: 0.7rem;
    justify-content: flex-start;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .preset-recipes-bar > .btn:last-child:nth-child(even) {
    grid-column: 1 / -1;
    justify-content: center;
  }

  /* Organized Map Toolbar Button Grid on Mobile */
  .studio-shell {
    padding: 8px 10px;
    gap: 12px;
  }
  .map-toolbar {
    padding: 10px;
  }
  .map-toolbar-actions {
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
  }
  .map-toolbar-actions > .btn:last-child {
    grid-column: 1 / -1;
  }

  /* Clean Aspect-Ratio Map Viewport on Mobile (Zero Letterbox Void) */
  .map-viewport {
    aspect-ratio: 16 / 10;
    min-height: 220px;
    height: auto;
  }
  .map-coords-readout {
    top: 8px;
    bottom: auto;
    left: 8px;
    padding: 3px 7px;
    font-size: 0.65rem;
  }
  .map-hud-controls {
    bottom: 8px;
    right: 8px;
    flex-direction: row;
    gap: 4px;
  }
  .map-hud-controls .btn-icon {
    min-width: 34px;
    min-height: 34px;
    padding: 5px;
  }

  /* Selection Chips in a 2-Column Grid on Mobile */
  .selection-tray {
    padding: 10px;
    flex-direction: column;
    align-items: stretch;
  }
  .selected-chips-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    width: 100%;
  }
  .country-chip {
    width: 100%;
    justify-content: space-between;
    font-size: 0.74rem;
    padding: 6px 8px;
  }

  /* Charter Header & Visual Synthesis on Mobile */
  .charter-header {
    padding: 10px 12px;
  }
  .charter-body {
    padding: 12px;
    gap: 14px;
  }
  .challenge-card {
    grid-template-columns: 1fr;
    padding: 14px;
  }
  .footer-inner {
    grid-template-columns: 1fr;
    gap: 18px;
  }

  /* Compact Cookie Banner on Mobile */
  .cookie-consent-bar {
    padding: 8px 10px;
  }
  .cookie-consent-inner {
    font-size: 0.74rem;
    gap: 8px;
  }
  .cookie-consent-inner .btn {
    padding: 6px 10px;
    min-height: 34px;
    font-size: 0.72rem;
    flex: 1 1 auto;
  }
}

@media (max-width: 520px) {
  .visual-synthesis-grid {
    grid-template-columns: 1fr;
  }
  .charter-actions-grid {
    grid-template-columns: 1fr;
  }
  .stats-ledger th,
  .stats-ledger td {
    padding: 8px 9px;
    font-size: 0.78rem;
  }
}

@media (max-width: 350px) {
  .brand-link svg {
    height: 28px;
    max-width: 142px;
  }
  .selected-chips-list {
    grid-template-columns: 1fr;
  }
}

.daily-card-actions {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: center;
}
.daily-inline-score-box {
  border: 1.5px solid var(--border-ink);
  background: var(--bg-surface);
  padding: 8px 12px;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 0.92rem;
  font-weight: 800;
  color: var(--accent-vermilion) !important;
  white-space: nowrap;
}
@media (max-width: 820px) {
  .daily-card-actions {
    grid-template-columns: 1fr 1fr;
  }
  .daily-card-actions > :first-child {
    grid-column: 1 / -1;
    width: 100%;
  }
  .daily-card-actions > .btn,
  .daily-card-actions > .daily-inline-score-box {
    width: 100%;
  }
}
