.reaction-page {
  --reaction-blue: #1d4ed8;
  --reaction-blue-light: #3b82f6;
  --reaction-green: #16a34a;
  --reaction-red: #dc2626;
  --reaction-yellow: #ca8a04;
}

.reaction-page .reaction-hero {
  overflow: hidden;
  background:
    radial-gradient(
      circle at 82% 18%,
      rgba(59, 130, 246, 0.17),
      transparent 31%
    ),
    linear-gradient(180deg, #f7faff 0%, #f8fafc 100%);
}

.reaction-preview {
  display: grid;
  grid-template-columns: 84px 84px;
  gap: 14px;
  align-items: center;
  justify-content: center;
  min-height: 290px;
  padding: clamp(28px, 4vw, 46px);
  border: 1px solid rgba(37, 99, 235, 0.2);
  border-radius: 28px;
  background: linear-gradient(145deg, #ffffff, #eaf2ff);
  box-shadow: 0 28px 65px rgba(29, 78, 216, 0.13);
}

.reaction-preview > div:last-child {
  grid-column: 1 / -1;
  text-align: center;
}

.preview-light {
  width: 80px;
  height: 80px;
  border: 9px solid #d9e2ef;
  border-radius: 50%;
  box-shadow: inset 0 7px 14px rgba(15, 23, 42, 0.2);
}

.preview-green {
  background: var(--reaction-green);
  box-shadow:
    0 0 30px rgba(22, 163, 74, 0.38),
    inset 0 7px 14px rgba(255, 255, 255, 0.2);
}

.preview-red {
  background: #fecaca;
}

.reaction-preview span {
  display: block;
  color: #64748b;
  font-size: 0.77rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.reaction-preview strong {
  display: block;
  margin: 5px 0 10px;
  color: #0f172a;
  font-size: clamp(2rem, 5vw, 3.8rem);
  line-height: 1;
}

.reaction-preview p {
  margin: 0;
  color: #475569;
}

.reaction-instructions {
  background: #ffffff;
}

.instruction-steps {
  display: grid;
  gap: 18px;
  margin: 24px 0 0;
  padding: 0;
  counter-reset: instruction;
  list-style: none;
}

.instruction-steps li {
  position: relative;
  min-height: 44px;
  padding-left: 58px;
  color: #475569;
  counter-increment: instruction;
}

.instruction-steps li::before {
  position: absolute;
  top: 0;
  left: 0;
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 12px;
  background: #eaf2ff;
  color: var(--reaction-blue);
  content: counter(instruction);
  font-weight: 900;
}

.criteria-panel {
  border-color: #bfdbfe;
  background: #f7faff;
}

.keyboard-tip {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-top: 22px;
  padding: 14px;
  border: 1px solid #dbeafe;
  border-radius: 14px;
  background: #ffffff;
  color: #334155;
}

.keyboard-tip svg {
  flex: 0 0 auto;
  color: var(--reaction-blue);
}

.keyboard-tip kbd {
  display: inline-grid;
  min-width: 26px;
  min-height: 25px;
  margin: 0 2px;
  padding: 2px 6px;
  place-items: center;
  border: 1px solid #cbd5e1;
  border-bottom-width: 3px;
  border-radius: 6px;
  background: #f8fafc;
  color: #0f172a;
  font:
    750 0.78rem/1 ui-monospace,
    monospace;
}

.reaction-tool-section {
  background:
    radial-gradient(
      circle at 15% 20%,
      rgba(37, 99, 235, 0.08),
      transparent 24%
    ),
    #f8fafc;
}

.reaction-app {
  max-width: 920px;
  margin: 0 auto;
  overflow: hidden;
  border: 1px solid #d7e2f2;
  border-radius: 28px;
  background: #ffffff;
  box-shadow: 0 30px 80px rgba(15, 23, 42, 0.12);
}

.reaction-toolbar {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
  border-bottom: 1px solid #dce6f5;
  background: #f8fafc;
}

.reaction-toolbar > div {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 84px;
  padding: 14px 20px;
  border-right: 1px solid #e2e8f0;
}

.reaction-toolbar span {
  color: #64748b;
  font-size: 0.7rem;
  font-weight: 850;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.reaction-toolbar strong {
  margin-top: 3px;
  color: #0f172a;
  font-size: 1.1rem;
}

.reaction-reset {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  min-width: 128px;
  padding: 14px 18px;
  border: 0;
  background: transparent;
  color: var(--reaction-blue);
  cursor: pointer;
  font-weight: 850;
}

.reaction-reset:hover,
.reaction-reset:focus-visible {
  background: #eaf2ff;
}

.reaction-stage {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 380px;
  padding: clamp(34px, 6vw, 64px) 24px 34px;
  background:
    radial-gradient(
      circle at 50% 35%,
      rgba(37, 99, 235, 0.08),
      transparent 34%
    ),
    #ffffff;
  text-align: center;
}

.traffic-light {
  display: flex;
  gap: 24px;
  padding: 20px;
  border: 1px solid #252f44;
  border-radius: 24px;
  background: #111827;
  box-shadow: 0 20px 38px rgba(15, 23, 42, 0.2);
}

.signal-light {
  width: clamp(72px, 13vw, 104px);
  aspect-ratio: 1;
  border: 8px solid #354158;
  border-radius: 50%;
  background: #202b40;
  box-shadow: inset 0 8px 18px rgba(0, 0, 0, 0.42);
  transition:
    background 120ms ease,
    box-shadow 120ms ease,
    transform 120ms ease;
}

.signal-green.is-on {
  background: #22c55e;
  box-shadow:
    0 0 34px rgba(34, 197, 94, 0.72),
    inset 0 8px 18px rgba(255, 255, 255, 0.22);
  transform: scale(1.03);
}

.signal-red.is-on {
  background: #ef4444;
  box-shadow:
    0 0 38px rgba(239, 68, 68, 0.78),
    inset 0 8px 18px rgba(255, 255, 255, 0.22);
  transform: scale(1.03);
}

.reaction-instruction {
  max-width: 680px;
  min-height: 58px;
  margin: 30px 0 8px;
  color: #0f172a;
  font-size: clamp(1.15rem, 3vw, 1.5rem);
  font-weight: 850;
  line-height: 1.35;
}

.reaction-stage.is-reacting .reaction-instruction {
  color: var(--reaction-red);
}

.reaction-feedback {
  min-height: 30px;
  color: #64748b;
  font-weight: 750;
}

.reaction-feedback[data-result='rapid'],
.reaction-feedback[data-result='good'] {
  color: var(--reaction-green);
}

.reaction-feedback[data-result='slow'] {
  color: var(--reaction-yellow);
}

.reaction-feedback[data-result='error'] {
  color: var(--reaction-red);
}

.attempt-progress {
  display: grid;
  grid-template-columns: repeat(12, minmax(8px, 1fr));
  gap: 8px;
  padding: 20px clamp(20px, 5vw, 48px);
  border-top: 1px solid #eef2f7;
  border-bottom: 1px solid #eef2f7;
  background: #fbfdff;
}

.attempt-dot {
  height: 10px;
  border-radius: 999px;
  background: #dbe3ee;
}

.attempt-dot[data-result='rapid'],
.attempt-dot[data-result='good'] {
  background: #22c55e;
}

.attempt-dot[data-result='slow'] {
  background: #eab308;
}

.attempt-dot[data-result='error'] {
  background: #ef4444;
}

.pedals {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  padding: clamp(20px, 4vw, 34px);
}

.pedal {
  display: grid;
  min-height: 150px;
  padding: 22px;
  place-items: center;
  border: 0;
  border-radius: 20px;
  color: #ffffff;
  cursor: pointer;
  touch-action: none;
  user-select: none;
  box-shadow: 0 16px 30px rgba(15, 23, 42, 0.14);
  transition:
    transform 100ms ease,
    filter 100ms ease,
    box-shadow 100ms ease;
}

.pedal svg {
  width: 34px;
  height: 34px;
}

.pedal strong {
  font-size: 1.25rem;
}

.pedal small {
  opacity: 0.82;
  font-weight: 650;
}

.pedal-brake {
  background: linear-gradient(145deg, #e54848, #b91c1c);
}

.pedal-accelerator {
  background: linear-gradient(145deg, #2f6ee8, #1d4ed8);
}

.pedal:hover {
  filter: brightness(1.06);
  transform: translateY(-2px);
}

.pedal.is-pressed,
.pedal:active {
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.18);
  filter: brightness(0.92);
  transform: translateY(3px) scale(0.99);
}

.pedal:disabled {
  cursor: not-allowed;
  filter: grayscale(0.35);
  opacity: 0.55;
}

.pedal-help {
  margin: -12px 24px 28px;
  color: #64748b;
  font-size: 0.85rem;
  text-align: center;
}

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

.reaction-results {
  margin: 0 clamp(20px, 4vw, 34px) clamp(20px, 4vw, 34px);
  padding: clamp(22px, 4vw, 34px);
  border: 1px solid #bbf7d0;
  border-radius: 20px;
  background: #f0fdf4;
  outline: none;
}

.reaction-results.is-failed {
  border-color: #fecaca;
  background: #fef2f2;
}

.result-status {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.result-status > svg {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  color: var(--reaction-green);
}

.is-failed .result-status > svg {
  color: var(--reaction-red);
}

.result-status span {
  color: #64748b;
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.result-status h3 {
  margin: 2px 0 5px;
  color: #0f172a;
  font-size: clamp(1.7rem, 4vw, 2.5rem);
}

.result-status p {
  margin: 0;
  color: #475569;
}

.result-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 24px 0;
}

.result-metrics article {
  display: flex;
  flex-direction: column;
  padding: 15px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.78);
}

.result-metrics span,
.result-metrics small {
  color: #64748b;
  font-size: 0.72rem;
  font-weight: 700;
}

.result-metrics strong {
  margin: 4px 0;
  color: #0f172a;
  font-size: 1.25rem;
}

.reaction-results h4 {
  margin: 0 0 12px;
  color: #0f172a;
}

.attempt-results {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 0 0 22px;
  padding: 0;
  list-style: none;
}

.attempt-results li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.72);
  color: #475569;
  font-size: 0.82rem;
}

.attempt-results li strong {
  color: var(--attempt-color, #0f172a);
  text-align: right;
}

.reaction-disclaimer {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  max-width: 920px;
  margin: 20px auto 0;
  border-color: #fde68a;
  background: #fffbeb;
}

.reaction-disclaimer svg {
  flex: 0 0 auto;
  color: #b45309;
}

.reaction-disclaimer p {
  margin: 0;
  color: #78350f;
}

.study-tips {
  display: grid;
  gap: 12px;
  margin: 22px 0 0;
  padding-left: 20px;
  color: #475569;
}

@media (max-width: 760px) {
  .reaction-preview {
    grid-template-columns: 66px 66px;
    min-height: 240px;
  }

  .preview-light {
    width: 64px;
    height: 64px;
  }

  .reaction-toolbar {
    grid-template-columns: repeat(3, 1fr);
  }

  .reaction-toolbar > div {
    min-height: 74px;
    padding: 10px 12px;
  }

  .reaction-reset {
    grid-column: 1 / -1;
    min-height: 48px;
    border-top: 1px solid #e2e8f0;
  }

  .result-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 520px) {
  .reaction-page h1 {
    overflow-wrap: anywhere;
    font-size: clamp(2.2rem, 11.5vw, 3rem);
  }

  .reaction-preview {
    grid-template-columns: 54px 54px;
    gap: 10px;
  }

  .preview-light {
    width: 52px;
    height: 52px;
    border-width: 6px;
  }

  .reaction-preview strong {
    font-size: 2rem;
  }

  .reaction-stage {
    min-height: 330px;
  }

  .attempt-progress {
    gap: 4px;
    padding-right: 18px;
    padding-left: 18px;
  }

  .pedals {
    gap: 10px;
    padding: 18px;
  }

  .pedal {
    min-height: 142px;
    padding: 16px 10px;
  }

  .pedal-help {
    margin-right: 18px;
    margin-left: 18px;
  }

  .attempt-results {
    grid-template-columns: 1fr;
  }
}

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