:root {
  color-scheme: dark;
  --bg: #071014;
  --panel: #101b21;
  --panel-2: #14242b;
  --line: rgba(156, 189, 197, 0.18);
  --text: #eff8f7;
  --muted: #8fa7a8;
  --blue: #3ba7ff;
  --green: #25c48f;
  --gold: #f4b84a;
  --red: #f05f57;
  --coal: #f17845;
  --wind: #22c4aa;
  --solar: #f6c84b;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(rgba(255, 255, 255, 0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.018) 1px, transparent 1px),
    radial-gradient(circle at 12% 8%, rgba(59, 167, 255, 0.16), transparent 28%),
    linear-gradient(145deg, #071014 0%, #0a1719 46%, #071014 100%);
  background-size: 32px 32px, 32px 32px, auto, auto;
  color: var(--text);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.shell {
  width: min(1380px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 22px 0 40px;
}

.topbar,
.panel,
.metric,
.rank-row,
.decision-row,
.log-list li {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(20, 36, 43, 0.92), rgba(13, 24, 29, 0.95));
  box-shadow: var(--shadow);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 1px solid rgba(59, 167, 255, 0.42);
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(59, 167, 255, 0.22), rgba(37, 196, 143, 0.14));
}

.brand-mark span {
  width: 23px;
  height: 31px;
  clip-path: polygon(48% 0, 88% 0, 61% 41%, 100% 41%, 35% 100%, 49% 55%, 15% 55%);
  background: linear-gradient(180deg, #f6d36a, #24c5aa);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

h1 {
  font-size: 24px;
}

h2 {
  font-size: 18px;
}

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

.nav-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid rgba(59, 167, 255, 0.45);
  border-radius: 8px;
  color: #ccecff;
  background: rgba(59, 167, 255, 0.1);
  font-size: 13px;
  font-weight: 900;
  text-decoration: none;
}

.small-action {
  min-height: 40px;
  padding: 0 14px;
  font-size: 13px;
}

.pill {
  min-width: 116px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
}

.pill span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
}

.pill strong {
  font-size: 16px;
}

.primary,
.secondary,
.danger {
  min-height: 44px;
  padding: 0 18px;
  border-radius: 8px;
  font-weight: 800;
}

.primary {
  border: 0;
  color: #061014;
  background: linear-gradient(135deg, #f4c35c, #28d4a1);
}

.secondary {
  border: 1px solid rgba(59, 167, 255, 0.45);
  color: #ccecff;
  background: rgba(59, 167, 255, 0.1);
}

.danger {
  border: 1px solid rgba(240, 95, 87, 0.45);
  color: #ffd3cf;
  background: rgba(240, 95, 87, 0.12);
}

.grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(340px, 0.8fr);
  gap: 16px;
  margin-top: 16px;
}

.host-grid {
  display: grid;
  grid-template-columns: minmax(360px, 0.85fr) minmax(0, 1.15fr);
  gap: 16px;
  margin-top: 16px;
}

.panel {
  padding: 18px;
}

.panel + .panel {
  margin-top: 16px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.field span {
  color: #d6e8e7;
  font-size: 13px;
  font-weight: 700;
}

.field-hint {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.field input,
.field select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.055);
  padding: 0 12px;
}

.hint {
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.metric-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.metric {
  min-height: 104px;
  padding: 16px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 28px;
}

.event-card {
  margin-top: 14px;
  padding: 16px;
  border: 1px solid rgba(37, 196, 143, 0.32);
  border-radius: 8px;
  background: rgba(37, 196, 143, 0.08);
}

.event-card p {
  margin-top: 8px;
  color: #d6e8e7;
  line-height: 1.55;
}

.event-card small {
  display: block;
  margin-top: 10px;
  color: var(--green);
  font-weight: 800;
}

.builds {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.decision-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 12px;
  box-shadow: none;
}

.decision-row button {
  height: 38px;
}

.rank-list,
.team-list,
.log-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.rank-row {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 13px;
  box-shadow: none;
}

.rank-row.active {
  border-color: rgba(244, 184, 74, 0.52);
  background: rgba(244, 184, 74, 0.09);
}

.rank-row span {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  color: #061014;
  background: var(--gold);
  font-weight: 900;
}

.rank-row em {
  color: var(--green);
  font-style: normal;
  font-weight: 800;
}

.team-list article {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}

.team-list header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  color: #061014;
  background: var(--green);
  font-size: 12px;
  font-weight: 900;
}

.badge.pending {
  color: #fff4d1;
  background: rgba(244, 184, 74, 0.24);
}

.team-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.team-stats div {
  padding: 9px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
}

.team-stats span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.team-stats strong {
  display: block;
  margin-top: 4px;
}

.log-list {
  padding: 0;
  list-style: none;
}

.log-list li {
  padding: 12px;
  color: #d6e8e7;
  box-shadow: none;
}

.asset-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.asset-list div {
  padding: 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
  color: #d6e8e7;
  font-size: 13px;
}

.player-shell {
  width: min(1540px, calc(100vw - 32px));
}

.join-card {
  max-width: 860px;
  margin: 18px auto 0;
}

.player-game {
  display: grid;
  grid-template-columns: minmax(620px, 1fr) 420px;
  grid-template-areas:
    "world command"
    "empire rank";
  gap: 16px;
  margin-top: 16px;
}

.world-panel {
  grid-area: world;
}

.command-panel {
  grid-area: command;
}

.empire-panel {
  grid-area: empire;
}

.rank-panel-game {
  grid-area: rank;
}

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.map-tip {
  color: var(--muted);
  font-size: 13px;
}

.world-map {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  min-height: 420px;
}

.world-tile {
  position: relative;
  min-height: 190px;
  padding: 16px;
  border: 1px solid rgba(156, 189, 197, 0.22);
  border-radius: 8px;
  color: var(--text);
  text-align: left;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(37, 196, 143, 0.08), rgba(59, 167, 255, 0.04)),
    rgba(255, 255, 255, 0.035);
}

.world-tile::after {
  position: absolute;
  right: -24px;
  bottom: -34px;
  width: 118px;
  height: 118px;
  border: 1px solid currentColor;
  border-radius: 50%;
  opacity: 0.12;
  content: "";
}

.world-tile.wind {
  color: var(--wind);
}

.world-tile.solar {
  color: var(--solar);
}

.world-tile.coal {
  color: var(--coal);
}

.world-tile.market {
  color: var(--blue);
}

.world-tile.green,
.world-tile.build,
.world-tile.balanced {
  color: var(--green);
}

.world-tile.selected {
  border-color: rgba(244, 184, 74, 0.8);
  box-shadow: 0 0 0 2px rgba(244, 184, 74, 0.18), var(--shadow);
}

.world-tile strong,
.world-tile em,
.world-tile small {
  display: block;
}

.world-tile strong {
  margin-top: 28px;
  color: var(--text);
  font-size: 18px;
}

.world-tile em {
  margin-top: 8px;
  color: currentColor;
  font-style: normal;
  font-weight: 900;
}

.world-tile small {
  margin-top: 8px;
  color: #cfe0df;
  line-height: 1.45;
}

.tile-id {
  position: absolute;
  top: 12px;
  left: 12px;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  color: #061014;
  background: currentColor;
  font-weight: 900;
}

.tile-assets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 14px;
}

.tile-assets i {
  display: inline-flex;
  padding: 5px 8px;
  border-radius: 999px;
  color: #dcebea;
  background: rgba(255, 255, 255, 0.08);
  font-size: 12px;
  font-style: normal;
}

.tile-assets .coal {
  color: var(--coal);
}

.tile-assets .wind {
  color: var(--wind);
}

.tile-assets .solar {
  color: var(--solar);
}

.compact-event {
  margin-top: 16px;
}

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

.resource-bar div {
  min-height: 86px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}

.resource-bar span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.resource-bar strong {
  display: block;
  margin-top: 8px;
  font-size: 28px;
}

.command-block {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.build-queue {
  margin-top: 12px;
}

.build-queue .decision-row {
  grid-template-columns: 1fr auto;
}

.build-queue .decision-row span,
.build-queue .decision-row small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.build-queue .decision-row strong {
  display: block;
  margin: 4px 0;
}

.empty-queue {
  padding: 12px;
  border: 1px dashed rgba(156, 189, 197, 0.24);
  border-radius: 8px;
  color: var(--muted);
  font-size: 13px;
}

.compact-controls {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.submit-turn {
  width: 100%;
  margin-top: 14px;
}

.decision-summary {
  display: grid;
  gap: 6px;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid rgba(244, 184, 74, 0.28);
  border-radius: 8px;
  color: #f7e6b2;
  background: rgba(244, 184, 74, 0.08);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.45;
}

.decision-summary span,
.decision-summary strong {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.decision-summary strong {
  color: var(--text);
  font-size: 15px;
}

.asset-list div strong,
.asset-list div span {
  display: block;
}

.asset-list div span {
  margin-top: 4px;
  color: var(--muted);
}

.toast {
  min-height: 24px;
  margin-top: 12px;
  color: var(--gold);
  font-size: 13px;
}

.rules-shell {
  width: min(1180px, calc(100vw - 32px));
}

.rules-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.rule-hero {
  grid-column: 1 / -1;
}

.rule-hero h2 {
  max-width: 900px;
  font-size: 28px;
  line-height: 1.35;
}

.rule-hero p,
.rule-copy {
  margin-top: 12px;
  color: #d6e8e7;
  line-height: 1.7;
}

.rule-steps,
.rule-cards,
.rule-table {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.rule-steps div,
.rule-cards article,
.rule-table div {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}

.rule-steps strong {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  margin-right: 8px;
  border-radius: 50%;
  color: #061014;
  background: var(--gold);
}

.rule-steps span,
.rule-table strong {
  color: var(--text);
  font-weight: 900;
}

.rule-steps p,
.rule-cards p,
.rule-table span {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  line-height: 1.55;
}

@media (max-width: 980px) {
  .topbar,
  .top-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .grid,
  .host-grid,
  .player-game,
  .form-grid,
  .metric-row,
  .team-stats {
    grid-template-columns: 1fr;
  }

  .rules-grid {
    grid-template-columns: 1fr;
  }

  .rule-hero h2 {
    font-size: 22px;
  }

  .player-game {
    grid-template-areas:
      "command"
      "world"
      "empire"
      "rank";
  }

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

  .decision-row {
    grid-template-columns: 1fr;
  }
}
