:root {
  color-scheme: dark;
  --ink: #f8f1df;
  --muted: #afa8b8;
  --night: #120f1d;
  --panel: #1b1628;
  --line: #3a3047;
  --gold: #f7c948;
  --orange: #f0783c;
  --blue: #58c7d7;
  --blue-dark: #153f51;
  --red: #ed4e5c;
  --red-dark: #561e32;
  --green: #53dd83;
  --shadow: #09070f;
  font-family: "Courier New", Courier, monospace;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

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

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(rgba(247, 201, 72, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(247, 201, 72, 0.035) 1px, transparent 1px),
    radial-gradient(circle at 50% -20%, #332647 0, var(--night) 55%);
  background-size: 24px 24px, 24px 24px, auto;
}

button,
a {
  font: inherit;
}

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

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 54px;
  margin-bottom: 18px;
  border-bottom: 2px solid var(--line);
}

.brand {
  display: inline-flex;
  gap: 10px;
  align-items: center;
  color: var(--ink);
  font-weight: 800;
  letter-spacing: 0.08em;
  text-decoration: none;
}

.brand-mark {
  color: var(--gold);
  font-size: 1.4rem;
}

.topbar-meta {
  display: flex;
  gap: 10px;
  align-items: center;
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
}

#best-reaction {
  color: var(--gold);
  font-weight: 800;
}

.language-chip {
  margin-left: 12px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  color: var(--ink);
}

.game-card {
  overflow: hidden;
  border: 3px solid var(--ink);
  background: var(--panel);
  box-shadow: 10px 10px 0 var(--shadow);
}

.scoreboard {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  min-height: 108px;
  border-bottom: 3px solid var(--ink);
}

.player-score {
  display: grid;
  grid-template-columns: auto auto auto;
  gap: 18px;
  align-items: center;
  padding: 18px 28px;
}

.player-two-score {
  justify-content: end;
}

.player-label,
.round-status {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.player-score strong {
  font-size: clamp(2.4rem, 6vw, 4.5rem);
  line-height: 0.8;
}

.player-one-score strong {
  color: var(--blue);
}

.player-two-score strong {
  color: var(--red);
}

kbd {
  display: inline-grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 2px solid var(--line);
  border-bottom-width: 5px;
  background: #241d33;
  color: var(--ink);
  font: inherit;
  font-weight: 800;
}

.round-status {
  display: grid;
  gap: 8px;
  min-width: 124px;
  place-items: center;
  color: var(--muted);
}

.round-pips {
  color: var(--gold);
  font-size: 1.3rem;
  letter-spacing: 0.18em;
}

.arena {
  position: relative;
  display: grid;
  grid-template-columns: minmax(112px, 0.6fr) minmax(360px, 2.3fr) minmax(112px, 0.6fr);
  min-height: 510px;
  overflow: hidden;
  background:
    linear-gradient(180deg, transparent 66%, rgba(0, 0, 0, 0.25) 66%),
    repeating-linear-gradient(90deg, transparent 0 44px, rgba(255, 255, 255, 0.018) 44px 46px);
  isolation: isolate;
}

.arena::before,
.arena::after {
  position: absolute;
  bottom: 0;
  z-index: -1;
  width: 32%;
  height: 18%;
  content: "";
  background: #271d34;
  clip-path: polygon(0 50%, 15% 50%, 15% 18%, 27% 18%, 27% 55%, 41% 55%, 41% 0, 54% 0, 54% 56%, 70% 56%, 70% 30%, 84% 30%, 84% 65%, 100% 65%, 100% 100%, 0 100%);
}

.arena::before {
  left: 0;
}

.arena::after {
  right: 0;
  transform: scaleX(-1);
}

.touch-zone {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  justify-content: center;
  border: 0;
  color: var(--ink);
  cursor: pointer;
  opacity: 0.78;
  touch-action: manipulation;
  user-select: none;
}

.touch-zone:focus-visible {
  z-index: 4;
  outline: 4px solid var(--gold);
  outline-offset: -8px;
}

.touch-zone-one {
  border-right: 2px solid var(--line);
  background: linear-gradient(90deg, var(--blue-dark), rgba(21, 63, 81, 0.18));
}

.touch-zone-two {
  border-left: 2px solid var(--line);
  background: linear-gradient(270deg, var(--red-dark), rgba(86, 30, 50, 0.18));
}

.zone-player {
  font-size: clamp(1.5rem, 4vw, 2.6rem);
  font-weight: 900;
}

.zone-key {
  width: 48px;
  height: 48px;
  border-color: var(--ink);
  background: var(--night);
  font-size: 1.4rem;
  box-shadow: 4px 4px 0 var(--shadow);
}

.zone-action {
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.1em;
}

.arena-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 56px 30px;
  text-align: center;
}

.eyebrow,
.section-kicker {
  margin: 0 0 14px;
  color: var(--gold);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.16em;
}

h1 {
  max-width: 680px;
  margin: 0;
  font-size: clamp(2.8rem, 8vw, 6.5rem);
  line-height: 0.88;
  letter-spacing: -0.08em;
  text-wrap: balance;
  text-shadow: 5px 5px 0 #5b2a38;
}

.status-copy {
  max-width: 560px;
  min-height: 54px;
  margin: 24px 0 22px;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 1rem;
  line-height: 1.6;
}

.signal {
  display: flex;
  gap: 10px;
  height: 22px;
  margin-bottom: 26px;
}

.signal span {
  width: 18px;
  height: 18px;
  border: 2px solid var(--line);
  background: #30283d;
  box-shadow: 3px 3px 0 var(--shadow);
}

.primary-button {
  min-width: 210px;
  min-height: 56px;
  padding: 16px 24px;
  border: 3px solid var(--ink);
  border-radius: 0;
  background: var(--gold);
  box-shadow: 6px 6px 0 var(--shadow);
  color: #21190e;
  cursor: pointer;
  font-weight: 900;
  letter-spacing: 0.08em;
  transition: transform 90ms ease, box-shadow 90ms ease, background 120ms ease;
}

.primary-button:hover {
  background: #ffe073;
}

.primary-button:active {
  transform: translate(4px, 4px);
  box-shadow: 2px 2px 0 var(--shadow);
}

.primary-button:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 4px;
}

.duel-controls {
  display: flex;
  gap: 18px;
  align-items: center;
  justify-content: center;
  margin-top: 26px;
}

.duel-controls span {
  display: flex;
  gap: 8px;
  align-items: center;
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 800;
}

.duel-controls strong {
  color: var(--gold);
  font-size: 0.7rem;
}

.duel-controls kbd {
  width: 34px;
  height: 34px;
}

.controls-copy {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.reaction-result {
  display: grid;
  gap: 8px;
  min-height: 88px;
  margin-bottom: 22px;
  place-items: center;
}

.reaction-result[hidden] {
  display: none;
}

.reaction-result span {
  color: var(--gold);
  font-weight: 800;
  letter-spacing: 0.12em;
}

.reaction-result strong {
  font-size: clamp(2rem, 6vw, 4.5rem);
  line-height: 1;
}

.arena[data-state="waiting"] .primary-button,
.arena[data-state="ready"] .primary-button {
  visibility: hidden;
}

.arena[data-state="waiting"] .signal span {
  animation: blink 900ms steps(1, end) infinite;
}

.arena[data-state="waiting"] .signal span:nth-child(2) {
  animation-delay: 300ms;
}

.arena[data-state="waiting"] .signal span:nth-child(3) {
  animation-delay: 600ms;
}

.arena[data-state="ready"] {
  background-color: #163825;
}

.arena[data-state="ready"] h1 {
  color: var(--green);
  text-shadow: 5px 5px 0 #163120;
  transform: scale(1.04);
}

.arena[data-state="ready"] .signal span {
  border-color: var(--green);
  background: var(--green);
  box-shadow: 0 0 18px rgba(83, 221, 131, 0.7), 3px 3px 0 var(--shadow);
}

.arena[data-state="false-start"] {
  background-color: #3d1724;
}

.arena[data-state="match-over"] {
  background-color: #322617;
}

.rules {
  display: grid;
  grid-template-columns: 0.85fr 1.6fr;
  gap: 70px;
  padding: 72px 18px 54px;
}

.rules h2 {
  max-width: 410px;
  margin: 0;
  font-size: clamp(1.8rem, 4vw, 3.5rem);
  line-height: 1.05;
  letter-spacing: -0.05em;
}

.rules ol {
  display: grid;
  gap: 0;
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: 2px solid var(--line);
}

.rules li {
  display: grid;
  grid-template-columns: 58px 1fr;
  gap: 20px;
  align-items: start;
  padding: 22px 0;
  border-bottom: 2px solid var(--line);
}

.rules li span {
  color: var(--gold);
  font-weight: 800;
}

.rules li p {
  margin: 0;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.95rem;
  line-height: 1.6;
}

.site-directory {
  padding: 64px 18px 72px;
  border-top: 2px solid var(--line);
}

.directory-heading,
.guide-heading {
  max-width: 720px;
}

.directory-heading h2,
.guide-heading h2 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 4rem);
  line-height: 1;
  letter-spacing: -0.06em;
}

.directory-heading > p:last-child {
  margin: 20px 0 0;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  line-height: 1.6;
}

.game-links {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 34px;
}

.game-links a {
  display: grid;
  min-height: 170px;
  padding: 24px;
  border: 2px solid var(--line);
  background: rgba(27, 22, 40, 0.76);
  color: var(--ink);
  text-decoration: none;
  transition: border-color 120ms ease, transform 120ms ease, box-shadow 120ms ease;
}

.game-links a:first-child {
  grid-column: span 2;
}

.game-links a:hover,
.game-links a:focus-visible {
  border-color: var(--gold);
  box-shadow: 5px 5px 0 var(--shadow);
  transform: translate(-2px, -2px);
  outline: none;
}

.game-links span {
  color: var(--gold);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.14em;
}

.game-links strong {
  align-self: end;
  margin-top: 22px;
  font-size: clamp(1.2rem, 2.6vw, 2rem);
}

.game-links small {
  margin-top: 8px;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.84rem;
  line-height: 1.5;
}

.guide-heading {
  margin-top: 74px;
}

.guide-links {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 30px;
  border-top: 2px solid var(--line);
}

.guide-links a {
  padding: 20px 18px;
  border-bottom: 2px solid var(--line);
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  line-height: 1.45;
  text-decoration-color: var(--gold);
  text-underline-offset: 5px;
}

.guide-links a:nth-child(odd) {
  border-right: 2px solid var(--line);
}

.guide-links a:hover,
.guide-links a:focus-visible {
  background: rgba(247, 201, 72, 0.08);
  color: var(--gold);
  outline: none;
}

@keyframes blink {
  0%, 33% { background: var(--gold); border-color: var(--gold); }
  34%, 100% { background: #30283d; border-color: var(--line); }
}

@media (max-width: 720px) {
  .shell {
    width: min(100% - 18px, 680px);
    padding-top: 10px;
  }

  .topbar {
    min-height: 48px;
  }

  .best-label,
  .language-chip {
    display: none;
  }

  .brand {
    font-size: 0.84rem;
  }

  .game-card {
    box-shadow: 6px 6px 0 var(--shadow);
  }

  .scoreboard {
    min-height: 84px;
  }

  .player-score {
    grid-template-columns: 1fr;
    gap: 2px;
    padding: 12px;
    text-align: center;
  }

  .player-two-score {
    justify-content: stretch;
  }

  .player-label {
    font-size: 0.65rem;
  }

  .control-hint {
    display: none;
  }

  .round-status {
    min-width: 90px;
    font-size: 0.64rem;
  }

  .round-pips {
    font-size: 0.9rem;
  }

  .arena {
    grid-template-columns: 72px minmax(0, 1fr) 72px;
    min-height: min(620px, calc(100svh - 150px));
  }

  .arena-center {
    padding: 34px 14px;
  }

  h1 {
    font-size: clamp(2.2rem, 13vw, 4.6rem);
  }

  .status-copy {
    min-height: 72px;
    font-size: 0.88rem;
  }

  .zone-key {
    width: 40px;
    height: 40px;
    font-size: 1.1rem;
  }

  .zone-action {
    max-width: 58px;
    font-size: 0.55rem;
    line-height: 1.25;
  }

  .duel-controls {
    gap: 10px;
  }

  .controls-copy {
    max-width: 230px;
    line-height: 1.45;
  }

  .primary-button {
    min-width: min(210px, 100%);
  }

  .rules {
    grid-template-columns: 1fr;
    gap: 36px;
    padding: 58px 8px 44px;
  }

  .site-directory {
    padding: 50px 8px 56px;
  }

  .game-links,
  .guide-links {
    grid-template-columns: 1fr;
  }

  .game-links a:first-child {
    grid-column: auto;
  }

  .guide-links a:nth-child(odd) {
    border-right: 0;
  }

}

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