:root,
:root[data-theme="light"],
:root[data-theme="dark"] {
  color-scheme: dark;
  --brand-navy: #111921;
  --brand-purple: #2c1a66;
  --brand-white: #f8fafc;
  --brand-offwhite: #17212c;
  --brand-gray: #b2b6b9;
  --brand-orange: #ea6753;
  --brand-violet: #2d1b46;
  --brand-cyan: #afdfe1;
  --bg: #030712;
  --surface: #111921;
  --surface2: #2d1b46;
  --border: #425466;
  --text: #f8fafc;
  --muted: #b2b6b9;
  --accent: #ea6753;
  --accent-h: #2c1a66;
  --green: #afdfe1;
  --red: #ea6753;
  --yellow: #ea6753;
  --ink: #f8fafc;
  --line: #425466;
  --panel: #111921;
  --accent-strong: #2c1a66;
  --accent-ink: #f8fafc;
  --soft: #17212c;
  --code: #2d1b46;
  --shadow: #030712;
  --radius: 8px;
  --mono: "Montserrat", sans-serif;
}

* {
  box-sizing: border-box;
  letter-spacing: 0;
}

html,
body {
  background: #030712;
  color: #f8fafc;
  font-family: "Montserrat", sans-serif;
}

body,
button,
input,
textarea,
select,
code,
pre,
kbd {
  font-family: "Montserrat", sans-serif;
}

a {
  color: #afdfe1;
}

a:hover {
  color: #ea6753;
}

body > main {
  padding-block: 18px 34px;
}

.site-hero {
  width: 100%;
  margin: 0;
  padding: 26px max(20px, calc((100% - 1180px) / 2)) 42px;
  background: #111921;
  color: #FFFFFF;
  border-bottom: 10px solid #2c1a66;
}

.site-hero .topbar,
.site-hero nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin: 0 0 34px;
}

.site-hero nav {
  justify-content: flex-start;
}

.hero-layout {
  display: block;
}

.hero-copy {
  max-width: 920px;
}

.site-hero .eyebrow {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  margin: 0 0 14px;
  border: 1px solid #afdfe1;
  border-radius: 8px;
  padding: 3px 10px;
  color: #afdfe1;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.site-hero h1 {
  max-width: 860px;
  margin: 0;
  color: #FFFFFF;
  font-size: clamp(2.6rem, 7vw, 6.2rem);
  font-weight: 700;
  line-height: 0.98;
  text-transform: uppercase;
}

.site-hero .lead,
.site-hero p {
  color: #FFFFFF;
}

.site-hero .lead {
  max-width: 720px;
  margin-block: 22px 0;
  font-size: clamp(1.02rem, 2vw, 1.3rem);
  line-height: 1.9;
}

.hero-proof {
  width: min(100%, 920px);
  margin-top: 34px;
  border: 1px solid #b2b6b9;
  border-radius: 8px;
  background: #111921;
  color: #f8fafc;
  overflow: hidden;
}

.hero-proof-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 54px;
  border-bottom: 1px solid #b2b6b9;
  padding: 12px 14px;
  background: #17212c;
}

.hero-proof-title {
  color: #f8fafc;
  font-weight: 700;
}

.hero-proof-badge {
  border-radius: 8px;
  padding: 4px 9px;
  background: #afdfe1;
  color: #111921;
  font-size: 0.72rem;
  font-weight: 700;
}

.hero-proof pre,
.hero-code {
  margin: 0;
  border: 0;
  border-radius: 0;
  padding: 18px;
  background: #111921;
  color: #FFFFFF;
  direction: rtl;
  text-align: right;
  white-space: pre-wrap;
}

.hero-proof code,
.hero-code code {
  background: transparent;
  color: #FFFFFF;
}

.metric-strip,
.gallery-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-top: 1px solid #b2b6b9;
  background: #111921;
}

.metric,
.gallery-meta span {
  display: flex;
  min-height: 76px;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  border-inline-start: 1px solid #b2b6b9;
  padding: 10px 14px;
  color: #f8fafc;
}

.metric:first-child,
.gallery-meta span:first-child {
  border-inline-start: 0;
}

.metric strong,
.gallery-meta strong {
  color: #afdfe1;
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1;
}

.metric small,
.gallery-meta small {
  color: #b2b6b9;
  font-size: 0.78rem;
  font-weight: 400;
  line-height: 1.45;
}

.brand-lockup {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-width: 240px;
  padding: 0;
  color: #f8fafc;
  text-align: start;
  text-decoration: none;
}

.brand-lockup.on-dark {
  color: #FFFFFF;
}

.brand-mark {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 84px;
  height: 68px;
  padding: 5px;
  border: 1px solid #b2b6b9;
  border-radius: 8px;
  background: #111921;
}

.brand-mark img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.brand-name {
  display: block;
  color: inherit;
  font-size: 0.98rem;
  font-weight: 700;
  line-height: 1.25;
}

.brand-tagline {
  display: block;
  max-width: 190px;
  color: inherit;
  font-size: 0.64rem;
  font-weight: 400;
  line-height: 1.35;
}

.theme-toggle {
  display: none;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.button,
.button.primary,
.badge.primary,
#run-btn {
  min-height: 42px;
  border: 1px solid #ea6753;
  border-radius: 8px;
  background: #ea6753;
  color: #FFFFFF;
  font-weight: 700;
  text-decoration: none;
  box-shadow: none;
}

.button.secondary,
.badge,
.nav-link,
.game-actions button,
.platform-actions button,
.platform-controls button,
.city-actions button,
.city-command-row button,
#game-reset,
#game-source-toggle,
#platform-source-toggle,
#platform-reset,
#city-source-toggle,
#city-reset,
#clear-btn {
  min-height: 38px;
  border: 1px solid #425466;
  border-radius: 8px;
  background: #111921;
  color: #f8fafc;
  font-weight: 700;
  text-decoration: none;
  box-shadow: none;
}

.site-hero .button.secondary,
.site-hero .nav-link {
  border-color: #b2b6b9;
  background: #111921;
  color: #FFFFFF;
}

.button:hover,
.button.primary:hover,
.badge:hover,
.badge.primary:hover,
.nav-link:hover,
#run-btn:hover:not(:disabled),
.game-actions button:hover:not(:disabled),
.platform-actions button:hover:not(:disabled),
.platform-controls button:hover:not(:disabled),
.city-actions button:hover:not(:disabled),
.city-command-row button:hover:not(:disabled) {
  border-color: #2c1a66;
  background: #2c1a66;
  color: #FFFFFF;
  text-decoration: none;
}

.site-hero .nav-link:hover,
.site-hero .button.secondary:hover {
  border-color: #afdfe1;
  background: #afdfe1;
  color: #111921;
}

main,
footer {
  color: #f8fafc;
}

main section {
  border-top: 0;
  padding: 34px 0;
}

main section + section {
  border-top: 1px solid #b2b6b9;
}

h1,
h2,
h3,
h4,
.panel-header h3,
#examples-panel h2 {
  color: #f8fafc;
  font-weight: 700;
}

main h2 {
  margin-bottom: 18px;
  font-size: clamp(1.45rem, 3vw, 2.1rem);
}

p,
li,
.lead,
.card p,
.section-head p {
  color: #b2b6b9;
  font-weight: 400;
}

.grid {
  gap: 18px;
}

.card {
  position: relative;
  min-height: 100%;
  border: 1px solid #b2b6b9;
  border-radius: 8px;
  background: #111921;
  color: #f8fafc;
  box-shadow: none;
}

.card::before {
  content: "";
  position: absolute;
  inset-block: 0;
  inset-inline-start: 0;
  width: 6px;
  border-radius: 8px 0 0 8px;
  background: #2c1a66;
}

.card:nth-child(3n + 1)::before {
  background: #ea6753;
}

.card:nth-child(3n + 2)::before {
  background: #2d1b46;
}

.card:hover {
  border-color: #2c1a66;
}

.card h3 {
  color: #f8fafc;
  font-weight: 700;
}

.card p {
  color: #b2b6b9;
}

.pill,
code,
pre,
.meta .pill {
  border: 1px solid #425466;
  border-radius: 8px;
  background: #17212c;
  color: #afdfe1;
}

pre {
  background: #111921;
  color: #FFFFFF;
}

pre code {
  border: 0;
  background: transparent;
  color: inherit;
}

footer {
  width: 100%;
  margin: 0;
  padding: 28px max(20px, calc((100% - 1120px) / 2)) 42px;
  border-top: 8px solid #2c1a66;
  background: #111921;
  color: #FFFFFF;
}

footer p,
footer code {
  color: #FFFFFF;
}

body > header:not(.site-hero),
#status-bar,
#examples-panel,
.panel-header {
  border-color: #b2b6b9;
  background: #111921;
  color: #FFFFFF;
}

body > header:not(.site-hero) {
  min-height: 92px;
  padding: 10px 18px;
}

header:not(.site-hero) .header-brand {
  gap: 16px;
}

header:not(.site-hero) .brand-lockup {
  min-width: 198px;
}

header:not(.site-hero) .brand-mark {
  width: 58px;
  height: 46px;
  padding: 3px;
}

header:not(.site-hero) .brand-name {
  font-size: 0.76rem;
}

header:not(.site-hero) .brand-tagline {
  max-width: 150px;
  font-size: 0.5rem;
}

header:not(.site-hero) .header-brand h1 {
  color: #FFFFFF;
  font-size: 1rem;
}

header:not(.site-hero) .header-brand h1 span {
  color: #b2b6b9;
}

.header-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

#status-bar {
  border-bottom: 1px solid #b2b6b9;
  background: #2d1b46;
}

#status-text {
  color: #FFFFFF;
}

#status-dot.ready,
#status-dot.busy {
  background: #afdfe1;
}

#status-dot.error {
  background: #ea6753;
}

.main-wrap {
  background: #030712;
}

#editor-panel,
#output-panel,
#examples-panel {
  border-color: #b2b6b9;
}

.panel-header {
  min-height: 46px;
  border-bottom: 1px solid #b2b6b9;
  background: #111921;
}

.panel-header h3,
#examples-panel h2 {
  color: #FFFFFF;
}

#examples-panel {
  background: #111921;
}

#examples-panel h2 {
  background: #111921;
  border-bottom: 1px solid #b2b6b9;
}

.example-btn {
  color: #f8fafc;
  font-family: "Montserrat", sans-serif;
}

.example-btn:hover,
.example-btn.active {
  border-color: #afdfe1;
  background: #17212c;
  color: #afdfe1;
}

.example-btn .ex-tag,
.example-btn[data-tier] .ex-tag,
.examples-section-header {
  color: #ea6753;
}

#editor,
#stdin-input,
#output {
  border-color: #b2b6b9;
  background: #111921;
  color: #f8fafc;
  font-family: "Montserrat", sans-serif;
}

#editor::placeholder,
#stdin-input::placeholder,
#output.empty {
  color: #b2b6b9;
}

#output.err {
  color: #ea6753;
}

#output.has-warn {
  color: #2d1b46;
}

#loading-overlay,
#game-panel,
#platform-panel,
#city-panel {
  background: #111921;
  color: #FFFFFF;
}

.loader-snake {
  display: none;
}

.loader-bar,
.energy-track,
.meter,
.mini-meter {
  border: 1px solid #b2b6b9;
  background: #2d1b46;
}

.loader-bar-inner,
#game-energy-bar,
.meter > i,
.mini-meter > i {
  background: #ea6753;
}

.game-title strong,
.platform-title strong,
.city-title strong,
.game-stat-value,
.platform-stat strong,
.city-metric strong,
.district-card strong,
.forecast-row strong,
.station-row strong,
#game-message,
#platform-message,
#city-message {
  color: #FFFFFF;
}

#game-board,
.platform-stage-wrap,
#platform-stage,
.city-map-wrap,
.city-board {
  border-color: #b2b6b9;
  background:
    radial-gradient(circle at 20% 38%, rgba(94, 234, 212, 0.13), transparent 28%),
    radial-gradient(circle at 78% 42%, rgba(234, 103, 83, 0.12), transparent 24%),
    linear-gradient(180deg, #111921 0%, #050914 100%);
  box-shadow: none;
}

.game-cell,
.platform-object,
.platform-tile,
.city-node,
.city-side,
.city-log,
.city-metric,
.district-card,
.city-selected,
.forecast-row,
.station-row,
.city-impact,
#game-log,
#platform-log {
  border-color: #b2b6b9;
  background: #111921;
  color: #f8fafc;
  box-shadow: none;
}

.game-cell.player,
.platform-hero,
.city-node.selected,
.district-card.selected {
  border-color: #ea6753;
  background: #ea6753;
  color: #FFFFFF;
  box-shadow: none;
}

.game-cell.near,
.platform-coin,
.city-road.active,
.status-pill[data-state="مراقبة"],
#city-result[data-result="نجاح"] {
  border-color: #afdfe1;
  background: #afdfe1;
  color: #111921;
}

.game-cell.treasure,
.platform-gate,
.city-node[data-alert="نعم"]::after {
  border-color: #ea6753;
  background: #ea6753;
  color: #FFFFFF;
}

.platform-hazard,
.city-node[data-state="خطر"],
.city-node[data-state="طارئ"],
.district-card[data-state="خطر"],
.district-card[data-state="طارئ"],
.status-pill[data-state="خطر"],
.status-pill[data-state="طارئ"],
#city-result[data-result="خسارة"] {
  border-color: #ea6753;
  background: #2d1b46;
  color: #FFFFFF;
}

.platform-tile.moving,
.city-node[data-state="متوتر"],
.city-node[data-state="ضغط"],
.district-card[data-state="متوتر"],
.district-card[data-state="ضغط"],
.status-pill[data-state="متوتر"],
.status-pill[data-state="ضغط"] {
  border-color: #ea6753;
  background: #2d1b46;
  color: #FFFFFF;
}

.platform-canvas {
  background: #030712;
}

#city-roads,
.city-road {
  stroke: #2c1a66;
  filter: none;
}

.status-pill {
  border: 1px solid #b2b6b9;
  border-radius: 8px;
  background: #17212c;
  color: #f8fafc;
}

.platform-controls {
  direction: ltr;
}

.platform-controls button,
.game-controls button {
  direction: rtl;
}

:focus-visible,
.button:focus-visible,
.badge:focus-visible,
.nav-link:focus-visible,
.card:focus-visible,
#run-btn:focus-visible,
#editor:focus-visible,
#stdin-input:focus-visible,
#platform-stage:focus-visible {
  outline: 3px solid #ea6753;
  outline-offset: 3px;
}

@media (max-width: 900px) {
  .metric-strip,
  .gallery-meta {
    grid-template-columns: 1fr;
  }

  .metric,
  .gallery-meta span {
    border-inline-start: 0;
    border-top: 1px solid #b2b6b9;
  }

  .metric:first-child,
  .gallery-meta span:first-child {
    border-top: 0;
  }

  body > header:not(.site-hero) {
    align-items: flex-start;
    flex-direction: column;
  }

  .header-links {
    justify-content: flex-start;
  }
}

@media (max-width: 640px) {
  .site-hero {
    padding: 20px 16px 32px;
  }

  .site-hero .topbar,
  .site-hero nav {
    align-items: flex-start;
    flex-direction: column;
  }

  .brand-lockup {
    min-width: 0;
  }

  .brand-name {
    font-size: 0.84rem;
  }

  .brand-tagline {
    font-size: 0.56rem;
  }
}
