:root {
  color-scheme: dark;
  --bg: #080a0f;
  --panel: #111820;
  --panel-strong: #17222b;
  --text: #f4ffe6;
  --muted: #9fb7b7;
  --green: #91f34d;
  --cyan: #48cae4;
  --amber: #f2c14e;
  --coral: #ef5d75;
  --border: #2c3942;
  --shadow: rgba(0, 0, 0, 0.42);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.025) 0 1px, transparent 1px 24px),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.018) 0 1px, transparent 1px 24px),
    var(--bg);
  color: var(--text);
  font-family: "Courier New", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

button,
select {
  font: inherit;
}

.game-shell {
  width: min(1180px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 12px;
}

.topbar,
.helpbar {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) auto minmax(160px, 1fr);
  align-items: center;
  gap: 14px;
  padding: 10px 12px;
  border: 2px solid var(--border);
  background: rgba(17, 24, 32, 0.94);
  box-shadow: 0 8px 24px var(--shadow);
}

.brand {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
}

.brand__title {
  color: var(--green);
  font-size: clamp(1.05rem, 2vw, 1.5rem);
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  text-shadow:
    -2px -2px 0 #0c1208,
    2px -2px 0 #0c1208,
    -2px 2px 0 #0c1208,
    2px 2px 0 #0c1208,
    0 3px 0 rgba(0, 0, 0, 0.4);
}

.brand__tag {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

.brand__link {
  color: var(--cyan);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  text-underline-offset: 3px;
}

.brand__link:focus-visible,
.brand__link:hover {
  color: var(--amber);
}

.area-picker {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
}

.area-picker select {
  width: 118px;
  min-height: 30px;
  border: 2px solid var(--border);
  border-radius: 4px;
  background: #0b1118;
  color: var(--text);
  font-weight: 900;
}

.hud {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.hud__item {
  display: inline-grid;
  gap: 2px;
  min-width: 74px;
  text-align: center;
}

.hud__label {
  color: var(--muted);
  font-size: 0.7rem;
  text-transform: uppercase;
}

.hud__value {
  color: var(--text);
  font-size: 1.1rem;
  font-weight: 900;
}

.health-meter {
  width: 150px;
  height: 12px;
  border: 2px solid #05070a;
  background: #26313a;
}

.health-meter__fill {
  display: block;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, var(--green), var(--amber), var(--coral));
}

.status {
  color: var(--cyan);
  justify-self: end;
  font-size: 0.9rem;
  text-transform: uppercase;
}

.game-stage {
  display: grid;
  min-height: 0;
  align-items: center;
}

.canvas-wrap {
  position: relative;
  width: min(100%, calc((100vh - 220px) * 16 / 9));
  min-width: 280px;
  aspect-ratio: 16 / 9;
  margin: 0 auto;
  border: 3px solid var(--border);
  background: #05070a;
  box-shadow: 0 18px 36px rgba(0, 0, 0, 0.48);
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: auto;
}

.helpbar {
  grid-template-columns: 1fr;
  color: var(--muted);
  font-size: 0.84rem;
  text-align: center;
}

.start-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(4, 6, 10, 0.86);
  z-index: 5;
}

.start-overlay.is-hidden {
  display: none;
}

.start-overlay__panel {
  display: grid;
  gap: 14px;
  padding: 22px 26px;
  border: 2px solid var(--border);
  background: rgba(17, 24, 32, 0.96);
  box-shadow: 0 18px 36px rgba(0, 0, 0, 0.48);
  text-align: center;
  max-width: min(92%, 420px);
}

.start-overlay__title {
  margin: 0;
  color: var(--green);
  font-size: 1.1rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.hero-picker {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.hero-card {
  display: grid;
  gap: 6px;
  justify-items: center;
  padding: 10px;
  border: 2px solid var(--border);
  border-radius: 6px;
  background: var(--panel-strong);
  color: var(--text);
  cursor: pointer;
}

.hero-card[aria-pressed="true"] {
  border-color: var(--amber);
  box-shadow: 0 0 0 2px rgba(242, 193, 78, 0.4);
}

.hero-card__swatch {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid #05070a;
}

.hero-card__name {
  font-size: 0.82rem;
  font-weight: 900;
  text-transform: uppercase;
}

.start-overlay__field {
  display: grid;
  gap: 6px;
  justify-items: center;
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

.start-overlay__field select {
  min-width: 140px;
  min-height: 32px;
  border: 2px solid var(--border);
  border-radius: 4px;
  background: #0b1118;
  color: var(--text);
  font-weight: 900;
}

.start-overlay__button {
  padding: 10px 18px;
  border: 2px solid var(--border);
  border-radius: 6px;
  background: var(--green);
  color: #080a0f;
  font-weight: 900;
  text-transform: uppercase;
  cursor: pointer;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 760px) {
  .game-shell {
    padding: 10px;
    gap: 10px;
  }

  .topbar {
    grid-template-columns: 1fr;
    justify-items: stretch;
    text-align: center;
  }

  .brand,
  .status {
    justify-content: center;
    justify-self: center;
  }

  .area-picker select {
    width: 132px;
  }

  .hud {
    flex-wrap: wrap;
    gap: 8px;
  }

  .canvas-wrap {
    width: 100%;
  }
}

@media (max-width: 420px) {
  .hud__item {
    min-width: 62px;
  }

  .health-meter {
    width: 118px;
  }

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