:root {
  color-scheme: dark;
  --ink: #090b0d;
  --surface: #111519;
  --surface-2: #181e23;
  --paper: #f2f0e9;
  --muted: #9ca5ab;
  --line: #30383e;
  --cyan: #38d9e6;
  --yellow: #f4d35e;
  --red: #ff5a5f;
  --green: #67d391;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--ink);
  color: var(--paper);
  font-family: "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  line-height: 1.6;
}

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

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

button {
  font: inherit;
}

.site-header {
  min-height: 76px;
  padding: 0 max(24px, calc((100vw - 1240px) / 2));
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  background: rgba(9, 11, 13, 0.92);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(14px);
}

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

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--cyan);
  color: var(--cyan);
  font-family: Consolas, monospace;
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
  letter-spacing: 0;
}

.brand strong {
  font-size: 15px;
}

.brand small {
  margin-top: -2px;
  color: var(--muted);
  font: 10px/1.2 Consolas, monospace;
}

nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

nav a {
  padding: 8px 12px;
  color: var(--muted);
  font-size: 14px;
}

nav a:hover,
nav a:focus-visible {
  color: var(--paper);
  background: var(--surface-2);
  outline: none;
}

.game-shell {
  width: min(1240px, calc(100% - 48px));
  margin: 0 auto;
  padding: 46px 0 68px;
}

.game-heading {
  margin-bottom: 24px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 36px;
}

.issue {
  margin: 0 0 8px;
  color: var(--cyan);
  font: 700 12px/1.2 Consolas, monospace;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(48px, 8vw, 96px);
  line-height: 0.95;
  letter-spacing: 0;
}

.game-tagline {
  max-width: 360px;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 16px;
  text-align: right;
}

.game-stage {
  position: relative;
  width: 100%;
  min-height: 520px;
  height: min(66vh, 720px);
  border: 1px solid var(--line);
  overflow: hidden;
  background: #080a0c;
  touch-action: none;
}

#gameCanvas {
  width: 100%;
  height: 100%;
  display: block;
}

.hud {
  position: absolute;
  top: 18px;
  left: 18px;
  right: 92px;
  display: flex;
  gap: 1px;
  pointer-events: none;
}

.hud-item {
  min-width: 94px;
  padding: 10px 14px;
  background: rgba(9, 11, 13, 0.84);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.hud-item span,
.hud-item strong {
  display: block;
}

.hud-item span {
  color: var(--muted);
  font: 10px/1.2 Consolas, monospace;
}

.hud-item strong {
  margin-top: 3px;
  font: 700 20px/1 Consolas, monospace;
}

.best-score {
  margin-left: auto;
}

.game-actions {
  position: absolute;
  top: 18px;
  right: 18px;
  display: flex;
  gap: 8px;
}

.icon-button {
  width: 38px;
  height: 38px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: var(--paper);
  background: rgba(9, 11, 13, 0.84);
  cursor: pointer;
}

.icon-button:hover,
.icon-button:focus-visible {
  border-color: var(--cyan);
  color: var(--cyan);
  outline: none;
}

.icon-button:disabled {
  opacity: 0.36;
  cursor: not-allowed;
}

.game-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(9, 11, 13, 0.7);
  opacity: 0;
  visibility: hidden;
  transition: opacity 180ms ease, visibility 180ms ease;
}

.game-overlay.is-visible {
  opacity: 1;
  visibility: visible;
}

.overlay-panel {
  width: min(460px, 100%);
  padding: 34px;
  border: 1px solid var(--line);
  background: var(--surface);
  text-align: center;
}

.overlay-panel h2 {
  margin-bottom: 22px;
  font-size: clamp(28px, 5vw, 44px);
  line-height: 1.15;
  letter-spacing: 0;
}

.control-guide {
  min-height: 38px;
  margin-bottom: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.control-guide i {
  width: 1px;
  height: 20px;
  margin: 0 4px;
  background: var(--line);
}

.keycap {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  color: var(--paper);
  font-family: Consolas, monospace;
}

.signal-swatch {
  width: 12px;
  height: 12px;
  display: inline-block;
}

.signal-swatch.good {
  background: var(--yellow);
}

.signal-swatch.bad {
  background: var(--red);
}

.primary-button {
  min-width: 154px;
  min-height: 48px;
  padding: 12px 22px;
  border: 1px solid var(--yellow);
  background: var(--yellow);
  color: #111;
  font-weight: 800;
  cursor: pointer;
}

.primary-button:hover,
.primary-button:focus-visible {
  background: transparent;
  color: var(--yellow);
  outline: none;
}

.touch-controls {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 18px;
  display: none;
  justify-content: space-between;
  pointer-events: none;
}

.touch-controls button {
  width: 68px;
  height: 54px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  color: var(--paper);
  background: rgba(9, 11, 13, 0.68);
  font-size: 22px;
  pointer-events: auto;
}

.touch-controls button:active {
  border-color: var(--cyan);
  color: var(--cyan);
}

.stage-caption {
  min-height: 46px;
  display: flex;
  align-items: center;
  gap: 22px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font: 11px/1.4 Consolas, monospace;
}

.stage-caption span:not(:last-child)::after {
  content: "/";
  margin-left: 22px;
  color: var(--line);
}

.content-section {
  width: min(1240px, calc(100% - 48px));
  margin: 0 auto;
  padding: 80px 0;
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 52px;
}

.section-label {
  color: var(--muted);
  font: 12px/1.4 Consolas, monospace;
}

.section-label span {
  color: var(--cyan);
}

.section-label p {
  margin: 8px 0 0;
}

.section-content > h2,
.about-grid h2 {
  max-width: 780px;
  margin-bottom: 42px;
  font-size: clamp(32px, 5vw, 58px);
  line-height: 1.12;
  letter-spacing: 0;
}

.log-entry {
  min-height: 104px;
  padding: 22px 0;
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr) 52px;
  align-items: start;
  gap: 28px;
}

.log-entry time {
  color: var(--muted);
  font: 12px/1.5 Consolas, monospace;
}

.log-entry h3 {
  margin-bottom: 6px;
  font-size: 18px;
}

.log-entry p {
  margin-bottom: 0;
  color: var(--muted);
}

.status {
  color: var(--green);
  font: 700 11px/1.5 Consolas, monospace;
  text-align: right;
}

.status.muted {
  color: var(--yellow);
}

.about-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(280px, 0.85fr);
  gap: 72px;
}

.about-grid h2 {
  margin-bottom: 24px;
}

.about-grid p {
  max-width: 680px;
  color: var(--muted);
  font-size: 17px;
}

.site-facts {
  margin: 0;
}

.site-facts div {
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 18px;
}

.site-facts dt {
  color: var(--muted);
}

.site-facts dd {
  margin: 0;
  font-weight: 700;
  text-align: right;
}

footer {
  width: min(1240px, calc(100% - 48px));
  min-height: 104px;
  margin: 0 auto;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  color: var(--muted);
  font-size: 13px;
}

footer p {
  margin: 0;
}

footer a:hover,
footer a:focus-visible {
  color: var(--cyan);
  outline: none;
}

@media (pointer: coarse), (max-width: 760px) {
  .touch-controls {
    display: flex;
  }
}

@media (max-width: 760px) {
  .site-header {
    min-height: 68px;
    padding-inline: 16px;
  }

  .brand strong {
    font-size: 14px;
  }

  nav {
    gap: 0;
  }

  nav a {
    padding: 8px;
    font-size: 13px;
  }

  .game-shell,
  .content-section,
  footer {
    width: min(100% - 28px, 1240px);
  }

  .game-shell {
    padding: 34px 0 52px;
  }

  .game-heading {
    display: block;
  }

  h1 {
    font-size: 54px;
  }

  .game-tagline {
    margin: 14px 0 0;
    text-align: left;
  }

  .game-stage {
    height: 66vh;
    min-height: 480px;
  }

  .hud {
    top: 12px;
    left: 12px;
    right: 12px;
    gap: 4px;
  }

  .hud-item {
    min-width: 0;
    flex: 1;
    padding: 8px;
  }

  .hud-item strong {
    font-size: 16px;
  }

  .best-score {
    display: none;
  }

  .game-actions {
    top: 64px;
    right: 12px;
  }

  .overlay-panel {
    padding: 26px 18px;
  }

  .control-guide {
    flex-wrap: wrap;
  }

  .stage-caption {
    gap: 10px;
    justify-content: space-between;
  }

  .stage-caption span:not(:last-child)::after {
    display: none;
  }

  .content-section {
    padding: 58px 0;
    grid-template-columns: 1fr;
    gap: 30px;
  }

  .section-label {
    display: flex;
    gap: 10px;
  }

  .section-label p {
    margin: 0;
  }

  .section-content > h2,
  .about-grid h2 {
    margin-bottom: 32px;
    font-size: 34px;
  }

  .log-entry {
    grid-template-columns: 1fr auto;
    gap: 8px 16px;
  }

  .log-entry time {
    grid-column: 1 / -1;
  }

  .about-grid {
    grid-template-columns: 1fr;
    gap: 32px;
  }
}

@media (max-width: 470px) {
  .brand small {
    display: none;
  }

  nav a:nth-child(2) {
    display: none;
  }

  .game-stage {
    min-height: 440px;
  }

  .stage-caption span:nth-child(2) {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .game-overlay {
    transition: none;
  }
}
