/* ═══════════════════════════════
   共用測驗樣式（quiz-common.css）
   hiragana-quiz.html 與 katakana-quiz.html 共用；
   頁面內嵌 <style> 在本檔之後載入，頁面差異規則以覆寫方式生效。
   ═══════════════════════════════ */
:root {
  --ink:     oklch(7%  0.012 250);
  --paper:   #f5f0e8;
  --accent:  oklch(47% 0.160 25);
  --soft:    oklch(40% 0.030 250);
  --card:    oklch(97% 0.008 80);
  --success: oklch(60% 0.140 145);
  --fail:    oklch(47% 0.160 25);
  --neutral: oklch(55% 0.015 250);
  --border:  oklch(88% 0.006 80);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: 'Noto Sans JP', 'Noto Sans TC', sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px 16px 40px;
}

.section-tab:last-child { border-right: none; }

.section-tab.active {
  background: var(--ink);
  color: var(--paper);
  font-weight: 400;
}

.mode-tab:last-child { border-right: none; }

.mode-tab.active {
  background: var(--ink);
  color: var(--paper);
  font-weight: 400;
}

.progress-bar {
  width: 100%;
  max-width: 360px;
  height: 3px;
  background: rgba(0,0,0,0.08);
  border-radius: 2px;
  margin-bottom: 18px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.4s ease;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px 24px 24px;
  max-width: 360px;
  width: 100%;
  position: relative;
  overflow: hidden;
  margin-bottom: 16px;
}

.card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--accent);
}

.sr-badge {
  position: absolute;
  top: 12px; right: 14px;
  font-size: 0.75rem;
  color: var(--soft);
  opacity: 0.5;
  letter-spacing: 0.08em;
}

.question-type {
  font-size: 0.85rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--soft);
  margin-bottom: 14px;
  font-weight: 400;
}

.options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }

.option-btn:hover:not(:disabled) { border-color: var(--accent); background: rgba(192,57,43,0.04); transform: translateY(-1px); }

.option-btn.correct { background: rgba(39,174,96,0.1); border-color: var(--success); color: var(--success); font-weight: 400; }

.option-btn.wrong { background: rgba(192,57,43,0.08); border-color: var(--fail); color: var(--fail); }

.option-btn:disabled { cursor: default; }

.input-wrap { margin-bottom: 12px; }

.romaji-input {
  width: 100%;
  padding: 13px 16px;
  font-size: 1rem;
  font-family: 'Noto Sans JP', 'Noto Sans TC', sans-serif;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: white;
  color: var(--ink);
  outline: none;
  transition: border-color 0.2s;
  text-align: center;
  letter-spacing: 0.08em;
}

.romaji-input:focus { border-color: var(--accent); }

.romaji-input.correct { border-color: var(--success); background: rgba(39,174,96,0.06); color: var(--success); }

.romaji-input.wrong { border-color: var(--fail); background: rgba(192,57,43,0.06); }

.submit-btn {
  width: 100%;
  background: var(--soft);
  color: white;
  border: none;
  border-radius: 10px;
  padding: 12px;
  font-size: 1rem;
  font-family: 'Noto Sans JP', 'Noto Sans TC', sans-serif;
  cursor: pointer;
  letter-spacing: 0.06em;
  transition: all 0.2s;
  margin-bottom: 10px;
}

.submit-btn:hover { background: var(--accent); }

.next-btn {
  width: 100%;
  background: var(--ink);
  color: var(--paper);
  border: none;
  border-radius: 10px;
  padding: 13px;
  font-size: 1rem;
  font-family: 'Noto Sans JP', 'Noto Sans TC', sans-serif;
  cursor: pointer;
  letter-spacing: 0.06em;
  transition: all 0.2s;
  display: none;
}

.next-btn:hover { background: var(--accent); transform: translateY(-1px); }

.next-btn.visible { display: block; }

.feedback.show-correct { background: rgba(39,174,96,0.08); color: var(--success); }

.feedback.show-wrong { background: rgba(192,57,43,0.06); color: var(--fail); }

.speak-btn { background: none; border: none; font-size: 1.1rem; cursor: pointer; padding: 0 4px; vertical-align: middle; opacity: 0.65; line-height: 1; }

.speak-btn:hover { opacity: 1; }

.score-display {
  display: flex;
  justify-content: space-between;
  max-width: 360px;
  width: 100%;
  padding: 0 4px;
}

.score-item { text-align: center; font-size: 0.85rem; color: var(--neutral); letter-spacing: 0.05em; }

.score-num { display: block; font-size: 1.5rem; font-weight: 400; color: var(--ink); font-family: 'Noto Sans JP', 'Noto Sans TC', sans-serif; }

.result-screen { text-align: center; padding: 16px 8px; }

.result-screen .big-emoji { font-size: 3rem; margin: 8px 0; }

.result-screen h2 { font-size: 1.2rem; font-weight: 400; margin-bottom: 8px; }

.result-screen p { font-size: 0.95rem; color: var(--soft); margin-bottom: 18px; line-height: 1.6; }

.kofi-cta { margin-top: 28px; padding-top: 18px; border-top: 1px solid var(--border); text-align: center; font-size: 0.9rem; }

.kofi-cta a { color: var(--soft); text-decoration: none; transition: color 0.2s; }

.kofi-cta a u { text-decoration: underline; text-underline-offset: 3px; }

.kofi-cta a:hover { color: var(--accent); }

.restart-btn {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 10px;
  padding: 12px 28px;
  font-size: 1rem;
  font-family: 'Noto Sans JP', 'Noto Sans TC', sans-serif;
  cursor: pointer;
  letter-spacing: 0.06em;
  transition: all 0.2s;
}

.restart-btn:hover { opacity: 0.88; transform: translateY(-1px); }

.wrong-list {
  margin-top: 20px;
  text-align: left;
  border-top: 1px solid var(--border);
  padding-top: 14px;
}

.wrong-title {
  font-size: 0.9rem;
  color: var(--accent);
  letter-spacing: 0.08em;
  margin-bottom: 10px;
  text-align: center;
}

.wrong-item {
  padding: 9px 6px;
  border-bottom: 1px dashed var(--border);
  font-size: 0.88rem;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.wrong-item:last-child { border-bottom: none; }

.wrong-front {
  font-family: 'Noto Sans JP', 'Noto Sans TC', sans-serif;
  color: var(--ink);
  font-size: 1.05rem;
  font-weight: 500;
  letter-spacing: 0.03em;
}

.wrong-back {
  color: var(--soft);
  line-height: 1.5;
}

.topic-btn.active {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
  font-weight: 400;
}

.hint-toggle-wrap {
  max-width: 360px;
  width: 100%;
  margin-bottom: 10px;
  display: flex;
  justify-content: flex-end;
}

.hint-toggle-btn {
  padding: 5px 12px;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  font-size: 0.88rem;
  font-family: 'Noto Sans JP', 'Noto Sans TC', sans-serif;
  cursor: pointer;
  background: white;
  color: var(--soft);
  transition: all 0.15s;
}

.hint-toggle-btn.active {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
  font-weight: 400;
}

.round-filter {
  display: flex;
  max-width: 360px;
  width: 100%;
  margin-bottom: 10px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.round-btn {
  flex: 1;
  padding: 9px 2px;
  border: none;
  background: white;
  color: var(--neutral);
  font-family: 'Noto Sans JP', 'Noto Sans TC', sans-serif;
  font-size: 0.88rem;
  cursor: pointer;
  transition: all 0.2s;
  border-right: 1px solid var(--border);
  letter-spacing: 0.02em;
}

.round-btn:last-child { border-right: none; }

.round-btn.active { background: var(--accent); color: white; font-weight: 400; }

.nav-links {
  display: flex;
  gap: 20px;
  width: 100%;
  max-width: 360px;
  margin-bottom: 12px;
}

.nav-links a {
  color: var(--soft);
  text-decoration: none;
  font-size: 0.85rem;
  letter-spacing: 0.03em;
  transition: color 0.2s;
}

.nav-links a:hover { color: var(--accent); }

.nav-links { align-items: center; }

.user-badge {
  margin-left: auto;
  display: flex; align-items: center; gap: 5px;
  font-size: 0.78rem; color: var(--soft);
  cursor: pointer; padding: 3px 10px;
  border-radius: 20px; border: 1px solid #ddd;
  background: transparent; transition: all 0.2s;
  white-space: nowrap; font-family: inherit;
}

.user-badge:hover { border-color: var(--accent); color: var(--accent); }

.sync-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: #ccc; flex-shrink: 0;
}

.sync-dot.synced { background: #27ae60; }

.sync-dot.syncing { background: #f39c12; animation: blink 1s infinite; }

.sync-dot.error { background: var(--accent); }

@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0.3} }

.user-modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; opacity: 0; pointer-events: none; transition: opacity 0.2s;
}

.user-modal-overlay.open { opacity: 1; pointer-events: all; }

.user-modal {
  background: var(--paper); border-radius: 12px;
  padding: 28px; width: min(90vw, 340px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.25);
}

.user-modal h3 { font-size: 1rem; margin-bottom: 8px; }

.user-modal p { font-size: 0.82rem; color: var(--soft); margin-bottom: 14px; line-height: 1.55; }

.user-modal input {
  width: 100%; padding: 9px 12px;
  border: 1.5px solid #ddd; border-radius: 8px;
  font-size: 0.95rem; font-family: monospace;
  background: white; margin-bottom: 4px;
}

.user-modal input:focus { outline: none; border-color: var(--accent); }

.user-modal-err { color: var(--accent); font-size: 0.78rem; min-height: 1.2em; margin-bottom: 10px; }

.user-modal-btns { display: flex; gap: 8px; }

.user-modal-btns button {
  flex: 1; padding: 9px; border-radius: 8px;
  border: none; font-size: 0.9rem; cursor: pointer; font-family: inherit;
}

.btn-confirm { background: var(--accent); color: white; }

.btn-cancel { background: #eee; color: var(--soft); }
