/* 中学マスター - スタイル */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: "Hiragino Kaku Gothic ProN", "Hiragino Sans", Meiryo, sans-serif;
  background: #f4f6fb;
  color: #2b3044;
  line-height: 1.7;
  -webkit-text-size-adjust: 100%;
}

main { max-width: 640px; margin: 0 auto; padding: 16px 16px 48px; }

/* ヘッダー */
.app-header {
  background: linear-gradient(135deg, #4f6df5, #7c4df5);
  color: #fff;
  padding: 14px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.app-header h1 { font-size: 20px; }
.header-left { display: flex; align-items: center; gap: 10px; }
.home-btn {
  background: rgba(255,255,255,.2); border: none; border-radius: 10px;
  font-size: 18px; padding: 6px 10px; cursor: pointer; line-height: 1;
}
.home-btn:active { transform: scale(.95); }
.xp-box { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: bold; }
.xp-bar-outer { width: 110px; height: 10px; background: rgba(255,255,255,.3); border-radius: 5px; overflow: hidden; }
.xp-bar-inner { height: 100%; width: 0; background: #ffd54f; border-radius: 5px; transition: width .4s; }

/* 画面 */
.screen { display: none; padding-top: 16px; }
.section-title { font-size: 17px; margin: 18px 0 10px; }

/* ストリーク・おすすめ */
.streak-box { font-size: 14px; color: #e65100; font-weight: bold; margin-bottom: 4px; min-height: 1em; }
.recommend-card {
  display: block; width: 100%;
  background: #fff; border: 2px solid #4f6df5; border-radius: 14px;
  padding: 14px 16px; text-align: left; cursor: pointer; font-size: 15px;
}
.recommend-card:active { transform: scale(.98); }
.recommend-label { color: #4f6df5; font-weight: bold; font-size: 13px; display: block; }

/* 教科カード */
.subject-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.subject-card {
  background: #fff; border: none; border-radius: 16px; padding: 20px 12px;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  cursor: pointer; box-shadow: 0 2px 8px rgba(40,50,90,.08); font-family: inherit;
}
.subject-card:active { transform: scale(.97); }
.subject-icon { font-size: 34px; }
.subject-name { font-size: 18px; font-weight: bold; }
.subject-progress { font-size: 12px; color: #7a8099; }
.subject-card.japanese { border-top: 5px solid #e05252; }
.subject-card.math { border-top: 5px solid #4f6df5; }
.subject-card.english { border-top: 5px solid #f5734d; }
.subject-card.science { border-top: 5px solid #2e9e57; }
.subject-card.social { border-top: 5px solid #b04df5; }

/* 大ボタン */
.big-btn {
  display: block; width: 100%; padding: 14px; margin-top: 10px;
  border: none; border-radius: 12px; font-size: 16px; font-weight: bold;
  cursor: pointer; background: #4f6df5; color: #fff; font-family: inherit;
}
.big-btn:active { transform: scale(.98); }
.weak-btn { background: #ff7043; }
.stats-btn { background: #26a69a; }
.danger-btn { background: #b0b6c8; font-size: 13px; padding: 10px; }
.badge { background: #fff; color: #ff7043; border-radius: 10px; padding: 0 8px; font-size: 13px; }

.back-btn {
  background: none; border: none; color: #4f6df5; font-size: 15px;
  cursor: pointer; padding: 4px 0; font-family: inherit; font-weight: bold;
}

/* 学年タブ */
.grade-tabs { display: flex; gap: 8px; margin: 10px 0 14px; }
.grade-tab {
  flex: 1; padding: 10px; border: none; border-radius: 10px; font-size: 15px;
  font-weight: bold; cursor: pointer; background: #e2e6f2; color: #5a617a; font-family: inherit;
}
.grade-tab.active { background: #4f6df5; color: #fff; }

/* 単元カード */
.unit-card {
  background: #fff; border-radius: 14px; padding: 14px 16px; margin-bottom: 12px;
  box-shadow: 0 2px 8px rgba(40,50,90,.08);
}
.unit-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.unit-name { font-size: 16px; font-weight: bold; }
.unit-stars { font-size: 15px; letter-spacing: 2px; }
.unit-desc { font-size: 12px; color: #7a8099; margin: 2px 0 10px; }
.unit-acc { font-size: 12px; color: #7a8099; margin-bottom: 8px; }
.step-btns { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.step-btn {
  padding: 10px 4px; border: none; border-radius: 10px; font-size: 14px; font-weight: bold;
  cursor: pointer; font-family: inherit; background: #eef1fa; color: #4f6df5;
}
.step-btn.cleared { background: #e3f6e8; color: #2e9e57; }
.step-btn.locked { background: #f0f1f5; color: #b8bdcc; cursor: not-allowed; }
.step-btn:not(.locked):active { transform: scale(.97); }

/* クイズ */
.quiz-header { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 14px; font-weight: bold; }
.progress-bar-outer { height: 8px; background: #e2e6f2; border-radius: 4px; margin: 10px 0; overflow: hidden; }
.progress-bar-inner { height: 100%; width: 0; background: linear-gradient(90deg,#4f6df5,#7c4df5); transition: width .3s; }
.question-history { font-size: 12px; color: #7a8099; min-height: 1.2em; }
.question-text {
  background: #fff; border-radius: 14px; padding: 18px; font-size: 18px; font-weight: bold;
  margin: 10px 0 14px; box-shadow: 0 2px 8px rgba(40,50,90,.08); white-space: pre-wrap;
}
.choices { display: grid; gap: 10px; }
.choice-btn {
  padding: 14px; border: 2px solid #dfe3f0; border-radius: 12px; background: #fff;
  font-size: 16px; text-align: left; cursor: pointer; font-family: inherit; line-height: 1.5;
}
.choice-btn:not(:disabled):active { border-color: #4f6df5; }
.choice-btn.correct { border-color: #2e9e57; background: #e3f6e8; font-weight: bold; }
.choice-btn.wrong { border-color: #e05252; background: #fdeaea; }
.choice-btn:disabled { cursor: default; color: #2b3044; opacity: .95; }

.hint-btn {
  margin-top: 12px; padding: 8px 14px; border: 1px dashed #f5a623; border-radius: 10px;
  background: #fff9ec; color: #b97a00; font-size: 14px; cursor: pointer; font-family: inherit;
}
.hint-text {
  margin-top: 8px; padding: 10px 14px; background: #fff9ec; border-radius: 10px;
  font-size: 14px; color: #7a5200;
}
.answer-result { font-size: 20px; font-weight: bold; margin-top: 14px; min-height: 1.2em; }
.answer-result.is-correct { color: #2e9e57; }
.answer-result.is-wrong { color: #e05252; }
.explanation {
  margin-top: 8px; padding: 14px; background: #eef4ff; border-left: 4px solid #4f6df5;
  border-radius: 8px; font-size: 15px; white-space: pre-wrap;
}
.next-btn { margin-top: 14px; }

/* 結果 */
.result-score { font-size: 30px; font-weight: bold; text-align: center; margin: 14px 0 4px; }
.result-msg { text-align: center; font-size: 17px; font-weight: bold; margin-bottom: 6px; }
.result-msg.clear { color: #2e9e57; }
.result-msg.notclear { color: #e08b00; }
.result-xp { text-align: center; color: #7c4df5; font-weight: bold; margin-bottom: 12px; }
.wrong-item { background: #fff; border-radius: 10px; padding: 10px 14px; margin-bottom: 8px; font-size: 13px; }
.wrong-label { font-weight: bold; color: #e05252; }

/* 成績 */
.stat-box { background: #fff; border-radius: 14px; padding: 14px 16px; margin-bottom: 14px; box-shadow: 0 2px 8px rgba(40,50,90,.08); }
.stat-row { display: flex; justify-content: space-between; padding: 4px 0; font-size: 14px; }
.acc-bar-row { margin-bottom: 10px; }
.acc-bar-label { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 3px; }
.acc-bar-outer { height: 10px; background: #e2e6f2; border-radius: 5px; overflow: hidden; }
.acc-bar-inner { height: 100%; border-radius: 5px; }
.acc-good { background: #4caf7a; }
.acc-mid { background: #f5b64d; }
.acc-bad { background: #f0705c; }
.muted { color: #99a0b5; font-size: 13px; }

.record-btn { background: #7c4df5; }
.report-btn { background: #e0a300; }
.test-btn { background: #536078; margin-bottom: 14px; }
.print-btn {
  background: #eef1fa; border: none; border-radius: 10px; color: #4f6df5;
  font-size: 13px; font-weight: bold; padding: 8px 14px; cursor: pointer; font-family: inherit;
}
.report-head { display: flex; justify-content: space-between; align-items: center; }

/* 学習記録バーチャート（単一系列・棒は控えめな太さ・上端4px丸め） */
.record-chart { display: flex; align-items: flex-end; gap: 4px; height: 150px; }
.rc-col { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; min-width: 0; }
.rc-val { font-size: 10px; color: #5a617a; height: 14px; line-height: 14px; }
.rc-bar-area { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; border-bottom: 1px solid #e2e6f2; }
.rc-bar { width: 60%; max-width: 18px; min-height: 2px; background: #4f6df5; border-radius: 4px 4px 0 0; opacity: .55; }
.rc-bar.rc-today { opacity: 1; }
.rc-label { font-size: 9px; color: #99a0b5; margin-top: 3px; white-space: nowrap; }
.rc-label:nth-child(3) { overflow: hidden; }

/* 成績の同期 */
.sync-row { display: flex; gap: 8px; margin: 10px 0; }
.sync-input {
  flex: 1; min-width: 0; padding: 10px 12px; border: 2px solid #dfe3f0; border-radius: 10px;
  font-size: 16px; font-family: inherit; letter-spacing: 1px; text-transform: uppercase;
}
.sync-input:focus { outline: none; border-color: #4f6df5; }
.sync-new-btn {
  padding: 10px 12px; border: none; border-radius: 10px; background: #eef1fa; color: #4f6df5;
  font-size: 13px; font-weight: bold; cursor: pointer; font-family: inherit; white-space: nowrap;
}
#sync-box .big-btn { margin-top: 4px; }

/* 成績表 */
.report-subject-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.report-table-wrap { overflow-x: auto; }
.report-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.report-table th, .report-table td { padding: 6px 8px; text-align: left; border-bottom: 1px solid #eef1f6; white-space: nowrap; }
.report-table th { color: #7a8099; font-size: 11px; font-weight: normal; }
.grade-mark {
  display: inline-block; width: 24px; height: 24px; line-height: 24px; text-align: center;
  border-radius: 6px; font-weight: bold; font-size: 13px;
}
.g-5 { background: #e3f6e8; color: #2e9e57; }
.g-4 { background: #eef4ff; color: #4f6df5; }
.g-3 { background: #fff9ec; color: #b97a00; }
.g-2 { background: #fdeaea; color: #e05252; }
.g-none { background: #f0f1f5; color: #b8bdcc; }

/* 印刷（成績表など、表示中の画面だけが刷られる） */
@media print {
  .app-header, .back-btn, .print-btn, .home-actions, .big-btn { display: none !important; }
  body { background: #fff; }
  .stat-box { box-shadow: none; border: 1px solid #ddd; }
}

@media (max-width: 420px) {
  .question-text { font-size: 16px; }
  .choice-btn { font-size: 15px; }
  .rc-label { font-size: 8px; transform: rotate(-45deg); }
}
