:root {
  --ink: #17233d;
  --muted: #748096;
  --line: #dfe5ea;
  --panel: rgba(255, 255, 255, 0.88);
  --white: #fff;
  --navy: #17345b;
  --navy-dark: #102846;
  --teal: #24a596;
  --teal-soft: #e4f5f2;
  --red: #e26666;
  --red-soft: #fff0ef;
  --shadow: 0 24px 70px rgba(28, 54, 82, 0.13);
  font-family: "DM Sans", "Noto Sans TC", sans-serif;
  color: var(--ink);
  background: #f5f8f7;
  font-synthesis: none;
}

* { box-sizing: border-box; }

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background:
    linear-gradient(135deg, rgba(240, 247, 245, 0.96), rgba(250, 250, 247, 0.98)),
    radial-gradient(circle at 18% 18%, rgba(36, 165, 150, 0.09), transparent 30%);
}

button, input { font: inherit; }
button { color: inherit; }

.ambient {
  position: fixed;
  z-index: -1;
  width: 430px;
  height: 430px;
  border-radius: 50%;
  filter: blur(2px);
  opacity: 0.55;
}
.ambient-one { top: -220px; right: -120px; background: rgba(36, 165, 150, 0.12); }
.ambient-two { bottom: -260px; left: -180px; background: rgba(23, 52, 91, 0.08); }

.app-shell { width: min(1120px, calc(100% - 40px)); margin: 0 auto; }

.site-header {
  height: 90px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand { display: inline-flex; align-items: center; gap: 11px; color: var(--navy); text-decoration: none; font-weight: 700; font-size: 20px; letter-spacing: -0.3px; }
.brand-mark { display: grid; place-items: center; width: 35px; height: 35px; border-radius: 10px; color: #fff; background: var(--navy); font-size: 16px; box-shadow: 0 8px 18px rgba(23, 52, 91, 0.18); }
.header-note { color: #9aa4b3; font-size: 12px; letter-spacing: 1.4px; text-transform: uppercase; }

.screen { display: none; }
.screen.is-active { display: flex; animation: screenIn 0.38s ease both; }
@keyframes screenIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.setup-screen { min-height: calc(100vh - 120px); align-items: center; justify-content: space-between; gap: 90px; padding: 34px 0 75px; }
.hero-copy { flex: 1; padding-left: 5px; }
.eyebrow { color: var(--teal); font-size: 11px; font-weight: 700; letter-spacing: 2.4px; }
.hero-copy h1 { margin: 20px 0 22px; color: var(--navy); font-size: clamp(44px, 5vw, 68px); line-height: 1.13; letter-spacing: -3px; }
.hero-copy h1 em { color: var(--teal); font-style: normal; }
.hero-copy p { color: var(--muted); font-size: 16px; }

.setup-card, .quiz-card, .result-card {
  background: var(--panel);
  border: 1px solid rgba(220, 227, 230, 0.8);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}
.setup-card { width: min(100%, 540px); padding: 34px; border-radius: 24px; }
.field-group { margin: 0 0 25px; padding: 0; border: 0; }
.field-group legend, .field-label { display: block; margin-bottom: 11px; color: #46536a; font-size: 12px; font-weight: 700; letter-spacing: 0.8px; text-transform: uppercase; }
.choice-grid { display: grid; gap: 12px; }
.two-columns { grid-template-columns: repeat(2, 1fr); }
.choice-card { position: relative; display: flex; min-height: 86px; align-items: center; gap: 12px; padding: 16px; cursor: pointer; border: 1px solid var(--line); border-radius: 15px; transition: 0.2s ease; }
.choice-card:hover { transform: translateY(-1px); border-color: #b7d5d0; }
.choice-card input { position: absolute; opacity: 0; pointer-events: none; }
.choice-icon { display: grid; place-items: center; width: 38px; height: 38px; flex: 0 0 auto; border-radius: 11px; color: var(--navy); background: #eef2f5; }
.choice-icon svg, .icon-button svg, .speak-button svg, .primary-button svg, .result-emblem svg { width: 21px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.choice-card strong, .choice-card small { display: block; }
.choice-card strong { color: #26334a; font-size: 14px; }
.choice-card small { margin-top: 3px; color: #8a94a4; font-size: 11px; }
.choice-check { position: absolute; top: 12px; right: 12px; width: 16px; height: 16px; border: 1.5px solid #cbd3dc; border-radius: 50%; }
.choice-card:has(input:checked) { border-color: var(--teal); background: rgba(228, 245, 242, 0.45); box-shadow: 0 0 0 3px rgba(36, 165, 150, 0.07); }
.choice-card:has(input:checked) .choice-icon { color: var(--teal); background: var(--teal-soft); }
.choice-card:has(input:checked) .choice-check { border: 4px solid var(--teal); }

.segmented-control { display: grid; grid-template-columns: repeat(3, 1fr); padding: 4px; border-radius: 12px; background: #edf1f2; }
.segmented-control label { cursor: pointer; }
.segmented-control input { position: absolute; opacity: 0; }
.segmented-control span { display: block; padding: 10px; border-radius: 9px; color: #778293; text-align: center; font-size: 13px; font-weight: 600; transition: 0.2s; }
.segmented-control input:checked + span { color: var(--navy); background: #fff; box-shadow: 0 3px 10px rgba(29, 52, 75, 0.09); }

.count-row { display: flex; gap: 12px; }
.count-input { width: 78px; padding: 10px 8px; border: 1px solid var(--line); border-radius: 11px; outline: none; color: var(--navy); background: #fff; text-align: center; font-weight: 700; }
.count-input:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(36, 165, 150, 0.1); }
.count-presets { display: grid; flex: 1; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.count-presets button { cursor: pointer; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: #7c8796; font-size: 12px; transition: 0.2s; }
.count-presets button:hover, .count-presets button.is-selected { color: var(--teal); border-color: #a8d7d1; background: var(--teal-soft); }

.option-row { display: flex; align-items: center; justify-content: space-between; margin: 0 0 20px; padding: 17px 18px; border-radius: 13px; background: #f5f7f7; }
.option-row strong, .option-row small { display: block; }
.option-row strong { color: #3c485e; font-size: 13px; }
.option-row small { margin-top: 3px; color: #929ba9; font-size: 11px; }
.switch { position: relative; display: block; width: 44px; height: 25px; }
.switch input { position: absolute; opacity: 0; }
.switch span { position: absolute; inset: 0; cursor: pointer; border-radius: 999px; background: #cbd3d7; transition: 0.2s; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 19px; height: 19px; border-radius: 50%; background: #fff; box-shadow: 0 2px 5px rgba(0,0,0,0.16); transition: 0.2s; }
.switch input:checked + span { background: var(--teal); }
.switch input:checked + span::after { transform: translateX(19px); }

.primary-button { display: flex; width: 100%; min-height: 52px; align-items: center; justify-content: center; gap: 10px; cursor: pointer; border: 0; border-radius: 13px; color: #fff; background: var(--navy); font-weight: 700; font-size: 14px; box-shadow: 0 10px 24px rgba(23, 52, 91, 0.18); transition: 0.2s; }
.primary-button:hover { transform: translateY(-1px); background: var(--navy-dark); box-shadow: 0 13px 28px rgba(23, 52, 91, 0.23); }
.primary-button:active { transform: translateY(0); }
.form-error { min-height: 18px; margin: -6px 0 8px; color: var(--red); font-size: 12px; }

.quiz-screen { width: min(780px, 100%); min-height: calc(100vh - 100px); margin: 0 auto; flex-direction: column; padding: 28px 0 70px; }
.quiz-topbar { display: flex; align-items: center; gap: 18px; }
.icon-button { display: grid; width: 42px; height: 42px; flex: 0 0 auto; place-items: center; cursor: pointer; border: 1px solid var(--line); border-radius: 12px; color: var(--navy); background: rgba(255,255,255,0.75); }
.progress-area { flex: 1; }
.progress-meta { display: flex; justify-content: space-between; margin-bottom: 8px; color: #798496; font-size: 12px; font-weight: 600; }
.progress-track { height: 6px; overflow: hidden; border-radius: 99px; background: #dfe7e6; }
.progress-track span { display: block; width: 2%; height: 100%; border-radius: inherit; background: var(--teal); transition: width 0.35s ease; }
.stats-row { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin: 23px 0 16px; }
.stat { padding: 7px 12px; border-radius: 999px; color: #8390a0; background: rgba(255,255,255,0.65); font-size: 11px; }
.stat strong { margin-left: 3px; color: #425069; }
.stat-dot { display: inline-block; width: 6px; height: 6px; margin-right: 4px; border-radius: 50%; }
.stat-correct .stat-dot { background: var(--teal); }
.stat-wrong .stat-dot { background: var(--red); }

.quiz-card { flex: 1; padding: 48px 60px 42px; border-radius: 26px; text-align: center; }
.question-kicker { color: #96a0ad; font-size: 11px; font-weight: 700; letter-spacing: 1.5px; }
.meaning-text { min-height: 64px; margin: 18px auto 25px; color: var(--navy); font-family: "Noto Sans TC", sans-serif; font-size: clamp(19px, 3vw, 27px); font-weight: 600; line-height: 1.55; }
.word-stage { display: flex; min-height: 80px; align-items: center; justify-content: center; gap: 18px; margin-bottom: 28px; }
.word-mask { color: #2a3b55; font-size: clamp(23px, 4vw, 34px); font-weight: 600; letter-spacing: 0.06em; overflow-wrap: anywhere; }
.speak-button { display: inline-flex; align-items: center; gap: 7px; flex: 0 0 auto; cursor: pointer; border: 0; border-radius: 999px; padding: 9px 12px; color: var(--teal); background: var(--teal-soft); font-size: 11px; font-weight: 700; }
.speak-button svg { width: 17px; }
.answer-form { width: min(480px, 100%); margin: 0 auto; }
.answer-form label { display: block; margin-bottom: 9px; color: #68758a; text-align: left; font-size: 11px; font-weight: 700; }
.answer-form input { width: 100%; height: 55px; margin-bottom: 13px; padding: 0 18px; border: 1.5px solid #dbe2e7; border-radius: 13px; outline: 0; color: var(--navy); background: #fbfcfc; text-align: center; font-size: 19px; font-weight: 600; letter-spacing: 0.5px; }
.answer-form input:focus { border-color: var(--teal); box-shadow: 0 0 0 4px rgba(36, 165, 150, 0.09); }
.answer-form input:disabled { opacity: 0.65; }
.feedback-panel { display: none; width: min(480px, 100%); align-items: center; gap: 13px; margin: 18px auto 0; padding: 14px 16px; border-radius: 13px; text-align: left; }
.feedback-panel.is-visible { display: flex; animation: feedbackIn 0.25s ease; }
@keyframes feedbackIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }
.feedback-panel.is-correct, .feedback-panel.is-reveal { color: #177b70; background: var(--teal-soft); }
.feedback-panel.is-wrong { color: #b54e4e; background: var(--red-soft); }
.feedback-icon { display: grid; width: 28px; height: 28px; place-items: center; border-radius: 50%; color: #fff; background: currentColor; }
.feedback-icon::after { color: #fff; font-weight: 700; }
.feedback-panel.is-correct .feedback-icon::after { content: "✓"; }
.feedback-panel.is-wrong .feedback-icon::after { content: "×"; font-size: 20px; }
.feedback-panel.is-reveal .feedback-icon::after { content: "A"; font-size: 12px; }
.feedback-panel strong { font-size: 13px; }
.feedback-panel p { margin: 3px 0 0; color: #657487; font-size: 12px; }
.keyboard-tip { margin: 17px 0 0; color: #9ba5b1; text-align: center; font-size: 11px; }
kbd { padding: 2px 6px; border: 1px solid #d8dee2; border-radius: 5px; background: #fff; box-shadow: 0 1px 1px rgba(0,0,0,0.05); font-size: 10px; }

.result-screen { min-height: calc(100vh - 120px); align-items: center; justify-content: center; padding: 30px 0 70px; }
.result-card { width: min(550px, 100%); padding: 45px; border-radius: 26px; text-align: center; }
.result-emblem { display: grid; width: 55px; height: 55px; margin: 0 auto 18px; place-items: center; border-radius: 17px; color: var(--teal); background: var(--teal-soft); }
.result-emblem svg { width: 28px; }
.result-card h2 { margin: 12px 0 8px; color: var(--navy); font-size: 30px; letter-spacing: -0.8px; }
.result-card > p { margin: 0; color: var(--muted); font-size: 13px; }
.score-ring { --score: 100; display: grid; width: 155px; height: 155px; margin: 30px auto; place-items: center; border-radius: 50%; background: conic-gradient(var(--teal) calc(var(--score) * 1%), #e9eeed 0); position: relative; }
.score-ring::before { content: ""; position: absolute; inset: 10px; border-radius: 50%; background: #fff; }
.score-ring div { position: relative; }
.score-ring strong { color: var(--navy); font-size: 38px; letter-spacing: -2px; }
.score-ring span { color: var(--navy); font-weight: 600; }
.score-ring small { display: block; color: #929dab; font-size: 10px; }
.result-stats { display: grid; grid-template-columns: repeat(3, 1fr); margin: 0 0 28px; padding: 20px 0; border-block: 1px solid #e7ebed; }
.result-stats div + div { border-left: 1px solid #e7ebed; }
.result-stats span, .result-stats strong { display: block; }
.result-stats span { color: #8d97a5; font-size: 11px; }
.result-stats strong { margin-top: 5px; color: var(--navy); font-size: 21px; }

@media (max-width: 820px) {
  .setup-screen { min-height: calc(100vh - 90px); justify-content: center; padding: 20px 0 55px; }
  .hero-copy { display: none; }
  .setup-card { margin: 0 auto; }
}

@media (max-width: 560px) {
  .app-shell { width: min(100% - 24px, 1120px); }
  .site-header { height: 70px; }
  .header-note { display: none; }
  .setup-screen { min-height: calc(100vh - 70px); padding: 12px 0 35px; }
  .setup-card { padding: 22px; border-radius: 20px; }
  .choice-card { min-height: 80px; padding: 12px; }
  .choice-icon { display: none; }
  .count-row { flex-direction: column; }
  .count-input { width: 100%; }
  .count-presets { height: 38px; }
  .quiz-screen { padding-top: 15px; }
  .stats-row { justify-content: center; }
  .quiz-card { padding: 35px 20px 30px; }
  .word-stage { flex-direction: column; gap: 12px; }
  .word-mask { letter-spacing: 0.02em; }
  .result-card { padding: 35px 22px; }
}

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