:root {
  --ink: #1f2a44;
  --paper: #fffdf5;
  --bg: #fff3d6;
  --sky: #8fd3ff;
  --pitch: #3fbf6b;
  --pitch-dark: #2fa457;
  --sun: #ffd43b;
  --keep: #1fa055;
  --problem: #3b7cf0;
  --try: #f2671d;
  --muted: #66708a;
  --accent: var(--sun);
  --on-accent: var(--ink);
  --radius: 20px;
  --display: "Mochiy Pop One", "Hiragino Maru Gothic ProN", sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background-color: var(--bg);
  background-image: radial-gradient(rgba(31, 42, 68, .07) 1.5px, transparent 1.5px);
  background-size: 18px 18px;
  color: var(--ink);
  font-family: "Zen Maru Gothic", "Hiragino Maru Gothic ProN", "BIZ UDPGothic", "Yu Gothic", system-ui, sans-serif;
  font-weight: 700;
  font-size: 17px;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
  word-break: keep-all; /* わかちがきの スペースで おりかえす */
  overflow-wrap: anywhere;
}

#app {
  max-width: 520px;
  margin: 0 auto;
  padding: 16px 16px calc(28px + env(safe-area-inset-bottom));
  min-height: 100dvh;
}

h1, h2, h3, p { margin: 0; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
svg { display: block; }

/* ---------- parts ---------- */
.card {
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: 0 5px 0 var(--ink);
  padding: 14px 16px;
  margin: 18px 0;
}
.card > h2 {
  font-family: var(--display);
  font-weight: 400;
  font-size: 1rem;
  margin-bottom: 8px;
}

.btn {
  border: 3px solid var(--ink);
  background: var(--paper);
  border-radius: 999px;
  padding: 10px 20px;
  min-height: 54px;
  box-shadow: 0 4px 0 var(--ink);
  transition: transform .08s, box-shadow .08s;
}
.btn:active { transform: translateY(4px); box-shadow: 0 0 0 var(--ink); }
.btn.primary { background: var(--accent); color: var(--on-accent); }
.btn.big {
  width: 100%;
  min-height: 74px;
  font-family: var(--display);
  font-weight: 400;
  font-size: 1.35rem;
  box-shadow: 0 6px 0 var(--ink);
}
.btn.big:active { transform: translateY(6px); }
.btn:disabled { opacity: .45; }

.items { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.items li {
  background: #f1ecdc;
  border-radius: 999px;
  padding: 3px 12px;
  font-size: .95rem;
}
.items li.win { background: #ffe680; }
.empty { color: var(--muted); font-size: .9rem; font-weight: 500; }

.bar {
  height: 18px;
  border: 3px solid var(--ink);
  border-radius: 999px;
  background: #fff;
  overflow: hidden;
}
.bar i {
  display: block;
  height: 100%;
  width: 0;
  background: repeating-linear-gradient(-45deg, #ffb703 0 10px, #ffd43b 10px 20px);
  border-right: 3px solid var(--ink);
  transition: width .9s cubic-bezier(.2, .8, .2, 1);
}
.bar i[style*="width: 0"], .bar i[style*="width:0"] { border-right: 0; }

/* ---------- home ---------- */
.hero {
  position: relative;
  border: 3px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: 0 5px 0 var(--ink);
  overflow: hidden;
  height: 168px;
  background: var(--sky);
}
.hero .bgart { position: absolute; inset: 0; width: 100%; height: 100%; }
.hero .title {
  position: absolute;
  left: 16px;
  top: 16px;
  font-family: var(--display);
  color: #fff;
  -webkit-text-stroke: 6px var(--ink);
  paint-order: stroke fill;
  line-height: 1.15;
}
.hero h1 { font-size: 1.9rem; font-weight: 400; letter-spacing: .02em; }
.hero p { font-size: .8rem; -webkit-text-stroke-width: 4px; }
.hero .kid { position: absolute; right: 22px; bottom: 6px; width: 84px; }
.hero .heroball { position: absolute; right: 108px; bottom: 10px; width: 34px; animation: bounce 1.1s ease-in-out infinite alternate; }
@keyframes bounce {
  from { transform: translateY(0) rotate(0); }
  to { transform: translateY(-26px) rotate(140deg); }
}

.player { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; align-items: center; }
.player .lvbadge {
  grid-row: span 3;
  width: 74px;
  height: 74px;
  border-radius: 50%;
  border: 3px solid var(--ink);
  background: var(--sun);
  display: grid;
  place-content: center;
  text-align: center;
  font-family: var(--display);
  font-weight: 400;
  line-height: 1;
  box-shadow: inset 0 -6px 0 rgba(0, 0, 0, .12);
}
.player .lvbadge small { font-size: .7rem; }
.player .lvbadge b { font-size: 1.9rem; font-weight: 400; }
.player .rank { font-family: var(--display); font-weight: 400; font-size: 1.15rem; }
.player .rest { font-size: .8rem; color: var(--muted); }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 18px 0; }
.stats div {
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: 16px;
  box-shadow: 0 4px 0 var(--ink);
  padding: 8px;
  text-align: center;
}
.stats b { display: block; font-family: var(--display); font-weight: 400; font-size: 1.7rem; line-height: 1.2; }
.stats span { font-size: .8rem; color: var(--muted); }

.card.next { background: #fff0e0; }
.card.next > h2 { color: #c2470a; }
.balls { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.balls li { display: flex; align-items: center; gap: 10px; font-size: 1.05rem; }
.balls svg { width: 30px; flex: none; }

.section-title {
  font-family: var(--display);
  font-weight: 400;
  font-size: 1.05rem;
  margin: 28px 0 10px;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 8px;
}
.section-title small { font-family: "Zen Maru Gothic", sans-serif; font-weight: 500; font-size: .75rem; color: var(--muted); }

.skills { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.skill {
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: 14px;
  padding: 8px 4px 6px;
  text-align: center;
  font-size: .72rem;
  line-height: 1.25;
}
.skill .ico { font-size: 1.7rem; line-height: 1.2; }
.skill .stars { letter-spacing: 1px; font-size: .8rem; color: #d9d2bd; }
.skill .stars b { color: #ffab00; font-weight: 400; }
.skill.zero { border-style: dashed; border-color: #b9b29b; color: var(--muted); background: transparent; }
.skill.zero .ico { filter: grayscale(1); opacity: .55; }

.badges { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px 6px; }
.medal { border: 0; background: none; padding: 0; text-align: center; font-size: .62rem; line-height: 1.2; }
.medal i {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  margin: 0 auto 4px;
  border-radius: 50%;
  border: 3px solid var(--ink);
  background: radial-gradient(circle at 35% 30%, #fff3b0, #ffc928 60%, #f29f05);
  font-style: normal;
  font-size: 1.5rem;
  box-shadow: 0 3px 0 var(--ink);
}
.medal.locked { color: var(--muted); }
.medal.locked i {
  background: #e9e3d0;
  border-color: #b9b29b;
  box-shadow: none;
  color: #b9b29b;
  font-family: var(--display);
}
.medal.new i { animation: medal .7s cubic-bezier(.2, 1.7, .4, 1) both; }
@keyframes medal {
  from { transform: scale(0) rotate(-180deg); }
}

.history details {
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: 14px;
  margin-bottom: 8px;
  padding: 0 14px;
}
.history summary { padding: 11px 0; cursor: pointer; display: flex; gap: 8px; align-items: center; }
.history summary small { margin-left: auto; color: var(--muted); font-weight: 500; }
.history h3 { font-size: .8rem; margin: 8px 0 4px; }
.history h3.k { color: var(--keep); }
.history h3.p { color: var(--problem); }
.history h3.t { color: var(--try); }
.link {
  border: 0;
  background: none;
  color: var(--muted);
  text-decoration: underline;
  font-size: .8rem;
  font-weight: 500;
  padding: 12px 0;
}

/* ---------- steps ---------- */
.step.keep { --accent: var(--keep); --on-accent: #fff; --tint: #dcf5e4; }
.step.problem { --accent: var(--problem); --on-accent: #fff; --tint: #dfeaff; }
.step.try { --accent: var(--try); --on-accent: #fff; --tint: #ffe6d3; }

.topbar { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.dots { display: flex; gap: 5px; flex: 1; }
.dots i { height: 12px; flex: 1; border: 2.5px solid var(--ink); border-radius: 6px; background: #fff; }
.dots i.on { background: var(--sun); }
.power {
  font-family: var(--display);
  font-size: .9rem;
  background: var(--ink);
  color: var(--sun);
  border-radius: 999px;
  padding: 3px 12px;
  animation: bump .3s;
}
@keyframes bump { 40% { transform: scale(1.25); } }
.close { border: 0; background: none; font-size: 1.2rem; width: 40px; height: 40px; color: var(--muted); }

.step h2 {
  font-family: var(--display);
  font-weight: 400;
  font-size: 1.45rem;
  display: flex;
  align-items: center;
  gap: 10px;
}
.kpt {
  display: inline-grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 14px;
  border: 3px solid var(--ink);
  box-shadow: 0 3px 0 var(--ink);
  background: var(--accent);
  color: var(--on-accent);
  font-size: 1.4rem;
  transform: rotate(-6deg);
  flex: none;
}
.lead { color: var(--muted); margin: 6px 0 14px; font-weight: 500; }
.group { font-size: .85rem; color: var(--muted); margin: 16px 0 8px; }

.chips { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.chip {
  position: relative;
  border: 3px solid var(--ink);
  background: var(--paper);
  border-radius: 16px;
  box-shadow: 0 4px 0 var(--ink);
  padding: 8px;
  min-height: 62px;
  display: flex;
  align-items: center;
  gap: 6px;
  text-align: left;
  font-size: .94rem;
  line-height: 1.25;
  transition: transform .08s, box-shadow .08s;
}
.chip:active { transform: translateY(4px); box-shadow: 0 0 0 var(--ink); }
.chip .ico {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: #f1ecdc;
  flex: none;
}
.chip.on { background: var(--tint); transform: translateY(2px); box-shadow: 0 2px 0 var(--ink); }
.chip.on .ico { background: #fff; }
.chip.on::after {
  content: "✓";
  position: absolute;
  top: -10px;
  right: -8px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 3px solid var(--ink);
  background: var(--accent);
  color: var(--on-accent);
  font-size: .8rem;
  line-height: 20px;
  text-align: center;
}
.chip.pop { animation: chip .3s cubic-bezier(.2, 1.8, .4, 1); }
@keyframes chip { from { transform: scale(.88); } }

.add { display: flex; gap: 8px; margin-top: 16px; }
.add input {
  flex: 1;
  min-width: 0;
  border: 3px solid var(--ink);
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 16px;
  background: #fff;
}
.add input:focus { outline: 3px solid var(--accent); outline-offset: 2px; }
.add .btn { padding: 0 18px; font-size: 1.3rem; }

.nav {
  position: sticky;
  bottom: 0;
  display: flex;
  gap: 10px;
  padding: 16px 0 calc(10px + env(safe-area-inset-bottom));
  margin-top: 16px;
  background: linear-gradient(to top, var(--bg) 72%, transparent);
}
.nav .primary { flex: 1; font-family: var(--display); font-weight: 400; font-size: 1.1rem; }

.kinds { display: grid; gap: 16px; margin-top: 20px; }
.kinds .btn {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 104px;
  border-radius: 24px;
  font-family: var(--display);
  font-weight: 400;
  font-size: 1.4rem;
  text-align: left;
  box-shadow: 0 6px 0 var(--ink);
}
.kinds .btn.match { background: #d8f3ff; }
.kinds .btn.practice { background: #e2f8e6; }

/* ---------- shoot scene ---------- */
.trycard {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: #fff;
  border: 3px solid var(--ink);
  border-radius: 16px;
  box-shadow: 0 4px 0 var(--ink);
  padding: 10px 16px;
  font-size: 1.25rem;
  margin-bottom: 14px;
}
.scene {
  position: relative;
  height: 310px;
  border: 3px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: 0 5px 0 var(--ink);
  overflow: hidden;
  background: repeating-linear-gradient(to bottom, var(--pitch) 0 36px, var(--pitch-dark) 36px 72px);
  user-select: none;
  -webkit-user-select: none;
}
.stand {
  position: absolute;
  inset: 0 0 auto;
  height: 58px;
  background:
    radial-gradient(circle, #ffd43b 3.5px, transparent 4.5px) 0 2px / 18px 16px,
    radial-gradient(circle, #ff8fb1 3.5px, transparent 4.5px) 9px 10px / 18px 16px,
    radial-gradient(circle, #9ad8ff 3.5px, transparent 4.5px) 4px 6px / 18px 16px,
    #2b3a67;
  border-bottom: 5px solid #f4f4f4;
}
.box { /* penalty area */
  position: absolute;
  left: 6%;
  right: 6%;
  top: 150px;
  height: 84px;
  border: 4px solid rgba(255, 255, 255, .7);
  border-top: 0;
  pointer-events: none;
}
.goal {
  position: absolute;
  top: 38px;
  left: 12%;
  width: 76%;
  height: 114px;
  border: 8px solid #fff;
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, .55) 0 1.5px, transparent 1.5px 13px),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, .55) 0 1.5px, transparent 1.5px 13px),
    rgba(15, 30, 60, .45);
  filter: drop-shadow(0 3px 0 rgba(0, 0, 0, .25));
  cursor: pointer;
}
.goal.shake { animation: net .5s; }
.goal.clang { animation: clang .35s; }
@keyframes net {
  30% { transform: scale(1.04, 1.08) translateY(-4px); }
  60% { transform: scale(.99, .98); }
}
@keyframes clang {
  25% { transform: translateX(-5px); }
  50% { transform: translateX(5px); }
  75% { transform: translateX(-2px); }
}
.keeper {
  position: absolute;
  top: 78px;
  left: 50%;
  width: 66px;
  margin-left: -33px;
  animation: sway 1.5s ease-in-out infinite alternate;
  pointer-events: none;
}
.keeper.stop { animation: none; }
@keyframes sway {
  from { transform: translateX(-36px); }
  to { transform: translateX(36px); }
}
.ball {
  position: absolute;
  bottom: 16px;
  left: 50%;
  width: 58px;
  margin-left: -29px;
  pointer-events: none;
  z-index: 2;
  filter: drop-shadow(0 5px 0 rgba(0, 0, 0, .22));
}
.goal { padding: 0; color: inherit; font: inherit; }
.tag {
  position: absolute;
  top: 5px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--display);
  font-size: 1.1rem;
  line-height: 1.5;
  white-space: nowrap;
  background: var(--sun);
  border: 3px solid var(--ink);
  border-radius: 999px;
  padding: 0 14px;
  box-shadow: 0 3px 0 var(--ink);
  animation: tag .8s ease-in-out infinite alternate;
}
@keyframes tag { to { transform: translateX(-50%) scale(1.1); } }
.spot {
  position: absolute;
  bottom: 14px;
  width: 31%;
  min-height: 54px;
  padding: 4px 6px;
  border: 3px solid var(--ink);
  border-radius: 16px;
  background: var(--paper);
  box-shadow: 0 4px 0 var(--ink);
  font-size: .85rem;
  line-height: 1.2;
  z-index: 2;
}
.spot:active { transform: translateY(4px); box-shadow: none; }
.spot.left { left: 10px; }
.spot.right { right: 10px; }
.scene.answered .tag, .scene.answered .spot { opacity: 0; pointer-events: none; transition: opacity .15s; }
.scene.answered .goal { cursor: default; }

.shout {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  padding-bottom: 26px; /* ゴールの したに だして、ボールを かくさない */
  opacity: 0;
  pointer-events: none;
  z-index: 3;
}
.shout b {
  font-family: var(--display);
  font-weight: 400;
  font-size: 3.2rem;
  line-height: 1.2;
  color: #fff;
  -webkit-text-stroke: 9px var(--ink);
  paint-order: stroke fill;
  transform: rotate(-4deg);
}
.shout.win b { color: var(--sun); }
.shout.show { animation: pop .45s cubic-bezier(.2, 1.6, .4, 1) forwards; }
@keyframes pop {
  from { opacity: 0; transform: scale(.3); }
  to { opacity: 1; transform: scale(1); }
}
.gain {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-family: var(--display);
  font-size: .95rem;
  background: var(--ink);
  color: var(--sun);
  border-radius: 999px;
  padding: 2px 14px;
}

/* ---------- done ---------- */
.done { text-align: center; }
.done .kid { width: 110px; margin: 4px auto 0; animation: jump .5s ease-in-out infinite alternate; }
@keyframes jump { to { transform: translateY(-12px); } }
.done > h2 { justify-content: center; }
.done .card { text-align: left; }
.gainbox { text-align: center !important; background: #fff9db; }
.gainbox .num { font-family: var(--display); font-size: 2.4rem; line-height: 1.2; }
.gainbox .label { font-size: .8rem; color: var(--muted); }
.gainbox .rank { font-family: var(--display); margin: 8px 0 6px; }
.levelup {
  display: inline-block;
  font-family: var(--display);
  font-size: 1.3rem;
  color: #fff;
  background: var(--try);
  border: 3px solid var(--ink);
  border-radius: 999px;
  padding: 2px 18px;
  margin-top: 12px;
  transform: rotate(-3deg);
  animation: medal .7s 1s cubic-bezier(.2, 1.7, .4, 1) both;
}
.done .card.k > h2 { color: var(--keep); }
.done .card.p > h2 { color: var(--problem); }
.done .badges { grid-template-columns: repeat(auto-fit, 72px); justify-content: center; }

/* ---------- misc ---------- */
#toast {
  position: fixed;
  left: 50%;
  bottom: calc(100px + env(safe-area-inset-bottom));
  transform: translate(-50%, 20px);
  background: var(--ink);
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: .9rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 20;
  max-width: 90vw;
  text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 30; }

@media (prefers-reduced-motion: reduce) {
  .keeper, .hero .heroball, .done .kid { animation: none; }
}

/* ---------- icons ---------- */
.ic { display: inline-block; width: 1.35em; height: 1.35em; vertical-align: -.32em; flex: none; }
.items li { display: inline-flex; align-items: center; gap: 4px; }
.items li small { font-size: .7rem; color: var(--muted); margin-left: 4px; }
.items li.win small { color: #8a5a00; }
.chip .ico .ic { width: 32px; height: 32px; }
.skill .ico .ic { width: 38px; height: 38px; }
.medal i .ic { width: 32px; height: 32px; }
.kinds .btn .ic { width: 60px; height: 60px; }
.trycard .ic { width: 34px; height: 34px; }
.power { display: inline-flex; align-items: center; gap: 2px; }
.gainbox .num .ic { width: .9em; height: .9em; vertical-align: -.1em; }
.history summary .ic { margin-right: -4px; }
.balls li svg { width: 30px; height: 30px; }

/* ---------- uniform ---------- */
.kit {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 2px dashed #d9d2bd;
}
.kit span { font-size: .8rem; color: var(--muted); width: 100%; }
.swatch {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 3px solid var(--ink);
  border-radius: 50%;
  background: var(--c);
  flex: none;
}
.swatch.on { box-shadow: 0 0 0 3px var(--paper), 0 0 0 6px var(--ink); }
.swatch.locked { background: #e9e3d0; border-color: #b9b29b; color: #8f8873; }
.swatch small { font-size: .55rem; font-family: var(--display); }
.rewards { list-style: none; margin: 14px 0 4px; padding: 0; display: grid; gap: 6px; justify-content: center; }
.rewards li { display: flex; align-items: center; gap: 8px; font-family: var(--display); }
.rewards .swatch { width: 26px; height: 26px; }
