:root {
  --tile-face: #c2c2c2;
  --tile-shadow: #8f8f8f;
  --tile-highlight: #dedede;
  --tile-mid: #a3a3a3;
  --arm-red: #d22a1e;
  --arm-red-dark: #8c130c;
  --arm-blue: #2438d2;
  --arm-blue-dark: #101f8a;
  --atom-red: #d81c10;
  --field-black: #050505;
  --ink: #151515;
  --muted-ink: #4e4a45;
  --paper: #f5f2ea;
  --paper-deep: #e6e0d4;
  --line: #6f6a64;
  --max-page: 1180px;
  color-scheme: light;
  font-family:
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  scroll-behavior: smooth;
}

body {
  min-height: 100%;
  margin: 0;
  background:
    linear-gradient(90deg, rgba(143, 143, 143, 0.18) 1px, transparent 1px),
    linear-gradient(0deg, rgba(143, 143, 143, 0.14) 1px, transparent 1px),
    var(--paper);
  background-size: 20px 20px, 20px 20px, auto;
  color: var(--ink);
  font-size: 16px;
  line-height: 1.5;
  text-rendering: optimizeLegibility;
}

a {
  color: inherit;
  text-decoration-thickness: 2px;
  text-underline-offset: 0.18em;
}

main {
  width: min(100%, var(--max-page));
  margin: 0 auto;
  padding: 22px 20px 0;
  overflow-x: clip;
}

.play-section {
  display: grid;
  gap: 18px;
  align-content: start;
  padding-bottom: 30px;
}

.play-heading {
  display: grid;
  justify-items: center;
  gap: 7px;
  text-align: center;
}

.eyebrow {
  margin: 0;
  color: var(--arm-blue);
  font-size: 0.82rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  color: var(--field-black);
  font-weight: 950;
  letter-spacing: 0;
  line-height: 1.02;
}

h1 {
  font-size: 3.35rem;
}

.hero-logo {
  display: inline-flex;
  align-items: baseline;
  gap: 0.02em;
}

.hero-a {
  position: relative;
  display: inline-block;
  left: -0.03em;
  width: 0.72em;
  height: 1.04em;
  margin: 0 -0.06em;
  vertical-align: -0.18em;
}

.hero-a-leg,
.hero-a-bar {
  position: absolute;
  display: block;
  border: 0.035em solid var(--field-black);
  box-shadow: inset 0 0.035em 0 rgba(255, 255, 255, 0.35);
}

.hero-a-leg {
  bottom: 0;
  width: 0.18em;
  height: 0.98em;
  transform-origin: bottom center;
}

.hero-a-red {
  left: 0;
  background: var(--arm-red);
  transform: rotate(25deg);
}

.hero-a-blue {
  right: 0;
  background: var(--arm-blue);
  transform: rotate(-25deg);
}

.hero-a-bar {
  z-index: -1;
  left: 0.16em;
  top: 0.75em;
  width: 0.4em;
  height: 0.1em;
  background: var(--field-black);
  box-shadow: none;
}

h2 {
  font-size: 2rem;
}

.lede {
  max-width: 640px;
  margin: 0;
  color: var(--muted-ink);
  font-size: 1.08rem;
  font-weight: 650;
}

.wall-rule {
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: min(360px, 80vw);
  height: 12px;
  margin-top: 3px;
  border: 2px solid var(--field-black);
  background: var(--field-black);
}

.wall-rule span {
  display: block;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.42), inset 0 -3px 0 rgba(0, 0, 0, 0.34);
}

.wall-red {
  background: var(--arm-red);
}

.wall-blue {
  background: var(--arm-blue);
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: center;
}

.game-stage {
  display: grid;
  justify-items: center;
  min-width: 0;
  width: 100%;
}

#game-root {
  display: grid;
  width: min(100%, 822px);
  min-height: 240px;
  min-width: 0;
  place-items: center;
  padding: 8px;
  border: 3px solid var(--field-black);
  background:
    linear-gradient(135deg, var(--tile-highlight) 0 10px, transparent 10px),
    linear-gradient(315deg, var(--tile-shadow) 0 10px, transparent 10px),
    var(--tile-mid);
  box-shadow:
    inset 3px 3px 0 var(--tile-highlight),
    inset -3px -3px 0 var(--tile-shadow),
    0 6px 0 rgba(5, 5, 5, 0.14);
}

#game-root > canvas,
canvas.game-canvas {
  display: block;
  width: min(100%, 800px, calc((100svh - 18rem) * 1.3333333));
  min-width: 280px;
  max-width: 100%;
  height: auto;
  aspect-ratio: 4 / 3;
  border: 2px solid var(--field-black);
  background: #111;
  box-shadow: 0 0 0 3px var(--field-black);
}

.game-frame {
  position: relative;
  display: grid;
  width: 100%;
  border: 2px solid var(--field-black);
  background: var(--field-black);
  box-shadow:
    0 0 0 2px var(--tile-highlight),
    0 0 0 4px var(--field-black);
}

.game-hud,
.game-progress {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  color: #fff;
  background: var(--field-black);
  font-weight: 850;
}

.game-hud button,
.game-menu button,
.game-interstitial button {
  min-height: 36px;
  border: 2px solid var(--field-black);
  background: var(--tile-face);
  color: var(--field-black);
  font: inherit;
  font-weight: 900;
  box-shadow: inset 2px 2px 0 var(--tile-highlight), inset -2px -2px 0 var(--tile-shadow);
  cursor: pointer;
}

.game-hud button:active,
.game-menu button:active,
.game-interstitial button:active {
  box-shadow: inset 2px 2px 0 var(--tile-shadow), inset -2px -2px 0 var(--tile-highlight);
}

.game-progress {
  min-height: 38px;
}

.game-progress progress {
  flex: 1 1 auto;
  height: 16px;
  border: 2px solid var(--tile-highlight);
  background: var(--field-black);
  accent-color: var(--arm-blue);
}

.progress-label {
  min-width: 96px;
  text-align: right;
}

.game-menu,
.game-interstitial {
  position: absolute;
  inset: 10px;
  display: none;
  place-items: center;
  padding: 24px;
  background: rgba(5, 5, 5, 0.78);
  color: #fff;
  text-align: center;
}

#game-root[data-state="demo"] .game-menu,
#game-root[data-state="levelCleared"] .game-interstitial,
#game-root[data-state="gameOver"] .game-interstitial {
  display: grid;
}

.screenshots-section {
  display: grid;
  gap: 18px;
  padding: 32px 0 38px;
  border-top: 4px solid var(--field-black);
}

.compact-heading {
  max-width: 780px;
}

.compact-heading p:last-child {
  max-width: 66ch;
  margin: 0;
  color: var(--muted-ink);
  font-weight: 650;
}

.screenshot-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.screenshot-card {
  display: grid;
  gap: 10px;
  margin: 0;
  min-width: 0;
}

.screenshot-card time {
  color: var(--arm-red);
  font-size: 1.45rem;
  font-weight: 950;
  line-height: 1;
}

.screenshot-image {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: contain;
  image-rendering: pixelated;
  border: 3px solid var(--field-black);
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.06) 1px, transparent 1px),
    linear-gradient(0deg, rgba(255, 255, 255, 0.06) 1px, transparent 1px),
    #050505;
  background-size: 22px 22px;
  box-shadow:
    inset 0 0 0 4px #151515,
    0 4px 0 rgba(5, 5, 5, 0.2);
}

.screenshot-card figcaption {
  margin: 0;
  color: var(--muted-ink);
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1.3;
}

.screenshot-card a {
  color: var(--field-black);
  font-weight: 900;
}

.tech-section {
  display: grid;
  grid-template-columns: minmax(220px, 0.72fr) minmax(0, 1.28fr);
  gap: 24px;
  padding: 30px 0 36px;
  border-top: 4px solid var(--field-black);
}

.tech-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.tech-badge {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-height: 66px;
  padding: 10px;
  border: 2px solid var(--field-black);
  background: var(--tile-face);
  box-shadow: inset 3px 3px 0 var(--tile-highlight), inset -3px -3px 0 var(--tile-shadow);
  color: var(--field-black);
  font-weight: 900;
}

.tech-badge img {
  display: grid;
  width: 48px;
  height: 42px;
  padding: 7px;
  border: 2px solid var(--field-black);
  background: #fff;
  object-fit: contain;
}

.tech-badge span {
  min-width: 0;
  color: var(--muted-ink);
  font-size: 0.94rem;
  line-height: 1.15;
}

.tech-rust img {
  background: #fff0e8;
}

.tech-wasm img {
  background: #ede7ff;
}

.tech-ts img {
  background: #e7f0ff;
}

.section-heading {
  display: grid;
  align-content: start;
  gap: 7px;
}

.site-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: min(100%, var(--max-page));
  margin: 0 auto;
  padding: 18px 20px 28px;
  border-top: 2px solid var(--line);
  color: var(--muted-ink);
  font-size: 0.92rem;
  font-weight: 650;
}

.site-footer p {
  max-width: 760px;
  margin: 0;
}

.noscript {
  margin: 16px auto;
  padding: 10px 14px;
  width: min(100% - 40px, 620px);
  border: 2px solid var(--field-black);
  background: var(--tile-face);
  color: var(--field-black);
  font-weight: 800;
}

@media (max-width: 860px) {
  main {
    padding: 18px 14px 0;
  }

  h1 {
    font-size: 2.6rem;
  }

  h2 {
    font-size: 1.65rem;
  }

  .tech-section {
    grid-template-columns: 1fr;
  }

  .screenshot-grid,
  .tech-strip {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  main {
    overflow-x: hidden;
  }

  h1 {
    font-size: 2.15rem;
  }

  .lede {
    font-size: 1rem;
  }

  #game-root {
    width: 100%;
    padding: 7px;
    border-width: 3px;
  }

  #game-root > canvas,
  canvas.game-canvas {
    min-width: 0;
    width: 100%;
  }

  .site-footer {
    display: grid;
  }
}

/* WS13–WS15 game shell: DOM HUD/chrome over a DPR-scaled canvas field. */
.game-root-shell {
  position: relative;
}

.game-root-shell .game-frame {
  position: relative;
  display: grid;
  grid-template-rows: auto var(--field-height, auto) auto;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
  border: 2px solid var(--field-black);
  background: var(--field-black);
  box-shadow:
    0 0 0 2px var(--tile-highlight),
    0 0 0 4px var(--field-black),
    inset 0 0 0 1px var(--tile-shadow);
  isolation: isolate;
  touch-action: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
}

.game-frame > canvas.game-canvas {
  position: relative;
  z-index: 1;
  display: block;
  grid-row: 2;
  min-width: 0;
  max-width: none;
  border: 0;
  aspect-ratio: auto;
  background: #000;
  box-shadow: none;
  cursor: crosshair;
  touch-action: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
}

.game-hud,
.game-progress {
  position: relative;
  z-index: 3;
  min-height: 36px;
  padding: 6px 10px;
  pointer-events: auto;
}

.game-hud {
  grid-row: 1;
  border-bottom: 2px solid var(--tile-shadow);
}

.game-progress {
  grid-row: 3;
  border-top: 2px solid var(--tile-shadow);
}

.hud-group {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.hud-level,
.hud-difficulty,
.hud-lives {
  white-space: nowrap;
}

.hud-difficulty {
  color: #d7d7d7;
}

.hud-lives {
  color: #fff;
  letter-spacing: 0.08em;
}

.game-close {
  display: none;
}

.game-progress .progress-track {
  position: relative;
  flex: 1 1 auto;
  height: 16px;
  min-width: 64px;
  border: 2px solid var(--tile-highlight);
  background: #101010;
  box-shadow: inset 0 0 0 1px #000;
}

.game-progress .progress-fill {
  width: var(--capture, 0%);
  height: 100%;
  background: linear-gradient(90deg, var(--arm-red), var(--arm-blue));
}

.game-progress .progress-threshold {
  position: absolute;
  top: -5px;
  bottom: -5px;
  left: var(--target, 75%);
  width: 2px;
  background: #fff;
  box-shadow: 0 0 0 1px #000;
}

.game-menu,
.game-interstitial {
  inset: 0;
  z-index: 5;
  padding: clamp(14px, 4vw, 32px);
  pointer-events: auto;
}

.game-menu-panel,
.game-interstitial-panel {
  display: grid;
  width: min(100%, 520px);
  gap: 16px;
  padding: clamp(18px, 4vw, 28px);
  border: 3px solid var(--tile-highlight);
  background: rgba(0, 0, 0, 0.92);
  box-shadow: 0 0 0 3px var(--field-black), inset 0 4px 0 rgba(255, 255, 255, 0.12);
}

.primary-action {
  min-height: 52px;
  padding: 10px 18px;
  font-size: 1.25rem;
}

.difficulty-block {
  display: grid;
  gap: 8px;
}

.control-label {
  color: #d7d7d7;
  font-size: 0.8rem;
  font-weight: 900;
  text-transform: uppercase;
}

.difficulty-options {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.difficulty-option {
  min-width: 0;
  padding: 7px 8px;
}

.difficulty-option.is-selected {
  background: linear-gradient(180deg, #fff, var(--tile-face));
  box-shadow: inset 2px 2px 0 #fff, inset -2px -2px 0 var(--arm-blue);
}

.difficulty-description,
.how-to-play p,
.interstitial-copy p {
  margin: 0;
  color: #ddd;
}

.how-to-play {
  color: #fff;
  text-align: left;
}

.how-to-play summary {
  cursor: pointer;
  font-weight: 900;
}

.interstitial-title {
  margin: 0;
  color: #fff;
  font-size: clamp(1.7rem, 4vw, 2.35rem);
}

.interstitial-copy,
.interstitial-actions {
  display: grid;
  gap: 8px;
}

.interstitial-actions {
  grid-template-columns: 1fr;
}

.game-toast {
  position: absolute;
  top: 48px;
  left: 50%;
  z-index: 6;
  padding: 6px 12px;
  border: 2px solid #fff;
  background: rgba(120, 0, 0, 0.9);
  color: #fff;
  font-weight: 900;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -8px);
  transition: opacity 120ms ease, transform 120ms ease;
}

.game-toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 640px) {
  .difficulty-options {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .hud-primary,
  .hud-secondary {
    gap: 8px;
  }

  .hud-difficulty {
    display: none;
  }
}

@media (pointer: coarse) and (max-width: 900px) {
  body.game-active {
    overflow: hidden;
    touch-action: none;
  }

  body.game-active #game-root {
    position: fixed;
    inset: 0;
    z-index: 1000;
    width: 100vw;
    height: 100dvh;
    min-height: 100dvh;
    padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
    border: 0;
    background: #000;
    box-shadow: none;
  }

  body.game-active .game-frame {
    max-width: none;
  }

  body.game-active .game-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .game-hud button,
  .game-menu button,
  .game-interstitial button {
    min-height: 44px;
  }

  .game-menu-panel,
  .game-interstitial-panel {
    max-height: calc(100dvh - 28px);
    overflow: auto;
  }
}
