/* ============ ごうかくチャーム — pastel cute theme ============ */
:root {
  --pink: #ff8fb8;
  --pink-deep: #f26a9e;
  --pink-pale: #ffe3ef;
  --lavender: #b79bff;
  --lavender-pale: #efe8ff;
  --mint: #6fd8c3;
  --mint-pale: #dff7f1;
  --lemon: #ffd97a;
  --lemon-pale: #fff4d6;
  --sky: #8fc7ff;
  --sky-pale: #e3f1ff;
  --ink: #5a4560;
  --ink-soft: #93809b;
  --card: #ffffff;
  --ok: #43c59e;
  --ng: #f47b9b;
  --radius: 22px;
  --shadow: 0 6px 24px rgba(242, 106, 158, 0.14);
  --font: "Zen Maru Gothic", "Kiwi Maru", "Hiragino Maru Gothic ProN", "BIZ UDGothic", "Yu Gothic UI", sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { font-size: 16px; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 10%, #ffeef6 0%, transparent 45%),
    radial-gradient(circle at 85% 25%, #f0e9ff 0%, transparent 45%),
    radial-gradient(circle at 50% 90%, #e4f6ff 0%, transparent 50%),
    linear-gradient(180deg, #fff7fb 0%, #f7f1ff 100%);
  min-height: 100vh;
  min-height: 100dvh;
  overscroll-behavior-y: none;
}
#app {
  max-width: 480px;
  margin: 0 auto;
  padding: max(env(safe-area-inset-top), 10px) 16px calc(84px + env(safe-area-inset-bottom));
  min-height: 100dvh;
}

.boot { text-align: center; padding-top: 40vh; color: var(--ink-soft); }
.boot-heart { font-size: 3rem; animation: bounce 1s ease-in-out infinite; }
@keyframes bounce { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-12px)} }

h1,h2,h3 { margin: 0; font-weight: 900; }
button { font-family: var(--font); border: none; cursor: pointer; }

/* ---------- header ---------- */
.app-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 2px 14px;
}
.app-title { font-size: 1.15rem; letter-spacing: .04em; color: var(--pink-deep); }
.app-title small { display:block; font-size:.62rem; color: var(--ink-soft); font-weight:700; letter-spacing:.12em; }
.head-stats { display: flex; gap: 8px; }
.stat-chip {
  background: var(--card); border-radius: 999px; padding: 6px 12px;
  font-size: .8rem; font-weight: 700; box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 4px;
}

/* ---------- cards ---------- */
.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px; margin-bottom: 14px;
}
.card.pale-pink { background: linear-gradient(135deg, #fff0f7, #ffe3ef); }
.card.pale-purple { background: linear-gradient(135deg, #f4eeff, #ece2ff); }

/* mission card */
.mission-card { display: flex; align-items: center; gap: 14px; }
.mission-mascot { font-size: 2.6rem; filter: drop-shadow(0 4px 6px rgba(242,106,158,.25)); }
.mission-body { flex: 1; }
.mission-body p { margin: 4px 0 0; font-size: .82rem; color: var(--ink-soft); font-weight: 700; }
.mission-title { font-size: 1rem; color: var(--pink-deep); }

/* subject grid */
.subject-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.subject-card {
  position: relative;
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px 14px 14px; text-align: left; transition: transform .12s ease;
}
.subject-card:active { transform: scale(.96); }
.subject-emoji { font-size: 1.9rem; }
.subject-name { font-size: 1rem; font-weight: 900; margin-top: 4px; }
.subject-sub { font-size: .72rem; color: var(--ink-soft); font-weight: 700; }
.subject-card .ring { position: absolute; top: 12px; right: 12px; }
.subject-card.s-math { border-top: 5px solid var(--sky); }
.subject-card.s-science { border-top: 5px solid var(--mint); }
.subject-card.s-social { border-top: 5px solid var(--lemon); }
.subject-card.s-kokugo { border-top: 5px solid var(--pink); }

.ring { display: block; }
.ring .bg { stroke: #f1e8f2; }
.ring .fg { stroke: var(--pink); stroke-linecap: round; transition: stroke-dashoffset .6s ease; }
.ring text { font-size: 11px; font-weight: 900; fill: var(--ink); }

/* big action buttons */
.btn {
  display: block; width: 100%; text-align: center;
  padding: 15px 18px; border-radius: 999px;
  font-size: 1rem; font-weight: 900; letter-spacing: .05em;
  color: #fff; background: linear-gradient(135deg, var(--pink), var(--pink-deep));
  box-shadow: 0 6px 18px rgba(242,106,158,.4);
  transition: transform .12s ease, box-shadow .12s ease;
}
.btn:active { transform: translateY(2px) scale(.98); box-shadow: 0 2px 8px rgba(242,106,158,.35); }
.btn.secondary { background: linear-gradient(135deg, var(--lavender), #9b7bf2); box-shadow: 0 6px 18px rgba(155,123,242,.35); }
.btn.ghost { background: #fff; color: var(--pink-deep); border: 2px solid var(--pink-pale); box-shadow: none; }
.btn.small { padding: 10px 16px; font-size: .85rem; width: auto; display: inline-block; }
.btn:disabled { opacity: .45; pointer-events: none; }
.btn + .btn { margin-top: 10px; }

/* ---------- unit list ---------- */
.page-head { display: flex; align-items: center; gap: 10px; margin: 4px 0 14px; }
.back-btn {
  background: #fff; border-radius: 50%; width: 40px; height: 40px;
  font-size: 1.1rem; box-shadow: var(--shadow); color: var(--pink-deep); font-weight: 900;
  flex-shrink: 0;
}
.page-head h2 { font-size: 1.15rem; }
.page-head .sub { font-size: .72rem; color: var(--ink-soft); font-weight: 700; }

.unit-row {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  background: var(--card); border-radius: 18px; box-shadow: var(--shadow);
  padding: 14px; margin-bottom: 10px; transition: transform .12s ease;
}
.unit-row:active { transform: scale(.97); }
.unit-emoji {
  width: 44px; height: 44px; border-radius: 14px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 1.4rem;
  background: var(--pink-pale);
}
.unit-info { flex: 1; min-width: 0; }
.unit-name { font-weight: 900; font-size: .92rem; }
.unit-meta { font-size: .7rem; color: var(--ink-soft); font-weight: 700; margin-top: 2px; }
.crowns { font-size: .8rem; letter-spacing: 1px; }
.crowns .off { opacity: .18; }

.bar { height: 7px; background: #f3eaf4; border-radius: 99px; overflow: hidden; margin-top: 6px; }
.bar > i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--pink), var(--lavender)); transition: width .5s ease; }

/* ---------- quiz ---------- */
.quiz-top { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.quiz-progress { flex: 1; height: 12px; background: #f3eaf4; border-radius: 99px; overflow: hidden; }
.quiz-progress > i { display: block; height: 100%; background: linear-gradient(90deg, var(--pink), var(--lavender)); border-radius: 99px; transition: width .35s ease; }
.quit-btn { background: none; font-size: 1.2rem; color: var(--ink-soft); }

.q-tag {
  display: inline-block; font-size: .68rem; font-weight: 900;
  background: var(--lavender-pale); color: #7b5fd0;
  border-radius: 999px; padding: 4px 12px; margin-bottom: 10px;
}
.q-tag.src { background: var(--lemon-pale); color: #b8860b; margin-left: 6px; }
.q-text { font-size: 1.02rem; line-height: 1.75; font-weight: 700; white-space: pre-wrap; }
.q-card { animation: slideIn .3s ease; }
@keyframes slideIn { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }

.choices { margin-top: 16px; display: flex; flex-direction: column; gap: 10px; }
.choice-btn {
  text-align: left; background: #fff; border: 2.5px solid #f3e6f0;
  border-radius: 16px; padding: 13px 14px; font-size: .92rem; font-weight: 700;
  line-height: 1.5; color: var(--ink); display: flex; gap: 10px; align-items: flex-start;
  transition: transform .1s ease, border-color .15s, background .15s;
}
.choice-btn:active { transform: scale(.98); }
.choice-btn .mark {
  flex-shrink: 0; width: 26px; height: 26px; border-radius: 50%;
  background: var(--pink-pale); color: var(--pink-deep);
  display: flex; align-items: center; justify-content: center; font-size: .8rem; font-weight: 900;
}
.choice-btn.selected { border-color: var(--lavender); background: var(--lavender-pale); }
.choice-btn.correct { border-color: var(--ok); background: #e9faf4; }
.choice-btn.correct .mark { background: var(--ok); color: #fff; }
.choice-btn.wrong { border-color: var(--ng); background: #fdeef3; }
.choice-btn.wrong .mark { background: var(--ng); color: #fff; }
.choice-btn.dim { opacity: .5; }
.choice-btn:disabled { cursor: default; }

.numeric-wrap { margin-top: 16px; display: flex; gap: 8px; align-items: center; }
.numeric-input {
  flex: 1; font-family: var(--font); font-size: 1.3rem; font-weight: 900; color: var(--ink);
  border: 2.5px solid #f3e6f0; border-radius: 16px; padding: 12px 16px; width: 100%;
  outline: none; text-align: center; background: #fff;
}
.numeric-input:focus { border-color: var(--lavender); }
.numeric-unit { font-weight: 900; color: var(--ink-soft); flex-shrink: 0; }

.answer-actions { margin-top: 16px; }

/* feedback panel */
.feedback { border-radius: var(--radius); padding: 16px; margin-top: 14px; animation: popIn .25s ease; }
@keyframes popIn { from { opacity: 0; transform: scale(.94); } to { opacity: 1; transform: none; } }
.feedback.good { background: #e9faf4; border: 2px solid #bdecdc; }
.feedback.bad { background: #fdeef3; border: 2px solid #fbd3e0; }
.feedback-head { font-size: 1.05rem; font-weight: 900; display: flex; align-items: center; gap: 8px; }
.feedback.good .feedback-head { color: #1d9e78; }
.feedback.bad .feedback-head { color: #e0507e; }
.feedback .answer-line { font-weight: 900; margin: 8px 0 4px; font-size: .9rem; }
.feedback .expl { font-size: .85rem; line-height: 1.8; margin: 6px 0 0; color: var(--ink); }

.why-box { margin-top: 14px; border-top: 2px dashed #f0d9e6; padding-top: 12px; }
.why-label { font-size: .8rem; font-weight: 900; color: #7b5fd0; margin-bottom: 8px; }

/* result screen */
.result-hero { text-align: center; padding: 26px 16px 20px; }
.result-emoji { font-size: 3.6rem; animation: bounce 1.2s ease-in-out infinite; }
.result-title { font-size: 1.4rem; color: var(--pink-deep); margin-top: 8px; }
.result-stats { display: flex; justify-content: center; gap: 12px; margin-top: 18px; }
.result-stat { background: #fff; border-radius: 18px; box-shadow: var(--shadow); padding: 12px 18px; min-width: 86px; }
.result-stat b { display: block; font-size: 1.4rem; color: var(--pink-deep); }
.result-stat span { font-size: .68rem; color: var(--ink-soft); font-weight: 700; }
.gem-pop { font-size: .95rem; font-weight: 900; color: #b8860b; margin-top: 14px; }

/* ---------- collection ---------- */
.charm-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.charm {
  background: var(--card); border-radius: 18px; box-shadow: var(--shadow);
  padding: 14px 8px; text-align: center;
}
.charm .c-emoji { font-size: 2rem; }
.charm .c-name { font-size: .68rem; font-weight: 900; margin-top: 6px; }
.charm .c-cond { font-size: .6rem; color: var(--ink-soft); font-weight: 700; margin-top: 2px; }
.charm.locked { opacity: .55; background: #f6eef4; box-shadow: none; }
.charm.locked .c-emoji { filter: grayscale(1); opacity: .5; }
.charm.new { animation: charmGet .5s ease; border: 2px solid var(--lemon); }
@keyframes charmGet { 0%{transform:scale(.5) rotate(-10deg)} 70%{transform:scale(1.15) rotate(4deg)} 100%{transform:none} }

/* ---------- bottom nav ---------- */
.bottom-nav {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px;
  background: rgba(255,255,255,.92); backdrop-filter: blur(12px);
  border-radius: 26px 26px 0 0; box-shadow: 0 -6px 24px rgba(183,155,255,.18);
  display: flex; padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
  z-index: 50;
}
.nav-btn {
  flex: 1; background: none; text-align: center; padding: 6px 0 4px;
  font-size: .62rem; font-weight: 900; color: var(--ink-soft); border-radius: 16px;
}
.nav-btn .nv { display: block; font-size: 1.35rem; margin-bottom: 1px; transition: transform .15s ease; }
.nav-btn.active { color: var(--pink-deep); background: var(--pink-pale); }
.nav-btn.active .nv { transform: scale(1.15); }
.nav-btn .badge {
  position: relative;
}
.nav-btn .badge::after {
  content: attr(data-n);
  position: absolute; top: -4px; right: -12px;
  background: var(--ng); color: #fff; font-size: .58rem; font-weight: 900;
  border-radius: 999px; padding: 1px 5px; min-width: 14px;
}

/* misc */
.empty-note { text-align: center; color: var(--ink-soft); font-weight: 700; font-size: .85rem; padding: 30px 10px; }
.section-label { font-size: .8rem; font-weight: 900; color: var(--ink-soft); letter-spacing: .1em; margin: 18px 4px 10px; }
.streak-flames { font-size: .8rem; }
.toast {
  position: fixed; left: 50%; bottom: 100px; transform: translateX(-50%);
  background: var(--ink); color: #fff; font-size: .8rem; font-weight: 700;
  border-radius: 999px; padding: 10px 20px; z-index: 99;
  animation: popIn .25s ease; box-shadow: 0 8px 20px rgba(0,0,0,.2);
  max-width: 90%; text-align: center;
}
.hint-text { font-size: .74rem; color: var(--ink-soft); font-weight: 700; margin-top: 8px; line-height: 1.6; }

/* ---------- 年度別チャレンジ ---------- */
.exam-timer {
  font-weight: 900; font-size: .85rem; color: var(--ink);
  background: #fff; border-radius: 999px; padding: 6px 12px;
  box-shadow: var(--shadow); flex-shrink: 0;
}
.exam-timer.urgent { color: #e0507e; animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 0%,100%{transform:scale(1)} 50%{transform:scale(1.08)} }
.score-big {
  font-size: 3rem; font-weight: 900; color: var(--ink); margin-top: 8px;
}
.score-big.pass {
  background: linear-gradient(135deg, var(--pink-deep), var(--lavender));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

/* ---------- クエスト & チケット ---------- */
.quest-row.done { opacity: .75; background: #fdf6fa; }
.quest-amount {
  font-weight: 900; color: #b8860b; font-size: .85rem;
  background: var(--lemon-pale); border-radius: 999px; padding: 6px 10px;
  flex-shrink: 0;
}
.ticket {
  display: flex; align-items: center; gap: 12px;
  background:
    radial-gradient(circle at 0 50%, transparent 9px, #fff 10px),
    radial-gradient(circle at 100% 50%, transparent 9px, #fff 10px);
  background-color: #fff;
  border: 2px dashed var(--pink);
  border-radius: 16px; padding: 14px 16px; margin-bottom: 10px;
  box-shadow: var(--shadow);
}
.ticket.used { border-color: #ddc9d6; opacity: .6; }
.ticket-left { flex: 1; min-width: 0; }
.ticket-amount { font-size: 1.35rem; font-weight: 900; color: var(--pink-deep); }
.ticket.used .ticket-amount { color: var(--ink-soft); }
.ticket-title { font-size: .8rem; font-weight: 900; margin-top: 2px; }
.ticket-code { font-size: .65rem; color: var(--ink-soft); font-weight: 700; margin-top: 2px; letter-spacing: .05em; }
.ticket-stamp {
  font-size: .7rem; font-weight: 900; color: var(--pink-deep);
  border: 2px solid var(--pink); border-radius: 999px; padding: 6px 10px;
  transform: rotate(-8deg); flex-shrink: 0;
}

.guide-link {
  display: inline-block; margin-top: 10px;
  font-size: .75rem; font-weight: 900; color: var(--ink-soft);
  text-decoration: none; background: #fff; border-radius: 999px;
  padding: 8px 16px; box-shadow: var(--shadow);
}

@media (max-width: 360px) {
  html { font-size: 14.5px; }
}
