:root {
  color-scheme: dark;
}

.test-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(240px, 320px);
  gap: 1.4rem;
  align-items: start;
}

.test-left {
  position: relative;
  min-height: 420px;
}

.screen {
  display: none;
  min-height: 420px;
}

.screen.is-active {
  display: block;
}

.landing-card,
.countdown-card,
.result-card {
  background: linear-gradient(150deg, rgba(18, 22, 30, 0.98), rgba(10, 12, 18, 0.94));
  border: 1px solid var(--dk-border);
  border-radius: var(--radius);
  padding: clamp(20px, 3vw, 32px);
  box-shadow: var(--shadow-sm);
}

.landing-title h2 {
  font-size: 1.4rem;
  color: var(--dk-text);
  margin-bottom: 6px;
}

.landing-sub {
  color: var(--dk-muted);
  margin-bottom: 16px;
}

.rule-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.rule-card {
  border: 1px solid rgba(138, 168, 197, 0.2);
  border-radius: 14px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.02);
  display: grid;
  gap: 8px;
}

.rule-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--dk-gold-dim);
}

.rule-visual {
  color: var(--dk-text);
  font-size: 1rem;
  letter-spacing: 0.12em;
}

.rule-action {
  font-size: 1.02rem;
  color: var(--dk-text);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid rgba(138, 168, 197, 0.3);
  font-size: 0.82rem;
}

.chip-red { color: #ff9c9c; border-color: rgba(225, 82, 82, 0.45); }
.chip-blue { color: #9cc8ff; border-color: rgba(74, 130, 210, 0.45); }

.landing-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin: 18px 0 8px;
}

.landing-stats div {
  border: 1px solid rgba(138, 168, 197, 0.16);
  border-radius: 12px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.02);
}

.stat-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--dk-muted);
}

.stat-value {
  display: block;
  font-size: 1.1rem;
  margin-top: 6px;
  color: var(--dk-text);
}

.landing-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.landing-notes {
  margin-top: 12px;
  color: var(--dk-muted);
  font-size: 0.92rem;
  line-height: 1.6;
}

.landing-notes .muted {
  opacity: 0.8;
}

.countdown-card {
  display: grid;
  place-items: center;
  text-align: center;
  gap: 10px;
  min-height: 360px;
}

.countdown-ring {
  width: 160px;
  height: 160px;
  border-radius: 50%;
  border: 1px solid rgba(138, 168, 197, 0.3);
  position: relative;
  box-shadow: inset 0 0 0 18px rgba(138, 168, 197, 0.05);
}

.countdown-text {
  font-size: clamp(2.8rem, 8vw, 4.6rem);
  font-family: 'Cormorant Garamond', serif;
  color: var(--dk-gold);
  animation: pulseScale 1s ease-in-out infinite;
}

@keyframes pulseScale {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.12); opacity: 0.7; }
}

.screen-test {
  position: relative;
  background: linear-gradient(150deg, rgba(18, 22, 30, 0.98), rgba(10, 12, 18, 0.94));
  border: 1px solid var(--dk-border);
  border-radius: var(--radius);
  padding: clamp(18px, 2.8vw, 28px);
  min-height: 460px;
  overflow: hidden;
}

.hud {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.test-stage {
  display: grid;
  place-items: center;
  text-align: center;
  gap: 12px;
  min-height: 280px;
}

.stimulus-frame {
  position: relative;
  width: min(240px, 70vw);
  height: min(240px, 70vw);
  display: grid;
  place-items: center;
}

.stimulus {
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.stimulus.show {
  opacity: 1;
}

.stimulus-glow {
  position: absolute;
  inset: 10px;
  border-radius: 20px;
  opacity: 0;
  filter: blur(16px);
  transition: opacity 0.2s ease;
}

.stimulus-glow.show {
  opacity: 0.55;
}

.status-line {
  color: var(--dk-text);
  font-size: 1rem;
}

.hint-line {
  color: var(--dk-muted);
  font-size: 0.92rem;
}

.mobile-controls {
  position: sticky;
  bottom: 0;
  display: none;
  gap: 12px;
  margin-top: 20px;
  justify-content: center;
}

.tap-btn {
  flex: 1;
  max-width: 220px;
  padding: 16px 12px;
  border-radius: 14px;
  border: 1px solid rgba(138, 168, 197, 0.3);
  background: rgba(255, 255, 255, 0.04);
  color: var(--dk-text);
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  transition: transform 0.1s ease, background 0.1s ease, border-color 0.1s ease;
}

.tap-btn:active,
.tap-btn.is-pressed {
  transform: translateY(2px) scale(0.98);
  background: rgba(210, 170, 104, 0.2);
  border-color: rgba(210, 170, 104, 0.6);
}

.pause-overlay {
  position: absolute;
  inset: 0;
  background: rgba(6, 8, 12, 0.7);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.pause-overlay.active {
  display: flex;
}

.pause-card {
  padding: 20px 24px;
  border-radius: 16px;
  border: 1px solid rgba(138, 168, 197, 0.25);
  background: rgba(10, 12, 18, 0.92);
  text-align: center;
}

.pause-card h3 {
  margin: 0 0 8px;
  font-size: 1.3rem;
}

.result-card {
  display: grid;
  gap: 16px;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}

.result-item {
  border: 1px solid rgba(138, 168, 197, 0.18);
  border-radius: 12px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.02);
  display: grid;
  gap: 6px;
}

.result-item span {
  color: var(--dk-muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.result-item strong {
  font-size: 1.2rem;
  color: var(--dk-text);
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.side-card {
  background: linear-gradient(150deg, rgba(18, 22, 30, 0.98), rgba(10, 12, 18, 0.94));
  border: 1px solid var(--dk-border);
  border-radius: 14px;
  padding: 16px;
  display: grid;
  gap: 10px;
  color: var(--dk-muted);
  font-size: 0.94rem;
}

.side-card h3 {
  color: var(--dk-text);
  font-size: 1.05rem;
}

.side-card ul {
  padding-left: 18px;
  display: grid;
  gap: 6px;
}

.focus-alert {
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid rgba(29, 158, 117, 0.35);
  background: rgba(29, 158, 117, 0.1);
  color: #9ad7c5;
}

.focus-alert.is-warning {
  border-color: rgba(163, 45, 45, 0.4);
  background: rgba(163, 45, 45, 0.16);
  color: #f0b6b6;
}

.test-attention .stimulus {
  width: 140px;
  height: 140px;
  border-radius: 18px;
  border: 6px solid transparent;
  background: rgba(255, 255, 255, 0.04);
  transform: scale(0.8);
}

.test-attention .stimulus.show {
  transform: scale(1);
}

.test-shape .stimulus {
  width: 140px;
  height: 140px;
  border-radius: 14px;
  border: 3px solid rgba(226, 230, 234, 0.55);
  background: rgba(226, 230, 234, 0.08);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.25);
  transform: scale(0.8);
  transition: opacity 0.25s ease, transform 0.25s ease, border-radius 0.2s ease;
}

.test-shape .stimulus.circle {
  border-radius: 50%;
}

.test-shape .stimulus.show {
  transform: scale(1);
}

.test-shape .stimulus-glow {
  border-radius: 24px;
  background: radial-gradient(circle at center, rgba(210, 170, 104, 0.5), transparent 60%);
}

.test-count .stimulus-frame,
.test-nback .stimulus-frame,
.test-audio .stimulus-frame {
  width: min(260px, 78vw);
  min-height: 120px;
  height: auto;
}

.test-count .stimulus {
  font-family: 'Outfit', sans-serif;
  font-size: clamp(2.2rem, 7vw, 3.6rem);
  letter-spacing: 0.22em;
  color: var(--dk-text);
  padding: 12px 16px;
  border-radius: 18px;
  border: 1px solid rgba(138, 168, 197, 0.35);
  background: rgba(255, 255, 255, 0.03);
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.25);
  transform: translateY(10px) scale(0.96);
}

.test-count .stimulus.show {
  transform: translateY(0) scale(1);
}

.test-count .rule-visual {
  font-size: 1.4rem;
  letter-spacing: 0.2em;
  font-family: 'Outfit', sans-serif;
}

.test-nback .stimulus,
.test-audio .stimulus {
  font-family: 'Cormorant Garamond', serif;
  font-size: clamp(2.6rem, 7vw, 4rem);
  letter-spacing: 0.16em;
  color: var(--dk-text);
  padding: 14px 20px;
  border-radius: 18px;
  border: 1px solid rgba(138, 168, 197, 0.35);
  background: rgba(255, 255, 255, 0.03);
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.25);
  transform: translateY(10px) scale(0.96);
}

.test-nback .stimulus.show {
  transform: translateY(0) scale(1);
}

.test-audio .stimulus {
  border-radius: 999px;
  transform: none;
  transition: none;
  opacity: 0;
}

.test-audio .stimulus.show {
  opacity: 0;
}

@media (max-width: 1000px) {
  .test-shell {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 860px) {
  .mobile-controls {
    display: flex;
  }

  .test-right {
    order: 2;
  }
}

@media (max-width: 640px) {
  .hud {
    flex-direction: column;
    align-items: flex-start;
  }

  .stimulus {
    width: 120px;
    height: 120px;
  }

  .mobile-controls {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 12px 16px 18px;
    background: linear-gradient(180deg, rgba(10, 12, 18, 0) 0%, rgba(10, 12, 18, 0.9) 40%, rgba(10, 12, 18, 0.98) 100%);
    z-index: 6;
  }

  .screen-test {
    padding-bottom: 110px;
  }
}
