:root {
  --bg1: #fdf6e9;
  --bg2: #fcefd8;
  --ink: #4a3a2c;
  --sub: #9b8676;
  --primary: #f0883e;
  --primary2: #f6a94b;
  --accent: #ef6b52;
  --accent-soft: #fff0e8;
  --line: #f0e3cf;
  --card: #fffdf7;
  --lv1: #5bbf73;
  --lv2: #f0a020;
  --lv3: #ef6b52;
  --lv4: #c79a4b;
}
* {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  font-family:
    "Zen Maru Gothic", "Hiragino Maru Gothic ProN", system-ui, sans-serif;
  font-weight: 500;
  color: var(--ink);
  font-size: 15.5px;
  line-height: 1.7;
  background: linear-gradient(180deg, #fdf6e9 0%, #fcefd8 100%);
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}
/* 背景の装飾ブロブ */
body::before,
body::after {
  content: "";
  position: fixed;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.35;
  z-index: 0;
}
body::before {
  width: 360px;
  height: 360px;
  background: #ffe08a;
  top: -120px;
  right: -100px;
}
body::after {
  width: 320px;
  height: 320px;
  background: #ffcca3;
  bottom: -120px;
  left: -110px;
}
.app {
  max-width: 740px;
  margin: 0 auto;
  padding: 18px 16px 70px;
  position: relative;
  z-index: 1;
}

header.top {
  padding: 10px 30px;
  margin-bottom: 16px;
  background: linear-gradient(135deg, #ffda6b 0%, #ffc24d 100%);
  border-radius: 26px;
  color: var(--ink);
  box-shadow: 0 10px 26px rgba(240, 160, 32, 0.3);
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  gap: 22px;
  border: 2px solid #fff1bf;
}
.mascot-hero {
  font-size: 62px;
  line-height: 1;
  flex: 0 0 auto;
  filter: drop-shadow(0 3px 4px rgba(0, 0, 0, 0.15));
}
.hero-text {
  text-align: left;
}
header.top h1 {
  margin: 0;
  font-family: "Yomogi", cursive;
  font-size: 54px;
  font-weight: 600;
  letter-spacing: 1px;
  display: inline-block;
  border-bottom: 6px solid var(--accent);
  padding-bottom: 2px;
  line-height: 1.1;
}
header.top p {
  margin: 10px 0 0;
  font-size: 14.5px;
  font-weight: 700;
}
.doodle {
  position: absolute;
  opacity: 0.85;
  pointer-events: none;
}

/* コーチ（吹き出し） */
.coach-row {
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  gap: 10px;
  margin: 16px 0 18px;
}
.coach-mini {
  font-size: 42px;
  flex: 0 0 auto;
  line-height: 1;
}
.coach-bubble {
  position: relative;
  background: #fff7e6;
  border: 2px solid #ffe2a6;
  border-radius: 14px;
  padding: 11px 15px;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--ink);
}
.coach-bubble::before {
  content: "";
  position: absolute;
  left: -9px;
  bottom: 12px;
  border: 7px solid transparent;
  border-right-color: #ffe2a6;
}
/* コーチのイラスト（画像があれば表示・無ければ絵文字） */
.mascot-hero img {
  width: 182px;
  height: auto;
  display: block;
}
.coach-mini img {
  width: 108px;
  height: auto;
  display: block;
}
.mascot-loading {
  font-size: 48px;
  margin-bottom: 8px;
}
.mascot-loading img {
  width: 150px;
  height: auto;
}

/* スマホなど幅が狭いときは、ヘッダーを崩れないように少し縮める */
@media (max-width: 560px) {
  header.top {
    padding: 10px 18px;
    gap: 12px;
  }
  .mascot-hero img {
    width: 96px;
  }
  header.top h1 {
    font-size: 32px;
  }
  header.top p {
    font-size: 12px;
  }
}

.stats {
  display: flex;
  gap: 10px;
  margin: 0 0 18px;
  justify-content: center;
  flex-wrap: wrap;
}
.chip {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 8px 16px;
  font-size: 13px;
  box-shadow: 0 4px 12px rgba(35, 40, 56, 0.05);
  display: flex;
  align-items: center;
  gap: 6px;
}
.chip b {
  color: var(--primary);
  font-size: 15px;
}

.card {
  background: var(--card);
  border-radius: 22px;
  padding: 24px;
  box-shadow: 0 10px 30px rgba(35, 40, 56, 0.07);
  border: 1px solid var(--line);
  margin-bottom: 16px;
}
.screen {
  display: none;
}
.screen.active {
  display: block;
  animation: fade 0.45s cubic-bezier(0.2, 0.7, 0.3, 1);
}
@keyframes fade {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: linear-gradient(135deg, var(--primary), var(--primary2));
  color: #fff;
  border: none;
  border-radius: 14px;
  padding: 16px 22px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(79, 93, 214, 0.35);
  transition:
    transform 0.12s,
    box-shadow 0.2s,
    filter 0.2s;
  width: 100%;
}
.btn:hover {
  filter: brightness(1.06);
  box-shadow: 0 10px 26px rgba(79, 93, 214, 0.45);
}
.btn:active {
  transform: scale(0.98);
}
.btn.accent {
  background: linear-gradient(135deg, #ff7a59, #ff5277);
  box-shadow: 0 8px 20px rgba(255, 82, 119, 0.35);
}
.btn.ghost {
  background: #fff;
  color: var(--primary);
  border: 2px solid var(--line);
  box-shadow: none;
}
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

.msg {
  background: linear-gradient(135deg, #f0f3ff, #f7f4ff);
  border-radius: 16px 16px 16px 4px;
  padding: 16px 18px;
  font-size: 14.5px;
  line-height: 1.75;
  border: 1px solid #e6e9fb;
}
.msg .who {
  font-size: 12px;
  color: var(--primary);
  font-weight: 700;
  margin-bottom: 5px;
}

.level-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 800;
  color: #fff;
  border-radius: 8px;
  padding: 3px 9px;
  margin-right: 8px;
  vertical-align: middle;
}
.lv1 {
  background: var(--lv1);
}
.lv2 {
  background: var(--lv2);
}
.lv3 {
  background: var(--lv3);
}
.lv4 {
  background: var(--lv4);
}

.size-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--ink);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: 999px;
  margin: 10px 0 2px;
}
h2.odai-title {
  font-size: 20px;
  margin: 14px 0 4px;
  line-height: 1.4;
}

table.brief {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  margin-top: 12px;
}
table.brief th,
table.brief td {
  text-align: left;
  vertical-align: top;
  padding: 9px 6px;
  border-bottom: 1px solid var(--line);
}
table.brief th {
  color: var(--sub);
  white-space: nowrap;
  width: 34%;
  font-weight: 600;
}
.must {
  color: var(--accent);
  font-weight: 700;
}

.upload-area {
  display: block;
  border: 2px dashed #c3c9e8;
  border-radius: 16px;
  padding: 28px;
  text-align: center;
  background: #f7f8fe;
  cursor: pointer;
  color: var(--sub);
  font-size: 14px;
  margin: 14px 0;
  transition:
    border-color 0.2s,
    background 0.2s;
}
.upload-area:hover {
  border-color: var(--primary);
  background: #f0f3ff;
}
.upload-area img {
  max-width: 100%;
  max-height: 280px;
  border-radius: 12px;
  margin-top: 10px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
}

.loading {
  text-align: center;
  padding: 46px 0;
}
.spinner {
  width: 58px;
  height: 58px;
  border: 5px solid var(--line);
  border-top-color: var(--primary);
  border-radius: 50%;
  margin: 0 auto 20px;
  animation: spin 1s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.score-big {
  text-align: center;
  padding: 6px 0 4px;
}
.score-ring {
  position: relative;
  width: 150px;
  height: 150px;
  margin: 0 auto;
}
.score-ring svg {
  transform: rotate(-90deg);
}
.score-ring .num {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.score-ring .num b {
  font-size: 46px;
  font-weight: 800;
  color: var(--ink);
  line-height: 1;
}
.score-ring .num small {
  font-size: 13px;
  color: var(--sub);
}
.score-rank-label {
  font-size: 14px;
  color: var(--sub);
  margin-top: 10px;
  font-weight: 600;
}

.review {
  background: var(--accent-soft);
  border-radius: 16px 16px 4px 16px;
  padding: 16px 18px;
  font-size: 14.5px;
  line-height: 1.75;
  margin: 16px 0;
  border: 1px solid #ffe1d7;
}
.review .who {
  font-size: 12px;
  color: var(--accent);
  font-weight: 700;
  margin-bottom: 5px;
}

.item {
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.item .row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.item .name {
  font-weight: 700;
  font-size: 14.5px;
}
.item .sc {
  font-weight: 800;
  color: var(--primary);
  font-size: 15px;
}
.item .cm {
  font-size: 13.5px;
  color: var(--sub);
  margin-top: 5px;
  line-height: 1.6;
}
.bar {
  height: 7px;
  background: var(--line);
  border-radius: 999px;
  margin-top: 7px;
  overflow: hidden;
}
.bar > div {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--primary2));
  border-radius: 999px;
  width: 0;
  transition: width 0.9s cubic-bezier(0.2, 0.7, 0.3, 1);
}

.checks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0;
}
.check {
  font-size: 12.5px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 999px;
  background: #e7f7ef;
  color: #138a5b;
}
.check.ng {
  background: #fdeaea;
  color: #d23b3b;
}

.priority {
  background: #fff8e8;
  border-left: 4px solid var(--lv2);
  padding: 14px 16px;
  border-radius: 10px;
  font-size: 14px;
  line-height: 1.65;
  margin: 14px 0;
}
.reco {
  background: #f1eefe;
  border-left: 4px solid var(--lv4);
  padding: 14px 16px;
  border-radius: 10px;
  font-size: 14px;
  line-height: 1.65;
  margin-top: 10px;
}

.section-label {
  font-size: 14px;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 6px;
}
.demo-note {
  font-size: 11.5px;
  color: var(--sub);
  text-align: center;
  margin-top: 12px;
  line-height: 1.5;
}
.footer-note {
  text-align: center;
  font-size: 11.5px;
  color: var(--sub);
  margin-top: 22px;
}

.toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--ink);
  color: #fff;
  padding: 12px 22px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  opacity: 0;
  transition:
    opacity 0.3s,
    transform 0.3s;
  pointer-events: none;
  z-index: 50;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.25);
}
.toast.show {
  opacity: 0.97;
  transform: translateX(-50%) translateY(0);
}

/* 紙吹雪 */
.confetti {
  position: fixed;
  top: -10px;
  width: 10px;
  height: 14px;
  z-index: 60;
  pointer-events: none;
  opacity: 0.9;
}
@keyframes drop {
  to {
    transform: translateY(110vh) rotate(720deg);
    opacity: 0;
  }
}

/* 改善ガイド（赤ペン添削） */
.annot-wrap {
  position: relative;
  display: inline-block;
  max-width: 100%;
  margin: 8px 0 14px;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.14);
}
.annot-img {
  display: block;
  max-width: 100%;
  max-height: 380px;
}
#annotLayer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.marker {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2.5px solid #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  animation: pop 0.4s ease backwards;
}
@keyframes pop {
  from {
    transform: translate(-50%, -50%) scale(0);
  }
  to {
    transform: translate(-50%, -50%) scale(1);
  }
}
.guide-good {
  background: #e7f7ef;
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 13.5px;
  line-height: 1.7;
  margin: 4px 0 14px;
}
.guide-good b {
  color: #138a5b;
}
.guide-item {
  display: flex;
  gap: 11px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}
.guide-item .gnum {
  flex: 0 0 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
}
.guide-item .gtxt {
  font-size: 13.5px;
  line-height: 1.6;
}
.guide-item .gtxt b {
  color: var(--ink);
}
.guide-item .gwhy {
  color: var(--sub);
  font-size: 12.5px;
  margin-top: 2px;
}
.demo-tag {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--sub);
  background: #eef0f7;
  border-radius: 6px;
  padding: 2px 8px;
  margin-top: 6px;
}

/* 採点の記録（履歴） */
.hist-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.hist-clear {
  background: none;
  border: none;
  color: var(--sub);
  font-size: 12px;
  cursor: pointer;
  text-decoration: underline;
}
.hist-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}
.hist-thumb {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 10px;
  flex: 0 0 auto;
  background: #eef0f7;
}
.hist-info {
  flex: 1;
  min-width: 0;
  cursor: pointer;
}
.hist-title {
  font-size: 13.5px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hist-meta {
  font-size: 11.5px;
  color: var(--sub);
  margin-top: 2px;
}
.hist-score {
  font-weight: 800;
  color: var(--primary);
  font-size: 15px;
  flex: 0 0 auto;
}
.hist-del {
  flex: 0 0 auto;
  background: #fdeaea;
  color: #d23b3b;
  border: none;
  border-radius: 9px;
  padding: 7px 10px;
  font-size: 15px;
  cursor: pointer;
}
.hist-del:hover {
  background: #fbd9d9;
}
.hist-empty {
  font-size: 13px;
  color: var(--sub);
  text-align: center;
  padding: 14px 0;
}

/* 参考デザインのモーダル */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(74, 58, 44, 0.45);
  display: none;
  align-items: flex-end;
  justify-content: center;
  z-index: 80;
}
.modal-overlay.show {
  display: flex;
}
.modal-card {
  background: var(--card);
  width: 100%;
  max-width: 740px;
  border-radius: 24px 24px 0 0;
  padding: 20px 18px 34px;
  max-height: 82vh;
  overflow: auto;
  animation: slideup 0.3s ease;
}
@keyframes slideup {
  from {
    transform: translateY(100%);
  }
  to {
    transform: none;
  }
}
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 16px;
}
.modal-x {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--sub);
}
.modal-sub {
  font-size: 12.5px;
  color: var(--sub);
  margin: 6px 0 14px;
}
.ref-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: 14px;
  margin-bottom: 10px;
  text-decoration: none;
  color: var(--ink);
  font-weight: 700;
  font-size: 14px;
  background: #fffdf7;
}
.ref-link:hover {
  background: var(--accent-soft);
}
.ref-link .rd {
  font-size: 11.5px;
  color: var(--sub);
  font-weight: 500;
  margin-top: 3px;
}
.ref-cat {
  font-size: 12px;
  color: var(--sub);
  font-weight: 700;
  margin: 14px 0 8px;
}
