:root {
  --bg: #EEF2F7;
  --card: #FFFFFF;
  --ink: #1B2A41;
  --muted: #64748B;
  --teal: #2B8C82;
  --teal-dark: #1F6B63;
  --amber: #E8A33D;
  --coral: #E8635A;
  --border: #DCE3EC;
}

html {
  width: 100%;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Noto Sans TC', 'Inter', system-ui, sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.progress-rail {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: var(--border);
  z-index: 10;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--teal);
  transition: width .4s ease;
}

.screen {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.hidden { display: none !important; }

.card {
  background: var(--card);
  border-radius: 20px;
  padding: 40px 32px;
  max-width: 480px;
  width: 100%;
  box-shadow: 0 8px 30px rgba(27, 42, 65, 0.08);
  display: flex;
  flex-direction: column;
}
.card > div { max-width: 100%; }
.card.center { text-align: center; align-items: center; }

h1 {
  font-family: 'Inter', sans-serif;
  font-weight: 700;
  font-size: 26px;
  margin: 16px 0 12px;
}
h2 {
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 20px;
  margin: 0 0 16px;
}
.lead { color: var(--muted); font-size: 15px; line-height: 1.6; margin: 0 0 24px; }
.muted { color: var(--muted); font-size: 14px; margin-top: 16px; }
.eyebrow { font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 0 0 8px; }

.steps { padding-left: 20px; color: var(--ink); line-height: 1.8; margin: 0 0 20px; }
.steps li { margin-bottom: 6px; }

.btn-primary {
  background: var(--teal);
  color: white;
  border: none;
  border-radius: 12px;
  padding: 14px 20px;
  font-size: 15px;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  width: 100%;
  transition: background .15s;
}
.btn-primary:hover { background: var(--teal-dark); }
.btn-primary:focus-visible { outline: 3px solid var(--amber); outline-offset: 2px; }

form { display: flex; flex-direction: column; gap: 16px; width: 100%; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--ink); font-weight: 500; text-align: left; }
input[type="number"], input[type="text"], select {
  font-family: 'Noto Sans TC', 'Inter', sans-serif;
  font-size: 16px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1.5px solid var(--border);
  background: #FBFCFE;
  color: var(--ink);
  width: 100%;
  max-width: 100%;
}
input:focus, select:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(43, 140, 130, 0.15);
}

.pulse-dot {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--teal);
  margin: 0 auto 8px;
  opacity: 0.85;
}
.pulse-dot.listening { animation: pulse 1.1s ease-in-out infinite; }
@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 0.85; }
  50% { transform: scale(1.25); opacity: 0.5; }
}

.countdown-number {
  font-family: 'Inter', sans-serif;
  font-weight: 700;
  font-size: 64px;
  color: var(--amber);
  line-height: 1;
}

.key-hint {
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  margin-top: 10px;
}
@media (hover: none) { .key-hint { display: none; } }

/* --- Masked sentence display --- */
.masked-sentence {
  text-align: center;
  font-size: 26px;
  letter-spacing: 0.04em;
  margin: 8px 0 4px;
  font-family: 'Noto Sans TC', sans-serif;
  font-weight: 700;
}

/* --- Multiple-choice buttons (single character) --- */
.choice-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  width: 100%;
}
.choice-btn {
  font-family: 'Noto Sans TC', sans-serif;
  font-size: 28px;
  font-weight: 600;
  padding: 20px 10px;
  border-radius: 14px;
  border: 2px solid var(--border);
  background: #FBFCFE;
  color: var(--ink);
  cursor: pointer;
  transition: border-color .15s, background .15s, transform .1s;
}
.choice-btn:hover { border-color: var(--teal); background: #F0FAF8; }
.choice-btn:active { transform: scale(0.97); }
.choice-btn.selected-correct { border-color: var(--teal); background: #DFF5F1; color: var(--teal-dark); }
.choice-btn.selected-wrong { border-color: var(--coral); background: #FCEAE8; color: var(--coral); }
.choice-btn:disabled { cursor: default; }

/* --- Multiple-choice buttons (full sentence variant) --- */
.choice-grid-sentences {
  grid-template-columns: 1fr;
  gap: 10px;
}
.choice-grid-sentences .choice-btn {
  font-size: 18px;
  text-align: left;
  padding: 16px 18px;
  font-weight: 500;
  line-height: 1.5;
}

#stimulusAudio { width: 100%; max-width: 100%; }

@media (max-width: 420px) {
  body { padding: 16px 12px; }
  .card { padding: 28px 20px; border-radius: 16px; }
  h1 { font-size: 22px; }
  .countdown-number { font-size: 52px; }
  .masked-sentence { font-size: 22px; }
  .choice-btn { font-size: 24px; padding: 16px 8px; }
}

@media (prefers-reduced-motion: reduce) {
  .pulse-dot.listening { animation: none; }
  .progress-fill { transition: none; }
}
