:root {
  --bg: #f8f4e8;
  --bg-deep: #e8f7f1;
  --card: rgba(255, 252, 246, 0.88);
  --card-strong: #fffaf1;
  --text: #153243;
  --muted: #55717f;
  --accent: #0f9d8f;
  --accent-deep: #0b6e66;
  --accent-warm: #ff7a3d;
  --accent-sun: #f6c945;
  --line: rgba(21, 50, 67, 0.12);
  --shadow: 0 20px 50px rgba(21, 50, 67, 0.12);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Avenir Next", "PingFang TC", "Noto Sans TC", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(246, 201, 69, 0.35), transparent 28%),
    radial-gradient(circle at 80% 15%, rgba(15, 157, 143, 0.22), transparent 24%),
    linear-gradient(180deg, #fff8e6 0%, #eef8f6 44%, #fefbf4 100%);
  overflow-x: hidden;
}

button {
  font: inherit;
  -webkit-tap-highlight-color: transparent;
}

.scene {
  position: fixed;
  inset: auto;
  width: 34rem;
  height: 34rem;
  border-radius: 50%;
  filter: blur(8px);
  opacity: 0.32;
  pointer-events: none;
  z-index: 0;
}

.scene-top {
  top: -10rem;
  right: -8rem;
  background:
    radial-gradient(circle at 30% 30%, rgba(255, 122, 61, 0.8), transparent 36%),
    radial-gradient(circle at 65% 58%, rgba(15, 157, 143, 0.72), transparent 38%);
  animation: floatCloud 12s ease-in-out infinite;
}

.scene-bottom {
  bottom: -14rem;
  left: -8rem;
  background:
    radial-gradient(circle at 55% 35%, rgba(246, 201, 69, 0.78), transparent 38%),
    radial-gradient(circle at 28% 62%, rgba(11, 110, 102, 0.5), transparent 34%);
  animation: floatCloud 14s ease-in-out infinite reverse;
}

.page-shell {
  position: relative;
  z-index: 1;
  width: min(1240px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(280px, 0.7fr);
  gap: 24px;
  padding: 30px;
  overflow: hidden;
  position: relative;
}

.hero::after {
  content: "";
  position: absolute;
  inset: auto -4rem -5rem auto;
  width: 18rem;
  height: 18rem;
  border-radius: 45% 55% 62% 38%;
  background: linear-gradient(135deg, rgba(246, 201, 69, 0.22), rgba(255, 122, 61, 0.28));
  transform: rotate(20deg);
}

.eyebrow {
  margin: 0 0 10px;
  font-size: 0.84rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent-deep);
  font-weight: 700;
}

.hero h1,
.panel-head h2,
.unit-header h2 {
  margin: 0;
  font-family: "Avenir Next Condensed", "PingFang TC", sans-serif;
  letter-spacing: 0.01em;
  overflow-wrap: anywhere;
}

.hero h1 {
  font-size: clamp(2.3rem, 4vw, 4.2rem);
  line-height: 0.96;
}

.hero-text {
  max-width: 44rem;
  margin: 16px 0 0;
  font-size: 1.06rem;
  line-height: 1.75;
  color: var(--muted);
}

.hero-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 22px;
}

.hero-badges span,
.meta-pills span,
.mission-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(15, 157, 143, 0.1);
  color: var(--accent-deep);
  font-weight: 700;
  font-size: 0.92rem;
}

.hero-status {
  display: grid;
  gap: 18px;
  align-content: center;
}

.status-ring {
  width: min(230px, 100%);
  aspect-ratio: 1;
  margin-left: auto;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at center, rgba(255, 250, 241, 0.96) 0 48%, transparent 49%),
    conic-gradient(from 210deg, var(--accent) 0%, var(--accent-sun) 55%, rgba(15, 157, 143, 0.16) 55%);
  box-shadow: inset 0 0 0 16px rgba(255, 255, 255, 0.52);
}

.status-ring span {
  display: block;
  font-size: 2.6rem;
  font-weight: 800;
}

.status-ring small,
.status-card small {
  color: var(--muted);
}

.status-card {
  padding: 18px 20px;
  border-radius: var(--radius-lg);
  background: var(--card-strong);
  border: 1px solid rgba(246, 201, 69, 0.4);
}

.status-card p,
.status-card strong,
.status-card small {
  display: block;
}

.status-card p {
  margin: 0 0 4px;
  color: var(--muted);
}

.status-card strong {
  margin-bottom: 8px;
  font-size: 1.16rem;
  overflow-wrap: anywhere;
}

.control-strip {
  display: grid;
  gap: 18px;
  margin-top: 24px;
  padding: 22px 24px;
}

.control-group h2 {
  margin: 0 0 10px;
  font-size: 1rem;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.chip {
  border: 0;
  border-radius: 999px;
  padding: 10px 16px;
  background: #fff;
  color: var(--muted);
  border: 1px solid transparent;
  box-shadow: 0 8px 18px rgba(21, 50, 67, 0.08);
  transition: transform 0.2s ease, background 0.2s ease, color 0.2s ease;
  cursor: pointer;
}

.chip:hover,
.chip:focus-visible {
  transform: translateY(-2px);
  outline: none;
  border-color: rgba(15, 157, 143, 0.25);
}

.chip.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  color: #fff;
}

.dashboard {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px;
  margin-top: 24px;
}

.unit-panel,
.flash-panel,
.quiz-panel,
.challenge-panel,
.match-panel {
  padding: 24px;
}

.unit-panel {
  grid-column: span 2;
}

.unit-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.unit-intro {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 1.03rem;
  line-height: 1.8;
}

.meta-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 22px;
}

.summary-card,
.section-item,
.option-btn,
.flash-card {
  border-radius: var(--radius-lg);
  background: var(--card-strong);
  border: 1px solid rgba(21, 50, 67, 0.08);
}

.summary-card {
  padding: 18px;
  position: relative;
  overflow: hidden;
}

.summary-card::before {
  content: "";
  position: absolute;
  inset: 0 auto auto 0;
  width: 100%;
  height: 4px;
  background: linear-gradient(90deg, var(--accent), var(--accent-sun));
}

.summary-card h3 {
  margin: 0 0 8px;
  font-size: 1.04rem;
}

.summary-card p,
.section-item p,
.quiz-note,
.challenge-feedback {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.section-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.section-item {
  padding: 18px;
}

.section-item h3 {
  margin: 0 0 8px;
  font-size: 1rem;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.panel-head p {
  margin-top: 0;
}

.primary-btn,
.ghost-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  min-height: 48px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.2s ease, opacity 0.2s ease;
  touch-action: manipulation;
}

.primary-btn {
  background: linear-gradient(135deg, var(--accent-warm), #ff9e4a);
  color: #fff;
}

.ghost-btn {
  background: rgba(15, 157, 143, 0.08);
  color: var(--accent-deep);
}

.primary-btn:hover,
.ghost-btn:hover,
.primary-btn:focus-visible,
.ghost-btn:focus-visible {
  transform: translateY(-2px);
  outline: none;
}

.flash-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.flash-card {
  min-height: 192px;
  padding: 0;
  cursor: pointer;
  overflow: hidden;
  text-align: left;
}

.flash-card-inner {
  display: grid;
  min-height: 192px;
}

.flash-face {
  padding: 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 192px;
}

.flash-front {
  background: linear-gradient(145deg, rgba(15, 157, 143, 0.14), rgba(255, 122, 61, 0.1));
}

.flash-back {
  background: linear-gradient(145deg, rgba(255, 122, 61, 0.14), rgba(246, 201, 69, 0.18));
  display: none;
}

.flash-card.flipped .flash-front {
  display: none;
}

.flash-card.flipped .flash-back {
  display: flex;
}

.flash-label {
  display: block;
  font-size: 0.8rem;
  color: var(--accent-deep);
  font-weight: 700;
  letter-spacing: 0.08em;
}

.flash-face strong {
  display: block;
  font-size: 1.1rem;
  line-height: 1.45;
}

.flash-face p {
  display: block;
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.65;
}

.quiz-stats {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(246, 201, 69, 0.18);
}

.quiz-stats span {
  font-size: 1.4rem;
  font-weight: 800;
}

.meter {
  margin-top: 16px;
  width: 100%;
  height: 10px;
  background: rgba(21, 50, 67, 0.08);
  border-radius: 999px;
  overflow: hidden;
}

.meter-fill {
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-warm));
  transition: width 0.28s ease;
}

.meter-fill-alt {
  background: linear-gradient(90deg, #325ae0, var(--accent-sun));
}

.quiz-box,
.challenge-box {
  margin-top: 18px;
}

.question-title,
.challenge-prompt {
  margin: 0 0 14px;
  font-size: 1.08rem;
  line-height: 1.65;
}

.question-helper {
  margin: -4px 0 14px;
  color: var(--muted);
  font-size: 0.92rem;
}

.option-list {
  display: grid;
  gap: 12px;
}

.option-btn {
  width: 100%;
  text-align: left;
  padding: 14px 16px;
  min-height: 58px;
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease;
}

.option-btn:hover,
.option-btn:focus-visible {
  transform: translateX(4px);
  outline: none;
  border-color: rgba(15, 157, 143, 0.3);
}

.option-btn.correct {
  border-color: rgba(15, 157, 143, 0.5);
  background: rgba(15, 157, 143, 0.12);
}

.option-btn.incorrect {
  border-color: rgba(255, 122, 61, 0.42);
  background: rgba(255, 122, 61, 0.12);
}

.quiz-note,
.challenge-feedback {
  margin-top: 14px;
  padding: 14px 16px;
  background: rgba(255, 250, 241, 0.9);
  border-radius: var(--radius-md);
  border: 1px solid rgba(21, 50, 67, 0.08);
}

.quiz-actions {
  display: flex;
  gap: 12px;
  margin-top: 18px;
}

.challenge-story {
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.75;
}

.challenge-panel {
  grid-column: span 2;
}

.hidden {
  display: none !important;
}

.empty-state {
  padding: 18px;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  line-height: 1.7;
}

@keyframes floatCloud {
  0%,
  100% {
    transform: translate3d(0, 0, 0) rotate(0deg);
  }
  50% {
    transform: translate3d(0, 18px, 0) rotate(8deg);
  }
}

@media (max-width: 1040px) {
  .hero,
  .dashboard {
    grid-template-columns: 1fr;
  }

  .hero {
    gap: 20px;
  }

  .hero-status {
    grid-template-columns: minmax(160px, 220px) minmax(0, 1fr);
    align-items: center;
  }

  .unit-panel {
    grid-column: span 1;
  }

  .summary-grid,
  .flash-grid,
  .section-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .challenge-panel {
    grid-column: span 1;
  }

  .status-ring {
    margin-left: 0;
  }

  .unit-header {
    flex-direction: column;
  }

  .meta-pills {
    justify-content: flex-start;
  }
}

@media (max-width: 900px) {
  .page-shell {
    width: min(100% - 24px, 100%);
    padding-bottom: 36px;
  }

  .hero,
  .control-strip,
  .unit-panel,
  .flash-panel,
  .quiz-panel,
  .challenge-panel,
  .match-panel {
    padding: 22px;
  }

  .chip-row {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding: 2px 2px 8px;
    margin: 0 -2px;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
  }

  .chip {
    flex: 0 0 auto;
    min-height: 44px;
    white-space: nowrap;
  }

  .hero-badges,
  .meta-pills {
    justify-content: flex-start;
  }
}

@media (max-width: 720px) {
  .page-shell {
    width: min(100% - 20px, 100%);
    padding-top: 16px;
  }

  .scene,
  .hero::after {
    display: none;
  }

  .hero,
  .control-strip,
  .unit-panel,
  .flash-panel,
  .quiz-panel,
  .challenge-panel,
  .match-panel {
    padding: 18px;
    border-radius: 22px;
  }

  .hero h1 {
    line-height: 1.02;
    font-size: clamp(2rem, 10vw, 3rem);
  }

  .summary-grid,
  .flash-grid,
  .section-list {
    grid-template-columns: 1fr;
  }

  .unit-header,
  .panel-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .hero-status {
    grid-template-columns: 1fr;
  }

  .status-ring {
    width: min(164px, 100%);
    margin: 0 auto;
    box-shadow: inset 0 0 0 12px rgba(255, 255, 255, 0.52);
  }

  .status-ring span {
    font-size: 2.2rem;
  }

  .status-card strong {
    font-size: 1.04rem;
  }

  .hero-badges,
  .meta-pills,
  .chip-row,
  .quiz-actions {
    width: 100%;
  }

  .hero-text,
  .unit-intro,
  .challenge-story,
  .summary-card p,
  .section-item p {
    font-size: 0.98rem;
  }

  .quiz-stats,
  .mission-tag {
    align-self: flex-start;
  }

  .primary-btn,
  .ghost-btn {
    width: 100%;
    justify-content: center;
  }

  .quiz-actions {
    flex-direction: column;
  }

  .flash-card,
  .flash-card-inner,
  .flash-face {
    min-height: 168px;
  }

  .question-title,
  .challenge-prompt {
    font-size: 1rem;
  }

  .question-helper {
    font-size: 0.88rem;
  }
}

@media (max-width: 480px) {
  .page-shell {
    width: min(100% - 16px, 100%);
    padding-top: 12px;
  }

  .hero,
  .control-strip,
  .unit-panel,
  .flash-panel,
  .quiz-panel,
  .challenge-panel,
  .match-panel {
    padding: 16px;
    border-radius: 20px;
  }

  .hero-badges span,
  .meta-pills span,
  .mission-tag {
    padding: 7px 12px;
    font-size: 0.84rem;
  }

  .chip {
    padding: 10px 14px;
    min-height: 42px;
  }

  .quiz-stats {
    width: 100%;
    justify-content: center;
  }

  .summary-card,
  .section-item {
    padding: 16px;
  }

  .flash-card,
  .flash-card-inner,
  .flash-face {
    min-height: 152px;
  }

  .option-btn {
    padding: 13px 14px;
  }
}
