:root {
  --primary: #e6003d;
  --primary-dark: #b8002f;
  --primary-tint: #ffe8ee;

  --blue: #249bd9;
  --blue-tint: #e5f3fb;
  --green: #3bb97d;
  --green-tint: #e6f8ef;
  --orange: #ff922e;
  --orange-tint: #fff0e2;
  --purple: #8b6bf2;
  --purple-tint: #efeaff;

  --grade1: #ff5c8a;
  --grade1-tint: #ffe5ec;
  --grade2: #ff922e;
  --grade2-tint: #fff0e2;
  --grade3: #ffc845;
  --grade3-tint: #fff7e0;
  --grade4: #3bb97d;
  --grade4-tint: #e6f8ef;
  --grade5: #249bd9;
  --grade5-tint: #e5f3fb;
  --grade6: #8b6bf2;
  --grade6-tint: #efeaff;

  --ink: #242424;
  --sub: #6b6b6b;
  --bg-soft: #f7f7f8;
  --line: #e8e8e8;
  --card-radius: 14px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  font-family: "Noto Sans JP", Roboto, "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, sans-serif;
  background: var(--bg-soft);
  color: var(--ink);
  margin: 0;
  line-height: 1.7;
  min-height: 100vh;
}

a { color: inherit; }

/* ===== ブランドバー ===== */
.brand-bar {
  display: block;
  text-decoration: none;
  text-align: center;
  padding: 10px 12px;
  font-weight: 700;
  font-size: clamp(0.85rem, 2.2vw, 0.95rem);
  letter-spacing: 0.02em;
  color: var(--primary);
  background: #fff;
  border-bottom: 1px solid var(--line);
}

/* ===== ヘッダー ===== */
header.site-header {
  background: #fff;
  padding: 30px 16px 26px;
  text-align: center;
  border-bottom: 1px solid var(--line);
}

header.site-header h1 {
  margin: 8px 0 0;
  font-size: clamp(1.35rem, 4.2vw, 1.9rem);
  font-weight: 700;
  color: var(--ink);
}

header.site-header p {
  margin: 8px 0 0;
  font-size: clamp(0.8rem, 2.4vw, 0.92rem);
  color: var(--sub);
}

header.site-header .header-emoji {
  font-size: clamp(1.8rem, 6vw, 2.4rem);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 64px; height: 64px;
  border-radius: 50%;
  background: var(--primary-tint);
}

main {
  max-width: 980px;
  margin: 0 auto;
  padding: 28px 16px 64px;
}

.breadcrumb {
  font-size: 0.88rem;
  margin-bottom: 18px;
}
.breadcrumb a { color: var(--blue); text-decoration: none; font-weight: 600; }
.breadcrumb a:hover { text-decoration: underline; }

.intro-box {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--card-radius);
  padding: 20px 22px;
  margin: 0 0 22px;
  font-size: 0.98rem;
  color: var(--ink);
}

/* ===== セクション見出し／なぞなぞバナー（トップページ） ===== */
.section-title {
  font-size: clamp(1.05rem, 3.2vw, 1.25rem);
  font-weight: 700;
  margin: 36px 0 14px;
  text-align: center;
  color: var(--ink);
}

.nazo-card {
  display: flex;
  align-items: center;
  gap: 18px;
  text-decoration: none;
  color: var(--ink);
  background: var(--orange-tint);
  border: 1px solid #ffd9b3;
  border-radius: var(--card-radius);
  padding: 20px 22px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.nazo-card:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(0,0,0,0.08); }

.nazo-emoji {
  font-size: 1.8rem;
  flex-shrink: 0;
  width: 56px; height: 56px;
  border-radius: 50%;
  background: #fff;
  display: flex; align-items: center; justify-content: center;
  color: var(--orange);
}
.nazo-body { flex: 1; }
.nazo-title { font-size: 1.1rem; font-weight: 700; color: var(--ink); }
.nazo-desc { font-size: 0.82rem; color: var(--sub); margin-top: 4px; line-height: 1.5; }
.nazo-arrow { font-size: 1.6rem; flex-shrink: 0; color: var(--orange); }

/* ===== グリッド共通 ===== */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-top: 24px;
}

/* ===== 学年カード（トップページ） ===== */
.grade-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  border-radius: var(--card-radius);
  padding: 26px 14px 18px;
  text-align: center;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-top: 4px solid var(--grade1);
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.grade-card:hover { transform: translateY(-3px); box-shadow: 0 10px 20px rgba(0,0,0,0.08); }

.grade-card .grade-emoji {
  font-size: 1.6rem;
  width: 48px; height: 48px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.grade-card .grade-name { font-size: 1.15rem; font-weight: 700; }
.grade-card .grade-subjects {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 4px;
}
.subj-badge {
  display: inline-flex; align-items: center; gap: 3px;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 0.72rem;
  font-weight: 700;
  background: var(--bg-soft);
  color: var(--sub);
}
.subj-badge--kokugo { background: var(--grade1-tint); color: var(--grade1); }
.subj-badge--eigo   { background: var(--grade5-tint); color: var(--grade5); }
.subj-badge--sansu  { background: var(--grade4-tint); color: var(--grade4); }

.grade-card.g1 { background: #fff; border-top-color: var(--grade1); color: var(--ink); }
.grade-card.g1 .grade-emoji { background: var(--grade1-tint); }
.grade-card.g2 { background: #fff; border-top-color: var(--grade2); color: var(--ink); }
.grade-card.g2 .grade-emoji { background: var(--grade2-tint); }
.grade-card.g3 { background: #fff; border-top-color: var(--grade3); color: var(--ink); }
.grade-card.g3 .grade-emoji { background: var(--grade3-tint); }
.grade-card.g4 { background: #fff; border-top-color: var(--grade4); color: var(--ink); }
.grade-card.g4 .grade-emoji { background: var(--grade4-tint); }
.grade-card.g5 { background: #fff; border-top-color: var(--grade5); color: var(--ink); }
.grade-card.g5 .grade-emoji { background: var(--grade5-tint); }
.grade-card.g6 { background: #fff; border-top-color: var(--grade6); color: var(--ink); }
.grade-card.g6 .grade-emoji { background: var(--grade6-tint); }

/* ===== 教科カード（学年トップページ） ===== */
.card.subject {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  background: #fff;
  border-radius: var(--card-radius);
  border: 1px solid var(--line);
  padding: 28px 16px;
  text-align: center;
  text-decoration: none;
  color: var(--ink);
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.card.subject:hover { transform: translateY(-3px); box-shadow: 0 10px 20px rgba(0,0,0,0.08); }

.subject-emoji {
  font-size: 1.8rem;
  width: 60px; height: 60px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.subject-emoji--kokugo { background: var(--grade1-tint); }
.subject-emoji--eigo   { background: var(--grade5-tint); }
.subject-emoji--sansu  { background: var(--grade4-tint); }

.subject-name { font-size: 1.2rem; font-weight: 700; }
.subject-desc { font-size: 0.82rem; color: var(--sub); line-height: 1.5; }

/* ===== 分野リスト（国語/英語/算数トップ） ===== */
.subject-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 18px;
}

.subject-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--card-radius);
  padding: 16px 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
  flex-wrap: wrap;
  gap: 12px;
}

.subject-row .label {
  font-size: 1.05rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
}
.subject-row .label .row-emoji {
  font-size: 1.1rem;
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--bg-soft);
  display: inline-flex; align-items: center; justify-content: center;
}

.subject-row .links { display: flex; flex-wrap: wrap; gap: 8px; }

/* ===== ボタン ===== */
.btn {
  display: inline-block;
  text-decoration: none;
  background: var(--primary);
  color: #fff;
  padding: 10px 22px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.92rem;
  border: none;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(230,0,61,0.25);
  transition: background 0.15s ease, transform 0.12s ease, box-shadow 0.12s ease;
}
.btn:hover { background: var(--primary-dark); transform: translateY(-1px); box-shadow: 0 4px 10px rgba(230,0,61,0.3); }
.btn:active { transform: translateY(0); }

.btn.secondary {
  background: #fff;
  color: var(--blue);
  border: 1.5px solid var(--blue);
  box-shadow: none;
}
.btn.secondary:hover { background: var(--blue-tint); }

.btn.pdf { background: var(--orange); box-shadow: 0 2px 6px rgba(255,146,46,0.3); }
.btn.pdf:hover { background: #e07a1a; box-shadow: 0 4px 10px rgba(255,146,46,0.35); }
.btn.pdf::before { content: "📄 "; }

.grade-tag {
  display: inline-block;
  padding: 5px 16px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
  margin-bottom: 10px;
  color: #fff;
}

.g1 { background: var(--grade1); }
.g2 { background: var(--grade2); }
.g3 { background: var(--grade3); color: #6b4a00; }
.g4 { background: var(--grade4); }
.g5 { background: var(--grade5); }
.g6 { background: var(--grade6); }

/* ===== クイズ ===== */
#quiz-app {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--card-radius);
  padding: 28px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.progress {
  font-size: 0.9rem;
  color: var(--sub);
  font-weight: 700;
  margin-bottom: 10px;
}

.question-text {
  font-size: clamp(1.1rem, 3.2vw, 1.35rem);
  font-weight: 700;
  margin: 12px 0 24px;
  white-space: pre-wrap;
  color: var(--ink);
}

.choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.choice-btn {
  background: #fff;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 15px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  color: var(--ink);
  transition: background 0.12s ease, border-color 0.12s ease;
}
.choice-btn:hover { background: var(--bg-soft); border-color: #d0d0d0; }
.choice-btn.correct { background: var(--green-tint); border-color: var(--green); }
.choice-btn.wrong { background: var(--primary-tint); border-color: var(--primary); }
.choice-btn:disabled { cursor: default; }
.choice-btn:disabled:hover { background: inherit; }

.feedback {
  margin-top: 18px;
  font-size: 1.1rem;
  font-weight: 700;
  min-height: 1.6em;
}
.feedback.ok { color: var(--green); }
.feedback.ng { color: var(--primary); }

.explanation {
  margin-top: 12px;
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--ink);
  background: var(--blue-tint);
  border: 1px solid #c9e6f7;
  border-radius: 12px;
  padding: 12px 16px;
  line-height: 1.6;
}
.explanation:empty { display: none; padding: 0; border: none; }

.review-item .explanation { margin-top: 8px; }

.quiz-footer {
  margin-top: 22px;
  text-align: right;
}

.result-score {
  font-size: clamp(1.5rem, 5.5vw, 2rem);
  font-weight: 700;
  text-align: center;
  margin: 12px 0 24px;
  color: var(--primary);
}

.review-item {
  border-top: 1px solid var(--line);
  padding: 14px 0;
}
.review-item .qt { font-weight: 700; }
.review-item .ans-ok { color: var(--green); font-weight: 700; }
.review-item .ans-ng { color: var(--primary); font-weight: 700; }

/* ===== 広告枠 ===== */
.ad-slot { width: 100%; margin: 18px 0; }
.ad-slot[hidden] { display: none; }
.ad-banner {
  display: flex; align-items: center; gap: 12px;
  background: #fff; border: 1px dashed #c9d4e0; border-radius: 12px;
  padding: 14px 18px; text-decoration: none; color: var(--sub);
  font-size: 0.85rem; line-height: 1.6;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.ad-banner:hover { border-color: #94a3b8; box-shadow: 0 4px 16px rgba(0,0,0,0.06); }
.ad-label {
  flex-shrink: 0; font-size: 0.64rem; font-weight: 700; letter-spacing: 0.05em;
  background: var(--bg-soft); color: var(--sub); padding: 3px 10px; border-radius: 20px;
}
.ad-img { max-width: 100%; display: block; border-radius: 10px; }

footer.site-footer {
  text-align: center;
  color: var(--sub);
  font-size: 0.84rem;
  padding: 26px;
  border-top: 1px solid var(--line);
  background: #fff;
}

/* ===== レスポンシブ ===== */
@media (max-width: 600px) {
  .subject-row { flex-direction: column; align-items: flex-start; }
  .subject-row .links { width: 100%; }
  .subject-row .links .btn { flex: 1; text-align: center; }
  header.site-header { padding: 24px 12px 20px; }
  main { padding: 20px 12px 48px; }
  .nazo-card { flex-direction: column; text-align: center; }
  .nazo-arrow { display: none; }
}

@media (max-width: 480px) {
  .choices { grid-template-columns: 1fr; }
  .grid { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; }
  .ad-banner { flex-wrap: wrap; }
}
