:root {
  --bg: #f4efe2;
  --ink: #1e2d2f;
  --muted: #66736c;
  --paper: rgba(255, 252, 241, 0.9);
  --paper-strong: #fff8e6;
  --line: rgba(48, 58, 54, 0.12);
  --green: #2f7d5b;
  --green-dark: #1c5645;
  --clay: #c5603d;
  --gold: #e6a93c;
  --blue: #3f6e94;
  --shadow: 0 24px 58px rgba(42, 50, 45, 0.14);
  --radius-xl: 30px;
  --radius-lg: 22px;
  --radius-md: 16px;
}

* {
  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(--ink);
  background:
    radial-gradient(circle at 8% 12%, rgba(230, 169, 60, 0.38), transparent 28%),
    radial-gradient(circle at 86% 14%, rgba(47, 125, 91, 0.23), transparent 26%),
    linear-gradient(135deg, #f8f0dd 0%, #edf4e8 48%, #f8eadf 100%);
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(47, 125, 91, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(47, 125, 91, 0.05) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.72), transparent 78%);
  animation: mapDrift 22s linear infinite;
}

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

.map-glow {
  position: fixed;
  width: 32rem;
  aspect-ratio: 1;
  border-radius: 42% 58% 50% 50%;
  z-index: 0;
  pointer-events: none;
  filter: blur(10px);
  opacity: 0.34;
}

.map-glow-top {
  top: -9rem;
  right: -7rem;
  background: radial-gradient(circle at 42% 35%, rgba(197, 96, 61, 0.8), transparent 38%), radial-gradient(circle at 60% 65%, rgba(47, 125, 91, 0.72), transparent 42%);
  animation: floatGlow 13s ease-in-out infinite;
}

.map-glow-bottom {
  bottom: -13rem;
  left: -9rem;
  background: radial-gradient(circle at 48% 38%, rgba(230, 169, 60, 0.85), transparent 42%), radial-gradient(circle at 35% 62%, rgba(63, 110, 148, 0.48), transparent 36%);
  animation: floatGlow 16s ease-in-out infinite reverse;
}

.stamp-field {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.stamp-field span {
  position: absolute;
  display: inline-grid;
  place-items: center;
  width: 86px;
  aspect-ratio: 1;
  border: 2px dashed rgba(47, 125, 91, 0.28);
  border-radius: 50%;
  color: rgba(28, 86, 69, 0.36);
  font-weight: 900;
  letter-spacing: 0.08em;
  transform: rotate(-12deg);
  animation: stampFloat 14s ease-in-out infinite;
}

.stamp-field span:nth-child(1) {
  top: 18%;
  left: 6%;
}

.stamp-field span:nth-child(2) {
  top: 12%;
  right: 28%;
  animation-delay: -5s;
}

.stamp-field span:nth-child(3) {
  bottom: 18%;
  right: 8%;
  animation-delay: -8s;
}

.stamp-field span:nth-child(4) {
  bottom: 28%;
  left: 13%;
  animation-delay: -11s;
}

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

.hero-panel,
.control-panel,
.mission-hub,
.panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

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

.hero-panel::after {
  content: "";
  position: absolute;
  right: -6rem;
  bottom: -7rem;
  width: 22rem;
  aspect-ratio: 1;
  border-radius: 42% 58% 63% 37%;
  background: linear-gradient(135deg, rgba(230, 169, 60, 0.22), rgba(197, 96, 61, 0.22));
  transform: rotate(18deg);
}

.hero-copy,
.passport-card {
  position: relative;
  z-index: 1;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--green-dark);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.mode-switch,
.hero-badges,
.keyword-list,
.chip-row,
.task-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.mode-link,
.hero-badges span,
.keyword-list span,
.mission-tag {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 8px 13px;
  border-radius: 999px;
  color: var(--green-dark);
  background: rgba(47, 125, 91, 0.1);
  font-weight: 800;
  text-decoration: none;
}

.mode-link.active {
  color: #fff;
  background: linear-gradient(135deg, var(--green), var(--green-dark));
}

.hero-panel h1 {
  margin: 18px 0 14px;
  max-width: 780px;
  font-size: clamp(2.6rem, 7vw, 5.5rem);
  line-height: 0.95;
  letter-spacing: -0.07em;
}

.hero-text,
.unit-intro,
.case-story {
  color: var(--muted);
  line-height: 1.8;
}

.hero-text {
  max-width: 780px;
  margin: 0 0 20px;
  font-size: 1.08rem;
}

.passport-card {
  align-self: stretch;
  display: grid;
  gap: 18px;
  align-content: center;
  border-radius: 28px;
  padding: 24px;
  color: #fff;
  background:
    linear-gradient(135deg, rgba(28, 86, 69, 0.92), rgba(63, 110, 148, 0.9)),
    repeating-linear-gradient(45deg, transparent 0 12px, rgba(255, 255, 255, 0.08) 12px 14px);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.24);
}

.passport-card p,
.passport-card small {
  margin: 0;
  color: rgba(255, 255, 255, 0.78);
}

.passport-card strong {
  display: block;
  margin: 4px 0 8px;
  font-size: 1.12rem;
  line-height: 1.45;
}

.passport-stamp {
  width: fit-content;
  padding: 10px 14px;
  border: 2px dashed rgba(255, 255, 255, 0.5);
  border-radius: 999px;
  font-weight: 900;
  transform: rotate(-4deg);
}

.level-ring {
  width: 168px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  justify-self: center;
  border-radius: 50%;
  color: var(--ink);
  background:
    radial-gradient(circle at center, #fff8e6 0 49%, transparent 50%),
    conic-gradient(from 210deg, var(--gold) 0%, var(--clay) 0%, rgba(255, 255, 255, 0.24) 0%);
  box-shadow: 0 20px 42px rgba(20, 36, 34, 0.2);
}

.level-ring span,
.level-ring small {
  grid-area: 1 / 1;
}

.level-ring span {
  font-size: 2.45rem;
  font-weight: 900;
}

.level-ring small {
  margin-top: 58px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

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

.control-group h2,
.mission-hub h2,
.panel h2 {
  margin: 0;
}

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

.chip {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 10px 16px;
  color: var(--muted);
  background: #fffaf0;
  box-shadow: 0 9px 18px rgba(42, 50, 45, 0.08);
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.chip:hover,
.chip:focus-visible {
  transform: translateY(-2px);
  outline: none;
  border-color: rgba(47, 125, 91, 0.28);
}

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

.mission-hub {
  display: grid;
  grid-template-columns: minmax(220px, 0.8fr) minmax(360px, 1.35fr) minmax(240px, 0.9fr);
  gap: 18px;
  margin-top: 24px;
  padding: 22px;
  overflow: hidden;
  position: relative;
}

.mission-hub::before {
  content: "";
  position: absolute;
  inset: -45% auto auto 35%;
  width: 38rem;
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(230, 169, 60, 0.22), transparent 62%);
  animation: scanGlow 6s ease-in-out infinite;
}

.energy-card,
.mission-map,
.feed-card {
  position: relative;
  z-index: 1;
}

.energy-card strong {
  display: block;
  margin: 14px 0 12px;
  font-size: clamp(2.2rem, 5vw, 3.5rem);
  line-height: 1;
}

.energy-card small {
  display: block;
  margin-top: 12px;
  color: var(--muted);
  line-height: 1.65;
}

.energy-track,
.meter {
  width: 100%;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(42, 50, 45, 0.08);
}

.energy-track {
  height: 16px;
  border: 1px solid rgba(255, 255, 255, 0.7);
}

.meter {
  height: 10px;
  margin-top: 16px;
}

.energy-fill,
.meter-fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--gold), var(--clay));
  transition: width 0.36s ease;
}

.meter-fill-warm {
  background: linear-gradient(90deg, var(--blue), var(--clay));
}

.mission-map {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.mission-node {
  position: relative;
  display: grid;
  gap: 8px;
  min-height: 116px;
  align-content: center;
  border: 1px solid rgba(42, 50, 45, 0.08);
  border-radius: 24px;
  padding: 16px;
  color: var(--ink);
  text-align: left;
  background: rgba(255, 255, 255, 0.76);
  box-shadow: 0 12px 28px rgba(42, 50, 45, 0.08);
  cursor: pointer;
  overflow: hidden;
  transition: transform 0.2s ease, background 0.2s ease;
}

.mission-node::after {
  content: "";
  position: absolute;
  inset: auto -24% -50% -24%;
  height: 82%;
  background: radial-gradient(circle, rgba(230, 169, 60, 0.24), transparent 68%);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.mission-node:hover,
.mission-node:focus-visible {
  transform: translateY(-3px);
  outline: none;
}

.mission-node span {
  width: 42px;
  height: 42px;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  color: var(--green-dark);
  background: rgba(47, 125, 91, 0.1);
  font-weight: 900;
}

.mission-node strong {
  position: relative;
  z-index: 1;
}

.mission-node.active {
  background: rgba(255, 248, 230, 0.94);
}

.mission-node.complete {
  color: #fff;
  background: linear-gradient(145deg, var(--green), var(--green-dark));
}

.mission-node.active::after,
.mission-node.complete::after {
  opacity: 1;
}

.mission-node.complete span {
  color: var(--green-dark);
  background: rgba(255, 255, 255, 0.9);
}

.activity-feed {
  display: grid;
  gap: 10px;
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
}

.feed-item {
  padding: 12px 14px;
  border: 1px solid rgba(42, 50, 45, 0.08);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.74);
}

.feed-item strong,
.feed-item span {
  display: block;
}

.feed-item strong {
  margin-bottom: 4px;
  color: var(--green-dark);
}

.feed-item span {
  color: var(--muted);
  line-height: 1.55;
  font-size: 0.92rem;
}

.feed-item.success {
  background: rgba(47, 125, 91, 0.11);
}

.feed-item.warning {
  background: rgba(197, 96, 61, 0.11);
}

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

.panel {
  padding: 24px;
}

.overview-panel,
.case-panel {
  grid-column: span 2;
}

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

.unit-intro {
  margin: 14px 0 0;
}

.summary-grid,
.section-list,
.flash-grid {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.summary-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

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

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

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

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

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

.summary-card p,
.section-card p,
.task-note {
  margin: 0;
  color: var(--muted);
  line-height: 1.72;
}

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

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

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

.flash-front {
  background: linear-gradient(145deg, rgba(47, 125, 91, 0.12), rgba(230, 169, 60, 0.14));
}

.flash-back {
  display: none;
  background: linear-gradient(145deg, rgba(197, 96, 61, 0.14), rgba(63, 110, 148, 0.13));
}

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

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

.flash-label {
  color: var(--green-dark);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.08em;
}

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

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

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

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

.ghost-btn {
  color: var(--green-dark);
  background: rgba(47, 125, 91, 0.1);
}

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

.score-pill {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  border-radius: 999px;
  padding: 10px 14px;
  background: rgba(230, 169, 60, 0.18);
  font-weight: 900;
}

.score-pill span {
  font-size: 1.5rem;
}

.task-box {
  margin-top: 18px;
}

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

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

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

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

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

.option-btn:hover,
.option-btn:focus-visible {
  transform: translateX(4px);
  outline: none;
  border-color: rgba(47, 125, 91, 0.32);
}

.option-btn.correct {
  border-color: rgba(47, 125, 91, 0.5);
  background: rgba(47, 125, 91, 0.12);
}

.option-btn.incorrect {
  border-color: rgba(197, 96, 61, 0.5);
  background: rgba(197, 96, 61, 0.13);
}

.task-note {
  margin-top: 14px;
  padding: 14px 16px;
  border: 1px solid rgba(42, 50, 45, 0.08);
  border-radius: var(--radius-md);
  background: rgba(255, 252, 241, 0.92);
}

.case-restart {
  margin-top: 18px;
}

.hidden {
  display: none !important;
}

.effect-layer {
  position: fixed;
  inset: 0;
  z-index: 20;
  overflow: hidden;
  pointer-events: none;
}

.feedback-burst {
  position: absolute;
  left: var(--burst-x);
  top: var(--burst-y);
  translate: -50% -50%;
  padding: 12px 18px;
  border-radius: 999px;
  color: #fff;
  font-weight: 900;
  box-shadow: 0 16px 36px rgba(42, 50, 45, 0.18);
  animation: feedbackPop 1.05s ease forwards;
}

.feedback-burst.success {
  background: linear-gradient(135deg, var(--green), var(--green-dark));
}

.feedback-burst.warning {
  background: linear-gradient(135deg, var(--clay), #8c3428);
}

.pulse-success {
  animation: panelPulseSuccess 0.7s ease;
}

.pulse-warning {
  animation: panelPulseWarning 0.7s ease;
}

.page-refresh .overview-panel,
.page-refresh .lens-panel,
.page-refresh .flash-panel,
.page-refresh .match-panel,
.page-refresh .quiz-panel,
.page-refresh .case-panel,
.page-refresh .mission-hub {
  animation: cardRefresh 0.62s ease both;
}

@keyframes mapDrift {
  from {
    background-position: 0 0;
  }
  to {
    background-position: 96px 48px;
  }
}

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

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

@keyframes scanGlow {
  0%,
  100% {
    opacity: 0.52;
    transform: translateX(-18px) scale(0.96);
  }
  50% {
    opacity: 0.94;
    transform: translateX(18px) scale(1.04);
  }
}

@keyframes feedbackPop {
  0% {
    opacity: 0;
    transform: translateY(16px) scale(0.82);
  }
  18% {
    opacity: 1;
    transform: translateY(0) scale(1.06);
  }
  100% {
    opacity: 0;
    transform: translateY(-44px) scale(0.92);
  }
}

@keyframes panelPulseSuccess {
  0%,
  100% {
    box-shadow: var(--shadow);
  }
  45% {
    box-shadow: 0 0 0 5px rgba(47, 125, 91, 0.18), var(--shadow);
  }
}

@keyframes panelPulseWarning {
  0%,
  100% {
    box-shadow: var(--shadow);
  }
  45% {
    box-shadow: 0 0 0 5px rgba(197, 96, 61, 0.2), var(--shadow);
  }
}

@keyframes cardRefresh {
  0% {
    opacity: 0.72;
    transform: translateY(6px) scale(0.995);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

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

  .overview-panel,
  .case-panel {
    grid-column: span 1;
  }

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

  .mission-map {
    grid-template-columns: repeat(4, minmax(132px, 1fr));
    overflow-x: auto;
    padding-bottom: 8px;
    -webkit-overflow-scrolling: touch;
  }
}

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

  .hero-panel,
  .control-panel,
  .mission-hub,
  .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;
    white-space: nowrap;
  }

  .stamp-field {
    display: none;
  }
}

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

  .map-glow,
  .hero-panel::after {
    display: none;
  }

  .hero-panel,
  .control-panel,
  .mission-hub,
  .panel {
    padding: 18px;
    border-radius: 22px;
  }

  .hero-panel h1 {
    font-size: clamp(2.05rem, 10vw, 3.1rem);
  }

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

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

  .mission-map {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow-x: visible;
  }

  .mission-node {
    min-height: 104px;
    padding: 14px;
  }

  .task-actions,
  .primary-btn,
  .ghost-btn {
    width: 100%;
  }

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

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

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

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

  .hero-panel,
  .control-panel,
  .mission-hub,
  .panel {
    padding: 16px;
    border-radius: 20px;
  }

  .mode-link,
  .hero-badges span,
  .keyword-list span,
  .mission-tag {
    min-height: 32px;
    padding: 7px 12px;
    font-size: 0.84rem;
  }

  .passport-card {
    padding: 18px;
  }

  .level-ring {
    width: 148px;
  }

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

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
