:root {
  --bg: #fff7fb;
  --panel: #ffffff;
  --ink: #342640;
  --muted: #796b84;
  --line: #eadcf1;
  --pink: #e95f9c;
  --pink-dark: #bd3977;
  --pink-soft: #fff0f7;
  --violet: #7654c7;
  --violet-soft: #f1ebff;
  --mint: #38aa91;
  --mint-soft: #e7faf4;
  --yellow: #fff3bd;
  --red: #c83e62;
  --shadow: 0 14px 36px rgba(105, 62, 116, .11);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic UI", "Noto Sans JP", sans-serif;
  color: var(--ink);
  background: var(--bg);
}

* { box-sizing: border-box; }

html { min-height: 100%; }

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 8% 0%, rgba(240, 135, 181, .22), transparent 24rem),
    radial-gradient(circle at 96% 18%, rgba(125, 222, 198, .22), transparent 22rem),
    linear-gradient(180deg, #fffafd, var(--bg));
}

button { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible { outline: 3px solid rgba(118, 84, 199, .35); outline-offset: 2px; }

.app-shell { width: min(760px, 100%); margin: 0 auto; padding: 10px 12px 30px; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: max(6px, env(safe-area-inset-top)) 0 10px;
}

.brand {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 7px;
  padding: 0;
  border: 0;
  color: inherit;
  text-align: left;
  background: transparent;
  cursor: pointer;
}

.brand img { width: 48px; height: 48px; border-radius: 50%; object-fit: cover; }
.brand span { display: grid; gap: 1px; }
.brand strong { font-size: 1rem; line-height: 1.2; }
.brand small { color: var(--muted); font-size: .68rem; white-space: nowrap; }

.privacy-pill {
  flex: 0 0 auto;
  max-width: 102px;
  padding: 6px 8px;
  border: 1px solid #bde8dc;
  border-radius: 999px;
  color: #267d69;
  background: var(--mint-soft);
  font-size: .66rem;
  font-weight: 800;
  text-align: center;
}

main { min-height: 65vh; }

.hero, .card {
  border: 1px solid rgba(230, 208, 239, .9);
  border-radius: 24px;
  background: rgba(255, 255, 255, .95);
  box-shadow: var(--shadow);
}

.hero {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: 1fr 110px;
  align-items: center;
  min-height: 180px;
  padding: 22px 16px 20px 20px;
  background: linear-gradient(135deg, #fff 15%, #fff0f7 68%, #eee8ff);
}

.hero::after {
  content: "";
  position: absolute;
  inset: auto -55px -70px auto;
  width: 170px;
  height: 170px;
  border-radius: 50%;
  background: rgba(100, 211, 182, .2);
}

.hero h1 { margin: 5px 0 7px; font-size: clamp(1.55rem, 7vw, 2.3rem); line-height: 1.18; }
.hero p { margin: 0; color: var(--muted); font-size: .9rem; line-height: 1.65; }
.hero img { position: relative; z-index: 1; width: 116px; height: 116px; object-fit: contain; }
.eyebrow { margin: 0; color: var(--pink-dark); font-size: .73rem; font-weight: 900; letter-spacing: .08em; }

.progress-card { margin-top: 12px; padding: 16px; }
.progress-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.progress-head strong { font-size: .95rem; }
.progress-head span { color: var(--violet); font-size: .8rem; font-weight: 900; }
.progress-track { height: 12px; margin-top: 9px; overflow: hidden; border-radius: 99px; background: #f0e8f4; }
.progress-track span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--pink), var(--violet), var(--mint)); transition: width .25s ease; }

.achievement-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 7px; margin-top: 12px; }
.achievement-chip { padding: 8px; border-radius: 12px; background: var(--pink-soft); font-size: .7rem; font-weight: 800; }
.achievement-chip:nth-child(2) { background: var(--violet-soft); }
.achievement-chip:nth-child(3), .achievement-chip:nth-child(4) { background: var(--mint-soft); }
.achievement-chip b { display: block; margin-top: 2px; font-size: 1rem; }

.section-title { margin: 22px 3px 10px; font-size: 1.05rem; }
.day-list { display: grid; gap: 9px; }
.day-card {
  width: 100%;
  min-height: 76px;
  display: grid;
  grid-template-columns: 52px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 18px;
  color: inherit;
  text-align: left;
  background: var(--panel);
  box-shadow: 0 5px 16px rgba(91, 55, 104, .06);
}
.day-card:not(:disabled) { cursor: pointer; }
.day-card.current { border: 2px solid #eaa0c3; background: linear-gradient(100deg, #fff, #fff1f7); }
.day-card.done { border-color: #bde8dc; background: linear-gradient(100deg, #fff, var(--mint-soft)); }
.day-card:disabled { opacity: .56; box-shadow: none; }
.day-number { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 15px; color: #fff; background: linear-gradient(135deg, var(--pink), var(--violet)); font-size: .73rem; font-weight: 900; }
.day-copy { min-width: 0; }
.day-copy strong { display: block; font-size: .94rem; }
.day-copy small { display: block; margin-top: 3px; color: var(--muted); font-size: .72rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.day-status { color: var(--violet); font-size: .72rem; font-weight: 900; }

.lesson-head { margin-bottom: 10px; padding: 13px 4px 4px; }
.back-button, .text-button {
  min-height: 44px;
  border: 0;
  color: var(--violet);
  background: transparent;
  font-weight: 800;
  cursor: pointer;
}
.lesson-head h1 { margin: 6px 0 3px; font-size: 1.35rem; }
.lesson-head p { margin: 0; color: var(--muted); font-size: .82rem; }

.step-strip { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; margin: 12px 0; }
.step-dot { min-height: 43px; display: grid; place-items: center; padding: 4px 2px; border-radius: 11px; color: #8a7d94; background: #f2edf5; font-size: .59rem; font-weight: 800; text-align: center; }
.step-dot.active { color: #fff; background: linear-gradient(135deg, var(--pink), var(--violet)); }
.step-dot.done { color: #267d69; background: var(--mint-soft); }

.question-card { padding: 17px; }
.question-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.phase-badge { display: inline-flex; align-items: center; min-height: 28px; padding: 5px 9px; border-radius: 999px; color: var(--violet); background: var(--violet-soft); font-size: .7rem; font-weight: 900; }
.question-count { color: var(--muted); font-size: .72rem; font-weight: 800; }
.phase-help { margin: 9px 0 0; color: var(--muted); font-size: .75rem; }
.prompt { margin: 19px 0; font-size: clamp(1.15rem, 5vw, 1.5rem); line-height: 1.65; font-weight: 900; }

.answer-display {
  width: 100%;
  min-height: 58px;
  padding: 12px 14px;
  border: 2px solid #decbea;
  border-radius: 15px;
  color: var(--ink);
  background: #fffafd;
  font: 800 1.2rem/1.4 ui-monospace, SFMono-Regular, Menlo, monospace;
  text-align: right;
}
.answer-display::placeholder { color: #b6aabd; font: 700 .8rem/1.4 -apple-system, BlinkMacSystemFont, sans-serif; }

.keypad { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; margin-top: 10px; }
.key {
  min-height: 48px;
  padding: 7px 3px;
  border: 1px solid #e2d4e8;
  border-radius: 13px;
  color: var(--ink);
  background: #fff;
  box-shadow: 0 2px 0 #e8ddec;
  font-size: 1.05rem;
  font-weight: 900;
  cursor: pointer;
}
.key.symbol { color: var(--violet); background: var(--violet-soft); }
.key.action { color: var(--pink-dark); background: var(--pink-soft); font-size: .72rem; }

.hint-area { margin-top: 12px; }
.hint-button { width: 100%; min-height: 46px; border: 1px solid #e9c9d8; border-radius: 14px; color: var(--pink-dark); background: var(--pink-soft); font-weight: 900; cursor: pointer; }
.hint-list { display: grid; gap: 7px; margin: 9px 0 0; padding: 0; list-style: none; }
.hint-list li { padding: 10px 12px; border-radius: 12px; background: #fff7d7; font-size: .8rem; line-height: 1.55; }
.hint-list b { color: #8a6400; }

.primary-button {
  width: 100%;
  min-height: 52px;
  margin-top: 12px;
  border: 0;
  border-radius: 15px;
  color: #fff;
  background: linear-gradient(135deg, var(--pink), var(--violet));
  box-shadow: 0 8px 18px rgba(158, 69, 139, .22);
  font-weight: 900;
  cursor: pointer;
}
.primary-button:disabled { opacity: .45; box-shadow: none; cursor: default; }
.secondary-button { background: linear-gradient(135deg, var(--mint), #3d8eb4); }

.feedback { margin-top: 13px; padding: 14px; border-radius: 15px; font-size: .84rem; line-height: 1.65; }
.feedback.correct { border: 1px solid #a9dfd1; background: var(--mint-soft); }
.feedback.wrong { border: 1px solid #f1bed0; background: var(--pink-soft); }
.feedback strong { display: block; margin-bottom: 4px; font-size: .98rem; }
.feedback .answer { margin-top: 7px; font-weight: 900; }

.example-card { padding: 22px 18px; text-align: center; background: linear-gradient(145deg, #fff, #f4edff); }
.example-character { width: 108px; height: 108px; object-fit: contain; }
.example-card h1 { margin: 4px 0 7px; font-size: 1.35rem; }
.example-problem { margin: 15px 0; padding: 14px; border-radius: 15px; background: #fff; font-size: 1.08rem; font-weight: 900; }
.example-steps { margin: 0; padding: 0; list-style: none; counter-reset: steps; text-align: left; }
.example-steps li { position: relative; margin-top: 8px; padding: 11px 10px 11px 42px; border-radius: 13px; background: var(--pink-soft); font-size: .83rem; line-height: 1.5; }
.example-steps li::before { counter-increment: steps; content: counter(steps); position: absolute; left: 11px; top: 10px; display: grid; place-items: center; width: 23px; height: 23px; border-radius: 50%; color: #fff; background: var(--pink); font-weight: 900; }
.example-answer { margin: 11px 0 0; color: var(--violet); font-weight: 900; }

.day-finish { padding: 22px 18px; text-align: center; }
.day-finish img, .complete-hero img { width: 150px; height: 150px; object-fit: contain; }
.day-finish h1, .complete-hero h1 { margin: 4px 0 8px; font-size: 1.45rem; }
.day-finish p, .complete-hero p { margin: 0; color: var(--muted); line-height: 1.7; }
.review-note { margin-top: 13px !important; padding: 10px; border-radius: 12px; background: var(--yellow); color: #705716 !important; font-size: .78rem; }

.complete-hero { padding: 20px; text-align: center; background: linear-gradient(145deg, #fff, #fff0f7 50%, #e9faf5); }
.complete-actions { display: grid; gap: 8px; margin-top: 15px; }

.explanation-list { display: grid; gap: 9px; }
.explanation-item { border: 1px solid var(--line); border-radius: 15px; background: #fff; overflow: hidden; }
.explanation-item summary { min-height: 54px; display: flex; align-items: center; gap: 8px; padding: 10px 12px; cursor: pointer; font-size: .82rem; font-weight: 800; }
.explanation-item summary::marker { color: var(--pink); }
.explanation-body { padding: 0 13px 13px; color: var(--muted); font-size: .8rem; line-height: 1.65; }
.explanation-body b { color: var(--violet); }
.tiny-achievement { margin-left: auto; flex: 0 0 auto; padding: 4px 7px; border-radius: 99px; color: #267d69; background: var(--mint-soft); font-size: .6rem; }

footer { padding: 24px 8px 0; text-align: center; color: var(--muted); font-size: .68rem; line-height: 1.6; }
footer p { margin: 0 auto; max-width: 520px; }
footer .text-button { margin-top: 3px; color: #9b7ca7; font-size: .68rem; }

@media (min-width: 640px) {
  .app-shell { padding: 16px 20px 40px; }
  .hero { grid-template-columns: 1fr 180px; padding: 28px 30px; }
  .hero img { width: 170px; height: 170px; }
  .achievement-grid { grid-template-columns: repeat(4, 1fr); }
  .keypad { grid-template-columns: repeat(6, 1fr); }
  .question-card { padding: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
