:root {
  --paper: #f7f4ee;
  --paper-deep: #efe9df;
  --sumi: #1c1a17;
  --sumi-soft: #4a463f;
  --shu: #c73a2b;
  --shu-deep: #a52e21;
  --ok: #2e7d4f;
  --line: #d9d2c5;
  --radius: 14px;
}

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

body {
  font-family: "Noto Sans JP", "Nunito Sans", sans-serif;
  background: var(--paper);
  color: var(--sumi);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

.site-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}
.brand {
  font-family: "Nunito Sans", sans-serif;
  font-weight: 900;
  letter-spacing: 0.06em;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
}
.brand-mark {
  width: 12px; height: 12px;
  background: var(--shu);
  border-radius: 50%;
  display: inline-block;
}
.brand-sub {
  font-family: "Noto Sans JP", sans-serif;
  font-weight: 500;
  color: var(--sumi-soft);
  font-size: 13px;
}

#app {
  max-width: 640px;
  margin: 0 auto;
  padding: 32px 20px 64px;
}

.screen { display: none; }
.screen.active { display: block; animation: fadein 0.25s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.title {
  font-size: 30px;
  font-weight: 900;
  line-height: 1.4;
  margin-bottom: 14px;
}
.lead { color: var(--sumi-soft); margin-bottom: 28px; }

.screen-title {
  font-size: 22px;
  font-weight: 900;
  margin-bottom: 8px;
}
.greeting { color: var(--sumi-soft); margin-bottom: 20px; }

.field { margin-bottom: 20px; }
.field label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--sumi-soft);
}
input[type="text"], input[type="number"], textarea {
  width: 100%;
  padding: 14px;
  font-size: 16px;
  font-family: inherit;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--sumi);
}
input:focus, textarea:focus { outline: 2px solid var(--shu); border-color: transparent; }
textarea { min-height: 140px; resize: vertical; }

.btn {
  display: inline-block;
  padding: 14px 28px;
  font-size: 16px;
  font-weight: 700;
  font-family: inherit;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.1s ease, background 0.15s ease;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--shu); color: #fff; }
.btn-primary:hover { background: var(--shu-deep); }
.btn-ghost {
  background: transparent;
  color: var(--sumi);
  border: 1.5px solid var(--line);
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* レベル選択 */
.level-list { display: grid; gap: 12px; }
.level-group { font-size: 12px; font-weight: 700; letter-spacing: 0.08em; color: var(--sumi-soft); margin-top: 8px; }
.level-group:first-child { margin-top: 0; }
.level-card {
  text-align: left;
  background: #fff;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.15s ease;
}
.level-card:hover { border-color: var(--shu); }
.level-card .lv {
  font-family: "Nunito Sans", sans-serif;
  font-weight: 900;
  color: var(--shu);
  font-size: 13px;
  letter-spacing: 0.08em;
}
.level-card .lv-name { font-weight: 700; font-size: 17px; margin: 2px 0; }
.level-card .lv-desc { font-size: 13px; color: var(--sumi-soft); }

/* 出題 */
.quiz-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.tag {
  background: var(--sumi);
  color: var(--paper);
  font-size: 12px;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 999px;
}
.progress-text { font-size: 13px; color: var(--sumi-soft); font-weight: 700; }
.progress-bar {
  height: 6px;
  background: var(--paper-deep);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 24px;
}
#progress-fill {
  height: 100%;
  width: 0;
  background: var(--shu);
  border-radius: 999px;
  transition: width 0.3s ease;
}
.q-category {
  font-size: 12px;
  font-weight: 700;
  color: var(--shu);
  margin-bottom: 6px;
  letter-spacing: 0.04em;
}
.q-text {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 20px;
  white-space: pre-wrap;
}

.choices { display: grid; gap: 10px; }
.choice {
  text-align: left;
  background: #fff;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: 15px;
  font-family: inherit;
  cursor: pointer;
  line-height: 1.6;
}
.choice:hover { border-color: var(--shu); }
.choice.correct { border-color: var(--ok); background: #eef6f0; }
.choice.wrong { border-color: var(--shu); background: #faeeec; }
.choice:disabled { cursor: default; opacity: 0.85; }

.calc-row { display: flex; gap: 10px; align-items: center; margin-bottom: 4px; }
.calc-row input { flex: 1; }
.calc-unit { font-weight: 700; color: var(--sumi-soft); white-space: nowrap; }

.essay-note { font-size: 12px; color: var(--sumi-soft); margin: 8px 0 12px; }

.q-actions { margin-top: 16px; }

/* フィードバック */
.feedback {
  margin-top: 24px;
  background: #fff;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
}
.feedback-result { font-size: 18px; font-weight: 900; margin-bottom: 12px; }
.feedback-result.good { color: var(--ok); }
.feedback-result.bad { color: var(--shu); }
.feedback-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--shu);
  letter-spacing: 0.08em;
  margin-bottom: 4px;
}
.feedback-text {
  font-size: 14px;
  margin-bottom: 18px;
  white-space: pre-wrap;
}
.hidden { display: none !important; }

/* 結果 */
.score-card {
  background: #fff;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  padding: 28px 20px;
  text-align: center;
  margin-bottom: 20px;
}
.result-badge {
  display: inline-block;
  background: var(--shu);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 14px;
  border-radius: 999px;
  margin-bottom: 10px;
}
.score-num {
  font-family: "Nunito Sans", sans-serif;
  font-size: 64px;
  font-weight: 900;
  line-height: 1.1;
}
.score-unit { font-size: 20px; margin-left: 4px; }
.score-detail { color: var(--sumi-soft); font-size: 13px; margin-top: 6px; }
.record-status { font-size: 12px; color: var(--sumi-soft); margin-top: 10px; }

.breakdown { display: grid; gap: 10px; margin-bottom: 28px; }
.bd-item {
  background: #fff;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: 13px;
}
.bd-item .bd-q { font-weight: 700; margin-bottom: 2px; }
.bd-item .bd-r.good { color: var(--ok); font-weight: 700; }
.bd-item .bd-r.bad { color: var(--shu); font-weight: 700; }

.result-actions { display: flex; gap: 12px; flex-wrap: wrap; }

.site-footer {
  text-align: center;
  font-size: 12px;
  color: var(--sumi-soft);
  padding: 24px;
  border-top: 1px solid var(--line);
}

@media (max-width: 480px) {
  .title { font-size: 24px; }
  .score-num { font-size: 52px; }
}
