:root {
  --bg: #f8fbff;
  --panel: rgba(255, 255, 255, 0.86);
  --panel-strong: rgba(255, 255, 255, 0.96);
  --line: rgba(59, 130, 246, 0.16);
  --text: #0f172a;
  --muted: #64748b;
  --brand: #0284c7;
  --brand-2: #2563eb;
  --accent: #f59e0b;
  --ok: #16a34a;
  --shadow: 0 20px 60px rgba(37, 99, 235, 0.12);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 8% 12%, rgba(56, 189, 248, 0.22), transparent 32%),
    radial-gradient(circle at 88% 6%, rgba(129, 140, 248, 0.20), transparent 30%),
    linear-gradient(180deg, #f8fbff 0%, #eef7ff 52%, #ffffff 100%);
  line-height: 1.65;
}

a { color: inherit; text-decoration: none; }

button {
  font: inherit;
  color: inherit;
}

.page-shell {
  width: min(1800px, calc(100% - 32px));
  margin: 0 auto;
}

.hero {
  position: relative;
  padding: 56px 0 10px;
  overflow: hidden;
}

.hero::after {
  content: "";
  position: absolute;
  inset: 20px 0 auto auto;
  width: 420px;
  height: 420px;
  border: 1px solid rgba(56, 189, 248, 0.16);
  border-radius: 50%;
  background: repeating-linear-gradient(90deg, transparent 0 22px, rgba(56,189,248,0.05) 23px 24px);
  mask-image: radial-gradient(circle, #000 0 45%, transparent 70%);
  pointer-events: none;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  border: 1px solid rgba(14, 165, 233, 0.24);
  border-radius: 999px;
  color: #0369a1;
  background: rgba(224, 242, 254, 0.80);
  font-size: 0.92rem;
  letter-spacing: 0.04em;
}

.eyebrow::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 16px var(--ok);
}

.hero h1 {
  max-width: 900px;
  margin-top: 22px;
  font-size: clamp(3rem, 7vw, 6.6rem);
  line-height: 1.02;
  letter-spacing: -0.06em;
}

.gradient-text {
  background: linear-gradient(90deg, #0f172a, #0284c7 48%, #2563eb 86%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero-desc {
  max-width: 760px;
  margin-top: 22px;
  color: #475569;
  font-size: 1.35rem;
}

.mode-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(8px, 1.4vw, 18px);
  margin: 36px 0 14px;
}

.mode-card {
  position: relative;
  min-height: 140px;
  padding: 18px;
  text-align: left;
  border: 1px solid rgba(56, 189, 248, 0.22);
  border-radius: 34px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(239, 246, 255, 0.78)),
    radial-gradient(circle at 14% 12%, rgba(56, 189, 248, 0.36), transparent 34%),
    radial-gradient(circle at 92% 0%, rgba(37, 99, 235, 0.26), transparent 36%);
  box-shadow: 0 22px 64px rgba(37, 99, 235, 0.14);
  cursor: pointer;
  overflow: hidden;
  isolation: isolate;
  transition: transform 0.22s ease, border-color 0.22s ease, box-shadow 0.22s ease;
}

.mode-card::before {
  content: "";
  position: absolute;
  inset: -42% auto auto -18%;
  width: 210px;
  height: 210px;
  border-radius: 50%;
  background: rgba(56, 189, 248, 0.20);
  filter: blur(4px);
  z-index: -1;
}

.mode-card::after {
  content: attr(data-index);
  position: absolute;
  right: 14px;
  bottom: 4px;
  color: rgba(2, 132, 199, 0.08);
  font-size: clamp(4.8rem, 9vw, 8.4rem);
  line-height: 1;
  font-weight: 900;
  letter-spacing: -0.12em;
}

.mode-card:hover,
.mode-card.active {
  border-color: rgba(56, 189, 248, 0.64);
  box-shadow: 0 32px 86px rgba(37, 99, 235, 0.22);
}

.mode-card.active {
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.54);
  background:
    radial-gradient(circle at 18% 18%, rgba(125, 211, 252, 0.56), transparent 34%),
    radial-gradient(circle at 88% 0%, rgba(96, 165, 250, 0.62), transparent 38%),
    linear-gradient(135deg, #0284c7, #2563eb 72%);
  box-shadow: 0 34px 90px rgba(37, 99, 235, 0.34);
}

.mode-card.active::before {
  background: rgba(255, 255, 255, 0.18);
}

.mode-card.active::after {
  color: rgba(255, 255, 255, 0.14);
}

.mode-card strong {
  position: relative;
  z-index: 1;
  display: block;
  max-width: min(100%, 520px);
  font-size: clamp(2.15rem, 4.2vw, 5.8rem);
  line-height: 0.9;
  overflow-wrap: anywhere;
  letter-spacing: -0.09em;
  text-transform: lowercase;
  background: linear-gradient(90deg, #0f172a, #0284c7 52%, #2563eb);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.mode-card.active strong {
  background: linear-gradient(90deg, #ffffff, #e0f2fe);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 28px;
  align-items: start;
  padding-bottom: 70px;
}

.content {
  display: grid;
  gap: 24px;
}

.book-section,
.tool-section {
  border: 1px solid var(--line);
  border-radius: 28px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(239, 246, 255, 0.82));
  box-shadow: var(--shadow);
  overflow: hidden;
}

.book-head,
.tool-head {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 18px;
  padding: 28px;
  border-bottom: 1px solid var(--line);
  background:
    radial-gradient(circle at 8% 0%, rgba(125, 211, 252, 0.28), transparent 34%),
    rgba(255, 255, 255, 0.56);
}

.book-head h2,
.tool-head h2 {
  font-size: clamp(1.6rem, 3vw, 2.3rem);
  letter-spacing: -0.04em;
}

.book-head p,
.tool-head p {
  margin-top: 8px;
  color: var(--muted);
}

.book-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #334155;
  font-size: 0.9rem;
  white-space: nowrap;
}

.pill {
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.12);
  border: 1px solid rgba(148, 163, 184, 0.20);
}

.book-body,
.tool-body { padding: 24px; }

.mode-workspace {
  display: grid;
  grid-template-columns: 1fr;
  gap: 22px;
  align-items: start;
}

.mode-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  padding: 14px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.76);
}

.mode-nav-stack {
  display: grid;
  gap: 18px;
}

.mode-nav-stack .mode-nav { position: static; }

.mode-nav-title {
  width: 100%;
  padding: 4px 8px 8px;
  color: #334155;
  font-size: 0.9rem;
  font-weight: 800;
}

.mode-nav-link {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 12px;
  color: #334155;
  background: transparent;
  text-align: left;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}

.mode-nav-link:hover,
.mode-nav-link.active {
  color: #075985;
  background: linear-gradient(135deg, rgba(224, 242, 254, 0.95), rgba(219, 234, 254, 0.86));
  border-color: rgba(125, 211, 252, 0.32);
}

.chapter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

.chapter-card {
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.72);
  overflow: hidden;
}

.chapter-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 16px 12px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.14);
}

.chapter-title h3 {
  font-size: 1rem;
  color: #0f172a;
}

.lesson-list {
  display: grid;
  gap: 8px;
  padding: 12px;
}

.lesson-link {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: start;
  padding: 10px;
  border-radius: 14px;
  color: #334155;
  background: transparent;
  transition: background 0.16s ease, color 0.16s ease;
}

.lesson-link:hover {
  color: #075985;
  background: rgba(224, 242, 254, 0.72);
}

.lesson-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #16a34a;
  color: #ffffff;
  font-size: 0.7rem;
  font-weight: 700;
  align-self: center;
  flex-shrink: 0;
}

.lesson-no {
  min-width: 44px;
  color: #38bdf8;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 1rem;
  padding-top: 1px;
}

.lesson-name {
  font-size: 1.08rem;
  line-height: 1.5;
}

.empty-book {
  padding: 28px;
  color: #94a3b8;
  border: 1px dashed rgba(148, 163, 184, 0.28);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.72);
}

.animation-chapters {
  display: grid;
  gap: 22px;
}

.animation-chapter {
  display: grid;
  gap: 14px;
}

.animation-chapter h3 {
  font-size: 1.18rem;
  letter-spacing: -0.02em;
}

.anim-right-col {
  display: grid;
  gap: 22px;
  align-content: start;
}

.chapter-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.chapter-tab {
  display: grid;
  gap: 4px;
  flex: 1 0 0;
  min-width: 0;
  padding: 12px 16px;
  border: 1px solid rgba(56, 189, 248, 0.24);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
  cursor: pointer;
  text-align: left;
  font-size: 0.95rem;
  transition: background 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

.chapter-tab:hover {
  border-color: rgba(56, 189, 248, 0.52);
  background: rgba(224, 242, 254, 0.72);
}

.chapter-tab.active {
  color: #ffffff;
  border-color: transparent;
  background: linear-gradient(135deg, #0284c7, #2563eb);
  box-shadow: 0 10px 30px rgba(37, 99, 235, 0.22);
}

.chapter-tab small {
  display: block;
  font-size: 0.80rem;
  opacity: 0.70;
}

.chapter-tab .tab-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chapter-tab .tab-head em {
  display: inline-block;
  font-style: normal;
  padding: 1px 8px;
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.18);
  color: #0284c7;
  font-size: 0.78rem;
  font-weight: 700;
  margin-left: auto;
}

.chapter-tab.active .tab-head em {
  background: rgba(255, 255, 255, 0.24);
  color: #ffffff;
}

.animation-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  justify-content: start;
}

.animation-card {
  position: relative;
  min-height: 230px;
  max-width: 380px;
  border: 1px solid rgba(56, 189, 248, 0.20);
  border-radius: 22px;
  overflow: hidden;
  background: #020617;
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.24);
  contain: layout paint;
}

.preview {
  height: 320px;
  background: #020617;
  overflow: hidden;
  contain: layout paint;
}

.preview iframe {
  width: 1200px;
  height: 760px;
  border: none;
  transform: translate(-120px, -110px) scale(0.58);
  transform-origin: 0 0;
  pointer-events: none;
  background: #020617;
}

.animation-title {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 14px;
  padding: 10px 12px;
  border-radius: 14px;
  color: #ffffff;
  background: rgba(15, 23, 42, 0.78);
  backdrop-filter: blur(10px);
  font-weight: 700;
}

.roll-call-panel {
  display: grid;
  gap: 18px;
  max-width: 100%;
}

.class-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.class-tab {
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid rgba(14, 165, 233, 0.24);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.8);
  cursor: pointer;
  font-weight: 700;
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}

.class-tab.active {
  color: #ffffff;
  border: none;
  background: linear-gradient(135deg, #0284c7, #2563eb);
  box-shadow: 0 8px 24px rgba(37, 99, 235, 0.28);
}

.roll-btn, .reset-btn {
  position: relative;
  overflow: hidden;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.roll-btn:active, .reset-btn:active {
  transform: scale(0.94);
}

.roll-btn::after, .reset-btn::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: rgba(255, 255, 255, 0.28);
  opacity: 0;
  transition: opacity 0.1s ease;
}

.roll-btn.busy::after, .reset-btn.busy::after {
  opacity: 1;
}

.roll-btn.busy {
  animation: btnPulse 0.6s ease;
}

.reset-btn.busy {
  animation: btnSpin 0.4s ease;
}

@keyframes btnPulse {
  0% { box-shadow: 0 0 0 0 rgba(56, 189, 248, 0.50); }
  70% { box-shadow: 0 0 0 16px rgba(56, 189, 248, 0); }
  100% { box-shadow: 0 0 0 0 rgba(56, 189, 248, 0); }
}

@keyframes btnSpin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.roll-btn, .reset-btn {
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid rgba(14, 165, 233, 0.24);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.8);
  cursor: pointer;
  font-weight: 700;
}

.class-tab.active,
.roll-btn {
  color: #ffffff;
  border: none;
  background: linear-gradient(135deg, #0284c7, #2563eb);
}

.roll-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.roll-result {
  display: grid;
  grid-template-rows: 1fr auto;
  align-items: center;
  min-height: 280px;
  width: 100%;
  border: 1px solid rgba(56, 189, 248, 0.22);
  border-radius: 24px;
  background:
    radial-gradient(circle at 50% 0%, rgba(56, 189, 248, 0.22), transparent 38%),
    rgba(255, 255, 255, 0.8);
  text-align: center;
}

.roll-result-inner {
  padding: 32px 20px 12px;
}

.student-name {
  font-size: clamp(4rem, 12vw, 8rem);
  line-height: 1;
  font-weight: 900;
  letter-spacing: -0.08em;
  color: #075985;
  overflow: hidden;
  white-space: nowrap;
  min-height: 1.1em;
}

.student-name.roll-anim {
  animation: nameRoll 0.36s ease-out;
}

@keyframes nameRoll {
  0% { transform: translateY(-80%) scaleY(0.6); opacity: 0; }
  40% { transform: translateY(8%) scaleY(1.1); opacity: 1; }
  70% { transform: translateY(-4%) scaleY(0.96); }
  100% { transform: translateY(0) scaleY(1); opacity: 1; }
}

.roll-status {
  padding: 14px 20px 18px;
  color: var(--muted);
  border-top: 1px solid rgba(148, 163, 184, 0.14);
}

.roll-bottom {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
}

/* 回答正确按钮 */
.score-btn {
  min-height: 42px;
  padding: 0 20px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, #16a34a, #22c55e);
  color: #ffffff;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.score-btn:hover {
  box-shadow: 0 6px 20px rgba(22, 163, 74, 0.36);
}

.score-btn:active {
  transform: scale(0.94);
}

/* 积分榜 */
.leaderboard {
  margin-top: 22px;
  padding: 20px;
  border: 1px solid rgba(56, 189, 248, 0.18);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.76);
}

.leaderboard-title {
  margin-bottom: 18px;
  font-size: 2.2rem;
  color: #075985;
  text-align: center;
}

/* 领奖台 */
.podium {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 16px;
  padding: 12px 0 0;
}

.podium-spot {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  max-width: 220px;
}

.podium-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 16px 20px 12px;
  border-radius: 18px;
  width: 100%;
  text-align: center;
}

.podium-rank {
  font-size: 2.8rem;
  font-weight: 900;
  line-height: 1;
}

.podium-name {
  font-size: 1.8rem;
  font-weight: 700;
  line-height: 1.2;
}

.podium-score {
  font-size: 1.4rem;
  font-weight: 600;
  opacity: 0.8;
}

.podium-stand {
  width: 100%;
  border-radius: 14px 14px 0 0;
}

/* 第一名 */
.spot-1 .podium-card {
  background: linear-gradient(180deg, #fef3c7, #fde68a);
  color: #78350f;
}
.spot-1 .podium-stand {
  height: 90px;
  background: linear-gradient(180deg, #fbbf24, #f59e0b);
  box-shadow: 0 -4px 20px rgba(245, 158, 11, 0.4);
}

/* 第二名 */
.spot-2 .podium-card {
  background: linear-gradient(180deg, #f8fafc, #e2e8f0);
  color: #334155;
}
.spot-2 .podium-stand {
  height: 60px;
  background: linear-gradient(135deg, #cbd5e1, #94a3b8, #cbd5e1, #64748b);
  box-shadow: 0 -4px 16px rgba(100, 116, 139, 0.35);
}

/* 第三名 */
.spot-3 .podium-card {
  background: linear-gradient(180deg, #fef7ed, #fde0c8);
  color: #78350f;
}
.spot-3 .podium-stand {
  height: 40px;
  background: linear-gradient(180deg, #d97706, #b45309);
  box-shadow: 0 -4px 12px rgba(180, 83, 9, 0.3);
}

footer {
  padding: 42px 0 56px;
  color: #64748b;
  text-align: center;
}

@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
  .mode-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .book-head, .tool-head { grid-template-columns: 1fr; }
  .book-meta { flex-wrap: wrap; }
}

@media (max-width: 620px) {
  .page-shell { width: min(100% - 20px, 1440px); }
  .hero { padding-top: 42px; }
  .mode-grid { gap: 8px; }
  .mode-card { min-height: 104px; border-radius: 20px; }
  .mode-card strong { font-size: clamp(1.45rem, 8vw, 2.7rem); letter-spacing: -0.07em; }
  .chapter-grid, .animation-grid { grid-template-columns: 1fr; }
  .book-body, .book-head, .tool-body, .tool-head { padding: 18px; }
}
