* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Hiragino Sans', 'Yu Gothic', 'Meiryo', sans-serif;
  background: #eef1f7;
  color: #1a1a2e;
  min-height: 100vh;
}

/* ── 画面切り替え ── */
.screen { display: none; }
.screen.active { display: block; }

/* ── スタート画面 ── */
#screen-start {
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}
#screen-start.active { display: flex; }

.start-card {
  background: white;
  border-radius: 20px;
  padding: 48px 40px;
  max-width: 480px;
  width: 100%;
  text-align: center;
  box-shadow: 0 8px 32px rgba(58, 10, 122, 0.12);
}

.logo {
  display: inline-block;
  background: #3a0a7a;
  color: white;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2px;
  padding: 4px 12px;
  border-radius: 4px;
  margin-bottom: 24px;
}

.start-card h1 {
  font-size: 28px;
  font-weight: 800;
  line-height: 1.4;
  color: #1a0a2e;
  margin-bottom: 20px;
}

.desc {
  font-size: 14px;
  color: #666;
  line-height: 1.7;
  margin-bottom: 28px;
}

.meta-row {
  display: flex;
  justify-content: center;
  gap: 20px;
  font-size: 13px;
  color: #3a0a7a;
  font-weight: 600;
  margin-bottom: 36px;
}

.btn-start {
  background: linear-gradient(135deg, #3a0a7a, #6a1aaa);
  color: white;
  border: none;
  border-radius: 12px;
  padding: 16px 40px;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
  transition: transform 0.1s, box-shadow 0.1s;
  box-shadow: 0 4px 16px rgba(58, 10, 122, 0.3);
}
.btn-start:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(58, 10, 122, 0.4); }
.btn-start:active { transform: translateY(0); }

/* ── 問題画面 ── */
#screen-quiz { min-height: 100vh; flex-direction: column; }
#screen-quiz.active { display: flex; }

.quiz-header {
  background: white;
  padding: 16px 24px 12px;
  border-bottom: 1px solid #e8e0f0;
  position: sticky;
  top: 0;
  z-index: 10;
}

.progress-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

#q-number {
  font-size: 14px;
  font-weight: 700;
  color: #3a0a7a;
}

#q-chapter {
  font-size: 12px;
  color: #888;
}

.progress-bar-wrap {
  background: #e8e0f0;
  border-radius: 99px;
  height: 6px;
  overflow: hidden;
}

.progress-bar {
  background: linear-gradient(90deg, #3a0a7a, #7a2ada);
  height: 100%;
  border-radius: 99px;
  transition: width 0.4s ease;
  width: 0%;
}

.quiz-body {
  flex: 1;
  padding: 28px 20px 40px;
  max-width: 600px;
  width: 100%;
  margin: 0 auto;
}

.question-text {
  font-size: 17px;
  font-weight: 600;
  line-height: 1.7;
  color: #1a0a2e;
  margin-bottom: 28px;
  background: white;
  border-radius: 14px;
  padding: 20px 22px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.06);
  border-left: 4px solid #3a0a7a;
}

/* ── 選択肢ボタン ── */
.choices {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}

.choice-btn {
  background: white;
  border: 2px solid #ddd;
  border-radius: 14px;
  padding: 18px 20px;
  font-size: 15px;
  font-weight: 500;
  color: #222;
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
  line-height: 1.5;
}

.choice-btn:hover:not(:disabled) {
  border-color: #7a2ada;
  background: #f5eeff;
  transform: translateX(4px);
}

.choice-btn:active:not(:disabled) { transform: translateX(2px); }

.choice-label {
  min-width: 32px;
  height: 32px;
  background: #f0eaff;
  color: #3a0a7a;
  font-weight: 800;
  font-size: 14px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* 正解・不正解のスタイル */
.choice-btn.correct {
  border-color: #2ea86a;
  background: #eafaf2;
}
.choice-btn.correct .choice-label {
  background: #2ea86a;
  color: white;
}

.choice-btn.wrong {
  border-color: #e05050;
  background: #fff0f0;
}
.choice-btn.wrong .choice-label {
  background: #e05050;
  color: white;
}

.choice-btn:disabled { cursor: default; }

/* ── 結果エリア ── */
.result-area {
  margin-top: 8px;
  background: white;
  border-radius: 14px;
  padding: 20px 22px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.06);
}

.result-area.hidden { display: none; }

.result-badge {
  font-size: 18px;
  font-weight: 800;
  margin-bottom: 12px;
}
.result-badge.correct-badge { color: #2ea86a; }
.result-badge.wrong-badge  { color: #e05050; }

.explanation-text {
  font-size: 14px;
  color: #444;
  line-height: 1.8;
  margin-bottom: 20px;
  border-top: 1px solid #eee;
  padding-top: 14px;
}

.btn-next {
  background: #3a0a7a;
  color: white;
  border: none;
  border-radius: 10px;
  padding: 14px 24px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
  transition: background 0.15s;
}
.btn-next:hover { background: #5a1aaa; }

/* ── 結果画面 ── */
#screen-result { padding: 32px 20px 60px; }
#screen-result.active { display: block; }

.result-card {
  max-width: 600px;
  margin: 0 auto;
}

.score-display {
  background: linear-gradient(135deg, #1a0a2e, #3a0a7a);
  color: white;
  border-radius: 20px;
  padding: 40px 24px;
  text-align: center;
  margin-bottom: 24px;
}

.score-display .score-num {
  font-size: 64px;
  font-weight: 800;
  line-height: 1;
  margin-bottom: 8px;
}

.score-display .score-label {
  font-size: 16px;
  opacity: 0.8;
}

.score-message {
  text-align: center;
  font-size: 16px;
  font-weight: 600;
  color: #3a0a7a;
  margin-bottom: 28px;
}

/* ── 復習リスト ── */
.review-list { margin-bottom: 28px; }

.review-header {
  font-weight: 700;
  font-size: 14px;
  color: #555;
  margin-bottom: 12px;
}

.review-item {
  background: white;
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 10px;
  border-left: 4px solid #ddd;
  font-size: 14px;
  line-height: 1.6;
}

.review-item.correct { border-left-color: #2ea86a; }
.review-item.wrong   { border-left-color: #e05050; }

.review-item .review-mark {
  font-weight: 800;
  margin-right: 6px;
}
.review-item.correct .review-mark { color: #2ea86a; }
.review-item.wrong   .review-mark { color: #e05050; }

.review-item .review-q {
  color: #333;
  margin-bottom: 4px;
}

.review-item .review-ans {
  font-size: 12px;
  color: #888;
}

/* ── スタート画面：用語カードへの導線 ── */
.btn-secondary {
  margin-top: 12px;
  background: white;
  color: #3a0a7a;
  border: 2px solid #3a0a7a;
  border-radius: 12px;
  padding: 14px 40px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
}
.btn-secondary:hover { background: #f5eeff; }

/* ── 用語カード画面 ── */
#screen-glossary { min-height: 100vh; }
#screen-glossary.active { display: block; }

.glossary-wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 20px 16px 60px;
}

.glossary-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.glossary-header h2 {
  flex: 1;
  font-size: 18px;
  color: #1a0a2e;
}
.glossary-stat {
  font-size: 12px;
  font-weight: 700;
  color: #3a0a7a;
  background: #f0eaff;
  padding: 5px 12px;
  border-radius: 99px;
}

.btn-back {
  background: none;
  border: none;
  color: #3a0a7a;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  padding: 6px 4px;
}

.glossary-search {
  width: 100%;
  padding: 12px 16px;
  border-radius: 12px;
  border: 2px solid #e8e0f0;
  font-size: 14px;
  margin-bottom: 12px;
  font-family: inherit;
}
.glossary-search:focus { outline: none; border-color: #7a2ada; }

.glossary-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}
.g-chip {
  font-size: 12px;
  padding: 6px 14px;
  border-radius: 99px;
  border: 1px solid #ddd;
  background: white;
  color: #666;
  cursor: pointer;
  font-family: inherit;
}
.g-chip.active {
  background: var(--chip-color, #3a0a7a);
  border-color: var(--chip-color, #3a0a7a);
  color: white;
}

.glossary-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.btn-mini {
  font-size: 12px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid #ddd;
  background: white;
  color: #444;
  cursor: pointer;
  font-family: inherit;
}
.btn-mini:hover { border-color: #7a2ada; }
.btn-mini.g-active-toggle { background: #3a0a7a; color: white; border-color: #3a0a7a; }
.btn-mini-danger:hover { border-color: #e05050; color: #e05050; }

.glossary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}
@media (max-width: 420px) {
  .glossary-grid { grid-template-columns: 1fr 1fr; }
}

.g-card { perspective: 1000px; height: 158px; cursor: pointer; }
.g-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.45s cubic-bezier(.2,.7,.3,1);
  transform-style: preserve-3d;
}
.g-card.g-flipped .g-inner { transform: rotateY(180deg); }

.g-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: 12px;
  background: white;
  box-shadow: 0 2px 10px rgba(0,0,0,0.06);
  border: 1px solid #e8e0f0;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
}
.g-back { transform: rotateY(180deg); overflow-y: auto; }

.g-tag {
  align-self: flex-start;
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  margin-bottom: auto;
}

.g-term {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.4;
  color: #1a0a2e;
  margin-top: 6px;
}
.g-hint { font-size: 10px; color: #999; margin-top: 4px; }

.g-def {
  font-size: 12px;
  line-height: 1.55;
  color: #333;
}
.g-term-echo {
  display: block;
  font-weight: 700;
  color: #3a0a7a;
  font-size: 11px;
  margin-bottom: 5px;
}

.g-knowrow { display: flex; gap: 5px; margin-top: auto; padding-top: 6px; }
.g-knowbtn {
  flex: 1;
  font-size: 10px;
  padding: 5px 3px;
  border-radius: 6px;
  border: 1px solid #ddd;
  background: #f7f5fb;
  color: #888;
  cursor: pointer;
  font-family: inherit;
}
.g-knowbtn.g-yes.active { background: #eafaf2; color: #2ea86a; border-color: #2ea86a; }
.g-knowbtn.g-no.active { background: #fff0f0; color: #e05050; border-color: #e05050; }

.g-card.g-known .g-front { opacity: 0.4; }

.glossary-empty {
  text-align: center;
  padding: 50px 20px;
  color: #999;
  font-size: 14px;
}
