:root {
  color-scheme: dark;
  --bg: #101312;
  --bg-2: #151a17;
  --panel: #1b211e;
  --panel-2: #242b27;
  --line: #39463f;
  --text: #eef2e9;
  --muted: #aeb9ae;
  --accent: #d8b85f;
  --accent-2: #6fb08a;
  --danger: #d36a4b;
  --ok: #7fb06a;
  --ink: #090b0a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 15% 0%, rgba(111, 176, 138, 0.16), transparent 34rem),
    linear-gradient(180deg, #101312 0%, #141812 48%, #0f1110 100%);
  color: var(--text);
  font-family: "Segoe UI", system-ui, sans-serif;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

button:hover,
button.active,
.primary-action:hover,
.secondary-action:hover,
.site-nav a:hover {
  border-color: var(--accent);
  color: #fff4cf;
}

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

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: min(1380px, calc(100vw - 24px));
  margin: 0 auto;
  padding: 12px 0;
  backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-logo {
  width: clamp(132px, 16vw, 220px);
  height: 46px;
  object-fit: contain;
  object-position: left center;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.46));
}

.game-page .brand-logo {
  width: clamp(124px, 13vw, 188px);
  height: 42px;
}

.site-nav {
  display: flex;
  gap: 8px;
}

.site-nav a {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(238, 242, 233, 0.14);
  border-radius: 6px;
  background: rgba(16, 19, 18, 0.66);
  color: var(--muted);
  padding: 0 12px;
  font-size: 13px;
}

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

.home-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(380px, 0.95fr);
  gap: 28px;
  align-items: center;
  min-height: clamp(430px, 58vh, 620px);
  padding: 34px 0 24px;
}

.standalone-hero {
  min-height: clamp(500px, 68vh, 720px);
  padding-bottom: 30px;
}

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

.hero-logo {
  width: min(640px, 100%);
  height: auto;
  display: block;
  margin: 8px 0 16px;
  filter: drop-shadow(0 22px 38px rgba(0, 0, 0, 0.42));
}

.hero-copy h1 {
  max-width: 780px;
  font-size: clamp(38px, 6vw, 76px);
  line-height: 1.02;
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.hero-lede {
  max-width: 680px;
  margin: 18px 0 0;
  color: #c4cec3;
  font-size: 18px;
  line-height: 1.7;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 24px;
}

.primary-action,
.secondary-action {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 18px;
  font-weight: 650;
}

.primary-action {
  border-color: #d8b85f;
  background: #d8b85f;
  color: #1d180b;
}

.primary-action:hover {
  color: #1d180b;
  filter: brightness(1.06);
}

.secondary-action {
  background: rgba(238, 242, 233, 0.05);
  color: var(--text);
}

.hero-visual {
  position: relative;
  min-height: 330px;
  border: 1px solid rgba(238, 242, 233, 0.15);
  border-radius: 8px;
  background:
    linear-gradient(145deg, rgba(36, 50, 40, 0.92), rgba(16, 19, 18, 0.94)),
    #172019;
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.28);
  overflow: hidden;
}

.hero-visual::before {
  content: "";
  position: absolute;
  inset: 16px;
  border: 1px solid rgba(238, 242, 233, 0.08);
  border-radius: 6px;
}

.map-grid {
  position: absolute;
  inset: 34px 30px 70px;
  display: grid;
  grid-template-columns: repeat(6, minmax(34px, 1fr));
  grid-auto-rows: minmax(34px, 1fr);
  gap: 5px;
  transform: rotateX(50deg) rotateZ(-34deg) translateY(12px);
  transform-origin: center;
}

.tile {
  min-width: 0;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 5px;
  background: #31442f;
  box-shadow: inset 0 0 16px rgba(0, 0, 0, 0.2);
}

.tile.field { background: #33482f; }
.tile.forest { background: #1d5139; }
.tile.ridge { background: #665e4c; }
.tile.water { background: #235360; }
.tile.road { background: #9a7a50; }
.tile.wall { background: #a59b8e; }
.tile.tower { background: #b96445; }
.tile.resource { background: #e1c161; }
.tile.core {
  background: #f0d875;
  box-shadow: 0 0 28px rgba(240, 216, 117, 0.48);
}
.tile.enemy {
  background: #cc544a;
  box-shadow: 0 0 22px rgba(204, 84, 74, 0.52);
}

.wave-line {
  position: absolute;
  right: -12%;
  bottom: 31%;
  width: 68%;
  height: 3px;
  background: linear-gradient(90deg, transparent, #f1d979, #d36a4b);
  transform: rotate(-18deg);
  box-shadow: 0 0 18px rgba(211, 106, 75, 0.45);
}

.hero-status {
  position: absolute;
  right: 18px;
  bottom: 18px;
  left: 18px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.hero-status span {
  min-width: 0;
  border: 1px solid rgba(238, 242, 233, 0.14);
  border-radius: 6px;
  background: rgba(9, 11, 10, 0.58);
  color: #dce5d8;
  padding: 9px 10px;
  text-align: center;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.field-report {
  display: grid;
  grid-template-columns: 0.75fr 1.25fr 1fr;
  gap: 1px;
  margin: 0 0 22px;
  border: 1px solid rgba(238, 242, 233, 0.14);
  border-radius: 8px;
  background: rgba(238, 242, 233, 0.1);
  overflow: hidden;
}

.field-report div {
  min-width: 0;
  background: rgba(16, 19, 18, 0.78);
  padding: 14px 16px;
}

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

.field-report strong {
  display: block;
  margin-top: 4px;
  font-size: 15px;
  overflow-wrap: anywhere;
}

.home-section {
  padding: 34px 0;
  scroll-margin-top: 76px;
}

.section-heading {
  display: grid;
  gap: 4px;
  margin-bottom: 16px;
}

.section-heading h2,
.play-cta h2 {
  font-size: 28px;
}

.notice-grid,
.how-grid,
.roadmap-list {
  display: grid;
  gap: 12px;
}

.notice-grid {
  grid-template-columns: 1.1fr 1fr 1fr;
}

.notice-card,
.how-grid article {
  min-width: 0;
  border: 1px solid rgba(238, 242, 233, 0.14);
  border-radius: 8px;
  background: rgba(27, 33, 30, 0.76);
  padding: 16px;
}

.notice-card.current {
  border-color: rgba(216, 184, 95, 0.48);
  background: rgba(216, 184, 95, 0.1);
}

.notice-card span {
  display: block;
  color: var(--accent);
  font-size: 12px;
  font-weight: 650;
}

.notice-card h3,
.how-grid h3 {
  margin: 8px 0 0;
  color: var(--text);
  font-size: 18px;
  line-height: 1.35;
}

.notice-card p,
.how-grid p {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.65;
}

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

.roadmap-list {
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}

.roadmap-item {
  position: relative;
  min-width: 0;
  border: 1px solid rgba(238, 242, 233, 0.14);
  border-radius: 8px;
  background: rgba(16, 19, 18, 0.72);
  padding: 16px;
}

.roadmap-item::before {
  content: "";
  position: absolute;
  top: 26px;
  left: -13px;
  width: 12px;
  height: 1px;
  background: rgba(216, 184, 95, 0.34);
}

.roadmap-item:first-child::before {
  display: none;
}

.roadmap-item span {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border: 1px solid rgba(216, 184, 95, 0.36);
  border-radius: 6px;
  color: var(--accent);
  padding: 0 8px;
  font-size: 12px;
  font-weight: 650;
}

.roadmap-item h3 {
  margin: 12px 0 0;
  color: var(--text);
  font-size: 16px;
  line-height: 1.35;
}

.roadmap-item p {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.62;
}

.roadmap-item.active {
  border-color: rgba(111, 176, 138, 0.48);
  background: rgba(111, 176, 138, 0.1);
}

.roadmap-item.next {
  border-color: rgba(216, 184, 95, 0.55);
  background: rgba(216, 184, 95, 0.11);
}

.roadmap-item.milestone {
  border-color: rgba(211, 106, 75, 0.42);
  background: rgba(211, 106, 75, 0.08);
}

.play-cta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin: 24px 0 8px;
  border: 1px solid rgba(216, 184, 95, 0.36);
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(216, 184, 95, 0.15), rgba(111, 176, 138, 0.1));
  padding: 18px;
}

.play-cta .primary-action {
  flex: 0 0 auto;
}

.topbar,
.hud,
.workspace {
  display: grid;
  gap: 12px;
}

.topbar {
  grid-template-columns: 1fr auto;
  align-items: end;
  margin-bottom: 12px;
  padding-top: 10px;
  scroll-margin-top: 76px;
}

.game-page .topbar {
  padding-top: 22px;
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--accent);
  font-size: 12px;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  font-weight: 650;
}

h1 {
  font-size: 28px;
}

h2 {
  margin-top: 4px;
  font-size: 15px;
}

.prototype-title {
  font-size: 28px;
}

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

.topbar-actions button {
  padding: 0 14px;
}

.hud {
  grid-template-columns: repeat(auto-fit, minmax(108px, 1fr));
  margin-bottom: 12px;
}

.stat {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 9px 10px;
}

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

.stat strong {
  display: block;
  margin-top: 2px;
  font-size: 18px;
}

.stat.danger strong {
  color: #ffb199;
}

.workspace {
  grid-template-columns: 230px minmax(640px, 1fr) 260px;
  align-items: start;
}

.panel {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(27, 33, 30, 0.92);
  padding: 12px;
}

.tool-grid {
  display: grid;
  gap: 8px;
}

.tool-grid button {
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px;
  min-width: 0;
  padding: 10px 12px;
  text-align: left;
}

.tool-title {
  color: var(--text);
  font-size: 16px;
  font-weight: 650;
  line-height: 1.25;
}

.tool-desc,
.tool-cost {
  display: block;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.tool-cost {
  color: #bed0c8;
}

.workers {
  display: grid;
  gap: 8px;
}

.worker-row {
  display: grid;
  grid-template-columns: 1fr 32px 36px 32px 44px;
  align-items: center;
  gap: 6px;
}

.worker-row span {
  color: var(--muted);
  font-size: 13px;
}

.worker-row strong {
  text-align: center;
}

.worker-row button {
  min-height: 30px;
}

.tile-info,
.resource-controls,
.population-controls,
.tech-controls,
.objectives,
.log {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.resource-controls {
  display: grid;
  gap: 8px;
}

.resource-card {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.03);
  padding: 8px;
}

.resource-card strong {
  display: block;
  margin-bottom: 4px;
  color: var(--text);
}

.resource-card dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 3px 10px;
  margin: 0 0 8px;
}

.resource-card dt {
  color: var(--muted);
}

.resource-card dd {
  margin: 0;
  color: var(--text);
}

.resource-actions {
  display: grid;
  grid-template-columns: 1fr 40px 40px 64px;
  gap: 6px;
  align-items: center;
}

.resource-actions button {
  min-height: 32px;
}

.population-card {
  display: grid;
  gap: 7px;
  border: 1px solid rgba(214, 178, 94, 0.32);
  border-radius: 6px;
  background: rgba(214, 178, 94, 0.08);
  padding: 8px;
}

.population-card.pressure {
  border-color: rgba(255, 135, 112, 0.48);
  background: rgba(126, 47, 38, 0.18);
}

.population-card strong {
  color: var(--text);
}

.population-card span {
  color: var(--muted);
  font-size: 12px;
}

.population-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.population-actions button {
  min-height: 32px;
  padding: 6px 8px;
}

.population-actions button:last-child:nth-child(odd) {
  grid-column: 1 / -1;
}

.preset-actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 5px;
}

.preset-actions button {
  min-height: 30px;
  padding: 4px 6px;
  font-size: 12px;
}

.tech-controls {
  display: grid;
  gap: 8px;
}

.tech-card,
.tech-line,
.tech-option {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.03);
  padding: 8px;
}

.tech-card strong,
.tech-line > strong,
.tech-option strong {
  display: block;
  color: var(--text);
  font-size: 13px;
}

.tech-card span,
.tech-option span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.tech-progress {
  height: 7px;
  margin-top: 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.09);
  overflow: hidden;
}

.tech-progress i {
  display: block;
  height: 100%;
  background: var(--accent);
}

.tech-option {
  display: grid;
  gap: 6px;
}

.tech-line {
  display: grid;
  gap: 7px;
  background: rgba(111, 176, 138, 0.05);
}

.tech-line > strong {
  color: var(--accent);
}

.tech-option.complete {
  border-color: rgba(127, 176, 106, 0.38);
  background: rgba(127, 176, 106, 0.08);
}

.tech-option.available:not(.complete) {
  border-color: rgba(214, 178, 94, 0.38);
}

.tech-option button {
  min-height: 30px;
}

.objectives {
  margin: 0;
  padding-left: 20px;
}

.board-wrap {
  min-width: 0;
  position: relative;
}

canvas {
  width: 100%;
  max-width: 832px;
  aspect-ratio: 26 / 16;
  display: block;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0d1113;
  image-rendering: pixelated;
}

.lost-overlay {
  position: absolute;
  inset: 1px;
  display: grid;
  place-content: center;
  gap: 10px;
  padding: 20px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.62);
  text-align: center;
}

.lost-overlay[hidden] {
  display: none;
}

.lost-overlay strong {
  font-size: 30px;
}

.lost-overlay span {
  max-width: 360px;
  color: var(--muted);
  font-size: 15px;
}

.battle-report {
  display: grid;
  grid-template-columns: repeat(2, minmax(120px, 1fr));
  gap: 6px;
  width: min(420px, 88vw);
  margin: 2px auto;
  color: var(--text);
  font-size: 13px;
}

.battle-report div {
  border: 1px solid rgba(214, 178, 94, 0.32);
  border-radius: 6px;
  background: rgba(17, 20, 23, 0.72);
  padding: 6px 8px;
}

.battle-report span {
  display: block;
  max-width: none;
  color: var(--muted);
  font-size: 11px;
}

.lost-overlay button {
  width: min(220px, 100%);
  margin: 0 auto;
  border-color: var(--accent);
  background: #3a3120;
}

.chart-overlay {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(5, 8, 7, 0.76);
  backdrop-filter: blur(2px);
}

.chart-overlay[hidden] {
  display: none;
}

.chart-dialog {
  width: min(820px, 100%);
  border: 1px solid rgba(214, 178, 94, 0.42);
  border-radius: 6px;
  background: rgba(15, 22, 18, 0.96);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.45);
  padding: 14px;
}

.chart-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.chart-heading span {
  display: block;
  color: var(--gold);
  font-size: 11px;
  text-transform: uppercase;
}

.chart-heading strong {
  color: var(--text);
  font-size: 20px;
}

.chart-heading button {
  min-width: 72px;
}

#battleChart {
  width: 100%;
  height: auto;
  max-height: 48vh;
  border: 1px solid rgba(214, 178, 94, 0.18);
  border-radius: 4px;
  background: rgba(8, 12, 10, 0.72);
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
}

.chart-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.chart-legend i {
  width: 12px;
  height: 3px;
  border-radius: 999px;
}

.guard-info {
  border: 1px solid rgba(214, 178, 94, 0.32);
  border-radius: 6px;
  background: rgba(214, 178, 94, 0.08);
  color: #e9d8a3;
  font-size: 12px;
  line-height: 1.45;
  padding: 8px;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.swatch {
  width: 12px;
  height: 12px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  display: inline-block;
}

.swatch.core { background: #dfc35d; }
.swatch.wall { background: #8b8174; }
.swatch.tower { background: #b46a49; }
.swatch.road { background: #76664f; }
.swatch.outpost { background: #68a188; }
.swatch.gatherer { background: #9f8f54; }
.swatch.house { background: #9a7252; }
.swatch.lab { background: #7c6aa5; }
.swatch.resource { background: #f3d77b; }
.swatch.protected { background: rgba(180, 40, 48, 0.78); }
.swatch.pressure { background: rgba(214, 178, 94, 0.55); }
.swatch.enemy { background: #d9534f; }
.swatch.path { background: #faf0ad; }

.log {
  max-height: 315px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.log p {
  margin: 0;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

@media (max-width: 1080px) {
  .home-hero,
  .topbar,
  .workspace {
    grid-template-columns: 1fr;
  }

  .home-hero {
    min-height: 0;
    padding-top: 22px;
  }

  .hero-visual {
    min-height: 300px;
  }

  .field-report {
    grid-template-columns: 1fr;
  }

  .notice-grid,
  .how-grid,
  .roadmap-list {
    grid-template-columns: 1fr 1fr;
  }

  .hud {
    grid-template-columns: repeat(4, minmax(88px, 1fr));
  }

  .topbar-actions {
    flex-wrap: wrap;
  }
}

@media (max-width: 620px) {
  .site-header {
    align-items: flex-start;
  }

  .site-nav {
    flex-direction: column;
    align-items: stretch;
  }

  .site-nav a {
    justify-content: center;
    padding: 0 10px;
  }

  .hero-copy h1 {
    font-size: 36px;
  }

  .brand-logo {
    width: 124px;
    height: 34px;
  }

  .hero-logo {
    margin-top: 4px;
  }

  .hero-lede {
    font-size: 16px;
  }

  .primary-action,
  .secondary-action {
    width: 100%;
  }

  .notice-grid,
  .how-grid,
  .roadmap-list {
    grid-template-columns: 1fr;
  }

  .roadmap-item::before {
    display: none;
  }

  .play-cta {
    align-items: stretch;
    flex-direction: column;
  }

  .hero-status {
    grid-template-columns: 1fr;
  }

  .map-grid {
    inset: 26px 22px 118px;
  }

  .hud {
    grid-template-columns: repeat(2, minmax(88px, 1fr));
  }

  h1 {
    font-size: 23px;
  }

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

  .tool-grid button {
    grid-template-columns: 1fr;
  }

  .lost-overlay strong {
    font-size: 24px;
  }

  .lost-overlay span {
    font-size: 13px;
  }
}
