.tap-shell {
  width: min(1060px, calc(100% - 32px));
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

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

.game-heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 32px;
  align-items: end;
  padding: 30px 34px;
  border-bottom: 3px solid var(--ink);
}

.game-heading .eyebrow {
  margin-bottom: 10px;
}

.game-heading h1 {
  max-width: 850px;
  font-size: clamp(2.25rem, 6.2vw, 4.75rem);
  line-height: 0.94;
  overflow-wrap: anywhere;
}

.lede {
  max-width: 730px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.6;
}

.progress-box {
  min-width: 150px;
  padding: 16px;
  border: 2px solid var(--line);
  background: #171220;
  text-align: center;
}

.progress-box > span,
.stat > span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.progress-box strong {
  color: var(--gold);
  font-size: 1.6rem;
}

.mode-panel {
  margin-block: 22px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  border-top: 2px solid var(--line);
  border-bottom: 3px solid var(--ink);
}

.stat {
  min-width: 0;
  padding: 16px 8px;
  border-right: 2px solid var(--line);
  text-align: center;
}

.stat:last-child {
  border-right: 0;
}

.stat strong {
  font-size: clamp(1rem, 2.4vw, 1.4rem);
  overflow-wrap: anywhere;
}

.game-stage {
  min-height: 690px;
  padding: 38px 34px 30px;
  background:
    linear-gradient(rgba(88, 199, 215, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(88, 199, 215, 0.035) 1px, transparent 1px),
    radial-gradient(circle at 50% 26%, #2b213a 0, transparent 54%);
  background-size: 24px 24px, 24px 24px, auto;
}

.game-stage[data-state="feedback"][data-result="incorrect"],
.game-stage[data-state="game-over"] {
  background-color: #351521;
}

.game-stage[data-state="complete"] {
  background-color: #2d2515;
}

.prompt-panel {
  display: flex;
  min-height: 500px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.stage-kicker {
  margin: 0 0 12px;
  color: var(--gold);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.14em;
}

.prompt-panel h2 {
  margin: 0;
  font-size: clamp(1.45rem, 3.8vw, 2.6rem);
  letter-spacing: -0.04em;
}

.prompt-panel > p:not(.stage-kicker, .sr-only) {
  max-width: 680px;
  min-height: 48px;
  margin: 14px 0 16px;
  color: var(--muted);
  line-height: 1.55;
}

.signal-display {
  position: relative;
  display: grid;
  width: min(330px, 82vw);
  min-height: 172px;
  margin: 2px 0 22px;
  place-items: center;
  overflow: hidden;
  border: 4px solid var(--line);
  background: #181221;
  box-shadow: 8px 8px 0 var(--shadow);
}

.signal-display::before {
  position: absolute;
  inset: 12px;
  border: 2px dashed rgba(88, 199, 215, 0.2);
  content: "";
}

.signal-count {
  position: relative;
  z-index: 2;
  color: var(--muted);
  font-size: clamp(4.2rem, 16vw, 7rem);
  font-weight: 950;
  letter-spacing: -0.13em;
  line-height: 1;
  text-shadow: 5px 5px 0 #0d0a12;
}

.signal-pips {
  position: absolute;
  right: 16px;
  bottom: 14px;
  display: flex;
  gap: 6px;
}

.signal-pips i {
  width: 12px;
  height: 12px;
  border: 2px solid var(--line);
  background: #30283d;
}

.game-stage[data-state="active"] .signal-display,
.game-stage[data-state="judging"] .signal-display {
  border-color: var(--blue);
  box-shadow: 8px 8px 0 var(--shadow), 0 0 34px rgba(88, 199, 215, 0.24);
}

.game-stage[data-state="active"] .signal-count,
.game-stage[data-state="judging"] .signal-count {
  color: var(--blue);
  animation: signal-pop 240ms steps(3, end);
}

.game-stage[data-target="double"] .signal-count {
  color: var(--gold);
}

.game-stage[data-target="double"] .signal-display {
  border-color: var(--gold);
}

.game-stage[data-target="single"] .signal-pips i:first-child,
.game-stage[data-target="double"] .signal-pips i {
  border-color: currentColor;
  background: currentColor;
  color: var(--blue);
}

.game-stage[data-target="double"] .signal-pips i {
  color: var(--gold);
}

.timing-wrap {
  width: min(580px, 100%);
  margin: 0 0 14px;
}

.timing-wrap[hidden] {
  display: none;
}

.timing-labels {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.67rem;
  font-weight: 850;
  letter-spacing: 0.1em;
}

.deadline-track {
  width: 100%;
  height: 15px;
  margin: 0;
  border: 3px solid var(--line);
  background: #0e0b14;
}

.deadline-fill {
  background: repeating-linear-gradient(90deg, var(--blue) 0 18px, #2f99a8 18px 21px);
  transform: scaleX(1);
}

.deadline-fill.is-danger {
  background: repeating-linear-gradient(90deg, var(--red) 0 18px, #9c3141 18px 21px);
}

.tap-status {
  display: grid;
  min-height: 53px;
  grid-template-columns: auto auto;
  gap: 2px 9px;
  align-items: center;
  margin-bottom: 10px;
  color: var(--gold);
}

.tap-status[hidden],
.result-flash[hidden] {
  display: none;
}

.tap-status strong {
  text-align: left;
}

.tap-status > span:last-child {
  grid-column: 2;
  color: var(--muted);
  font-size: 0.76rem;
  text-align: left;
}

.tap-dot {
  width: 20px;
  height: 20px;
  grid-row: span 2;
  border: 3px solid var(--gold);
  background: var(--gold);
  box-shadow: 3px 3px 0 var(--shadow);
}

.result-flash {
  display: flex;
  min-height: 53px;
  margin-bottom: 10px;
  flex-direction: column;
  justify-content: center;
}

.result-flash strong {
  color: var(--green);
  font-size: 1.8rem;
}

.result-flash span {
  color: var(--muted);
  font-size: 0.84rem;
}

.response-pad {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  width: min(580px, 100%);
  min-height: 112px;
  margin: 8px auto 0;
  align-items: center;
  gap: 20px;
  padding: 16px 28px;
  border: 4px solid var(--ink);
  border-radius: 0;
  background: var(--blue);
  box-shadow: 7px 7px 0 var(--shadow);
  color: #10131c;
  cursor: pointer;
  text-align: left;
  touch-action: manipulation;
  user-select: none;
}

.response-pad:disabled {
  cursor: default;
  filter: saturate(0.35);
  opacity: 0.48;
}

.response-pad:not(:disabled):hover {
  background: #88eff8;
}

.response-pad:not(:disabled):active,
.response-pad.is-pressed {
  transform: translate(3px, 3px);
  box-shadow: 4px 4px 0 var(--shadow);
}

.response-pad:focus-visible {
  outline: 4px solid var(--gold);
  outline-offset: 3px;
}

.pad-icon {
  display: flex;
  gap: 7px;
}

.pad-icon i {
  width: 28px;
  height: 43px;
  border: 4px solid #153f51;
  background: rgba(255, 255, 255, 0.22);
}

.response-pad strong {
  display: block;
  font-size: 1.45rem;
  letter-spacing: 0.08em;
}

.response-pad small {
  display: block;
  margin-top: 5px;
  color: #1d4e56;
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0.08em;
}

.control-note {
  max-width: 720px;
  margin: 19px auto 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.5;
  text-align: center;
}

.game-stage[data-state="active"] .primary-button,
.game-stage[data-state="judging"] .primary-button,
.game-stage[data-state="feedback"] .primary-button,
.game-stage[data-state="waiting"] .primary-button {
  visibility: hidden;
}

.content-section {
  display: grid;
  grid-template-columns: 0.85fr 1.6fr;
  gap: 64px;
  padding: 76px 18px 58px;
}

.content-section h2,
.info-panel h2,
.faq-section h2,
.related-section h2 {
  margin: 0;
  font-size: clamp(1.8rem, 4vw, 3rem);
  line-height: 1.08;
  letter-spacing: -0.05em;
}

.steps-list {
  margin: 0;
  padding: 0;
  border-top: 2px solid var(--line);
  list-style: none;
}

.steps-list li {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 18px;
  padding: 20px 0;
  border-bottom: 2px solid var(--line);
}

.steps-list span {
  color: var(--gold);
  font-weight: 800;
}

.steps-list p,
.info-panel p,
.faq-list p {
  margin: 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.7;
}

.reading-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px;
}

.info-panel {
  min-width: 0;
  padding: 30px;
  border: 2px solid var(--line);
  background: var(--panel);
}

.info-panel h2 {
  margin-bottom: 22px;
  overflow-wrap: anywhere;
}

.info-panel > p:not(.section-kicker) + p {
  margin-top: 16px;
}

.faq-section,
.related-section {
  padding: 72px 18px 0;
}

.faq-list {
  margin-top: 28px;
  border-top: 2px solid var(--line);
}

.faq-list details {
  border-bottom: 2px solid var(--line);
}

.faq-list summary {
  padding: 22px 44px 22px 0;
  color: var(--ink);
  cursor: pointer;
  font-size: 1.05rem;
  font-weight: 800;
  line-height: 1.4;
}

.faq-list details p {
  max-width: 850px;
  padding: 0 0 24px;
}

.related-links {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-top: 28px;
}

.related-links a {
  display: flex;
  min-width: 0;
  min-height: 118px;
  flex-direction: column;
  justify-content: space-between;
  padding: 18px;
  border: 2px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  font-weight: 800;
  line-height: 1.35;
  overflow-wrap: anywhere;
  text-decoration: none;
}

.related-links a:hover,
.related-links a:focus-visible {
  border-color: var(--gold);
  outline: 0;
}

.related-links small {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 400;
}

@keyframes signal-pop {
  0% { transform: scale(0.62); opacity: 0; }
  55% { transform: scale(1.12); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

@media (max-width: 820px) {
  .game-heading { grid-template-columns: minmax(0, 1fr); }
  .progress-box { display: flex; align-items: center; justify-content: space-between; }
  .progress-box > span { margin: 0; }
  .stats-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stat:nth-child(3) { border-right: 0; }
  .stat:nth-child(-n + 3) { border-bottom: 2px solid var(--line); }
  .stat:nth-child(5) { grid-column: span 2; border-right: 0; }
  .related-links { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 620px) {
  .tap-shell { width: min(100% - 18px, 600px); padding-top: 10px; }
  .game-card { box-shadow: 6px 6px 0 var(--shadow); }
  .game-heading { gap: 20px; padding: 24px 18px; }
  .game-heading h1 { font-size: clamp(2rem, 10.5vw, 3.5rem); }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat:nth-child(odd),
  .stat:nth-child(even) { grid-column: span 1; border-right: 2px solid var(--line); border-bottom: 2px solid var(--line); }
  .stat:nth-child(even) { border-right: 0; }
  .stat:nth-child(5) { grid-column: span 2; border-right: 0; border-bottom: 0; }
  .game-stage { min-height: 720px; padding: 32px 14px 24px; }
  .prompt-panel { min-height: 520px; }
  .signal-display { width: min(270px, 80vw); min-height: 150px; }
  .signal-count { font-size: 4.6rem; }
  .response-pad { min-height: 112px; gap: 13px; padding: 13px 17px; }
  .pad-icon i { width: 21px; height: 36px; border-width: 3px; }
  .response-pad strong { font-size: 1.18rem; }
  .content-section,
  .reading-grid { grid-template-columns: minmax(0, 1fr); }
  .content-section { gap: 30px; padding: 58px 8px 44px; }
  .info-panel { padding: 24px 20px; }
  .faq-section,
  .related-section { padding: 58px 8px 0; }
  .related-links { grid-template-columns: minmax(0, 1fr); }
  .related-links a { min-height: 92px; }
}

@media (max-width: 360px) {
  .tap-shell { width: calc(100% - 12px); }
  .game-heading { padding-inline: 13px; }
  .game-stage { padding-inline: 10px; }
  .signal-display { width: min(242px, 79vw); }
  .response-pad { padding-inline: 12px; }
  .response-pad small { letter-spacing: 0.02em; }
}

@media (prefers-reduced-motion: reduce) {
  .game-stage[data-state="active"] .signal-count,
  .game-stage[data-state="judging"] .signal-count { animation: none; }
  .response-pad { transition: none; }
}
