:root {
  --bg: #F1F2F6;
  --card: #FFFFFF;
  --accent: #3B59F2;
  --accent-soft: #E7EBFE;
  --danger: #EB4236;
  --danger-soft: #FDE8E6;
  --ok: #2EB86B;
  --ok-soft: #E3F6EA;
  --text: #212639;
  --muted: #858C9E;
  --line: #E3E5EC;
  --radius: 20px;
  --shadow: 0 4px 16px rgba(33, 38, 57, 0.06);
  --font: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN",
    "Noto Sans JP", "Yu Gothic", "Meiryo", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  min-height: 100vh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.app {
  max-width: 480px;
  margin: 0 auto;
  padding: 16px 16px 40px;
}

/* ---- brand ---- */
.brand {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 4px 4px 14px;
}
.brand-logo {
  font-weight: 800;
  font-size: 20px;
  letter-spacing: 0.02em;
  color: var(--accent);
}
.brand-sub {
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
}

/* ---- cards ---- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 20px;
  margin-bottom: 14px;
}
.card-title {
  margin: 0 0 12px;
  font-size: 15px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.02em;
}

/* ---- buttons ---- */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 52px;
  padding: 0 18px;
  border: 0;
  border-radius: 14px;
  font: inherit;
  font-size: 16px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: transform 80ms ease, opacity 120ms ease;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-secondary { background: var(--accent-soft); color: var(--accent); }
.btn-x { background: var(--text); color: #fff; }
.btn-text {
  display: block;
  margin: 14px auto 0;
  padding: 8px 16px;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.btn-text:active { opacity: 0.6; }

/* ---- top ---- */
.hero { padding: 28px 22px; }
.hero-eyebrow {
  margin: 0 0 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
}
.hero-title {
  margin: 0 0 12px;
  font-size: 30px;
  line-height: 1.3;
  font-weight: 800;
  letter-spacing: -0.01em;
}
.hero-lead { margin: 0 0 14px; color: var(--muted); font-size: 15px; }
.hero-points {
  margin: 0 0 22px;
  padding: 0;
  list-style: none;
  font-size: 14px;
  color: var(--text);
}
.hero-points li {
  position: relative;
  padding-left: 20px;
  margin-bottom: 6px;
}
.hero-points li::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 9px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
}
.error { color: var(--danger); font-size: 14px; margin: 12px 0 0; }

/* ---- quiz ---- */
.progress {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 4px 14px;
}
.progress-track {
  flex: 1;
  height: 8px;
  border-radius: 4px;
  background: #E3E5EC;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  width: 0;
  border-radius: 4px;
  background: var(--accent);
  transition: width 200ms ease;
}
.progress-count {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  min-width: 52px;
  text-align: right;
}
.quiz { padding: 26px 20px 18px; text-align: center; }
.quiz.pop { animation: pop 140ms ease-out; }
@keyframes pop {
  from { opacity: 0.4; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
.pos-chip {
  display: inline-block;
  min-width: 28px;
  padding: 2px 8px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}
.quiz-word {
  margin: 10px 0 4px;
  font-size: 46px;
  line-height: 1.2;
  font-weight: 800;
  letter-spacing: -0.01em;
  word-break: keep-all;
}
.quiz-ask { margin: 0 0 18px; font-size: 13px; color: var(--muted); }
.choices { display: grid; gap: 10px; }
.choice {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 54px;
  padding: 10px 14px;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  background: #fff;
  color: var(--text);
  font: inherit;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.35;
  text-align: center;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: background 100ms ease, border-color 100ms ease, transform 80ms ease;
}
.choice:active:not(:disabled) { transform: scale(0.985); background: #F7F8FB; }
.choice:disabled { cursor: default; }
.choice.is-correct {
  background: var(--ok-soft);
  border-color: var(--ok);
  color: #1E8A4F;
}
.choice.is-wrong {
  background: var(--danger-soft);
  border-color: var(--danger);
  color: #B3271E;
  animation: shake 200ms ease;
}
@keyframes shake {
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

/* ---- result ---- */
.result-main { text-align: center; padding: 28px 20px 20px; }
.result-label { margin: 0; font-size: 14px; font-weight: 700; color: var(--muted); }
.result-vocab {
  margin: 4px 0 10px;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.result-approx { font-size: 22px; color: var(--muted); margin-right: 4px; }
#r-vocab { font-size: 64px; }
.result-unit { font-size: 26px; margin-left: 4px; }
.tier-chip {
  display: inline-block;
  margin: 0 0 8px;
  padding: 6px 16px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
}
.result-sub { margin: 0; font-size: 13px; color: var(--muted); }
.result-rank { margin-top: 4px; color: var(--accent); font-weight: 700; }
.note { margin: 12px 0 0; font-size: 12px; color: var(--muted); }

.bars { display: grid; gap: 12px; }
.bar-row { display: grid; grid-template-columns: 56px 1fr 48px; align-items: center; gap: 10px; }
.bar-label { font-size: 14px; font-weight: 700; }
.bar-label small { display: block; font-size: 11px; color: var(--muted); font-weight: 600; }
.bar-track { height: 12px; border-radius: 6px; background: #E3E5EC; overflow: hidden; }
.bar-fill {
  height: 100%;
  width: 0;
  border-radius: 6px;
  background: var(--accent);
  transition: width 500ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
.bar-pct {
  font-size: 14px;
  font-weight: 700;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.share-preview {
  display: block;
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--line);
  margin-bottom: 12px;
}
.share-actions { display: grid; gap: 10px; }

.cta { background: var(--accent-soft); box-shadow: none; }
.cta .card-title { color: var(--accent); }
.cta-lead { margin: 0 0 14px; font-size: 14px; }

.missed summary {
  cursor: pointer;
  list-style: none;
  margin: 0;
}
.missed summary::-webkit-details-marker { display: none; }
.missed summary::after { content: "＋"; float: right; color: var(--muted); }
.missed[open] summary::after { content: "－"; }
.missed-list {
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 6px;
  font-size: 15px;
}
.missed-list li { display: flex; gap: 10px; align-items: baseline; }
.missed-list .ko { font-weight: 700; min-width: 5em; }
.missed-list .ja { color: var(--muted); font-size: 14px; }

.credits {
  margin-top: 28px;
  font-size: 11px;
  color: var(--muted);
  text-align: center;
  line-height: 1.5;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
