:root {
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #141414;
  background: #f6f7f8;
  font-synthesis: none;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, #ffffff 0%, #f6f7f8 100%);
}

button { font: inherit; }

.app-shell {
  width: min(100%, 560px);
  margin: 0 auto;
  min-height: 100vh;
  padding: 28px 20px 40px;
}

.screen { display: none; }
.screen.active { display: block; }
#home-screen { padding-top: 38px; }

.brand {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.brand span {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 999px;
  background: #eceff1;
  font-weight: 700;
}

h1 {
  margin: 18px 0 10px;
  font-size: clamp(34px, 10vw, 52px);
  line-height: 1.06;
  letter-spacing: -0.04em;
}

.lead {
  margin: 0 0 24px;
  color: #62666b;
  font-size: 16px;
  line-height: 1.7;
}

.primary-button,
.secondary-button,
.answer-button {
  border: 0;
  border-radius: 18px;
  cursor: pointer;
  transition: transform 0.08s ease, opacity 0.2s ease, background 0.2s ease;
}

.primary-button:active,
.secondary-button:active,
.answer-button:active { transform: scale(0.985); }

.primary-button {
  width: 100%;
  padding: 18px 20px;
  background: #111214;
  color: #ffffff;
  font-weight: 800;
  font-size: 17px;
  box-shadow: 0 12px 30px rgba(17, 18, 20, 0.14);
}

.primary-button.compact {
  margin-top: 18px;
  padding: 15px 18px;
}

.secondary-button {
  width: 100%;
  padding: 16px 20px;
  background: #e9ecef;
  color: #111214;
  font-weight: 800;
}

.random-start { margin-top: 12px; }

.daily-card {
  padding: 18px;
  border: 1px solid #e7e9ec;
  border-radius: 22px;
  background: #ffffff;
  box-shadow: 0 16px 40px rgba(17, 18, 20, 0.06);
}

.daily-copy {
  display: grid;
  gap: 3px;
  margin-bottom: 16px;
}

.daily-label {
  width: fit-content;
  padding: 4px 7px;
  border-radius: 999px;
  background: #f0f2f4;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.12em;
}

.daily-copy strong { font-size: 19px; }
.daily-copy small { color: #858a91; }

.daily-stats {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid #eef0f2;
}

.daily-stats span { color: #7b8087; font-size: 12px; }
.daily-stats strong { font-size: 22px; }

.stats-card {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.stats-card > div,
.result-card {
  background: #ffffff;
  border: 1px solid #eceff1;
  border-radius: 18px;
  padding: 18px;
}

.stat-label,
.result-card span {
  display: block;
  color: #7b8087;
  font-size: 12px;
  margin-bottom: 6px;
}

.stats-card strong,
.result-card strong { font-size: 22px; }

.rule-note {
  margin: 16px 4px 0;
  color: #8a8f96;
  font-size: 12px;
  line-height: 1.6;
}

.quiz-header {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 14px;
  align-items: start;
}

.text-button {
  padding: 8px 0;
  border: 0;
  background: transparent;
  color: #777c82;
  cursor: pointer;
}

.progress-wrap { min-width: 0; }

.progress-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 800;
}

.progress-bar {
  height: 8px;
  background: #e6e9ec;
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  width: 10%;
  height: 100%;
  background: #17191c;
  transition: width 0.2s ease;
}

.mode-badge {
  width: fit-content;
  margin: 18px 0 -10px;
  padding: 5px 9px;
  border-radius: 999px;
  background: #eceff1;
  color: #555a60;
  font-size: 11px;
  font-weight: 800;
}

.question-card {
  margin-top: 28px;
  padding: 28px 22px;
  background: #ffffff;
  border: 1px solid #ebedef;
  border-radius: 24px;
  box-shadow: 0 20px 50px rgba(17, 18, 20, 0.06);
}

.question-meta {
  margin: 0 0 14px;
  color: #8a8f96;
  font-size: 12px;
  font-weight: 700;
}

.question-title {
  margin: 0;
  font-size: 22px;
  line-height: 1.65;
  letter-spacing: -0.02em;
}

.answer-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 30px;
}

.answer-button {
  min-height: 118px;
  font-size: 52px;
  font-weight: 900;
  background: #f2f4f6;
  color: #15171a;
}

.answer-button:hover { background: #e9ecef; }
.answer-button:disabled { cursor: default; opacity: 0.7; }
.answer-button.picked-correct { background: #e8f4ec; opacity: 1; }
.answer-button.picked-wrong { background: #f8e8e8; opacity: 1; }

.feedback {
  margin-top: 24px;
  padding-top: 22px;
  border-top: 1px solid #eceff1;
}

.feedback.hidden,
.hidden { display: none; }

.feedback-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
}

.feedback-result { font-size: 20px; font-weight: 900; }
.answer-time { color: #777c82; font-size: 13px; font-weight: 800; }

.feedback-text {
  margin: 10px 0 0;
  color: #5f646a;
  line-height: 1.7;
}

#result-screen {
  padding-top: 34px;
  text-align: center;
}

.eyebrow {
  margin: 0;
  color: #8b9096;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.18em;
}

.result-mode-label {
  margin: 6px 0 0;
  color: #7d8288;
  font-size: 13px;
  font-weight: 800;
}

.result-time {
  margin-top: 18px;
  font-size: clamp(54px, 16vw, 82px);
  font-weight: 900;
  letter-spacing: -0.05em;
}

.new-best {
  display: inline-block;
  margin-top: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: #111214;
  color: #ffffff;
  font-size: 13px;
  font-weight: 800;
}

.result-message {
  min-height: 1.6em;
  margin: 14px auto 0;
  color: #62666b;
  font-size: 14px;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 24px;
  text-align: left;
}

.result-actions {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

@media (max-width: 420px) {
  .app-shell { padding-inline: 14px; }
  .question-card { padding-inline: 18px; }
  .answer-button { min-height: 104px; }
}

/* v0.3: race / streak additions */
.daily-stats > div {
  display: grid;
  gap: 3px;
}

.daily-attempt-stat {
  text-align: right;
}

.daily-attempt-stat strong {
  font-size: 18px;
}

.race-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 24px;
  margin-top: 7px;
  font-size: 11px;
  font-weight: 800;
}

#streak-text {
  color: #858a91;
  transition: color 0.2s ease, transform 0.2s ease;
}

#streak-text.is-hot {
  color: #111214;
  transform: translateY(-1px);
}

.best-delta {
  font-variant-numeric: tabular-nums;
}

.best-delta.is-ahead,
.best-comparison.is-ahead {
  color: #267243;
}

.best-delta.is-behind,
.best-comparison.is-behind {
  color: #a94343;
}

.best-comparison {
  margin: 10px 0 0;
  font-size: 13px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

/* v1.1: topic-focused play */
.topic-section {
  margin-top: 24px;
}

.topic-lead {
  margin: -2px 2px 10px;
  color: #7b8087;
  font-size: 12px;
  line-height: 1.55;
}

.topic-chips {
  display: flex;
  gap: 8px;
  margin-inline: -2px;
  padding: 2px 2px 7px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.topic-chips::-webkit-scrollbar { display: none; }

.topic-chip {
  flex: 0 0 auto;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid #e4e7ea;
  border-radius: 999px;
  background: #fff;
  color: #24272a;
  cursor: pointer;
  text-align: left;
  transition: transform 0.08s ease, background 0.16s ease, color 0.16s ease, border-color 0.16s ease;
}

.topic-chip:active { transform: scale(0.98); }
.topic-chip strong { display: block; font-size: 13px; line-height: 1.1; white-space: nowrap; }
.topic-chip small { display: block; margin-top: 3px; color: #8a8f96; font-size: 10px; line-height: 1; }
.topic-chip.active { border-color: #111214; background: #111214; color: #fff; }
.topic-chip.active small { color: #c8ccd0; }

.topic-play-card {
  margin-top: 8px;
  padding: 14px;
  border: 1px solid #e7e9ec;
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 12px 28px rgba(17, 18, 20, 0.04);
}

.topic-play-copy {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 8px;
  align-items: baseline;
  margin-bottom: 12px;
}

.topic-play-copy > span {
  padding: 3px 6px;
  border-radius: 999px;
  background: #eef0f2;
  color: #666b71;
  font-size: 9px;
  font-weight: 900;
}

.topic-play-copy strong { font-size: 16px; }
.topic-play-copy small {
  grid-column: 1 / -1;
  margin-top: 5px;
  color: #888d93;
  font-size: 11px;
  line-height: 1.45;
}

.topic-mode-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.topic-mode-button {
  min-width: 0;
  min-height: 58px;
  padding: 9px 6px;
  border: 0;
  border-radius: 15px;
  background: #f0f2f4;
  color: #17191c;
  cursor: pointer;
  transition: transform 0.08s ease, opacity 0.16s ease;
}

.topic-mode-button:active { transform: scale(0.975); }
.topic-mode-button:disabled { opacity: 0.4; cursor: default; }
.topic-mode-button strong { display: block; font-size: 15px; font-weight: 950; line-height: 1.1; }
.topic-mode-button small { display: block; margin-top: 4px; color: #777c82; font-size: 9px; font-weight: 800; white-space: nowrap; }

/* v0.4: endless challenge modes */
.mode-section {
  margin-top: 28px;
}

.section-heading {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0 2px 10px;
}

.section-heading span {
  padding: 4px 7px;
  border-radius: 999px;
  background: #111214;
  color: #fff;
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.12em;
}

.section-heading h2 {
  margin: 0;
  font-size: 15px;
  letter-spacing: -0.01em;
}

.mode-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.mode-card-button {
  appearance: none;
  width: 100%;
  border: 1px solid #e6e9ec;
  border-radius: 20px;
  padding: 16px;
  background: #fff;
  color: #15171a;
  text-align: left;
  cursor: pointer;
  box-shadow: 0 12px 28px rgba(17, 18, 20, 0.045);
  transition: transform 0.08s ease, border-color 0.2s ease;
}

.mode-card-button:active { transform: scale(0.985); }
.mode-card-button:hover { border-color: #cfd4d9; }

.mode-card-button > span,
.mode-card-button > strong,
.mode-card-button > small,
.mode-card-button > em { display: block; }

.mode-icon {
  width: fit-content;
  min-width: 34px;
  margin-bottom: 12px;
  padding: 6px 9px;
  border-radius: 11px;
  background: #f0f2f4;
  font-size: 15px;
  font-weight: 950;
  line-height: 1;
}

.mode-card-button strong {
  font-size: 15px;
  line-height: 1.35;
}

.mode-card-button small {
  min-height: 36px;
  margin-top: 5px;
  color: #777c82;
  font-size: 11px;
  line-height: 1.5;
}

.mode-card-button em {
  margin-top: 11px;
  color: #9a9fa5;
  font-size: 10px;
  font-style: normal;
  font-weight: 800;
}

.mode-card-button em b {
  margin-left: 3px;
  color: #111214;
  font-size: 14px;
}

#timer-text {
  font-variant-numeric: tabular-nums;
  transition: transform 0.12s ease;
}

#timer-text.timer-danger {
  color: #a94343;
  transform: scale(1.08);
}

@media (max-width: 360px) {
  .mode-grid { grid-template-columns: 1fr; }
  .mode-card-button small { min-height: 0; }
}

.data-status {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 14px 4px 0;
  color: #7d8288;
  font-size: 11px;
  line-height: 1.5;
}

.data-status > span:first-child {
  padding: 3px 7px;
  border-radius: 999px;
  background: #eceff1;
  color: #555a60;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .08em;
}

.question-source {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: 12px;
  background: #f7f8f9;
  color: #747a80;
  font-size: 11px;
  line-height: 1.5;
}

.question-source a {
  color: #32363a;
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.reviewed-badge,
.draft-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 900;
}

.reviewed-badge {
  background: #e8f4ec;
  color: #2f6842;
}

.draft-badge {
  background: #f8eee1;
  color: #8a5d20;
}

.legal-basis {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 999px;
  background: #f5f5f5;
  color: #555;
  font-size: 0.76rem;
  line-height: 1.25;
}

/* v0.9: result review */
.review-card {
  margin-top: 14px;
  background: #ffffff;
  border: 1px solid #eceff1;
  border-radius: 18px;
  text-align: left;
  overflow: hidden;
}

.review-toggle {
  appearance: none;
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  align-items: center;
  padding: 17px 18px;
  border: 0;
  background: #ffffff;
  color: #15171a;
  text-align: left;
  cursor: pointer;
}

.review-toggle > span:first-child {
  font-size: 15px;
  font-weight: 900;
}

.review-toggle strong {
  color: #7f848a;
  font-size: 11px;
  font-weight: 800;
}

#review-chevron {
  width: 22px;
  text-align: center;
  color: #777c82;
  font-size: 20px;
  line-height: 1;
}

.review-panel {
  padding: 0 18px 18px;
  border-top: 1px solid #f0f1f2;
}

.review-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 0 10px;
}

.review-heading h2 {
  margin: 0;
  font-size: 14px;
}

.review-filters {
  display: flex;
  gap: 5px;
  padding: 3px;
  border-radius: 999px;
  background: #f1f3f5;
}

.review-filter {
  border: 0;
  border-radius: 999px;
  padding: 6px 9px;
  background: transparent;
  color: #73787e;
  font-size: 10px;
  font-weight: 900;
  cursor: pointer;
}

.review-filter.active {
  background: #ffffff;
  color: #15171a;
  box-shadow: 0 1px 4px rgba(17, 18, 20, 0.08);
}

.review-list { display: grid; gap: 10px; }

.review-item {
  padding: 14px;
  border: 1px solid #eceff1;
  border-radius: 15px;
  background: #fbfbfc;
}

.review-item.is-wrong { border-color: #ead4d4; }

.review-item-top {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.review-number {
  color: #969ba1;
  font-size: 10px;
  font-weight: 900;
}

.review-topic {
  overflow: hidden;
  color: #72777d;
  font-size: 10px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.review-status {
  font-size: 10px;
  font-weight: 900;
}

.review-status.is-correct { color: #267243; }
.review-status.is-wrong { color: #a94343; }

.review-statement {
  margin: 10px 0 0;
  color: #25282b;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.65;
}

.review-answers {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 10px;
}

.review-answers span {
  padding: 5px 8px;
  border-radius: 9px;
  background: #f0f2f4;
  color: #686d73;
  font-size: 10px;
  font-weight: 800;
}

.review-answers b {
  margin-left: 3px;
  color: #17191c;
  font-size: 13px;
}

.review-explanation {
  margin: 11px 0 0;
  color: #5e6369;
  font-size: 12px;
  line-height: 1.7;
}

.review-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  margin-top: 10px;
  color: #8a8f95;
  font-size: 9px;
  line-height: 1.5;
}

.review-foot a {
  color: #4f555b;
  font-weight: 900;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.review-empty {
  margin: 10px 0 2px;
  padding: 16px;
  border-radius: 12px;
  background: #f7f8f9;
  color: #72777d;
  font-size: 12px;
  text-align: center;
}

@media (max-width: 420px) {
  .review-heading {
    align-items: flex-start;
    flex-direction: column;
  }
}

/* v1.0: smartphone-first interaction */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  overscroll-behavior-y: contain;
}

button,
summary,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  touch-action: manipulation;
}

.app-shell {
  padding-top: max(28px, env(safe-area-inset-top));
  padding-bottom: max(40px, calc(24px + env(safe-area-inset-bottom)));
}

.quiz-header {
  position: sticky;
  top: 0;
  z-index: 30;
  margin: -8px -8px 0;
  padding: calc(8px + env(safe-area-inset-top)) 8px 10px;
  background: rgba(246, 247, 248, 0.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.question-card {
  scroll-margin-top: 92px;
}

.answer-grid {
  position: sticky;
  bottom: calc(10px + env(safe-area-inset-bottom));
  z-index: 20;
  margin-inline: -8px;
  padding: 8px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 14px 34px rgba(17, 18, 20, 0.12);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.question-card.answered .answer-grid {
  position: static;
  margin-inline: 0;
  padding: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.review-item {
  padding: 0;
  overflow: clip;
}

.review-item-summary {
  position: relative;
  display: block;
  padding: 14px 36px 14px 14px;
  list-style: none;
  cursor: pointer;
  touch-action: manipulation;
}

.review-item-summary::-webkit-details-marker { display: none; }
.review-item-summary::marker { content: ""; }

.review-item-body {
  padding: 0 14px 14px;
  border-top: 1px solid #edf0f2;
}

.review-item-chevron {
  position: absolute;
  top: 50%;
  right: 14px;
  transform: translateY(-50%);
  color: #858a91;
  font-size: 18px;
  line-height: 1;
  transition: transform 0.15s ease;
}

.review-item[open] .review-item-chevron {
  transform: translateY(-50%) rotate(180deg);
}

.review-item[open] .review-statement {
  margin-bottom: 2px;
}

@media (max-width: 480px) {
  .app-shell {
    width: 100%;
    padding-inline: 12px;
    padding-top: max(14px, env(safe-area-inset-top));
  }

  #home-screen { padding-top: 18px; }

  h1 {
    margin-top: 14px;
    font-size: clamp(34px, 11vw, 46px);
  }

  .lead {
    margin-bottom: 18px;
    font-size: 14px;
    line-height: 1.6;
  }

  .daily-card { padding: 15px; border-radius: 20px; }
  .primary-button { min-height: 56px; padding: 15px 18px; }
  .secondary-button { min-height: 52px; padding: 14px 18px; }

  .topic-section { margin-top: 20px; }
  .topic-chip { min-height: 46px; padding-inline: 13px; }
  .topic-play-card { padding: 12px; border-radius: 18px; }
  .topic-mode-button { min-height: 60px; }

  .mode-section { margin-top: 22px; }
  .mode-grid { grid-template-columns: 1fr; }
  .mode-card-button {
    display: grid;
    grid-template-columns: auto 1fr auto;
    grid-template-areas:
      "icon title best"
      "icon desc best";
    column-gap: 12px;
    row-gap: 2px;
    align-items: center;
    min-height: 78px;
    padding: 13px 14px;
  }
  .mode-icon { grid-area: icon; margin: 0; }
  .mode-card-button strong { grid-area: title; }
  .mode-card-button small { grid-area: desc; min-height: 0; margin: 0; }
  .mode-card-button em { grid-area: best; margin: 0; text-align: right; }

  .stats-card > div,
  .result-card { padding: 14px; }

  .quiz-header {
    margin-inline: -4px;
    padding-inline: 6px;
  }

  .mode-badge { margin-top: 12px; }
  .question-card {
    margin-top: 18px;
    padding: 20px 16px;
    border-radius: 20px;
  }
  .question-meta { margin-bottom: 10px; }
  .question-title {
    font-size: 19px;
    line-height: 1.58;
  }
  .answer-grid {
    gap: 10px;
    margin-top: 22px;
  }
  .answer-button {
    min-height: 92px;
    border-radius: 17px;
    font-size: 48px;
  }

  #result-screen { padding-top: 20px; }
  .result-time { margin-top: 12px; }
  .result-grid { gap: 8px; margin-top: 18px; }
  .review-card { margin-top: 10px; }
  .review-panel { padding-inline: 12px; }
  .review-toggle { padding-inline: 14px; }
  .review-heading { padding-top: 12px; }
  .review-statement { font-size: 13px; line-height: 1.58; }
  .review-item-summary { padding: 12px 34px 12px 12px; }
  .review-item-body { padding: 0 12px 12px; }
  .result-actions {
    position: static;
    padding: 0 0 calc(8px + env(safe-area-inset-bottom));
    margin: 18px 0 0;
    background: transparent;
  }
}

/* v1.4: home information architecture + smartphone polish */
.random-card {
  margin-top: 12px;
  padding: 18px;
  border: 1px solid #e7e9ec;
  border-radius: 22px;
  background: #ffffff;
  box-shadow: 0 16px 40px rgba(17, 18, 20, 0.05);
}

.random-copy {
  display: grid;
  gap: 3px;
  margin-bottom: 14px;
}

.random-label {
  width: fit-content;
  padding: 4px 7px;
  border-radius: 999px;
  background: #eef0f2;
  color: #555a60;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.1em;
}

.random-copy strong { font-size: 18px; }
.random-copy small { color: #858a91; }
.random-start { margin-top: 0; }

.random-stats {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid #eef0f2;
}

.random-stats > div {
  display: grid;
  gap: 3px;
}

.random-stats span {
  color: #7b8087;
  font-size: 12px;
}

.random-stats strong {
  font-size: 20px;
  font-variant-numeric: tabular-nums;
}

.random-attempt-stat { text-align: right; }

.text-button {
  min-width: 48px;
  min-height: 44px;
  margin: -4px 0 0 -4px;
  padding: 8px 4px;
  font-weight: 800;
}

.quiz-header {
  align-items: center;
}

.progress-row,
.race-row,
.result-time,
#best-time,
#daily-best-time,
#timer-text {
  font-variant-numeric: tabular-nums;
}

.question-title,
.feedback-text,
.review-statement,
.review-explanation {
  overflow-wrap: anywhere;
  word-break: normal;
}

.answer-button,
.topic-mode-button,
.mode-card-button,
.topic-chip,
.primary-button,
.secondary-button,
.review-toggle,
.review-filter {
  min-height: 44px;
}

@media (max-width: 480px) {
  .daily-card,
  .random-card {
    padding: 14px;
    border-radius: 19px;
  }

  .daily-copy,
  .random-copy {
    margin-bottom: 12px;
  }

  .daily-copy strong,
  .random-copy strong {
    font-size: 18px;
  }

  .daily-stats,
  .random-stats {
    margin-top: 12px;
    padding-top: 12px;
  }

  .daily-stats strong,
  .random-stats strong {
    font-size: 19px;
  }

  .mode-section { margin-top: 24px; }
  .topic-section { margin-top: 26px; }

  .section-heading {
    margin-bottom: 9px;
  }

  .topic-lead {
    margin-bottom: 8px;
  }

  .quiz-header {
    grid-template-columns: 52px minmax(0, 1fr);
    gap: 8px;
  }

  .progress-row {
    margin-bottom: 6px;
  }

  .race-row {
    min-height: 20px;
    margin-top: 5px;
  }

  .mode-badge {
    margin-bottom: -6px;
  }

  .question-card {
    padding-bottom: 16px;
  }

  .question-title {
    line-height: 1.62;
  }

  .answer-grid {
    bottom: calc(6px + env(safe-area-inset-bottom));
    margin-inline: -5px;
    padding: 6px;
    border-radius: 19px;
  }

  .answer-button {
    min-height: 88px;
  }

  .feedback-heading {
    align-items: center;
  }

  .feedback-text {
    font-size: 13px;
    line-height: 1.65;
  }

  .question-source {
    gap: 6px;
    padding: 9px 10px;
    font-size: 10px;
  }

  .result-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .review-toggle {
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 7px;
  }

  .review-toggle strong {
    white-space: nowrap;
  }
}

@media (max-width: 340px) {
  .app-shell { padding-inline: 10px; }

  .daily-stats span,
  .random-stats span { font-size: 11px; }
  .daily-stats strong,
  .random-stats strong { font-size: 17px; }

  .topic-mode-actions {
    gap: 6px;
  }

  .topic-mode-button {
    padding-inline: 4px;
  }

  .topic-mode-button strong { font-size: 14px; }
  .topic-mode-button small { font-size: 8px; }

  .result-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .question-card.answered .answer-grid {
    display: none;
  }

  .primary-button.compact {
    margin-top: 14px;
  }

  .feedback .question-source {
    margin-top: 12px;
  }
}

@media (max-width: 480px) {
  h1 {
    font-size: clamp(31px, 9vw, 40px);
    letter-spacing: -0.05em;
    white-space: nowrap;
  }
}

/* v1.5: shared challenge / social share */
.shared-challenge-card {
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
  padding: 16px;
  border: 1px solid #dfe3e7;
  border-radius: 20px;
  background: #ffffff;
  box-shadow: 0 12px 28px rgba(17, 18, 20, 0.05);
}

.shared-challenge-card > div {
  display: grid;
  gap: 4px;
}

.shared-challenge-card > div > span {
  width: fit-content;
  padding: 3px 7px;
  border-radius: 999px;
  background: #111214;
  color: #fff;
  font-size: 9px;
  font-weight: 900;
  letter-spacing: .12em;
}

.shared-challenge-card strong { font-size: 16px; }
.shared-challenge-card small { color: #7c8187; line-height: 1.5; }
.shared-challenge-card .primary-button.compact { margin-top: 0; }

.share-result-button {
  appearance: none;
  width: 100%;
  min-height: 52px;
  margin-top: 14px;
  border: 1px solid #dfe3e7;
  border-radius: 16px;
  background: #fff;
  color: #17191c;
  font: inherit;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(17, 18, 20, 0.035);
}

.share-result-button:active { transform: scale(.985); }
.share-result-button span { margin-right: 5px; }

.share-status {
  margin: 8px 4px 0;
  color: #687078;
  font-size: 12px;
  line-height: 1.5;
}

.review-detail-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 46px;
  margin-top: 12px;
  padding: 11px 14px;
  border: 1px solid #dfe3e7;
  border-radius: 13px;
  background: #fff;
  color: #17191c;
  font-size: 13px;
  font-weight: 900;
  text-decoration: none;
}

.review-detail-link:active { transform: scale(.99); }

@media (max-width: 430px) {
  .share-result-button { min-height: 50px; }
  .shared-challenge-card { padding: 14px; }
}


/* 仕訳10 v0.1 overrides */
.weak-card,
.learn-entry {
  margin-top: 12px;
  padding: 18px;
  border: 1px solid #e7e9ec;
  border-radius: 22px;
  background: #fff;
  box-shadow: 0 16px 40px rgba(17,18,20,.045);
}
.weak-copy { display:grid; gap:3px; margin-bottom:14px; }
.weak-label {
  width: fit-content;
  padding: 4px 7px;
  border-radius: 999px;
  background:#eef0f2;
  color:#555a60;
  font-size:10px;
  font-weight:900;
  letter-spacing:.1em;
}
.weak-copy strong { font-size:18px; }
.weak-copy small { color:#858a91; }
.weak-stat {
  display:flex;
  justify-content:space-between;
  align-items:baseline;
  gap:12px;
  margin-top:12px;
  padding-top:12px;
  border-top:1px solid #eef0f2;
}
.weak-stat span { color:#7b8087; font-size:12px; }
.weak-stat strong { font-size:18px; }
.weak-card button:disabled { opacity:.45; cursor:default; }

.learn-entry { margin-top:26px; }
.learn-entry p {
  margin:0;
  color:#676c72;
  font-size:13px;
  line-height:1.75;
}
.learn-entry-link,
.learning-link {
  display:inline-flex;
  align-items:center;
  margin-top:12px;
  color:#17191c;
  font-size:13px;
  font-weight:900;
  text-decoration:none;
  border-bottom:1px solid #aeb3b8;
}
.learning-link {
  margin-top:14px;
  padding:10px 0 2px;
}

.choice-grid {
  display:grid;
  grid-template-columns:1fr;
  gap:10px;
  margin-top:24px;
}
.choice-button {
  min-height:68px;
  display:grid;
  grid-template-columns:40px minmax(0,1fr);
  gap:10px;
  align-items:center;
  padding:12px 14px;
  border:1px solid #e7eaed;
  border-radius:16px;
  background:#f6f7f8;
  color:#15171a;
  text-align:left;
  font-size:14px;
  font-weight:750;
  line-height:1.55;
}
.choice-button:hover { background:#eef1f3; }
.choice-key {
  width:34px;
  height:34px;
  display:grid;
  place-items:center;
  border-radius:11px;
  background:#fff;
  border:1px solid #dde1e4;
  font-size:15px;
  font-weight:950;
}
.choice-text { overflow-wrap:anywhere; white-space:pre-line; }
.choice-button.correct-answer {
  border-color:#9bcaaa;
  background:#edf8f0;
  opacity:1;
}
.choice-button.picked-correct {
  border-color:#62a878;
  background:#e5f5ea;
}
.choice-button.picked-wrong {
  border-color:#d59a9a;
  background:#f9eaea;
}
.question-card.answered .choice-grid {
  position:static;
  box-shadow:none;
  background:transparent;
  backdrop-filter:none;
  -webkit-backdrop-filter:none;
}
.question-card.answered .choice-button { opacity:.72; }
.question-card.answered .choice-button.correct-answer,
.question-card.answered .choice-button.picked-correct,
.question-card.answered .choice-button.picked-wrong { opacity:1; }

.review-answer {
  margin:0;
  color:#555b61;
  font-size:12px;
  line-height:1.65;
}
.review-detail-link {
  display:inline-block;
  margin-top:10px;
  color:#17191c;
  font-size:12px;
  font-weight:900;
  text-decoration:underline;
  text-underline-offset:3px;
}
.review-result-badge {
  flex:0 0 auto;
  width:26px;
  height:26px;
  display:grid;
  place-items:center;
  border-radius:9px;
  background:#edf5ef;
  font-weight:950;
}
.review-item.is-wrong .review-result-badge { background:#f8eaea; }

@media (max-width:480px) {
  .weak-card,
  .learn-entry { padding:14px; border-radius:19px; }
  .choice-grid {
    position:sticky;
    bottom:calc(6px + env(safe-area-inset-bottom));
    z-index:10;
    margin-inline:-5px;
    padding:6px;
    border-radius:18px;
    background:rgba(255,255,255,.94);
    backdrop-filter:blur(12px);
    -webkit-backdrop-filter:blur(12px);
    box-shadow:0 10px 28px rgba(17,18,20,.08);
  }
  .choice-button {
    min-height:62px;
    grid-template-columns:36px minmax(0,1fr);
    padding:10px 11px;
    font-size:13px;
  }
  .choice-key { width:30px; height:30px; }
  .question-title { font-size:18px; line-height:1.55; }
}

/* SEO用ページでは公開を前提にするため、ホームの情報密度を抑える */
.data-status { margin-bottom:10px; }


/* v0.6 exam-scope switch */
.scope-switch-card {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  padding: 16px;
  margin: 18px 0;
  border: 1px solid var(--line, #e5e7eb);
  border-radius: 18px;
  background: var(--card, #fff);
}
.scope-switch-copy {
  display: grid;
  gap: 3px;
}
.scope-switch-label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .12em;
  color: var(--muted, #6b7280);
}
.scope-switch-copy strong {
  font-size: 18px;
}
.scope-switch-copy small {
  font-weight: 700;
}
.scope-switch-copy em {
  min-height: 1.25em;
  font-size: 12px;
  font-style: normal;
  color: var(--muted, #6b7280);
}
.scope-select-label {
  font-size: 12px;
  font-weight: 700;
}
.scope-select {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line, #d1d5db);
  border-radius: 12px;
  background: #fff;
  font: inherit;
}
.scope-switch-card.scope-future {
  border-style: dashed;
}
.scope-switch-card.scope-legacy {
  border-style: dashed;
}
@media (min-width: 640px) {
  .scope-switch-card {
    grid-template-columns: 1fr minmax(220px, 280px);
    align-items: end;
  }
  .scope-select-label {
    grid-column: 2;
    grid-row: 1;
    align-self: start;
  }
  .scope-select {
    grid-column: 2;
    grid-row: 1;
    align-self: end;
  }
}


/* v0.7 mobile flow polish */
button,
.answer-button,
.choice-button,
.topic-chip,
.primary-button,
.secondary-button,
.learning-link,
.learn-entry-link {
  touch-action: manipulation;
}

@media (max-width: 640px) {
  .choice-button { min-height: 58px; }
  .choice-key { flex: 0 0 32px; }
  .feedback { scroll-margin-top: 12px; }
  .learning-link {
    display: block;
    min-height: 44px;
    padding: 11px 0;
  }
  #next-button {
    width: 100%;
    min-height: 50px;
  }
}


/* v1.0 achievements */
.home-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.achievements-button {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 7px;
  font-size: 25px;
  line-height: 1;
  cursor: pointer;
  border-radius: 999px;
  touch-action: manipulation;
}

.achievements-button:hover,
.achievements-button:focus-visible {
  background: rgba(17, 24, 39, .06);
  outline: none;
}

.achievements-button:active {
  transform: scale(.92);
}

.achievement-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  align-items: end;
}

.achievement-modal.hidden {
  display: none;
}

.achievement-backdrop {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: rgba(15, 23, 42, .38);
}

.achievement-sheet {
  position: relative;
  z-index: 1;
  width: min(100%, 560px);
  max-height: min(80vh, 620px);
  margin: 0 auto;
  padding: 20px 18px calc(20px + env(safe-area-inset-bottom));
  border-radius: 24px 24px 0 0;
  background: #fff;
  box-shadow: 0 -16px 50px rgba(15, 23, 42, .18);
  overflow: auto;
}

.achievement-sheet-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.achievement-sheet-head > div {
  display: grid;
  gap: 3px;
}

.achievement-kicker {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .14em;
  color: #6b7280;
}

.achievement-sheet-head h2 {
  margin: 0;
  font-size: 24px;
}

.achievement-sheet-head small {
  color: #6b7280;
}

.achievement-close {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 999px;
  background: #f3f4f6;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.achievement-list {
  display: grid;
  gap: 10px;
}

.achievement-item {
  display: grid;
  grid-template-columns: 42px 1fr auto;
  align-items: center;
  gap: 12px;
  min-height: 76px;
  padding: 12px;
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  background: #f9fafb;
  opacity: .58;
}

.achievement-item.unlocked {
  background: #fff;
  opacity: 1;
}

.achievement-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  font-size: 25px;
}

.achievement-item > div {
  display: grid;
  gap: 3px;
}

.achievement-item strong {
  font-size: 15px;
}

.achievement-item small {
  color: #6b7280;
  line-height: 1.45;
}

.achievement-state {
  min-width: 28px;
  text-align: center;
  font-size: 18px;
  font-weight: 800;
}

.achievement-item.unlocked .achievement-state {
  color: #15803d;
}

body.modal-open {
  overflow: hidden;
}

@media (min-width: 640px) {
  .achievement-modal {
    align-items: center;
    padding: 24px;
  }

  .achievement-sheet {
    border-radius: 24px;
    padding-bottom: 20px;
  }
}


/* v1.1 achievement progress icon and completion dates */
.achievements-button.achievement-empty {
  filter: grayscale(1);
  opacity: .42;
}

.achievement-date {
  display: block;
  min-height: 1.2em;
  margin-top: 2px;
  font-size: 11px;
  color: #6b7280;
}


/* v1.2 home message */
.home-title {
  display: grid;
  gap: 7px;
}

.home-subject {
  display: block;
  font-size: .42em;
  line-height: 1.2;
  letter-spacing: .02em;
  font-weight: 900;
}

.home-catch {
  display: block;
}

/* v1.2 learning overlay: mobile-first, result/quiz remains underneath */
.learning-overlay {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: grid;
  align-items: end;
}

.learning-overlay.hidden {
  display: none;
}

.learning-overlay-backdrop {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: rgba(15, 23, 42, .42);
}

.learning-overlay-panel {
  position: relative;
  z-index: 1;
  width: min(100%, 820px);
  height: min(94dvh, 900px);
  margin: 0 auto;
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
  background: #fff;
  border-radius: 22px 22px 0 0;
  box-shadow: 0 -20px 60px rgba(15, 23, 42, .22);
}

.learning-overlay-header {
  min-height: 58px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 8px max(12px, env(safe-area-inset-right)) 8px max(12px, env(safe-area-inset-left));
  border-bottom: 1px solid #e8ebee;
  background: rgba(255, 255, 255, .96);
}

.learning-overlay-header strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  color: #686e75;
}

.learning-overlay-close {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  border: 0;
  border-radius: 12px;
  background: #f2f4f5;
  color: #17191b;
  font-weight: 900;
  cursor: pointer;
}

.learning-frame-wrap {
  position: relative;
  min-height: 0;
  background: #f6f7f8;
}

.learning-overlay-frame {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
  opacity: 0;
  transition: opacity .14s ease;
}

.learning-overlay-frame.is-ready {
  opacity: 1;
}

.learning-overlay-loading {
  position: absolute;
  z-index: 2;
  inset: 0;
  display: grid;
  place-items: center;
  background: #fff;
  color: #7b8188;
  font-size: 13px;
  font-weight: 800;
}

.learning-overlay-loading.hidden {
  display: none;
}

body.learning-overlay-open {
  overflow: hidden;
}

@media (max-width: 640px) {
  .learning-overlay-panel {
    width: 100%;
    height: 100dvh;
    border-radius: 0;
  }

  .learning-overlay-header {
    padding-top: max(8px, env(safe-area-inset-top));
  }

  .learning-overlay-close {
    min-height: 46px;
    padding-inline: 8px 11px;
    font-size: 14px;
  }

  .learning-overlay-header strong {
    font-size: 12px;
  }
}


/* v1.3: unmistakable answer feedback */
.answer-flash {
  position: fixed;
  inset: 0;
  z-index: 1150;
  display: grid;
  place-items: center;
  pointer-events: none;
}

.answer-flash.hidden {
  display: none;
}

.answer-flash-symbol {
  display: grid;
  place-items: center;
  width: min(48vw, 210px);
  height: min(48vw, 210px);
  font-size: min(44vw, 190px);
  font-weight: 900;
  line-height: 1;
  opacity: 0;
  transform: scale(.72);
  text-shadow: 0 8px 28px rgba(15, 23, 42, .14);
}

.answer-flash.is-correct .answer-flash-symbol {
  color: #16a34a;
}

.answer-flash.is-wrong .answer-flash-symbol {
  color: #dc2626;
}

.answer-flash.is-showing .answer-flash-symbol {
  animation: answer-flash-pop .66s cubic-bezier(.2,.8,.2,1) both;
}

@keyframes answer-flash-pop {
  0%   { opacity: 0; transform: scale(.58); }
  20%  { opacity: .96; transform: scale(1.08); }
  55%  { opacity: .92; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.12); }
}

.feedback.feedback-correct {
  border-color: rgba(22, 163, 74, .28);
  background: rgba(22, 163, 74, .06);
}

.feedback.feedback-wrong {
  border-color: rgba(220, 38, 38, .28);
  background: rgba(220, 38, 38, .06);
}

.feedback.feedback-correct .feedback-result {
  color: #15803d;
}

.feedback.feedback-wrong .feedback-result {
  color: #b91c1c;
}

@media (prefers-reduced-motion: reduce) {
  .answer-flash.is-showing .answer-flash-symbol {
    animation-duration: .34s;
  }
}
