/* 全局与背景 -------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, "Microsoft YaHei", sans-serif;
  color: #f7f2ff;
  background:
    radial-gradient(circle at 0% 0%, rgba(255, 192, 203, 0.16), transparent 55%),
    radial-gradient(circle at 100% 0%, rgba(155, 196, 255, 0.18), transparent 55%),
    radial-gradient(circle at 50% 100%, rgba(255, 255, 255, 0.12), transparent 60%),
    radial-gradient(circle at 50% 10%, rgba(203, 166, 247, 0.35), transparent 55%),
    #050515;
  background-attachment: fixed;
}

body {
  display: flex;
  align-items: stretch;
  justify-content: center;
}

.magic-page {
  width: 100%;
  min-height: 100vh;
  max-width: 1080px;
  padding: 16px 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* 头部 -------------------------------------------------- */
.magic-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px 6px;
  border-radius: 16px;
  background: linear-gradient(120deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02));
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(14px);
}

.logo-title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-orb {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 30% 20%, #ffe9ff, #ff9bd7 45%, #b07bff 70%, #4b2b90 100%);
  box-shadow:
    0 0 16px rgba(255, 171, 255, 0.9),
    0 0 28px rgba(132, 94, 247, 0.8);
  position: relative;
  animation: orbPulse 3.2s ease-in-out infinite;
}

.logo-orb::after {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.6);
}

.title-text h1 {
  margin: 0;
  font-size: 1.4rem;
  letter-spacing: 0.08em;
  text-shadow: 0 0 8px rgba(255, 241, 255, 0.8);
}

.title-text .subtitle {
  margin: 2px 0 0;
  font-size: 0.82rem;
  opacity: 0.86;
}

/* 主体布局 -------------------------------------------------- */
.magic-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.welcome-panel {
  padding: 14px 16px;
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(234, 179, 255, 0.16), rgba(129, 140, 248, 0.12));
  border: 1px solid rgba(244, 219, 255, 0.45);
  box-shadow:
    0 10px 28px rgba(76, 29, 149, 0.6),
    0 0 36px rgba(251, 207, 232, 0.24);
}

.welcome-text {
  margin: 0 0 4px;
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 0.06em;
}

.welcome-sub {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.6;
  opacity: 0.96;
}

/* 学科详情区域（例如英语分支） -------------------------------------------------- */
.subject-detail {
  margin-top: 8px;
  padding: 16px 18px 20px;
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.18), rgba(129, 140, 248, 0.16));
  border: 1px solid rgba(191, 219, 254, 0.7);
  box-shadow:
    0 18px 40px rgba(15, 23, 42, 0.95),
    0 0 40px rgba(96, 165, 250, 0.6);
}

.subject-detail[hidden] {
  display: none;
}

.subject-detail h2 {
  margin: 0 0 8px;
  font-size: 1.15rem;
  letter-spacing: 0.08em;
}

.subject-detail p {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.6;
  opacity: 0.95;
}

.subject-detail .magic-btn {
  margin-top: 14px;
}

.subject-detail-header {
  margin-bottom: 10px;
}

.subject-detail-sub {
  font-size: 0.86rem;
  opacity: 0.9;
}

/* 英语列表：可滚动的副本清单 ------------------------------------ */
.english-scroll {
  margin-top: 10px;
  padding-right: 4px;
  max-height: 340px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
}

.english-scroll::-webkit-scrollbar {
  width: 6px;
}

.english-scroll::-webkit-scrollbar-track {
  background: transparent;
}

.english-scroll::-webkit-scrollbar-thumb {
  background: linear-gradient(to bottom, rgba(191, 219, 254, 0.8), rgba(244, 114, 182, 0.9));
  border-radius: 999px;
}

.english-item {
  padding: 10px 12px 14px;
  border-radius: 14px;
  background: radial-gradient(circle at 0% 0%, rgba(248, 250, 252, 0.14), transparent 60%),
              linear-gradient(135deg, rgba(15, 23, 42, 0.96), rgba(30, 64, 175, 0.92));
  border: 1px solid rgba(191, 219, 254, 0.7);
  box-shadow:
    0 10px 26px rgba(15, 23, 42, 0.9),
    0 0 30px rgba(129, 140, 248, 0.6);
}

.english-item h3 {
  margin: 4px 0 6px;
  font-size: 1rem;
  letter-spacing: 0.06em;
}

.english-item-desc {
  font-size: 0.88rem;
  line-height: 1.6;
  margin-bottom: 4px;
}

.english-item-meta {
  margin-top: 6px;
  margin-bottom: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  font-size: 0.78rem;
  opacity: 0.9;
}

.english-item-tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  background: linear-gradient(120deg, rgba(251, 207, 232, 0.18), rgba(129, 140, 248, 0.2));
  border: 1px solid rgba(251, 207, 232, 0.7);
}

.english-item-btn {
  margin-top: 0;
  align-self: flex-end;
}

.english-item-game {
  position: relative;
  overflow: hidden;
}

.english-item-game::before {
  content: "";
  position: absolute;
  inset: -40%;
  background:
    radial-gradient(circle at 10% 0%, rgba(251, 113, 133, 0.12), transparent 60%),
    radial-gradient(circle at 100% 80%, rgba(129, 140, 248, 0.18), transparent 55%);
  opacity: 0.9;
  pointer-events: none;
}

.english-item-game > * {
  position: relative;
  z-index: 1;
}

/* 魔法阵舞台 -------------------------------------------------- */
.circle-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
}

/* 舞台：正方形 + 透视，用于立体圆弧旋转 */
.circle-container {
  position: relative;
  width: min(340px, 80vw);
  aspect-ratio: 1 / 1;
  perspective: 1000px;
  transform-style: preserve-3d;
  cursor: grab;
  touch-action: none; /* 移动端禁用默认滚动手势，保证连续 pointermove */
  --ring-rotation: 0deg;
  --ring-radius: 140px; /* 学科卡圆弧半径(px)，由 JS 按容器尺寸重算 */
}

.circle-face {
  position: absolute;
  inset: 0;
  padding-top: 10%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  border-radius: 26px;
  background: radial-gradient(circle at 50% 0%, rgba(255, 255, 255, 0.2), rgba(8, 7, 28, 0.9));
  border: 1px solid rgba(215, 189, 255, 0.52);
  box-shadow:
    0 22px 45px rgba(17, 24, 39, 0.92),
    0 0 65px rgba(192, 132, 252, 0.55);
  backface-visibility: hidden;
  transform-style: preserve-3d;
}

.circle-front {
  transform: rotateY(0deg);
}

.circle-back {
  transform: rotateY(180deg);
}

.circle-container.flipped .circle-front {
  animation: flipFront 1s ease-in-out forwards;
}

.circle-container.flipped .circle-back {
  animation: flipBack 1s ease-in-out forwards;
}

/* 魔法阵本体 -------------------------------------------------- */
.magic-circle {
  position: relative;
  width: 76%;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  display: grid;
  place-items: center;
  overflow: visible;
}

.magic-circle.faint {
  opacity: 0.7;
  filter: blur(0.4px);
}

/* 魔法阵核心：再放大、适度倾斜 */
.magic-circle-core {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 84%;
  margin-left: -42%;
  margin-top: -42%;
  aspect-ratio: 1 / 1;
  transform: rotateX(14deg) rotateZ(-4deg) translateZ(28px);
  transform-style: preserve-3d;
  filter: drop-shadow(0 18px 36px rgba(15, 23, 42, 0.9));
}

.circle-layer {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border-style: solid;
  border-color: rgba(236, 229, 255, 0.9) transparent rgba(236, 229, 255, 0.9) transparent;
  pointer-events: none;
}

.circle-layer.outer {
  border-width: 2px;
  box-shadow:
    0 0 22px rgba(250, 232, 255, 0.9),
    0 0 40px rgba(214, 158, 255, 0.75),
    0 0 80px rgba(129, 140, 248, 0.85);
  animation: circleRotate 18s linear infinite;
}

.circle-layer.middle {
  inset: 12%;
  border-width: 1.5px;
  border-style: dashed;
  opacity: 0.85;
  animation: circleRotateReverse 12s linear infinite;
}

.circle-layer.inner {
  inset: 25%;
  border-width: 2px;
  border-color: rgba(250, 250, 255, 0.95);
  box-shadow: inset 0 0 16px rgba(191, 219, 254, 0.9);
}

/* 魔法阵中心：复杂几何纹理（圆、五角星、五边形、点） */
.circle-texture {
  position: absolute;
  inset: 5%;
  border-radius: 50%;
  pointer-events: none;
}

.texture-inner-circle {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 22%;
  height: 22%;
  margin-left: -11%;
  margin-top: -11%;
  border-radius: 50%;
  border: 1.5px solid rgba(236, 229, 255, 0.85);
  box-shadow: inset 0 0 12px rgba(191, 219, 254, 0.6), 0 0 10px rgba(214, 158, 255, 0.5);
}

.texture-pentagram {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 72%;
  height: 72%;
  margin-left: -36%;
  margin-top: -36%;
  background: transparent;
  clip-path: polygon(
    50% 2%,
    61% 38%,
    98% 38%,
    68% 60%,
    79% 96%,
    50% 74%,
    21% 96%,
    32% 60%,
    2% 38%,
    39% 38%
  );
  border: 1px solid rgba(250, 232, 255, 0.8);
  box-shadow: 0 0 14px rgba(214, 158, 255, 0.5);
  animation: textureGlow 3s ease-in-out infinite alternate;
}

.texture-pentagon {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 42%;
  height: 42%;
  margin-left: -21%;
  margin-top: -21%;
  background: transparent;
  clip-path: polygon(50% 0%, 100% 38%, 81% 100%, 19% 100%, 0% 38%);
  border: 1px solid rgba(236, 229, 255, 0.7);
  box-shadow: inset 0 0 8px rgba(191, 219, 254, 0.4);
}

.texture-dot {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-left: -3px;
  margin-top: -3px;
  background: rgba(250, 250, 255, 0.9);
  box-shadow: 0 0 8px rgba(251, 113, 133, 0.8), 0 0 16px rgba(167, 139, 250, 0.6);
}
.texture-dot-0 { left: 50%; top: 12%; }
.texture-dot-1 { left: 86%; top: 38%; }
.texture-dot-2 { left: 86%; top: 62%; }
.texture-dot-3 { left: 14%; top: 62%; }
.texture-dot-4 { left: 14%; top: 38%; }

@keyframes textureGlow {
  to { box-shadow: 0 0 20px rgba(214, 158, 255, 0.7), 0 0 30px rgba(129, 140, 248, 0.4); }
}

/* 学科环：3D 立体圆弧，卡片沿圆环分布不叠在一起（参考图效果） */
.subject-ring {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transform-origin: center center;
  transform: rotateY(var(--ring-rotation));
  transition: transform 0.15s ease-out;
}

.subject-card {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 78%;
  max-width: 240px;
  padding: 12px 14px 18px;
  border-radius: 18px;
  background: linear-gradient(150deg, rgba(15, 23, 42, 0.95), rgba(30, 64, 175, 0.92));
  border: 1px solid rgba(219, 234, 254, 0.55);
  box-shadow:
    0 16px 36px rgba(15, 23, 42, 0.9),
    0 0 32px rgba(129, 140, 248, 0.5);
  color: #f7f2ff; /* 确保在不支持滤镜的浏览器中文字清晰可见 */
  transform-origin: center center;
  /* 3D 圆弧：先居中，再绕 Y 轴转到对应角度，再沿 Z 轴推到圆环上，侧面卡片略缩小 */
  transform:
    translate(-50%, -50%)
    rotateY(calc(var(--i) * 60deg))
    translateZ(var(--ring-radius))
    scale(0.88);
  backface-visibility: hidden;
  opacity: 0.4;
  pointer-events: auto; /* 允许所有卡片点击内部按钮 */
  backdrop-filter: blur(12px);
  transition:
    opacity 0.2s ease-out,
    box-shadow 0.2s ease-out,
    transform 0.2s ease-out;
}

.subject-card h2 {
  margin: 0 0 6px;
  font-size: 1.25rem;
  letter-spacing: 0.1em;
}

.subject-card p {
  margin: 0;
  font-size: 0.98rem;
  line-height: 1.55;
  opacity: 0.9;
}

.subject-card .magic-btn {
  margin-top: 10px;
}

.subject-card.is-active {
  opacity: 1;
  transform:
    translate(-50%, -50%)
    rotateY(calc(var(--i) * 60deg))
    translateZ(var(--ring-radius))
    scale(1);
  box-shadow:
    0 24px 50px rgba(17, 24, 39, 1),
    0 0 56px rgba(191, 219, 254, 0.9);
  pointer-events: auto;
  z-index: 2;
}

.circle-label {
  padding: 4px 16px 18px;
  text-align: center;
}

.circle-label h2 {
  margin: 0 0 4px;
  font-size: 1.15rem;
  letter-spacing: 0.12em;
}

.circle-label p {
  margin: 0;
  font-size: 0.88rem;
  opacity: 0.92;
}

.hint-text {
  margin-top: 6px;
  font-size: 0.8rem;
  opacity: 0.85;
}

/* 按钮 -------------------------------------------------- */
.magic-btn {
  margin-top: 10px;
  padding: 8px 22px;
  border-radius: 999px;
  border: 1px solid rgba(248, 250, 252, 0.85);
  background: radial-gradient(circle at 30% 0%, #fdf2ff, #f9a8d4 40%, #a855f7 85%);
  color: #111827;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  box-shadow:
    0 10px 25px rgba(59, 7, 100, 0.8),
    0 0 30px rgba(244, 114, 182, 0.7);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  text-decoration: none; /* a 标签形式的按钮去掉下划线 */
  transition:
    transform 0.22s ease,
    box-shadow 0.22s ease,
    filter 0.22s ease;
}

.magic-btn::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 0% 0%, rgba(255, 255, 255, 0.9), transparent 60%);
  opacity: 0;
  transition: opacity 0.25s ease;
}

.magic-btn:hover {
  transform: translateY(-1px) scale(1.02);
  box-shadow:
    0 14px 30px rgba(67, 56, 202, 0.9),
    0 0 40px rgba(251, 113, 133, 0.85);
  filter: saturate(1.1);
}

.magic-btn:hover::after {
  opacity: 0.9;
}

.magic-btn:active {
  transform: translateY(1px) scale(0.98);
  box-shadow:
    0 8px 20px rgba(55, 48, 163, 0.9),
    0 0 20px rgba(244, 114, 182, 0.9);
}

/* 页脚 -------------------------------------------------- */
.magic-footer {
  margin-top: auto;
  padding: 6px 6px 0;
  font-size: 0.76rem;
  text-align: right;
  opacity: 0.78;
}

/* 动画 -------------------------------------------------- */
@keyframes orbPulse {
  0% {
    transform: scale(1);
    box-shadow:
      0 0 10px rgba(255, 192, 255, 0.9),
      0 0 22px rgba(139, 92, 246, 0.7);
  }
  50% {
    transform: scale(1.06);
    box-shadow:
      0 0 18px rgba(255, 255, 255, 1),
      0 0 40px rgba(236, 72, 153, 0.9);
  }
  100% {
    transform: scale(1);
    box-shadow:
      0 0 10px rgba(255, 192, 255, 0.9),
      0 0 22px rgba(139, 92, 246, 0.7);
  }
}

@keyframes circleRotate {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

@keyframes circleRotateReverse {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(-360deg);
  }
}

@keyframes runesGlow {
  0% {
    text-shadow:
      0 0 8px rgba(248, 250, 252, 0.9),
      0 0 18px rgba(251, 113, 133, 0.75);
  }
  100% {
    text-shadow:
      0 0 16px rgba(248, 250, 252, 1),
      0 0 36px rgba(244, 114, 182, 0.96);
  }
}

@keyframes flipFront {
  0% {
    transform: rotateY(0deg);
  }
  50% {
    transform: rotateY(90deg);
  }
  100% {
    transform: rotateY(180deg);
  }
}

@keyframes flipBack {
  0% {
    transform: rotateY(-180deg);
  }
  50% {
    transform: rotateY(-90deg);
  }
  100% {
    transform: rotateY(0deg);
  }
}

/* 响应式优化 -------------------------------------------------- */
@media (min-width: 768px) {
  .magic-page {
    padding: 22px 26px 26px;
  }

  .magic-header {
    padding: 14px 22px 10px;
  }

  .title-text h1 {
    font-size: 1.6rem;
  }

  .circle-container {
    width: min(420px, 60vw);
    aspect-ratio: 1 / 1;
  }
}

@media (max-width: 480px) {
  .magic-page {
    padding-inline: 12px;
  }

  .magic-header {
    padding-inline: 12px;
  }

  .title-text h1 {
    font-size: 1.18rem;
  }

  .welcome-panel {
    padding-inline: 12px;
  }
}

