:root {
  color-scheme: dark;
  --bg: #05070b;
  --panel: #10131c;
  --panel-2: #161b26;
  --line: rgba(132, 255, 184, 0.25);
  --text: #f4ffe8;
  --muted: #a9b7ac;
  --green: #7cff6b;
  --cyan: #4df1ff;
  --amber: #ffd35a;
  --red: #ff615e;
  --shadow: 0 22px 80px rgba(0, 0, 0, 0.55);
}

* {
  box-sizing: border-box;
}

html {
  max-width: 100%;
  scroll-behavior: smooth;
  overflow-x: hidden;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at 20% 10%, rgba(77, 241, 255, 0.12), transparent 24rem),
    radial-gradient(circle at 80% 20%, rgba(124, 255, 107, 0.1), transparent 22rem),
    linear-gradient(135deg, #05070b 0%, #0b0d13 50%, #070a0b 100%);
  color: var(--text);
  font-family: "Courier New", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  line-height: 1.5;
  overflow-x: hidden;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  content: "";
  background:
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.035) 0 1px, transparent 1px 4px),
    radial-gradient(circle, rgba(255, 255, 255, 0.55) 0 1px, transparent 1.5px);
  background-size: auto, 120px 120px;
  opacity: 0.35;
  mix-blend-mode: screen;
}

a {
  color: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible {
  outline: 3px solid var(--amber);
  outline-offset: 4px;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem clamp(1rem, 4vw, 3rem);
  border-bottom: 2px solid var(--line);
  background: rgba(5, 7, 11, 0.84);
  backdrop-filter: blur(12px);
}

.brand,
.site-nav {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.brand {
  color: var(--green);
  font-weight: 900;
  text-decoration: none;
  text-transform: uppercase;
}

.brand-mark {
  display: grid;
  width: 2.35rem;
  height: 2.35rem;
  place-items: center;
  border: 2px solid var(--green);
  background: #07120d;
  color: var(--green);
  box-shadow: 0 0 18px rgba(124, 255, 107, 0.28);
}

.site-nav a {
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
  text-decoration: none;
  text-transform: uppercase;
}

.site-nav a:hover {
  color: var(--cyan);
}

main {
  position: relative;
  z-index: 1;
}

.hero,
.game-section,
.controls-section {
  width: min(1180px, calc(100% - 2rem));
  margin: 0 auto;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(320px, 1fr);
  gap: clamp(2rem, 6vw, 4.5rem);
  align-items: center;
  min-height: calc(100vh - 4.5rem);
  padding: clamp(3rem, 8vw, 6.5rem) 0 clamp(2rem, 5vw, 3rem);
}

.eyebrow {
  margin: 0 0 0.75rem;
  color: var(--amber);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

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

h1 {
  max-width: 10ch;
  margin-bottom: 1.1rem;
  color: var(--green);
  font-size: clamp(3.6rem, 9vw, 8rem);
  line-height: 0.88;
  letter-spacing: 0;
  text-shadow: 0 0 18px rgba(124, 255, 107, 0.38);
  text-transform: uppercase;
}

h2 {
  margin-bottom: 0.8rem;
  font-size: clamp(1.8rem, 3.8vw, 3.2rem);
  line-height: 1;
  letter-spacing: 0;
  text-transform: uppercase;
}

h3 {
  margin-bottom: 0.65rem;
  font-size: 1.15rem;
  letter-spacing: 0;
  text-transform: uppercase;
}

.hero-lede,
.hero-note,
.section-heading p,
.sync-section p,
.about-section p,
.control-card p {
  max-width: 65ch;
  color: var(--muted);
  font-size: 1.02rem;
}

.hero-note {
  max-width: 38rem;
}

.button,
.icon-button,
.control-button {
  border: 2px solid var(--green);
  border-radius: 0;
  background: #07120d;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-weight: 900;
  text-decoration: none;
  text-transform: uppercase;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.75), 0 0 22px rgba(124, 255, 107, 0.18);
  transition:
    transform 120ms ease,
    border-color 120ms ease,
    color 120ms ease,
    background 120ms ease;
}

.button:hover,
.icon-button:hover,
.control-button:hover {
  transform: translateY(-2px);
  border-color: var(--cyan);
  color: var(--cyan);
}

.button:disabled,
.icon-button:disabled,
.control-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  transform: none;
  border-color: rgba(132, 255, 184, 0.34);
  color: rgba(244, 255, 232, 0.5);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 3.15rem;
  padding: 0.85rem 1.15rem;
}

.button.primary,
.control-button.fire {
  border-color: var(--amber);
  background: #1a1405;
  color: var(--amber);
}

.control-button.bomb {
  border-color: #ff615e;
  background: #180808;
  color: #ffd35a;
}

.hero-screen {
  position: relative;
  min-height: clamp(23rem, 43vw, 34rem);
  border: 3px solid var(--green);
  background:
    linear-gradient(rgba(124, 255, 107, 0.04) 2px, transparent 2px),
    linear-gradient(90deg, rgba(124, 255, 107, 0.04) 2px, transparent 2px),
    #070a10;
  background-size: 32px 32px, 32px 32px, auto;
  box-shadow: var(--shadow), inset 0 0 42px rgba(124, 255, 107, 0.12);
  overflow: hidden;
}

.scanline-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.06) 0 1px, transparent 1px 5px);
}

.pixel-star {
  position: absolute;
  width: 8px;
  height: 8px;
  background: var(--cyan);
  box-shadow: 0 0 12px var(--cyan);
}

.pixel-star.s1 {
  left: 18%;
  top: 16%;
}

.pixel-star.s2 {
  left: 78%;
  top: 21%;
  background: var(--amber);
}

.pixel-star.s3 {
  left: 62%;
  top: 70%;
}

.pixel-meteor {
  position: absolute;
  width: 48px;
  height: 48px;
  background:
    linear-gradient(90deg, transparent 0 8px, #76644f 8px 40px, transparent 40px),
    linear-gradient(#9d876c 0 8px, #b79c74 8px 36px, #5f5145 36px 48px);
  box-shadow: 0 0 18px rgba(255, 211, 90, 0.25);
}

.pixel-meteor.m1 {
  left: 18%;
  top: 25%;
  transform: rotate(18deg);
}

.pixel-meteor.m2 {
  right: 18%;
  top: 48%;
  width: 34px;
  height: 34px;
  transform: rotate(-22deg);
}

.pixel-cannon {
  position: absolute;
  left: 50%;
  bottom: 18%;
  width: 0;
  height: 0;
  border-left: 28px solid transparent;
  border-right: 28px solid transparent;
  border-bottom: 78px solid var(--green);
  transform: translateX(-50%) rotate(17deg);
  filter: drop-shadow(0 0 15px rgba(124, 255, 107, 0.5));
}

.pixel-shot {
  position: absolute;
  left: 57%;
  bottom: 45%;
  width: 8px;
  height: 44px;
  background: var(--cyan);
  box-shadow: 0 0 16px var(--cyan);
  transform: rotate(17deg);
}

.game-section,
.controls-section {
  padding: clamp(3rem, 8vw, 5rem) 0;
}

.section-heading {
  margin-bottom: 1.25rem;
}

.game-shell {
  border: 3px solid var(--green);
  background: var(--panel);
  box-shadow: var(--shadow), inset 0 0 42px rgba(124, 255, 107, 0.1);
  overflow: hidden;
  touch-action: manipulation;
}

.game-toolbar {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-auto-rows: 3.35rem;
  gap: 2px;
  border-bottom: 3px solid var(--green);
  background: var(--green);
}

.stat {
  display: grid;
  grid-template-rows: 0.8rem minmax(0, 1fr);
  align-content: center;
  min-width: 0;
  min-height: 0;
  padding: 0.42rem 0.55rem;
  overflow: hidden;
  background: #08100d;
}

.stat span {
  display: block;
  color: var(--muted);
  font-size: 0.58rem;
  font-weight: 900;
  line-height: 1;
  text-transform: uppercase;
}

.stat strong {
  display: block;
  min-width: 0;
  overflow: hidden;
  color: var(--green);
  font-size: 1rem;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-shadow: 0 0 12px rgba(124, 255, 107, 0.3);
}

.loadout-value {
  display: flex;
  height: 2.3rem;
  max-height: 2.3rem;
  align-items: center;
  justify-content: flex-start;
  color: var(--amber);
  font-size: 0.92rem;
  line-height: 1.05;
  white-space: pre-line;
  text-overflow: clip;
}

.canvas-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  min-height: 29rem;
  background: #05070b;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  background: #05070b;
  image-rendering: pixelated;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.game-overlay {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(5, 7, 11, 0.76);
}

.game-overlay.is-visible {
  display: flex;
}

.overlay-panel {
  width: min(35rem, 100%);
  padding: clamp(1.2rem, 4vw, 2rem);
  border: 3px solid var(--amber);
  background: #0b0d13;
  box-shadow: 0 0 0 4px rgba(0, 0, 0, 0.65), 0 0 34px rgba(255, 211, 90, 0.22);
  text-align: center;
}

.score-panel {
  width: min(44rem, 100%);
}

.overlay-panel p {
  color: var(--muted);
}

.mission-list {
  display: grid;
  gap: 0.35rem;
  margin: 0.85rem auto 1rem;
  padding: 0;
  color: var(--muted);
  font-size: 0.9rem;
  list-style: none;
  text-align: left;
}

.mission-list li::before {
  color: var(--amber);
  content: "> ";
  font-weight: 900;
}

.mode-select {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
  margin: 0.9rem 0 0.85rem;
}

.mode-card {
  min-width: 0;
  min-height: 4.7rem;
  padding: 0.65rem;
  border: 2px solid rgba(132, 255, 184, 0.24);
  background: #07120d;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  text-align: left;
  touch-action: manipulation;
}

.mode-card strong,
.mode-card span {
  display: block;
}

.mode-card strong {
  color: var(--green);
  font-size: 0.82rem;
  text-transform: uppercase;
}

.mode-card span {
  margin-top: 0.28rem;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.25;
}

.mode-card.is-selected {
  border-color: var(--amber);
  background: #1a1405;
  box-shadow: 0 0 18px rgba(255, 211, 90, 0.14);
}

.board-label {
  margin: 0.75rem 0 0;
  color: var(--amber);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.score-form {
  display: grid;
  gap: 0.45rem;
  margin: 0.8rem auto 0;
  text-align: left;
}

.score-form label {
  color: var(--amber);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.score-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.55rem;
  align-items: stretch;
}

.score-input {
  min-width: 0;
  min-height: 3.15rem;
  padding: 0.75rem 0.85rem;
  border: 2px solid rgba(132, 255, 184, 0.42);
  border-radius: 0;
  background: #05090d;
  color: var(--text);
  font: inherit;
  font-weight: 900;
  text-transform: uppercase;
  outline: none;
}

.score-input:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 16px rgba(77, 241, 255, 0.18);
}

.status-line {
  min-height: 1.15rem;
  margin: 0;
  font-size: 0.78rem;
}

.status-line[data-tone="ok"] {
  color: var(--green);
}

.status-line[data-tone="error"] {
  color: var(--red);
}

.leaderboard {
  display: grid;
  gap: 0.35rem;
  margin: 1rem auto 0;
  padding: 0;
  list-style: none;
  text-align: left;
}

.leaderboard.compact {
  max-height: 16rem;
  overflow: auto;
}

.leaderboard li {
  display: grid;
  grid-template-columns: 2.5rem 1fr auto auto;
  gap: 0.65rem;
  align-items: center;
  min-width: 0;
  padding: 0.45rem 0.55rem;
  border: 2px solid rgba(132, 255, 184, 0.18);
  background: rgba(7, 18, 13, 0.8);
  color: var(--muted);
  font-size: 0.9rem;
}

.leaderboard li.is-player {
  border-color: var(--amber);
  color: var(--text);
  background: rgba(255, 211, 90, 0.1);
  box-shadow: 0 0 18px rgba(255, 211, 90, 0.14);
}

.leaderboard .rank,
.leaderboard .score,
.leaderboard .tag {
  color: var(--green);
  font-weight: 900;
}

.leaderboard .name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leaderboard .tag {
  color: var(--amber);
  font-size: 0.76rem;
}

.overlay-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.8rem;
  margin-top: 1rem;
}

.action-bar,
.mobile-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem;
  border-top: 3px solid var(--line);
  background: #090d12;
}

.action-bar {
  justify-content: flex-end;
}

.icon-button {
  min-width: 6.4rem;
  min-height: 2.8rem;
  padding: 0.55rem 0.8rem;
}

.icon-button[aria-pressed="true"] {
  border-color: var(--amber);
  color: var(--amber);
}

.mobile-controls {
  display: none;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.control-group {
  display: grid;
  gap: 0.55rem;
  min-width: 0;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.action-controls {
  grid-template-columns: minmax(0, 1fr) 4.4rem;
  align-items: center;
}

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

.control-button {
  min-height: 4.2rem;
  padding: 0.78rem 0.55rem;
  font-size: 0.98rem;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.control-button.fire {
  font-size: 1.08rem;
}

.control-button.bomb {
  font-size: 0.82rem;
}

.control-button.direction {
  border-color: var(--cyan);
  background: #071016;
  color: var(--cyan);
  font-size: 1.4rem;
  line-height: 1;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.75), inset 0 -8px 0 rgba(77, 241, 255, 0.08), 0 0 22px rgba(77, 241, 255, 0.16);
}

.controls-section {
  display: grid;
  grid-template-columns: 0.75fr 1.25fr;
  gap: 1.25rem;
  align-items: start;
}

.control-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
  gap: 1rem;
}

.control-card {
  min-height: 12rem;
  padding: 1rem;
  border: 2px solid var(--line);
  background: rgba(16, 19, 28, 0.82);
}

.sync-section,
.about-section {
  display: grid;
  grid-template-columns: 0.8fr 1.2fr;
  gap: 1.5rem;
  width: 100%;
  padding: clamp(3rem, 7vw, 5rem) max(1rem, calc((100vw - 1180px) / 2));
  border-block: 3px solid var(--line);
  background: rgba(124, 255, 107, 0.045);
}

.about-section {
  border-top: 0;
  background: rgba(16, 19, 28, 0.54);
}

.site-footer {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1rem;
  padding: 2rem clamp(1rem, 4vw, 3rem);
  border-top: 2px solid var(--line);
  color: var(--muted);
}

kbd {
  display: inline-block;
  min-width: 1.65rem;
  padding: 0.05rem 0.35rem;
  border: 2px solid var(--line);
  background: #070a10;
  color: var(--green);
  font: inherit;
  font-size: 0.86em;
  font-weight: 900;
  text-align: center;
}

@media (max-width: 920px) {
  .hero,
  .controls-section,
  .sync-section,
  .about-section {
    grid-template-columns: 1fr;
  }

  .hero {
    min-height: auto;
  }

  .game-toolbar {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

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

@media (max-width: 620px) {
  .hero,
  .game-section,
  .controls-section {
    width: min(100% - 0.75rem, 1180px);
  }

  .site-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.6rem;
    padding: 0.75rem;
  }

  .site-nav {
    width: 100%;
    justify-content: space-between;
  }

  h1 {
    font-size: clamp(3.1rem, 16vw, 4.9rem);
  }

  .button {
    width: 100%;
  }

  .game-section,
  .controls-section {
    padding: 2rem 0;
  }

  .game-section {
    padding-top: 0.8rem;
  }

  .game-section .section-heading {
    margin-bottom: 0.55rem;
  }

  .game-section .section-heading p {
    font-size: 0.9rem;
  }

  .game-shell {
    border-width: 2px;
  }

  .game-toolbar {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-auto-rows: 2.75rem;
    gap: 1px;
  }

  .stat {
    min-width: 0;
    padding: 0.28rem 0.32rem;
  }

  .stat span {
    font-size: 0.48rem;
  }

  .stat strong {
    font-size: 0.76rem;
  }

  .loadout-value {
    height: 1.7rem;
    max-height: 1.7rem;
    font-size: 0.62rem;
    line-height: 1.02;
  }

  .canvas-wrap {
    aspect-ratio: auto;
    height: clamp(22rem, 48vh, 28rem);
    min-height: 22rem;
  }

  .action-bar {
    position: relative;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1.15rem;
    padding: 1.25rem 0.55rem 0.58rem;
    border-top: 0;
    background: rgba(9, 13, 18, 0.9);
  }

  .action-bar::before {
    content: "";
    position: absolute;
    top: 0.34rem;
    left: 1rem;
    right: 1rem;
    height: 3px;
    background:
      linear-gradient(90deg, transparent, rgba(77, 241, 255, 0.28), rgba(132, 255, 184, 0.92), rgba(255, 211, 90, 0.42), transparent);
    box-shadow: 0 0 10px rgba(77, 241, 255, 0.55), 0 0 16px rgba(132, 255, 184, 0.32);
    opacity: 0.92;
  }

  .icon-button {
    min-width: 0;
    min-height: 2.55rem;
    flex: 1;
    padding: 0.4rem 0.32rem;
    font-size: 0.72rem;
    color: var(--muted);
    background: rgba(7, 10, 16, 0.82);
  }

  .mobile-controls {
    display: grid;
    grid-template-columns: minmax(0, 1.32fr) minmax(0, 1fr);
    gap: 0.6rem;
    padding: 0.55rem;
  }

  .control-group {
    gap: 0.45rem;
  }

  .control-button {
    min-height: 4rem;
    padding: 0.55rem 0.25rem;
    font-size: 0.88rem;
  }

  .control-button.fire {
    min-height: 4.35rem;
    font-size: 1.02rem;
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.75), inset 0 -9px 0 rgba(255, 211, 90, 0.1), 0 0 24px rgba(255, 211, 90, 0.2);
  }

  .control-button.bomb {
    width: 3.15rem;
    min-width: 3.15rem;
    min-height: 3.15rem;
    height: 3.15rem;
    justify-self: center;
    align-self: center;
    padding: 0;
    border-radius: 999px;
    border-color: var(--red);
    background: #240607;
    color: #ffd35a;
    font-size: 0.58rem;
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.75), inset 0 -7px 0 rgba(0, 0, 0, 0.28), 0 0 18px rgba(255, 97, 94, 0.2);
  }

  .control-button.direction {
    min-height: 4.15rem;
    font-size: 1.45rem;
  }

  .overlay-panel {
    max-height: calc(100% - 1rem);
    overflow: auto;
    padding: 0.72rem;
  }

  .overlay-panel h3 {
    font-size: 1rem;
    line-height: 1.18;
    margin: 0.2rem 0 0.55rem;
  }

  .mission-list {
    gap: 0.2rem;
    margin: 0.45rem auto 0.7rem;
    font-size: 0.78rem;
    line-height: 1.2;
  }

  .mode-select {
    gap: 0.45rem;
    margin: 0.55rem 0 0.55rem;
  }

  .mode-card {
    min-height: 3.9rem;
    padding: 0.48rem;
  }

  .mode-card strong {
    font-size: 0.68rem;
  }

  .mode-card span {
    font-size: 0.64rem;
    line-height: 1.18;
  }

  .overlay-actions .button {
    min-height: 2.9rem;
  }

  .score-row {
    grid-template-columns: 1fr;
    gap: 0.45rem;
  }

  .score-input {
    min-height: 2.8rem;
    font-size: 0.85rem;
  }

  .leaderboard li {
    grid-template-columns: 2rem 1fr auto;
    gap: 0.45rem;
    font-size: 0.8rem;
  }

  .leaderboard .tag {
    display: none;
  }
}

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