:root {
  color: #172638;
  background: #f5f7fb;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", sans-serif;
  font-size: 16px;
  line-height: 1.7;
  font-synthesis: none;
  text-size-adjust: 100%;
}

* { box-sizing: border-box; }

body { margin: 0; }

button, input { font: inherit; }

.app-shell {
  width: min(720px, calc(100% - 32px));
  margin: 0 auto;
  padding: max(24px, env(safe-area-inset-top)) 0 max(40px, env(safe-area-inset-bottom));
}

h1, h2, p { margin-top: 0; }
h1 { font-size: clamp(1.65rem, 6vw, 2.3rem); line-height: 1.35; margin-bottom: 4px; }
h2 { font-size: 1.2rem; line-height: 1.5; }
p, label, legend { overflow-wrap: anywhere; }

.eyebrow { color: #506b8b; font-weight: 700; margin-bottom: 8px; }
.history-summary { display: flex; flex-wrap: wrap; gap: 8px 20px; color: #425a73; font-size: .92rem; }
.pwa-status { color: #255d3b; font-size: .9rem; margin: 8px 0; }
#update-button { margin: 4px 0 10px; }
#source-link { color: #145a9e; font-weight: 700; }
#source-link:focus-visible { outline: 3px solid #f0ae35; outline-offset: 3px; }
.source-attribution { color: #596b7d; font-size: .9rem; }
.card { background: #fff; border-radius: 16px; box-shadow: 0 8px 24px #283d5817; margin-top: 20px; padding: clamp(18px, 4vw, 28px); }
.hidden { display: none !important; }
#source, .notice, .keyboard-help { color: #596b7d; font-size: .9rem; }
#source { margin-bottom: 12px; }
#question { white-space: pre-wrap; line-height: 1.8; }

.choices {
  min-width: 0;
  border: 0;
  margin: 18px 0 20px;
  padding: 0;
}
.choices legend { color: #40566e; font-weight: 700; margin-bottom: 10px; padding: 0; }
.choice-list { display: grid; gap: 10px; }
.choice {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-height: 56px;
  border: 1px solid #b8c7d8;
  border-radius: 12px;
  cursor: pointer;
  padding: 14px 16px;
  line-height: 1.7;
  touch-action: manipulation;
}
.choice:has(input:checked) { background: #e8f2ff; border-color: #176cc1; box-shadow: inset 0 0 0 1px #176cc1; }
.choice input { flex: 0 0 auto; width: 20px; height: 20px; margin: 2px 0 0; accent-color: #1168bb; }

button {
  appearance: none;
  min-height: 48px;
  background: #1168bb;
  border: 0;
  border-radius: 10px;
  color: #fff;
  cursor: pointer;
  font-weight: 700;
  padding: 11px 18px;
  touch-action: manipulation;
}
button:hover:not(:disabled) { background: #0b559b; }
button:focus-visible, input:focus-visible, .choice:focus-within { outline: 3px solid #f0ae35; outline-offset: 3px; }
button:disabled { background: #718499; cursor: not-allowed; }
.button-secondary { background: #e7edf4; color: #17324e; }
.button-secondary:hover:not(:disabled) { background: #d5e0eb; }
.is-correct { color: #137345; }
.is-incorrect { color: #a51f1f; }
#explanation { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.8; }
.status { min-height: 0; margin: 10px 0; color: #255d3b; }
.status:empty { display: none; }
.status-error { color: #a51f1f; font-weight: 700; }
.pwa-status.status-error { color: #a51f1f; font-weight: 700; }
.history-tools p { color: #52667c; }
.history-actions { display: flex; flex-wrap: wrap; gap: 10px; }

@media (max-width: 520px) {
  .app-shell { width: min(100% - 24px, 720px); padding-top: max(18px, env(safe-area-inset-top)); }
  .card { border-radius: 14px; margin-top: 16px; }
  .history-actions { display: grid; grid-template-columns: 1fr; }
  .history-actions button { width: 100%; }
  #answer-button, #next-button, #restart-button { width: 100%; }
}

@media (prefers-reduced-motion: no-preference) {
  button, .choice { transition: background-color 120ms ease, border-color 120ms ease; }
}
