:root {
  --c-bg: #f5f7fb;
  --c-bg-grad-1: #eef2ff;
  --c-bg-grad-2: #f5f7fb;
  --c-surface: #ffffff;
  --c-primary: #4f46e5;
  --c-primary-hover: #4338ca;
  --c-primary-soft: #eef2ff;
  --c-text: #1f2937;
  --c-text-sub: #6b7280;
  --c-text-muted: #9ca3af;
  --c-border: #e5e7eb;
  --c-success: #10b981;
  --c-success-soft: #ecfdf5;
  --c-error: #ef4444;
  --c-error-soft: #fef2f2;
  --c-accent: #f59e0b;

  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow-card: 0 2px 20px rgba(79, 70, 229, 0.08);
  --shadow-card-hover: 0 4px 28px rgba(79, 70, 229, 0.14);

  --ff-ui: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --ff-serif: Georgia, "Noto Serif JP", "Hiragino Mincho ProN", serif;
  --ff-num: "Inter", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: linear-gradient(180deg, var(--c-bg-grad-1) 0%, var(--c-bg-grad-2) 320px);
  background-attachment: fixed;
  color: var(--c-text);
  font-family: var(--ff-ui);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

a { color: var(--c-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.app {
  flex: 1;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

.hero {
  text-align: center;
  padding: 8px 8px 24px;
}
.hero h1 {
  font-size: 1.5rem;
  margin: 0 0 10px;
  letter-spacing: 0.02em;
}
.hero .lead {
  color: var(--c-text-sub);
  margin: 0;
  font-size: 0.95rem;
}

.br-sp { display: inline; }
@media (min-width: 768px) {
  .br-sp { display: none; }
}

.card {
  background: var(--c-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 24px;
  margin-bottom: 16px;
}
.card h2 {
  margin: 0 0 12px;
  font-size: 1.125rem;
}
.card h2:not(:first-child) { margin-top: 24px; }
.card h3 { margin-top: 0; font-size: 1.05rem; }

.card-flat {
  background: transparent;
  padding: 8px 4px 0;
}
.card-flat h3 { font-size: 1rem; color: var(--c-text-sub); margin: 24px 0 8px; }
.how {
  margin: 0;
  padding-left: 1.2em;
  color: var(--c-text-sub);
  font-size: 0.9rem;
  line-height: 1.9;
}

.center { text-align: center; }
.center-text { text-align: center; color: var(--c-text-sub); }

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}
.chip {
  background: var(--c-surface);
  border: 1.5px solid var(--c-border);
  color: var(--c-text);
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 0.92rem;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
  line-height: 1.3;
}
.chip:hover { border-color: var(--c-primary); color: var(--c-primary); }
.chip.is-selected {
  background: var(--c-primary-soft);
  border-color: var(--c-primary);
  color: var(--c-primary);
  font-weight: 600;
}
.chip-sub {
  display: inline-block;
  font-size: 0.75rem;
  color: var(--c-text-muted);
  margin-left: 4px;
  font-weight: 400;
}
.chip.is-selected .chip-sub { color: var(--c-primary); opacity: 0.75; }

.btn {
  display: inline-block;
  background: var(--c-primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  padding: 14px 32px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
  min-height: 48px;
  margin-top: 16px;
}
.btn:hover { background: var(--c-primary-hover); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:focus-visible { outline: 2px solid var(--c-primary); outline-offset: 2px; }
.btn.is-disabled, .btn:disabled { background: var(--c-text-muted); cursor: not-allowed; transform: none; }
.btn-wide { display: block; width: 100%; }
.btn-primary { }
.btn-secondary {
  background: transparent;
  color: var(--c-primary);
  border: 1px solid var(--c-primary);
}
.btn-secondary:hover {
  background: var(--c-primary);
  color: #fff;
}

.nav-top {
  margin: 0 0 10px;
  text-align: left;
}
.nav-top-link {
  color: var(--c-text-muted);
  text-decoration: none;
  font-size: 0.88rem;
  line-height: 1.4;
  padding: 6px 2px;
  display: inline-block;
}
.nav-top-link:hover {
  color: var(--c-primary);
  text-decoration: underline;
}

.quiz-nav {
  display: flex;
  gap: 12px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--c-border, #e5e7eb);
}
.quiz-nav-btn {
  flex: 1;
  margin-top: 0;
  padding-left: 12px;
  padding-right: 12px;
}
.quiz-nav-btn#btn-prev { flex: 0 1 42%; }
.quiz-nav-btn#btn-next { flex: 1 1 58%; }
@media (max-width: 420px) {
  .quiz-nav { gap: 8px; }
  .quiz-nav-btn { font-size: 0.92rem; padding: 14px 8px; }
}

.fine {
  font-size: 0.8rem;
  color: var(--c-text-muted);
  margin: 10px 0 0;
  line-height: 1.6;
}

.screen { display: none; }
.screen[data-active="true"] { display: block; animation: fadeIn 0.3s ease; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.dots {
  display: flex;
  gap: 8px;
  justify-content: center;
  padding: 24px 0 8px;
}
.dots span {
  width: 12px; height: 12px;
  background: var(--c-primary);
  border-radius: 50%;
  animation: pulse 1.2s infinite ease-in-out;
}
.dots span:nth-child(2) { animation-delay: 0.2s; }
.dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes pulse {
  0%, 100% { opacity: 0.3; transform: scale(0.8); }
  40% { opacity: 1; transform: scale(1); }
}
.loading-text { margin: 12px 0 6px; font-weight: 600; }

.ready-icon {
  display: block;
  width: 96px;
  height: 96px;
  margin: 8px auto 18px;
  filter: drop-shadow(0 10px 20px rgba(16, 185, 129, 0.25));
  animation: popIn 0.5s cubic-bezier(0.2, 1.4, 0.4, 1);
}
.ri-blob {
  transform-box: fill-box;
  transform-origin: 50% 50%;
  animation: riBlobPulse 2.8s ease-in-out infinite;
}
.ri-check {
  stroke-dasharray: 60;
  stroke-dashoffset: 60;
  animation: riCheckDraw 0.55s 0.25s ease-out forwards;
}
.ri-sparkles circle,
.ri-sparkles path {
  transform-box: fill-box;
  transform-origin: center;
  animation: riSparkle 2s ease-in-out infinite;
}
.ri-sparkles circle:nth-child(2) { animation-delay: 0.35s; }
.ri-sparkles circle:nth-child(3) { animation-delay: 0.7s; }
.ri-sparkles circle:nth-child(4) { animation-delay: 1.0s; }
.ri-sparkles path            { animation-delay: 0.5s; }

@keyframes popIn {
  from { opacity: 0; transform: scale(0.4) rotate(-12deg); }
  to   { opacity: 1; transform: scale(1)   rotate(0deg); }
}
@keyframes riBlobPulse {
  0%, 100% { transform: scale(1)    rotate(0deg); }
  50%      { transform: scale(1.04) rotate(-3deg); }
}
@keyframes riCheckDraw {
  to { stroke-dashoffset: 0; }
}
@keyframes riSparkle {
  0%, 100% { opacity: 0.45; transform: scale(0.8); }
  50%      { opacity: 1;    transform: scale(1.2); }
}

@media (prefers-reduced-motion: reduce) {
  .ready-icon, .ri-blob, .ri-check, .ri-sparkles circle, .ri-sparkles path {
    animation: none;
  }
  .ri-check { stroke-dashoffset: 0; }
}
.ready-meta { margin: 8px 0 10px; }
.ready-title {
  margin: 0 0 16px;
  font-size: 0.95rem;
  color: var(--c-text-sub);
  line-height: 1.55;
  font-weight: 600;
}
.ready-title:empty { display: none; }
.ready-desc {
  color: var(--c-text-sub);
  font-size: 0.95rem;
  margin: 8px 0 20px;
  line-height: 1.8;
}

.passage-head {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px dashed var(--c-border);
}
.badge {
  display: inline-block;
  background: var(--c-primary-soft);
  color: var(--c-primary);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}
#reading-title {
  margin: 0;
  font-size: 1.15rem;
  line-height: 1.5;
}

.passage {
  font-family: var(--ff-serif);
  font-size: 1.05rem;
  line-height: 1.95;
  color: var(--c-text);
  margin: 0 0 16px;
}
.passage p { margin: 0 0 1em; }
.passage p:last-child { margin-bottom: 0; }

.progress {
  display: flex;
  justify-content: flex-end;
  color: var(--c-text-sub);
  font-size: 0.85rem;
  margin-bottom: 4px;
  font-family: var(--ff-num);
}
#quiz-question {
  font-size: 1.05rem;
  line-height: 1.6;
  margin: 4px 0 16px;
}

.choices { display: flex; flex-direction: column; gap: 10px; }
.choice {
  background: var(--c-surface);
  border: 1.5px solid var(--c-border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  cursor: pointer;
  text-align: left;
  font-size: 0.95rem;
  line-height: 1.5;
  transition: all 0.15s ease;
  font-family: inherit;
  color: var(--c-text);
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.choice:hover { border-color: var(--c-primary); }
.choice.is-selected {
  border-color: var(--c-primary);
  background: var(--c-primary-soft);
}
.choice-letter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px; height: 24px;
  background: var(--c-border);
  color: var(--c-text-sub);
  border-radius: 50%;
  font-size: 0.8rem;
  font-weight: 700;
  flex: 0 0 24px;
  font-family: var(--ff-num);
}
.choice.is-selected .choice-letter { background: var(--c-primary); color: #fff; }

.result-heading { text-align: center; margin: 0 0 8px; }

.wpm-block {
  text-align: center;
  padding: 16px 0 8px;
}
.wpm-value {
  font-family: var(--ff-num);
  font-size: 3.5rem;
  font-weight: 800;
  line-height: 1;
  color: var(--c-primary);
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.wpm-unit {
  color: var(--c-text-sub);
  font-size: 0.95rem;
  margin-top: 4px;
}
.wpm-sub { color: var(--c-text-muted); font-size: 0.8rem; }

.wpm-bar {
  margin: 20px auto 8px;
  max-width: 420px;
  height: 10px;
  background: var(--c-border);
  border-radius: 999px;
  position: relative;
  overflow: visible;
}
.wpm-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #818cf8, var(--c-primary));
  border-radius: 999px;
  width: 0%;
  transition: width 0.8s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.wpm-bar-marks {
  display: flex;
  justify-content: space-between;
  color: var(--c-text-muted);
  font-size: 0.7rem;
  font-family: var(--ff-num);
  margin-top: 4px;
  padding: 0 2px;
}
.wpm-eval {
  margin: 14px 0 0;
  font-size: 0.95rem;
  color: var(--c-text);
}
.wpm-eval strong { color: var(--c-primary); }

.stat-row {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px dashed var(--c-border);
}
.stat {
  flex: 1 1 100px;
  min-width: 100px;
  text-align: center;
  padding: 8px;
}
.stat-label { display: block; color: var(--c-text-sub); font-size: 0.8rem; }
.stat-value {
  display: block;
  font-family: var(--ff-num);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--c-text);
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}

.answers-list { display: flex; flex-direction: column; gap: 16px; }
.answer-item {
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
}
.answer-item.is-correct { border-color: var(--c-success); background: var(--c-success-soft); }
.answer-item.is-wrong { border-color: var(--c-error); background: var(--c-error-soft); }
.answer-q { font-weight: 600; margin: 0 0 8px; font-size: 0.95rem; }
.answer-meta { font-size: 0.8rem; color: var(--c-text-sub); margin-bottom: 8px; }
.answer-meta .ok { color: var(--c-success); font-weight: 700; }
.answer-meta .ng { color: var(--c-error); font-weight: 700; }
.answer-explain {
  margin: 8px 0 0;
  font-size: 0.9rem;
  line-height: 1.75;
  color: var(--c-text);
  background: rgba(255,255,255,0.6);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
}

.expressions-list {
  display: flex;
  flex-direction: column;
}
.expr-item {
  padding: 16px 0;
  border-bottom: 1px solid var(--c-border);
}
.expr-item:first-child { padding-top: 4px; }
.expr-item:last-child { border-bottom: none; padding-bottom: 0; }
.expr-phrase {
  font-family: var(--ff-serif);
  font-size: 1.1rem;
  color: var(--c-text);
  font-weight: 700;
  margin: 0 0 6px;
  letter-spacing: 0.01em;
}
.expr-meaning {
  margin: 0 0 8px;
  font-weight: 500;
  font-size: 0.95rem;
  color: var(--c-text);
}
.expr-tip {
  margin: 0;
  color: var(--c-text-sub);
  font-size: 0.85rem;
  line-height: 1.75;
  padding-left: 12px;
  border-left: 2px solid var(--c-primary-soft);
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: #1f2937;
  color: #fff;
  padding: 12px 20px;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  box-shadow: 0 10px 30px rgba(0,0,0,0.2);
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s ease;
  max-width: 92%;
  text-align: center;
  z-index: 100;
}
.toast.is-show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast.is-error { background: var(--c-error); }

.site-footer {
  text-align: center;
  padding: 16px;
  color: var(--c-text-muted);
  font-size: 0.8rem;
}

@media (min-width: 768px) {
  .app { padding: 40px 24px 64px; }
  .hero { padding: 16px 16px 32px; }
  .hero h1 { font-size: 2rem; }
  .hero .lead { font-size: 1rem; }
  .card { padding: 32px; }
  .card h2 { font-size: 1.25rem; }
  #reading-title { font-size: 1.25rem; }
  .passage { font-size: 1.15rem; line-height: 2.0; }
  .wpm-value { font-size: 4.5rem; }
  .stat-value { font-size: 1.75rem; }
  #quiz-question { font-size: 1.15rem; }
}

.bookmark-note {
  margin: 0 0 16px;
  padding: 10px 14px;
  background: #fef3c7;
  border-radius: 8px;
  color: #92400e;
  font-size: 0.85rem;
  line-height: 1.5;
  text-align: left;
}

.share-card .share-lead {
  color: var(--c-text-muted);
  font-size: 0.9rem;
  margin: 0 0 14px;
  line-height: 1.6;
}
.share-buttons {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
.share-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  font-weight: 600;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: transform 0.15s ease, filter 0.15s ease;
  font-family: inherit;
  line-height: 1.3;
  text-align: center;
}
.share-btn:hover { transform: translateY(-1px); filter: brightness(1.05); }
.share-btn:active { transform: translateY(0); }
.share-btn-x { background: #0f172a; color: #fff; }
.share-btn-line { background: #06c755; color: #fff; }
.share-btn-fb { background: #1877f2; color: #fff; }
.share-btn-copy {
  background: #fff;
  color: var(--c-text);
  border: 1px solid var(--c-border, #e5e7eb);
}
.share-btn-copy:hover { background: #f9fafb; }

#result-passage-title {
  margin: 8px 0 16px;
  font-size: 1.05rem;
  line-height: 1.5;
  color: var(--c-text);
}

@media (min-width: 520px) {
  .share-buttons { grid-template-columns: repeat(4, 1fr); }
}

/* 挑戦履歴 / 人気文章リスト */
.muted-small {
  font-size: 0.75rem;
  color: var(--c-text-muted);
  font-weight: 400;
  margin-left: 6px;
}
.list-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.list-empty {
  color: var(--c-text-muted);
  font-size: 0.85rem;
  margin: 0;
  padding: 12px 2px;
  line-height: 1.7;
}
.list-item {
  display: block;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}
.list-item:hover {
  border-color: var(--c-primary);
  box-shadow: var(--shadow-card);
  transform: translateY(-1px);
  text-decoration: none;
}
.list-item-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.list-item-date {
  font-size: 0.75rem;
  color: var(--c-text-muted);
  font-family: var(--ff-num);
  white-space: nowrap;
}
.list-item-title {
  margin: 0 0 6px;
  font-size: 0.98rem;
  line-height: 1.5;
  color: var(--c-text);
  font-weight: 600;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.list-item-stats {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 0.8rem;
  color: var(--c-text-sub);
}
.list-item-stats strong {
  font-family: var(--ff-num);
  font-weight: 700;
  color: var(--c-text);
}

.popular-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.list-rank {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--c-primary);
  color: #fff;
  font-family: var(--ff-num);
  font-weight: 700;
  font-size: 0.9rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.popular-item:nth-child(1) .list-rank { background: #f59e0b; }
.popular-item:nth-child(2) .list-rank { background: #9ca3af; }
.popular-item:nth-child(3) .list-rank { background: #b45309; }
.list-item-body { flex: 1; min-width: 0; }
