:root {
  color-scheme: light;
  font-family: "Helvetica Neue", Arial, "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, sans-serif;
  line-height: 1.7;
  color: #23303d;
  background: #f4f7fb;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 0;
  background: linear-gradient(135deg, #fbfdff, #f0f6fc);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.site-shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 44px;
}

.hero,
.tool-panel,
.result-panel,
.panel,
.related-tools,
.app-comment-section,
.return-links a,
.ad-row {
  background: #fff;
  border: 1px solid #dfe7ef;
  border-radius: 8px;
  box-shadow: 0 8px 22px rgba(38, 67, 96, 0.08);
}

.hero {
  padding: clamp(24px, 5vw, 48px);
  text-align: center;
}

.series-label,
.section-kicker,
.ad-label {
  color: #4f738f;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  margin: 0 0 0.35rem;
}

h1,
h2,
h3 {
  letter-spacing: 0;
  line-height: 1.25;
  margin: 0 0 0.8rem;
}

h1 { font-size: clamp(2rem, 4vw, 3.2rem); }
h2 { font-size: clamp(1.35rem, 2.4vw, 1.9rem); }
h3 { font-size: 1.1rem; }

.subtitle {
  font-size: clamp(1.05rem, 2vw, 1.3rem);
  font-weight: 700;
  margin: 0 auto 0.8rem;
  max-width: 760px;
}

.lead,
.note {
  max-width: 780px;
  margin: 0.5rem auto 0;
}

.note {
  color: #526b7d;
  font-size: 0.95rem;
}

.tool-panel {
  display: grid;
  gap: 22px;
  grid-template-columns: minmax(260px, 0.9fr) minmax(300px, 1.1fr);
  margin: 24px 0;
  padding: clamp(18px, 3vw, 28px);
}

.settings,
.practice-box {
  min-width: 0;
}

label,
fieldset {
  display: block;
  margin: 0 0 1rem;
}

label span,
legend {
  display: block;
  font-weight: 700;
  margin-bottom: 0.35rem;
}

input,
select {
  border: 1px solid #bfd1df;
  border-radius: 8px;
  padding: 0.65rem 0.75rem;
  width: 100%;
}

fieldset {
  border: 1px solid #d7e4f2;
  border-radius: 8px;
  padding: 0.8rem;
}

fieldset label {
  align-items: center;
  display: flex;
  gap: 0.35rem;
  margin: 0;
}

fieldset input {
  width: auto;
}

.dan-grid {
  display: grid;
  gap: 0.45rem;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 0.7rem;
}

.action-row,
.answer-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
}

.answer-form label {
  flex: 1 1 160px;
  margin: 0;
}

.primary-button,
.quiet-button,
.save-button {
  border: 0;
  border-radius: 8px;
  font-weight: 800;
  padding: 0.75rem 1rem;
}

.primary-button { background: #1b6aae; color: #fff; }
.save-button { background: #225b76; color: #fff; }
.quiet-button { background: #e8eef5; color: #1f3346; }

button:disabled,
input:disabled {
  opacity: 0.55;
}

.progress,
.feedback {
  color: #526b7d;
  font-weight: 700;
}

.question {
  align-items: center;
  background: #f3f9ff;
  border: 1px solid #d3e5f6;
  border-radius: 10px;
  display: flex;
  font-size: clamp(2.3rem, 8vw, 5rem);
  font-weight: 900;
  justify-content: center;
  min-height: 160px;
  margin: 1rem 0;
}

.feedback {
  min-height: 3.5rem;
  margin: 0.5rem 0;
}

.feedback.is-correct,
.feedback.is-wrong {
  font-size: 1.25rem;
  line-height: 1.4;
  font-weight: 900;
  animation: answer-pop 180ms ease-out;
}

.feedback.is-correct { color: #c62828; }
.feedback.is-wrong { color: #1565c0; }
.question.is-finished { font-size: clamp(1.25rem, 4vw, 2rem); }
.result-panel[hidden] { display: none; }

@keyframes answer-pop {
  from { transform: translateY(4px); opacity: 0.4; }
  to { transform: translateY(0); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .feedback { animation: none; }
}

.result-panel {
  margin: 24px 0;
  padding: clamp(18px, 3vw, 28px);
}

.stats-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.stats-grid div {
  background: #f7fbff;
  border: 1px solid #d8e7f4;
  border-radius: 8px;
  padding: 0.85rem;
}

.stats-grid span,
.stats-grid strong {
  display: block;
}

.stats-grid strong {
  font-size: 1.5rem;
}

.mistakes {
  margin-top: 1.2rem;
}

.info-grid {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 24px 0;
}

.panel,
.related-tools,
.app-comment-section {
  padding: clamp(18px, 3vw, 28px);
}

.tool-links,
.return-links {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  margin-top: 1rem;
}

.tool-links a,
.return-links a {
  background: #f7fbff;
  border: 1px solid #d8e7f4;
  border-radius: 8px;
  color: #1c5c9d;
  display: block;
  padding: 0.8rem 0.9rem;
  text-decoration: none;
  overflow-wrap: anywhere;
}

.tool-links strong,
.tool-links span,
.return-links strong,
.return-links span,
.return-links small {
  display: block;
}

.tool-links span,
.return-links small {
  color: #526b7d;
  font-size: 0.9rem;
}

.ad-row {
  margin: 24px 0;
  min-height: 250px;
  padding: 16px;
  text-align: center;
}

.return-links {
  margin: 24px 0;
}

.lab-footer {
  color: #607483;
  font-size: 0.9rem;
  padding: 24px 0 0;
  text-align: center;
}

@media (max-width: 760px) {
  .site-shell {
    width: min(100% - 20px, 1120px);
    padding-top: 16px;
  }

  .tool-panel,
  .info-grid,
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .question {
    min-height: 130px;
  }
}

/* H1 compact guard: screen-only PC 48px, SP 28px. */
@media screen {
  h1 {
    font-size: 48px !important;
    text-wrap: balance;
  }
}

@media screen and (max-width: 640px) {
  h1 {
    font-size: 28px !important;
    text-wrap: balance;
  }
}
