:root {
  --bg: #fbf3e3;
  --bg-deep: #f3dfbd;
  --paper: #fffaf0;
  --paper-strong: #fff6df;
  --coffee: #3f2618;
  --coffee-2: #5b3a27;
  --muted: #7b6658;
  --accent: #e87924;
  --accent-dark: #b95618;
  --accent-soft: #ffe0b7;
  --sage: #3f7a52;
  --sage-soft: #e6f2df;
  --wrong: #a84732;
  --line: #e5c99f;
  --shadow: 0 18px 44px rgba(74, 44, 24, 0.16);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100%;
  margin: 0;
  padding: 28px 28px 72px;
  color: var(--coffee);
  font-family: "PingFang TC", "Microsoft JhengHei", "Noto Sans TC", "Heiti TC", sans-serif;
  background:
    linear-gradient(90deg, rgba(63, 38, 24, 0.035) 1px, transparent 1px),
    linear-gradient(rgba(63, 38, 24, 0.035) 1px, transparent 1px),
    radial-gradient(circle at 12% 8%, rgba(232, 121, 36, 0.14), transparent 28%),
    linear-gradient(135deg, var(--bg) 0%, #fff8ea 48%, var(--bg-deep) 100%);
  background-size: 36px 36px, 36px 36px, auto, auto;
}

button {
  font: inherit;
}

button:focus-visible {
  outline: 4px solid rgba(232, 121, 36, 0.42);
  outline-offset: 3px;
}

.app-shell {
  width: min(1240px, 100%);
  min-height: calc(100vh - 112px);
  margin: 0 auto;
}

.screen {
  display: none;
}

.screen.active {
  display: block;
  animation: screenIn 260ms ease-out;
}

.home-screen {
  min-height: calc(100vh - 112px);
  padding: 48px;
  position: relative;
  overflow: hidden;
  background: rgba(255, 250, 240, 0.78);
  border: 2px solid rgba(91, 58, 39, 0.16);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.home-screen::before {
  content: "";
  position: absolute;
  inset: 18px;
  border: 1px dashed rgba(91, 58, 39, 0.2);
  border-radius: var(--radius);
  pointer-events: none;
}

.home-copy,
.mode-grid,
.text-link {
  position: relative;
  z-index: 1;
}

.brandline {
  width: fit-content;
  margin: 0 0 18px;
  padding: 10px 16px;
  color: var(--accent-dark);
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: 0;
  background: var(--accent-soft);
  border: 2px solid rgba(232, 121, 36, 0.25);
  border-radius: var(--radius);
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  max-width: 820px;
  margin-bottom: 16px;
  color: var(--coffee);
  font-size: 4.8rem;
  line-height: 1.05;
  letter-spacing: 0;
}

.subtitle {
  margin-bottom: 44px;
  color: var(--coffee-2);
  font-size: 2.05rem;
  font-weight: 700;
}

.home-visual {
  position: absolute;
  right: 54px;
  top: 42px;
  width: 300px;
  height: 240px;
  color: var(--coffee);
}

.home-visual span {
  position: absolute;
  display: grid;
  place-items: center;
  width: 96px;
  height: 96px;
  font-size: 4.1rem;
  background: rgba(255, 250, 240, 0.86);
  border: 2px solid rgba(91, 58, 39, 0.18);
  border-radius: 50%;
  box-shadow: 0 14px 32px rgba(74, 44, 24, 0.12);
}

.home-visual .stamp {
  right: 120px;
  top: 6px;
  transform: rotate(-10deg);
}

.home-visual .lens {
  right: 28px;
  top: 70px;
  width: 124px;
  height: 124px;
  font-size: 5rem;
  border-color: rgba(232, 121, 36, 0.4);
}

.home-visual .target {
  right: 168px;
  top: 132px;
  transform: rotate(8deg);
}

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

.mode-card {
  min-height: 168px;
  padding: 26px 22px;
  color: var(--coffee);
  font-size: 1.75rem;
  font-weight: 900;
  line-height: 1.25;
  text-align: left;
  cursor: pointer;
  background: var(--paper);
  border: 3px solid rgba(91, 58, 39, 0.18);
  border-radius: var(--radius);
  box-shadow: 0 12px 28px rgba(74, 44, 24, 0.12);
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.mode-card:hover {
  transform: translateY(-5px);
  border-color: rgba(232, 121, 36, 0.62);
  background: #fff2d8;
  box-shadow: 0 18px 38px rgba(74, 44, 24, 0.18);
}

.mode-icon {
  display: block;
  margin-bottom: 18px;
  font-size: 3rem;
}

.text-link {
  margin-top: 26px;
  padding: 12px 16px;
  color: var(--coffee-2);
  font-size: 1.08rem;
  font-weight: 800;
  cursor: pointer;
  background: transparent;
  border: 0;
  border-bottom: 3px solid rgba(232, 121, 36, 0.45);
}

.text-link:hover {
  color: var(--accent-dark);
  border-bottom-color: var(--accent);
}

.mode-screen {
  padding: 26px;
  background: rgba(255, 250, 240, 0.82);
  border: 2px solid rgba(91, 58, 39, 0.14);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
  padding-bottom: 18px;
  border-bottom: 2px solid rgba(91, 58, 39, 0.12);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent-dark);
  font-size: 1.05rem;
  font-weight: 900;
}

h2 {
  margin: 0;
  color: var(--coffee);
  font-size: 2.65rem;
  line-height: 1.12;
  letter-spacing: 0;
}

.small-button,
.control-button {
  min-height: 52px;
  padding: 12px 20px;
  color: var(--coffee);
  font-size: 1.08rem;
  font-weight: 900;
  cursor: pointer;
  background: #fff8e8;
  border: 2px solid rgba(91, 58, 39, 0.22);
  border-radius: var(--radius);
  transition: transform 150ms ease, background 150ms ease, border-color 150ms ease, opacity 150ms ease;
}

.small-button:hover,
.control-button:hover {
  transform: translateY(-2px);
  background: #ffefcf;
  border-color: rgba(232, 121, 36, 0.55);
}

.small-button:disabled,
.control-button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
  transform: none;
}

.danger {
  color: #fff;
  background: var(--wrong);
  border-color: rgba(168, 71, 50, 0.7);
}

.danger:hover {
  background: #8f3825;
}

.status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.counter,
.category-pill {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  padding: 8px 14px;
  color: var(--coffee-2);
  font-size: 1.1rem;
  font-weight: 900;
  background: var(--paper-strong);
  border: 2px solid rgba(91, 58, 39, 0.14);
  border-radius: var(--radius);
}

.category-pill {
  color: var(--accent-dark);
}

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

.dot {
  width: 14px;
  height: 14px;
  background: #dcc09a;
  border-radius: 50%;
}

.dot.active {
  background: var(--accent);
  transform: scale(1.18);
}

.lesson-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 22px;
  align-items: stretch;
}

.teacher-card,
.practice-card,
.buzzer-card,
.challenge-panel,
.result-panel,
.mistake-card {
  background: var(--paper);
  border: 2px solid rgba(91, 58, 39, 0.15);
  border-radius: var(--radius);
  box-shadow: 0 14px 30px rgba(74, 44, 24, 0.1);
}

.teacher-card,
.practice-card {
  min-height: 470px;
  padding: 28px;
}

.card-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  color: var(--accent-dark);
  font-size: 1.35rem;
  font-weight: 900;
}

.teacher-note {
  color: var(--coffee);
  font-size: 1.55rem;
  line-height: 1.75;
  white-space: pre-line;
}

.teacher-note strong,
.key-text {
  color: var(--accent-dark);
}

.question-text {
  margin-bottom: 20px;
  color: var(--coffee);
  font-size: 2rem;
  font-weight: 900;
  line-height: 1.38;
}

.option-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.option-button {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 64px;
  padding: 14px 18px;
  color: var(--coffee);
  font-size: 1.32rem;
  font-weight: 900;
  line-height: 1.25;
  text-align: left;
  cursor: pointer;
  background: #fff9eb;
  border: 2px solid rgba(91, 58, 39, 0.14);
  border-radius: var(--radius);
  transition: transform 150ms ease, background 150ms ease, border-color 150ms ease, opacity 150ms ease;
}

.option-button:hover {
  transform: translateX(4px);
  background: #ffefcf;
  border-color: rgba(232, 121, 36, 0.5);
}

.option-letter {
  display: inline-grid;
  flex: 0 0 auto;
  place-items: center;
  width: 40px;
  height: 40px;
  color: #fffaf0;
  background: var(--coffee-2);
  border-radius: 50%;
}

.option-button.selected {
  border-color: var(--accent);
  background: #ffedce;
}

.option-button.correct {
  color: #163a21;
  background: var(--sage-soft);
  border-color: rgba(63, 122, 82, 0.72);
}

.option-button.correct .option-letter {
  background: var(--sage);
}

.option-button.muted {
  opacity: 0.42;
}

.option-button.reveal.correct {
  animation: answerPop 420ms ease-out;
}

.feedback {
  margin-top: 18px;
  padding: 16px 18px;
  font-size: 1.25rem;
  font-weight: 800;
  line-height: 1.55;
  border-radius: var(--radius);
  animation: feedbackIn 220ms ease-out;
}

.hint-box {
  color: #6c441d;
  background: #fff0c9;
  border: 2px solid rgba(232, 121, 36, 0.34);
}

.answer-box {
  color: #193c22;
  background: #e8f3df;
  border: 2px solid rgba(63, 122, 82, 0.35);
}

.control-bar {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 20px;
}

.control-bar.wrap {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.control-button {
  min-height: 66px;
  font-size: 1.2rem;
}

.control-button.accent {
  color: #fffaf0;
  background: var(--accent);
  border-color: var(--accent-dark);
}

.control-button.accent:hover {
  background: var(--accent-dark);
}

.control-button.accent-soft {
  background: var(--accent-soft);
  border-color: rgba(232, 121, 36, 0.38);
}

.control-button.dark {
  color: #fffaf0;
  background: var(--coffee-2);
  border-color: var(--coffee);
}

.control-button.dark:hover {
  background: var(--coffee);
}

.buzzer-card {
  padding: 32px;
}

.buzzer-question {
  margin-bottom: 26px;
  color: var(--coffee);
  font-size: 2.8rem;
  font-weight: 900;
  line-height: 1.25;
}

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

.big-options .option-button {
  min-height: 92px;
  font-size: 1.55rem;
}

.challenge-body {
  min-height: 560px;
}

.challenge-panel,
.result-panel {
  padding: 32px;
}

.challenge-start {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 24px;
  align-items: center;
}

.challenge-start h3,
.result-panel h3 {
  margin-bottom: 12px;
  font-size: 2.45rem;
  line-height: 1.16;
}

.challenge-start p,
.result-panel p,
.mistake-toolbar p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.6;
}

.start-button {
  min-width: 220px;
  min-height: 92px;
  padding: 18px 28px;
  color: #fffaf0;
  font-size: 1.55rem;
  font-weight: 900;
  cursor: pointer;
  background: var(--accent);
  border: 3px solid var(--accent-dark);
  border-radius: var(--radius);
  box-shadow: 0 16px 30px rgba(232, 121, 36, 0.22);
  transition: transform 150ms ease, background 150ms ease;
}

.start-button:hover {
  transform: translateY(-4px);
  background: var(--accent-dark);
}

.challenge-question-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.progress-text {
  color: var(--coffee-2);
  font-size: 1.18rem;
  font-weight: 900;
}

.challenge-question {
  margin-bottom: 22px;
  font-size: 2.35rem;
  font-weight: 900;
  line-height: 1.32;
}

.challenge-actions,
.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 22px;
}

.score-board {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin: 24px 0;
}

.score-card {
  padding: 20px;
  background: #fff6df;
  border: 2px solid rgba(91, 58, 39, 0.14);
  border-radius: var(--radius);
}

.score-card strong {
  display: block;
  margin-bottom: 4px;
  color: var(--accent-dark);
  font-size: 2.6rem;
  line-height: 1;
}

.score-card span {
  color: var(--muted);
  font-size: 1rem;
  font-weight: 900;
}

.mistake-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  padding: 18px 20px;
  background: var(--paper);
  border: 2px solid rgba(91, 58, 39, 0.14);
  border-radius: var(--radius);
}

.mistake-list {
  display: grid;
  gap: 14px;
}

.mistake-card {
  padding: 20px;
}

.mistake-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.mistake-tag {
  padding: 6px 10px;
  color: var(--accent-dark);
  font-size: 0.95rem;
  font-weight: 900;
  background: var(--accent-soft);
  border-radius: var(--radius);
}

.mistake-question {
  margin-bottom: 12px;
  font-size: 1.35rem;
  font-weight: 900;
  line-height: 1.45;
}

.mistake-detail {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.mistake-detail div {
  padding: 12px;
  background: #fff7e6;
  border: 1px solid rgba(91, 58, 39, 0.12);
  border-radius: var(--radius);
}

.mistake-detail strong {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.95rem;
}

.empty-state {
  padding: 32px;
  color: var(--muted);
  font-size: 1.35rem;
  font-weight: 800;
  text-align: center;
  background: var(--paper);
  border: 2px dashed rgba(91, 58, 39, 0.2);
  border-radius: var(--radius);
}

.site-footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  min-height: 48px;
  color: #fff8e8;
  font-size: 1.05rem;
  font-weight: 900;
  letter-spacing: 0;
  background: var(--coffee);
  border-top: 3px solid var(--accent);
}

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

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

@keyframes answerPop {
  0% {
    transform: scale(0.98);
  }
  55% {
    transform: scale(1.025);
  }
  100% {
    transform: scale(1);
  }
}

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

@media (max-width: 1040px) {
  body {
    padding: 20px 18px 72px;
  }

  h1 {
    max-width: 620px;
    font-size: 3.75rem;
  }

  .home-visual {
    opacity: 0.55;
    transform: scale(0.86);
    transform-origin: top right;
  }

  .lesson-layout,
  .challenge-start {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 720px) {
  .home-screen,
  .mode-screen {
    padding: 20px;
  }

  .home-screen::before,
  .home-visual {
    display: none;
  }

  .brandline {
    font-size: 1rem;
  }

  h1 {
    font-size: 2.7rem;
  }

  h2 {
    font-size: 2rem;
  }

  .subtitle {
    margin-bottom: 28px;
    font-size: 1.45rem;
  }

  .mode-grid,
  .big-options,
  .score-board,
  .mistake-detail {
    grid-template-columns: 1fr;
  }

  .mode-card {
    min-height: 112px;
    font-size: 1.35rem;
  }

  .mode-icon {
    display: inline-block;
    margin: 0 10px 0 0;
    font-size: 1.8rem;
  }

  .topbar,
  .status-row,
  .mistake-toolbar,
  .challenge-question-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .teacher-card,
  .practice-card,
  .buzzer-card,
  .challenge-panel,
  .result-panel {
    padding: 20px;
  }

  .teacher-note,
  .big-options .option-button {
    font-size: 1.18rem;
  }

  .question-text,
  .buzzer-question,
  .challenge-question {
    font-size: 1.55rem;
  }

  .control-bar,
  .control-bar.wrap {
    grid-template-columns: 1fr;
  }
}
