:root {
  color-scheme: dark;
  --ink: #071014;
  --ink-raised: #0b181b;
  --ink-panel: #102124;
  --line: rgba(221, 255, 228, 0.14);
  --line-bright: rgba(221, 255, 228, 0.26);
  --paper: #edf6e8;
  --muted: #8aa29a;
  --accent: #c7ff49;
  --accent-dim: rgba(199, 255, 73, 0.16);
  --shadow: rgba(1, 11, 13, 0.6);
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  background: var(--ink);
  color: var(--paper);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--ink);
}

body {
  min-width: 320px;
  min-height: 100dvh;
  margin: 0;
  background:
    radial-gradient(circle at 14% 16%, rgba(44, 106, 96, 0.18), transparent 26rem),
    radial-gradient(circle at 90% 8%, rgba(199, 255, 73, 0.08), transparent 24rem),
    var(--ink);
}

button,
a {
  font: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible,
a:focus-visible,
canvas:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}

.page-shell {
  width: min(1440px, calc(100% - 40px));
  min-height: 100dvh;
  margin: 0 auto;
  padding: 26px 0 20px;
}

.masthead,
.site-footer,
.game-topline,
.game-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.masthead {
  min-height: 40px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 18px;
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--paper);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-decoration: none;
}

.wordmark-mark {
  display: block;
  width: 12px;
  height: 12px;
  border: 2px solid var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.masthead-note,
.site-footer {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.main-stage {
  padding: 42px 0 54px;
}

.game-shell {
  overflow: hidden;
  border: 1px solid var(--line-bright);
  border-radius: 24px;
  background: var(--ink-raised);
  box-shadow: 0 30px 80px var(--shadow);
}

.game-topline {
  min-height: 48px;
  border-bottom: 1px solid var(--line);
  padding: 0 18px;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
  letter-spacing: 0.14em;
}

.game-status,
.energy-readout,
.control-line {
  display: flex;
  align-items: center;
}

.game-status {
  gap: 9px;
}

.status-spark {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 12px rgba(199, 255, 73, 0.75);
}

.text-button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.14em;
  padding: 7px 0;
}

.text-button:hover {
  color: var(--paper);
}

.game-board-wrap {
  position: relative;
  background: #081517;
}

#gameCanvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 5 / 3;
  background: #081517;
  touch-action: none;
}

.hud {
  position: absolute;
  z-index: 2;
  top: 18px;
  right: 18px;
  left: 18px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  pointer-events: none;
}

.hud-cell {
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid rgba(221, 255, 228, 0.16);
  border-radius: 12px;
  background: rgba(7, 16, 20, 0.66);
  backdrop-filter: blur(9px);
}

.hud-label,
.score-lockup span,
.best-line,
.eyebrow {
  display: block;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 9px;
  letter-spacing: 0.17em;
  text-transform: uppercase;
}

.hud-cell strong {
  display: block;
  margin-top: 5px;
  color: var(--paper);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 14px;
  font-weight: 600;
}

.energy-readout {
  gap: 10px;
}

.energy-bar {
  display: block;
  flex: 1;
  height: 4px;
  overflow: hidden;
  border-radius: 4px;
  background: rgba(221, 255, 228, 0.13);
}

.energy-bar i {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 160ms ease-out;
}

.game-screen {
  position: absolute;
  z-index: 3;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 32px;
  background: rgba(5, 15, 17, 0.62);
  opacity: 0;
  pointer-events: none;
  transition: opacity 260ms ease;
}

.game-screen.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.screen-copy {
  width: min(520px, 100%);
  padding: 34px;
  border: 1px solid rgba(221, 255, 228, 0.22);
  border-radius: 18px;
  background: rgba(10, 28, 30, 0.91);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.34);
  text-align: left;
}

.compact-copy {
  width: min(420px, 100%);
}

.eyebrow {
  margin: 0 0 15px;
  color: var(--accent);
}

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

h1,
h2 {
  margin-bottom: 14px;
  color: var(--paper);
  font-size: clamp(42px, 7vw, 84px);
  font-weight: 650;
  letter-spacing: -0.07em;
  line-height: 0.9;
}

h2 {
  font-size: clamp(34px, 5vw, 60px);
}

.lede {
  max-width: 33rem;
  margin-bottom: 26px;
  color: #b9c9bf;
  font-size: 15px;
  line-height: 1.55;
}

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  border: 1px solid var(--accent);
  border-radius: 12px;
  padding: 0 18px;
  background: var(--accent);
  color: #102014;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.11em;
}

.primary-button:hover {
  background: #e1ff8a;
  transform: translateY(-1px);
}

.primary-button:active {
  transform: translateY(1px) scale(0.98);
}

.control-line {
  flex-wrap: wrap;
  gap: 8px 14px;
  margin: 25px 0 0;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 9px;
  letter-spacing: 0.08em;
}

.control-line span {
  color: var(--paper);
}

.score-lockup {
  display: flex;
  align-items: baseline;
  gap: 14px;
  margin: 22px 0 8px;
}

.score-lockup strong {
  color: var(--accent);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 42px;
  font-weight: 600;
  letter-spacing: -0.06em;
}

.best-line {
  margin-bottom: 23px;
}

.game-footer {
  gap: 20px;
  min-height: 50px;
  border-top: 1px solid var(--line);
  padding: 0 18px;
  color: var(--muted);
  font-size: 11px;
}

.game-footer p {
  margin: 0;
}

.footer-key {
  flex: none;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: 0.1em;
}

.afterword {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(260px, 0.7fr);
  gap: 12vw;
  padding: 72px 4vw 10px;
}

.afterword h2 {
  max-width: 460px;
  margin-bottom: 0;
  font-size: clamp(34px, 5vw, 64px);
}

.afterword > p {
  max-width: 370px;
  margin: 35px 0 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.65;
}

.site-footer {
  border-top: 1px solid var(--line);
  padding-top: 15px;
}

.noscript {
  padding: 20px;
  color: var(--paper);
  text-align: center;
}

@media (max-width: 760px) {
  .page-shell {
    width: min(100% - 24px, 1440px);
    padding-top: 16px;
  }

  .masthead-note {
    display: none;
  }

  .main-stage {
    padding: 22px 0 34px;
  }

  .game-shell {
    border-radius: 18px;
  }

  .hud {
    top: 10px;
    right: 10px;
    left: 10px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .hud-cell {
    padding: 8px 10px;
  }

  .hud-cell strong {
    font-size: 12px;
  }

  .game-screen {
    padding: 16px;
  }

  .screen-copy {
    padding: 24px;
  }

  h1,
  h2 {
    font-size: clamp(36px, 14vw, 62px);
  }

  .game-footer {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
    padding: 13px 14px;
  }

  .afterword {
    grid-template-columns: 1fr;
    gap: 20px;
    padding: 54px 4px 0;
  }

  .afterword > p {
    margin-top: 0;
  }

  .site-footer {
    align-items: flex-start;
    flex-direction: column;
    gap: 7px;
    line-height: 1.5;
  }
}

@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;
  }
}
