/* ===== Reset & Base ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
  background: #dde3ee;
  color: #333;
  min-height: 100vh;
  animation: bodyFadeIn 0.5s ease;
}

@keyframes bodyFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

a {
  color: #3a9bd5;
  text-decoration: none;
}
a:hover { text-decoration: underline; }

/* ===== Hero ===== */
.hero {
  background: linear-gradient(135deg, #3d96d4 0%, #2b7cb8 100%);
  color: white;
  text-align: center;
  padding: 60px 20px 50px;
  animation: heroSlideIn 0.7s ease;
}

@keyframes heroSlideIn {
  from { opacity: 0; transform: translateY(-20px); }
  to   { opacity: 1; transform: translateY(0); }
}

.hero-icon {
  font-size: 64px;
  line-height: 1;
  margin-bottom: 16px;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,.2));
  animation: iconBounce 1.2s ease infinite alternate;
}

@keyframes iconBounce {
  from { transform: translateY(0); }
  to   { transform: translateY(-6px); }
}

.hero h1 {
  font-size: 52px;
  font-weight: 700;
  margin-bottom: 12px;
  letter-spacing: -1px;
}

.hero-subtitle {
  font-size: 18px;
  opacity: 0.9;
  margin-bottom: 28px;
}

.btn-start {
  display: inline-block;
  background: #f5a623;
  color: white;
  border: none;
  padding: 12px 36px;
  border-radius: 6px;
  font-size: 16px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
  text-decoration: none;
  animation: btnPulse 2s ease infinite;
}
.btn-start:hover { background: #e8951a; text-decoration: none; color: white; transform: scale(1.04); }

@keyframes btnPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(245,166,35,0.4); }
  50%      { box-shadow: 0 0 0 8px rgba(245,166,35,0); }
}

/* ===== Navbar ===== */
.navbar {
  background: white;
  border-bottom: 1px solid #e0e0e0;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}

.nav-inner {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 48px;
}

.nav-left, .nav-right {
  display: flex;
  align-items: center;
  gap: 20px;
}

.nav-logo {
  font-weight: 700;
  color: #3d96d4;
  font-size: 15px;
}

.nav-link {
  color: #555;
  font-size: 14px;
  font-weight: 500;
  transition: color 0.2s;
}
.nav-link:hover { color: #3d96d4; text-decoration: none; }

/* ===== Main / Test Grid ===== */
.main-content {
  max-width: 900px;
  margin: 0 auto;
  padding: 32px 20px 48px;
}

/* ===== Home Ad Banner ===== */
.home-ad-banner {
  background: #fff;
  border-bottom: 1px solid #e4e8ef;
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  min-height: 130px;
  padding: 10px 20px;
}
.home-ad-tag {
  font-size: 11px;
  color: #bbb;
  letter-spacing: 0.5px;
  padding: 2px 7px;
  background: #f0f2f5;
  border-radius: 3px;
}

/* ===== Test Cards Grid ===== */
.tests-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.test-card {
  background: white;
  border-radius: 12px;
  padding: 36px 20px 28px;
  text-align: center;
  cursor: pointer;
  position: relative;
  transition: transform 0.18s, box-shadow 0.18s;
  box-shadow: 0 1px 4px rgba(0,0,0,.07);
  animation: cardFadeIn 0.5s ease both;
  animation-delay: calc(var(--i, 0) * 0.07s + 0.1s);
}
.test-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 28px rgba(0,0,0,.12);
}

@keyframes cardFadeIn {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

.test-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.25s;
}
.test-card:hover .test-icon { transform: scale(1.12); }
.test-icon svg { width: 100%; height: 100%; }

.test-card h3 {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 8px;
  color: #2c3e50;
}
.test-card p {
  font-size: 13px;
  color: #7f8c9a;
  line-height: 1.55;
}

.badge-new {
  position: absolute;
  top: 12px;
  right: 12px;
  background: #e74c3c;
  color: white;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 5px;
  animation: badgePop 0.4s ease 0.5s both;
}
@keyframes badgePop {
  from { transform: scale(0); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

/* ===== Footer ===== */
.footer {
  text-align: right;
  padding: 30px 40px;
  font-size: 12px;
  color: #999;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}
.footer a { color: #3a9bd5; font-size: 12px; }

/* ===== Modal Overlay ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: #dde3ee;
  overflow-y: auto;
  z-index: 1000;
  animation: modalFadeIn 0.35s ease;
}

@keyframes modalFadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.modal-closing {
  animation: modalFadeOut 0.25s ease forwards;
}

@keyframes modalFadeOut {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(12px); }
}

.modal-full {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.modal-close {
  text-align: center;
  padding: 10px;
  cursor: pointer;
  color: #888;
  font-size: 14px;
  background: white;
  border-bottom: 1px solid #eee;
  transition: color 0.2s, background 0.2s;
}
.modal-close:hover { color: #e74c3c; background: #fef2f2; }

/* ===== Modal Hero ===== */
.modal-hero {
  background: linear-gradient(135deg, #3d96d4 0%, #2b7cb8 100%);
  color: white;
  text-align: center;
  padding: 50px 20px 40px;
  position: relative;
  animation: modalHeroIn 0.5s ease;
}

@keyframes modalHeroIn {
  from { opacity: 0; transform: scale(0.97); }
  to   { opacity: 1; transform: scale(1); }
}

.modal-hero-icon {
  font-size: 50px;
  margin-bottom: 14px;
  line-height: 1.1;
  animation: iconBounce 1.5s ease infinite alternate;
}

.modal-hero h2 {
  font-size: 42px;
  font-weight: 700;
  margin-bottom: 12px;
}

.modal-hero p {
  font-size: 16px;
  opacity: 0.9;
  margin-bottom: 20px;
  line-height: 1.6;
}

/* ===== Modal Body ===== */
.modal-body {
  max-width: 900px;
  margin: 0 auto;
  padding: 30px 20px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  width: 100%;
  animation: bodyFadeIn 0.4s ease 0.15s both;
}

.stat-section, .about-section {
  background: white;
  border-radius: 10px;
  padding: 24px;
  animation: cardFadeIn 0.4s ease both;
  animation-delay: 0.2s;
}

.stat-section h3, .about-section h3 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 16px;
  color: #222;
}

.about-section p {
  font-size: 14px;
  color: #444;
  margin-bottom: 12px;
  line-height: 1.7;
}

/* ===== Reaction Test - Fullscreen ===== */
.reaction-fullscreen {
  position: relative;
  width: 100%;
  min-height: 340px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  overflow: hidden;
}

/* Flash overlay on "go" */
.reaction-fullscreen::after {
  content: '';
  position: absolute;
  inset: 0;
  background: white;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.1s;
}
/* 反应测试：红→绿瞬间切换，不做动画，避免影响计时 */

/* 状态颜色 */
.reaction-state-idle   { background: #3d96d4; }
.reaction-state-waiting   { background: #d93025; }
.reaction-state-ready  { background: #4caf50; }
.reaction-state-result { background: #4caf50; }
.reaction-state-toosoon{ background: #3d96d4; }

/* 等待状态脉冲动画 */
.reaction-state-waiting .reaction-fs-inner {
  animation: waitPulse 1.2s ease infinite;
}

@keyframes waitPulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.03); }
}

.reaction-fs-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  position: relative;
  z-index: 1;
  animation: fsTextFade 0.3s ease;
}

@keyframes fsTextFade {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.reaction-dots {
  font-size: 28px;
  color: rgba(255,255,255,0.7);
  letter-spacing: 4px;
  animation: dotsBlink 1.5s ease infinite;
}

@keyframes dotsBlink {
  0%, 100% { opacity: 0.7; }
  50%      { opacity: 1; }
}

.reaction-fs-text {
  font-size: 52px;
  font-weight: 700;
  color: white;
  text-align: center;
  line-height: 1.2;
  text-shadow: 0 2px 8px rgba(0,0,0,0.15);
  transition: opacity 0.2s;
}

/* 结果文字弹出 */
.reaction-state-result .reaction-fs-text {
  animation: resultPop 0.4s ease;
}

@keyframes resultPop {
  0%   { transform: scale(0.7); opacity: 0; }
  60%  { transform: scale(1.08); }
  100% { transform: scale(1); opacity: 1; }
}

.reaction-ms-display {
  font-size: 38px;
  font-weight: 700;
  color: rgba(255,255,255,0.92);
  margin-top: 4px;
  animation: resultPop 0.5s ease 0.1s both;
}

.reaction-sub-text {
  font-size: 16px;
  color: rgba(255,255,255,0.75);
  margin-top: -8px;
  animation: fsTextFade 0.3s ease;
}

/* 关闭按钮 — 叠在全屏区上方，不参与点击穿透 */
.reaction-close-btn {
  position: relative;
  z-index: 10;
}

/* 历史记录条 */
.reaction-history {
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.reaction-history-item {
  background: #eef4fb;
  border-radius: 6px;
  padding: 5px 12px;
  font-size: 13px;
  color: #3d96d4;
  font-weight: 600;
  animation: cardFadeIn 0.3s ease both;
}

/* ===== Sequence Test ===== */
.sequence-grid {
  display: grid;
  grid-template-columns: repeat(3, 80px);
  gap: 10px;
  margin: 20px auto;
  justify-content: center;
}

.seq-cell {
  width: 80px;
  height: 80px;
  background: #5aaddd;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, transform 0.15s, box-shadow 0.2s;
  border: 3px solid transparent;
}
.seq-cell.active {
  background: #fff;
  border-color: #3d96d4;
  box-shadow: 0 0 16px rgba(61,150,212,0.5);
  animation: cellGlow 0.4s ease;
}
.seq-cell.highlight {
  background: #f5f5f5;
  transform: scale(0.95);
  transition: background 0.1s, transform 0.1s;
}
.seq-cell.wrong {
  background: #e74c3c !important;
  animation: shake 0.4s ease;
}

@keyframes cellGlow {
  0%   { box-shadow: 0 0 0 rgba(61,150,212,0); }
  50%  { box-shadow: 0 0 24px rgba(61,150,212,0.7); }
  100% { box-shadow: 0 0 16px rgba(61,150,212,0.5); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%      { transform: translateX(-6px); }
  40%      { transform: translateX(6px); }
  60%      { transform: translateX(-4px); }
  80%      { transform: translateX(4px); }
}

.level-display {
  margin-top: 12px;
  font-size: 20px;
  font-weight: 700;
  color: white;
  animation: fsTextFade 0.3s ease;
}

/* ===== Aim Test ===== */
.aim-icon { font-size: 48px; margin: 10px 0; opacity: 0.9; }

.aim-area {
  position: relative;
  width: 600px;
  height: 300px;
  background: rgba(255,255,255,.1);
  border-radius: 12px;
  margin: 20px auto;
  overflow: hidden;
}

.aim-start {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 700;
  color: white;
  cursor: pointer;
  background: rgba(255,255,255,.15);
  border-radius: 50%;
  width: 100px;
  height: 100px;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  transition: background 0.2s, transform 0.2s;
}
.aim-start:hover { background: rgba(255,255,255,.3); transform: translate(-50%, -50%) scale(1.08); }

.aim-target {
  position: absolute;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #7ec8e3, #3d96d4);
  border: 3px solid white;
  cursor: pointer;
  transition: background 0.1s, transform 0.12s;
  animation: targetSpawn 0.25s ease both;
  box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}
.aim-target:hover { background: #fff; transform: scale(1.1); }

@keyframes targetSpawn {
  from { transform: scale(0); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

/* ===== Number Memory ===== */
.number-display {
  font-size: 56px;
  font-weight: 700;
  color: white;
  letter-spacing: 8px;
  margin: 20px auto;
  min-height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: numFadeIn 0.4s ease;
}

@keyframes numFadeIn {
  from { opacity: 0; transform: scale(1.15); }
  to   { opacity: 1; transform: scale(1); }
}

.number-input {
  font-size: 28px;
  padding: 12px 24px;
  border-radius: 8px;
  border: 2px solid rgba(255,255,255,.5);
  background: rgba(255,255,255,.15);
  color: white;
  text-align: center;
  letter-spacing: 4px;
  width: 300px;
  margin-bottom: 16px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.number-input:focus {
  border-color: white;
  box-shadow: 0 0 12px rgba(255,255,255,.3);
}
.number-input::placeholder { color: rgba(255,255,255,.6); }

/* ===== Verbal Memory ===== */
.verbal-word {
  font-size: 48px;
  font-weight: 700;
  color: white;
  margin: 20px auto;
  min-height: 70px;
  animation: wordSlideIn 0.35s ease;
}

@keyframes wordSlideIn {
  from { opacity: 0; transform: translateY(14px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.btn-verbal {
  border: none;
  padding: 12px 32px;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  margin: 6px;
  transition: opacity 0.2s, transform 0.15s;
  color: white;
}
.btn-verbal.seen { background: #3d96d4; }
.btn-verbal.new  { background: #2ecc71; }
.btn-verbal:hover { opacity: 0.85; transform: scale(1.05); }

/* ===== Chimp Test ===== */
.chimp-grid {
  display: grid;
  gap: 8px;
  margin: 20px auto;
  justify-content: center;
}

.chimp-cell {
  width: 70px;
  height: 70px;
  background: #5aaddd;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 700;
  color: white;
  cursor: pointer;
  transition: background 0.15s, transform 0.15s;
}
.chimp-cell.empty { background: transparent; cursor: default; }
.chimp-cell.hidden { color: transparent; }
.chimp-cell:not(.empty):hover { background: #4a9bc8; transform: scale(1.05); }
.chimp-cell.wrong-click {
  background: #e74c3c !important;
  animation: shake 0.4s ease;
}

/* Chimp number appear animation */
.chimp-cell:not(.hidden):not(.empty) {
  animation: chimpNumIn 0.3s ease;
}

@keyframes chimpNumIn {
  from { transform: scale(0.6); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

/* ===== Visual Memory ===== */
.visual-grid {
  display: grid;
  gap: 6px;
  margin: 20px auto;
  justify-content: center;
}

.visual-cell {
  background: rgba(255,255,255,.2);
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
}
.visual-cell.highlighted {
  background: white;
  animation: cellGlowWhite 0.5s ease;
}
.visual-cell.selected {
  background: #f5a623;
  transform: scale(0.92);
  transition: background 0.1s, transform 0.1s;
}
.visual-cell.correct {
  background: #27ae60;
  animation: correctPop 0.3s ease;
}
.visual-cell.wrong {
  background: #e74c3c;
  animation: shake 0.4s ease;
}

@keyframes cellGlowWhite {
  0%   { box-shadow: 0 0 0 rgba(255,255,255,0); }
  50%  { box-shadow: 0 0 18px rgba(255,255,255,0.8); }
  100% { box-shadow: 0 0 6px rgba(255,255,255,0.3); }
}

@keyframes correctPop {
  0%   { transform: scale(0.8); }
  50%  { transform: scale(1.1); }
  100% { transform: scale(1); }
}

/* ===== Typing Test ===== */
.typing-text {
  background: rgba(255,255,255,.15);
  border-radius: 10px;
  padding: 20px 28px;
  font-size: 18px;
  line-height: 1.8;
  text-align: left;
  max-width: 700px;
  margin: 20px auto;
  color: white;
  letter-spacing: 0.3px;
  transition: box-shadow 0.3s;
}
.typing-text.typing-active {
  box-shadow: 0 0 16px rgba(255,255,255,0.15);
}

.typing-text .char-correct { color: #a8d8a8; }
.typing-text .char-wrong  { color: #e74c3c; text-decoration: underline; }
.typing-text .char-current { border-bottom: 2px solid white; }

.typing-input {
  width: 700px;
  max-width: 90vw;
  padding: 12px 20px;
  font-size: 18px;
  border-radius: 8px;
  border: 2px solid rgba(255,255,255,.4);
  background: rgba(255,255,255,.15);
  color: white;
  margin-bottom: 12px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}
.typing-input::placeholder { color: rgba(255,255,255,.5); }
.typing-input:focus { border-color: white; background: rgba(255,255,255,.25); box-shadow: 0 0 12px rgba(255,255,255,.2); }

/* ===== Canvas Charts ===== */
canvas {
  width: 100% !important;
  height: 160px !important;
  display: block;
  animation: cardFadeIn 0.5s ease both;
  animation-delay: 0.3s;
}

/* ===== Result Screens ===== */
.final-score {
  margin-top: 20px;
  font-size: 22px;
  font-weight: 700;
  color: white;
  background: rgba(255,255,255,.15);
  display: inline-block;
  padding: 14px 30px;
  border-radius: 8px;
  animation: resultPop 0.5s ease;
}

/* ===== Responsive ===== */
@media (max-width: 700px) {
  .tests-grid { grid-template-columns: repeat(2, 1fr); }
  .modal-body { grid-template-columns: 1fr; }
  .aim-area { width: 90vw; height: 200px; }
  .typing-input { width: 90vw; }
  .hero h1 { font-size: 36px; }
  .modal-hero h2 { font-size: 28px; }
  .reaction-fs-text { font-size: 36px; }
  .home-ad-banner { min-height: 80px; }
}

@media (max-width: 460px) {
  .tests-grid { grid-template-columns: 1fr; }
}
