/* styles.css — Hiragana Flashcards */

:root {
  --bg: #f4f7fb;
  --card-bg: #ffffff;
  --text: #1f2d3d;
  --muted: #7f8c9b;
  --primary: #d64550;
  --primary-dark: #b63741;
  --ok: #2e9e5b;
  --bad: #d64550;
  --border: #e3e8ef;
  --accent: #3f51b5;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans",
    "Noto Sans JP", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

#app { max-width: 560px; margin: 0 auto; padding: 20px; min-height: 100vh; }
.screen { display: none; }
.screen.active { display: block; }

/* ---------- setup ---------- */
.setup-header { text-align: center; margin: 24px 0; }
.setup-header h1 { font-size: 26px; }
.subtitle { color: var(--accent); font-size: 16px; }
.hint { color: var(--muted); font-size: 13px; margin-top: 10px; }

.setup-section { margin-bottom: 20px; }
.section-label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }

#level-select {
  width: 100%;
  padding: 12px;
  font-size: 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card-bg);
}

.btn-link {
  background: none; border: none; color: var(--accent);
  font-size: 13px; cursor: pointer; margin-top: 8px; padding: 0;
}
.btn-link:hover { text-decoration: underline; }

#custom-rows { display: none; }
#custom-rows.visible { display: block; }

.row-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.row-check {
  display: flex; align-items: center; gap: 8px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  cursor: pointer;
  font-size: 14px;
  user-select: none;
}
.row-check.on { border-color: var(--accent); background: #eef1fb; }
.row-check input { accent-color: var(--accent); }
.row-check .row-chars { color: var(--muted); font-size: 12px; margin-left: auto; }

.start-area { text-align: center; margin-top: 28px; }
.word-count { color: var(--muted); font-size: 14px; margin-bottom: 10px; }

/* ---------- buttons ---------- */
.btn {
  background: var(--card-bg);
  border: 1px solid var(--border);
  padding: 12px 18px;
  border-radius: 12px;
  font-size: 16px;
  cursor: pointer;
}
.btn:hover:not(:disabled) { background: #f0f0f0; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; border: none; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-ghost { border-style: dashed; color: var(--muted); }
.btn-icon {
  background: none; border: none; font-size: 20px;
  cursor: pointer; color: var(--muted); padding: 4px 8px;
}

/* ---------- card screen ---------- */
.card-header {
  display: flex; align-items: center; gap: 14px;
  margin: 8px 0 20px;
}
.card-progress { font-size: 14px; color: var(--muted); }
.card-streak { font-size: 14px; margin-left: auto; }

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.06);
  text-align: center;
  padding: 32px 20px;
  margin-bottom: 16px;
  transition: transform 0.1s;
}
.card.shake { animation: shake 0.35s; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  75% { transform: translateX(8px); }
}
.card-emoji { font-size: 56px; line-height: 1; margin-bottom: 12px; }
.card-word {
  font-size: 64px; font-weight: 700; letter-spacing: 0.05em;
  font-family: "Hiragino Sans", "Noto Sans JP", sans-serif;
}
.speak-btn {
  display: inline-block;
  font-size: 18px;
  margin-top: 6px;
  padding: 6px 10px;
  border-radius: 8px;
}
.speak-btn:hover { background: #eef1fb; }
.card-meaning { color: var(--muted); font-size: 15px; margin-top: 10px; }

/* 意味 (meaning) answer mode: emoji + meaning hidden until answered/revealed;
   mic hidden — speech recognition hears Japanese, but you answer in English */
.mode-meaning .card-emoji,
.mode-meaning .card-meaning { display: none; }
.mode-meaning.revealed .card-emoji,
.mode-meaning.revealed .card-meaning { display: block; }
.mode-meaning #btn-mic { display: none; }
.card-romaji {
  margin-top: 10px; font-size: 15px; color: var(--accent);
  opacity: 0; transition: opacity 0.2s;
}
.card-romaji.visible { opacity: 1; }

/* live speech recognition display */
.card-heard {
  margin-top: 14px;
  padding: 8px 14px;
  font-size: 20px;
  font-family: "Hiragino Sans", "Noto Sans JP", sans-serif;
  color: var(--accent);
  background: #eef1fb;
  border-radius: 10px;
  min-height: 20px;
  max-width: 90%;
  margin-left: auto; margin-right: auto;
  overflow-wrap: break-word;
}
.card-heard:empty { display: none; }

.card-feedback {
  min-height: 26px;
  text-align: center;
  font-size: 15px;
  margin-bottom: 12px;
}
.card-feedback.ok { color: var(--ok); font-weight: 600; }
.card-feedback.bad { color: var(--bad); }

.answer-area { display: flex; gap: 8px; }
#answer-input {
  flex: 1;
  padding: 12px 14px;
  font-size: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card-bg);
}
#answer-input:focus { outline: 2px solid var(--accent); border-color: transparent; }
.btn-mic { white-space: nowrap; }
.btn-mic.listening { background: #ffe9e9; border-color: var(--bad); color: var(--bad); }

.card-actions { display: flex; gap: 8px; margin-top: 12px; }
.card-actions .btn { flex: 1; }

/* ---------- done screen ---------- */
.done-section { text-align: center; }
.done-score { font-size: 40px; font-weight: 700; }
.done-streak { color: var(--muted); font-size: 14px; margin-bottom: 16px; }
.done-missed {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  font-size: 15px;
}
.missed-title { color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.missed-word { display: inline-block; margin: 4px 8px; font-size: 17px; }
.missed-word small { color: var(--muted); font-size: 12px; }

.setup-section .btn { margin: 0 6px 8px 0; width: 100%; }

@media (max-width: 480px) {
  #app { padding: 12px; }
  .card-word { font-size: 48px; }
  .row-grid { grid-template-columns: 1fr; }
}
