@import url('https://fonts.googleapis.com/css2?family=M+PLUS+Rounded+1c:wght@400;700;800&display=swap');

:root {
  --bg: #eef6ff;
  --bg2: #fff8f0;
  --card: #ffffff;
  --border: rgba(15, 23, 42, 0.08);
  --text: #1e293b;
  --muted: #64748b;
  --accent: #3b82f6;
  --accent2: #8b5cf6;
  --accent-soft: #dbeafe;
  --good: #10b981;
  --good-bg: #d1fae5;
  --bad: #ef4444;
  --bad-bg: #fee2e2;
  --warn: #f59e0b;
  --shadow: 0 8px 32px rgba(59, 130, 246, 0.12);
  --radius: 20px;
  font-family: 'M PLUS Rounded 1c', -apple-system, BlinkMacSystemFont, 'Hiragino Sans', sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  min-height: 100dvh;
  background:
    radial-gradient(ellipse at 10% 0%, rgba(147, 197, 253, 0.5), transparent 50%),
    radial-gradient(ellipse at 90% 20%, rgba(253, 186, 116, 0.35), transparent 45%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg2) 100%);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

#app {
  max-width: 440px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: 0.75rem 1rem 2rem;
  display: flex;
  flex-direction: column;
}

.screen { display: none; flex: 1; flex-direction: column; gap: 0.85rem; }
.screen.active { display: flex; animation: fadeIn 0.35s ease; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.brand {
  text-align: center;
  padding: 0.75rem 0 0.25rem;
}
.brand .logo {
  font-size: 2.75rem;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.08));
  animation: bob 2.5s ease-in-out infinite;
}
@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}
.brand h1 {
  font-size: 1.65rem;
  font-weight: 800;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.brand .sub { color: var(--muted); font-size: 0.92rem; margin-top: 0.2rem; }

.hero-strip {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  background: linear-gradient(135deg, #fff, #eff6ff);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.hero-mascot { font-size: 2.2rem; }
.hero-text { flex: 1; font-size: 0.88rem; color: var(--muted); line-height: 1.45; }
.hero-text strong { color: var(--text); font-size: 1rem; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
}

label {
  display: block;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

input, select {
  width: 100%;
  background: #f8fafc;
  border: 2px solid #e2e8f0;
  color: var(--text);
  border-radius: 14px;
  padding: 0.75rem 0.9rem;
  font-size: 1rem;
  font-family: inherit;
  margin-bottom: 0.85rem;
  outline: none;
}
input:focus, select:focus { border-color: var(--accent); background: #fff; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  width: 100%;
  border: none;
  border-radius: 16px;
  padding: 0.95rem 1rem;
  font-size: 1.05rem;
  font-weight: 800;
  font-family: inherit;
  cursor: pointer;
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  color: #fff;
  box-shadow: 0 4px 14px rgba(59, 130, 246, 0.35);
  transition: transform 0.15s, box-shadow 0.15s;
}
.btn:active { transform: scale(0.98); }
.btn.secondary {
  background: #fff;
  border: 2px solid #e2e8f0;
  color: var(--text);
  box-shadow: none;
  margin-top: 0.55rem;
}
.btn.ghost {
  background: transparent;
  color: var(--accent);
  box-shadow: none;
  font-weight: 700;
  margin-top: 0.35rem;
}
.btn-play::before { content: '🚀 '; }

.msg { font-size: 0.85rem; color: var(--bad); min-height: 1.2em; margin-top: 0.5rem; }
.msg.ok { color: var(--good); }

/* ── 山登り進捗 ── */
.mountain-wrap { margin: 0.25rem 0; }

.mountain-scene {
  position: relative;
  height: 168px;
  border-radius: 18px;
  overflow: hidden;
  background: linear-gradient(180deg, #bae6fd 0%, #e0f2fe 45%, #fef3c7 100%);
  border: 2px solid rgba(255,255,255,0.8);
}

.mountain-sky { position: absolute; inset: 0; pointer-events: none; }
.mountain-sky .sun {
  position: absolute; top: 8px; right: 12px; font-size: 1.5rem;
  animation: pulse 3s ease infinite;
}
.mountain-sky .cloud {
  position: absolute; font-size: 1.1rem; opacity: 0.85;
  animation: drift 8s ease-in-out infinite;
}
.mountain-sky .c1 { top: 12px; left: 8%; }
.mountain-sky .c2 { top: 28px; left: 55%; animation-delay: -3s; font-size: 0.95rem; }
@keyframes drift {
  0%, 100% { transform: translateX(0); }
  50% { transform: translateX(12px); }
}
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

.mountain-body {
  position: absolute;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: 78%;
  height: 88%;
}

.mountain-shape {
  position: absolute;
  inset: 0;
  background: linear-gradient(160deg, #86efac 0%, #4ade80 35%, #78716c 70%, #fafafa 100%);
  clip-path: polygon(50% 0%, 100% 100%, 0% 100%);
  opacity: 0.92;
}

.mountain-trail {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 4px;
  height: 92%;
  transform: translateX(-50%);
  background: repeating-linear-gradient(
    180deg,
    #fef08a 0px,
    #fef08a 8px,
    #fbbf24 8px,
    #fbbf24 16px
  );
  border-radius: 4px;
  opacity: 0.85;
}

.mountain-flags { position: absolute; inset: 0; pointer-events: none; }
.mountain-flag {
  position: absolute;
  left: 50%;
  transform: translate(-50%, 50%);
  font-size: 0.85rem;
  opacity: 0.35;
  filter: grayscale(0.6);
  transition: all 0.3s;
}
.mountain-flag.reached {
  opacity: 1;
  filter: none;
  transform: translate(-50%, 50%) scale(1.15);
}

.mountain-climber {
  position: absolute;
  left: 50%;
  transform: translate(-50%, 0);
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: bottom 0.6s cubic-bezier(0.34, 1.2, 0.64, 1);
  z-index: 2;
}
.climber-emoji { font-size: 1.6rem; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2)); }
.climber-pack { font-size: 0.75rem; margin-top: -4px; }

.mountain-footer {
  position: absolute;
  bottom: 6px;
  left: 8px;
  right: 8px;
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  font-weight: 800;
  color: #334155;
  background: rgba(255,255,255,0.75);
  backdrop-filter: blur(4px);
  padding: 0.25rem 0.5rem;
  border-radius: 8px;
}
.mountain-caption {
  text-align: center;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--muted);
  margin-top: 0.35rem;
}

.mountain-mini .mountain-scene { height: 72px; border-radius: 12px; }
.mountain-mini .mountain-climber .climber-emoji { font-size: 1.1rem; }
.mountain-mini .mountain-flag { font-size: 0.65rem; }
.mountain-mini .mountain-footer { display: none; }

/* ── キャラパネル ── */
.partner-panel {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  background: linear-gradient(135deg, #fff, color-mix(in srgb, var(--partner-color, #3b82f6) 8%, white));
  border: 2px solid color-mix(in srgb, var(--partner-color, #3b82f6) 25%, transparent);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.partner-avatar {
  font-size: 2.5rem;
  line-height: 1;
  animation: bob 2s ease-in-out infinite;
  filter: drop-shadow(0 3px 6px rgba(0,0,0,0.1));
}
.partner-name {
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--partner-color, var(--accent));
}
.partner-line {
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.45;
  margin-top: 0.15rem;
}
.partner-panel.celebrate .partner-avatar { animation: wiggle 0.5s ease; }
.partner-panel.shake .partner-avatar { animation: shake 0.4s ease; }

@keyframes wiggle {
  0%, 100% { transform: rotate(0); }
  25% { transform: rotate(-8deg) scale(1.1); }
  75% { transform: rotate(8deg) scale(1.1); }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

/* ── 問題カード ── */
.quest-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
  padding-bottom: 0.65rem;
  border-bottom: 2px dashed #e2e8f0;
}
.quest-badge, .quest-kind, .quest-dir {
  font-size: 0.72rem;
  font-weight: 800;
  padding: 0.3rem 0.55rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: #1d4ed8;
}
.quest-kind {
  background: color-mix(in srgb, var(--kind-color, #8b5cf6) 15%, white);
  color: var(--kind-color, #7c3aed);
}
.quest-deco {
  margin-left: auto;
  font-size: 1.1rem;
  letter-spacing: 0.15em;
}
.quest-spell .quest-badge { background: #fef3c7; color: #b45309; }
.quest-order .quest-badge { background: #fce7f3; color: #be185d; }

.quest-boss-mode {
  border-bottom-color: #fecaca;
  background: linear-gradient(90deg, rgba(254,226,226,0.4), transparent);
  border-radius: 12px;
  padding: 0.5rem;
  margin: -0.25rem -0.25rem 0.65rem;
  animation: bossPulse 2s ease infinite;
}
.quest-boss {
  width: 100%;
  text-align: center;
  font-size: 0.85rem;
  font-weight: 800;
  padding: 0.35rem 0.6rem;
  border-radius: 10px;
  background: linear-gradient(135deg, #fee2e2, #fecaca);
  color: #b91c1c;
  margin-bottom: 0.35rem;
  letter-spacing: 0.05em;
}
@keyframes bossPulse {
  0%, 100% { box-shadow: 0 0 0 rgba(239,68,68,0); }
  50% { box-shadow: 0 0 12px rgba(239,68,68,0.25); }
}

.combo-hud {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  color: #b45309;
  font-weight: 800;
  font-size: 0.75rem;
  transition: transform 0.2s;
}
.combo-hud.combo-hot {
  background: linear-gradient(135deg, #fecaca, #fde68a);
  color: #dc2626;
  animation: comboGlow 0.8s ease infinite alternate;
}
.combo-hud.combo-pop { transform: scale(1.2); }
.combo-emoji { font-size: 0.9rem; }
.combo-n { font-size: 0.95rem; }
@keyframes comboGlow {
  from { box-shadow: 0 0 4px rgba(245,158,11,0.4); }
  to { box-shadow: 0 0 10px rgba(239,68,68,0.5); }
}

.fireworks-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  overflow: hidden;
}
.firework {
  position: absolute;
  animation: fireBurst 1.8s ease forwards;
  opacity: 0;
}
@keyframes fireBurst {
  0% { opacity: 0; transform: scale(0.3) translateY(20px); }
  15% { opacity: 1; transform: scale(1.2); }
  100% { opacity: 0; transform: scale(1.5) translateY(-30px); }
}

.result-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 0.75rem;
  justify-content: center;
}
.earn-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.4rem 0.65rem;
  border-radius: 999px;
  background: linear-gradient(135deg, #eff6ff, #dbeafe);
  border: 2px solid #93c5fd;
  font-size: 0.78rem;
  font-weight: 800;
  color: #1d4ed8;
}
.result-tip {
  text-align: center;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

.list-item.list-boss {
  background: linear-gradient(90deg, rgba(254,226,226,0.35), transparent);
  border-radius: 10px;
  margin: 0 -0.25rem;
  padding-left: 0.25rem;
  padding-right: 0.25rem;
}
.list-mastery.learning { background: #fef3c7; color: #b45309; }
.list-mastery.master { background: #fef9c3; color: #a16207; }

.prompt {
  font-size: 1.35rem;
  font-weight: 800;
  line-height: 1.45;
  margin: 0.35rem 0 0.85rem;
  color: #0f172a;
}

.choices { display: flex; flex-direction: column; gap: 0.55rem; }
.choice {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  text-align: left;
  background: #f8fafc;
  border: 2px solid #e2e8f0;
  color: var(--text);
  border-radius: 14px;
  padding: 0.85rem 1rem;
  font-size: 1rem;
  font-family: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s, background 0.15s;
}
.choice-mark { font-size: 1.1rem; flex-shrink: 0; }
.choice:active, .choice:hover {
  border-color: var(--accent);
  background: #eff6ff;
  transform: scale(1.01);
}

.tokens { display: flex; flex-wrap: wrap; gap: 0.45rem; margin-bottom: 0.75rem; min-height: 2.5rem; }
.token {
  background: linear-gradient(135deg, #dbeafe, #e0e7ff);
  border: 2px solid #93c5fd;
  color: var(--text);
  border-radius: 999px;
  padding: 0.5rem 0.85rem;
  font-size: 0.95rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(59,130,246,0.15);
}
.token.used { opacity: 0.35; transform: scale(0.95); }

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}
.stat {
  background: linear-gradient(180deg, #f8fafc, #f1f5f9);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0.65rem 0.35rem;
  text-align: center;
}
.stat .n { font-size: 1.35rem; font-weight: 800; color: var(--accent); }
.stat .l { font-size: 0.68rem; font-weight: 700; color: var(--muted); margin-top: 0.1rem; }

.stat-icon .n { font-size: 1.5rem; }

.stats-note {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
  text-align: center;
  margin-top: 0.55rem;
  line-height: 1.45;
}
.stats-note strong { color: var(--accent); }

.help-card { max-height: 70dvh; overflow-y: auto; }
.help-block {
  margin-bottom: 1rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px dashed #e2e8f0;
}
.help-block:last-of-type { border-bottom: none; margin-bottom: 0.75rem; }
.help-block h2 {
  font-size: 0.95rem;
  font-weight: 800;
  margin-bottom: 0.4rem;
  color: var(--text);
}
.help-block p {
  font-size: 0.85rem;
  line-height: 1.55;
  color: var(--muted);
}
.help-block p strong { color: var(--text); }
.help-list {
  margin: 0.35rem 0 0.5rem 1.1rem;
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--muted);
}
.help-note {
  font-size: 0.78rem !important;
  background: #eff6ff;
  padding: 0.5rem 0.65rem;
  border-radius: 10px;
  margin-top: 0.35rem;
}

.skill-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin-top: 0.75rem;
}
.skill-chip {
  text-align: center;
  padding: 0.65rem 0.4rem;
  border-radius: 14px;
  border: 2px solid var(--border);
  background: #fff;
}
.skill-chip .icon { font-size: 1.4rem; }
.skill-chip .val { font-size: 1.1rem; font-weight: 800; color: var(--accent2); }
.skill-chip .lbl { font-size: 0.65rem; color: var(--muted); font-weight: 700; }

.session-hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0.75rem;
  background: #fff;
  border-radius: 14px;
  border: 1px solid var(--border);
  font-size: 0.82rem;
  font-weight: 800;
  color: var(--muted);
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
.session-hud .xp { color: var(--warn); }

.feedback {
  margin-top: 0.75rem;
  padding: 0.65rem 0.85rem;
  border-radius: 12px;
  font-size: 0.88rem;
  font-weight: 700;
  line-height: 1.45;
  min-height: 2.5rem;
}
.feedback.good { background: var(--good-bg); color: #047857; }
.feedback.bad { background: var(--bad-bg); color: #b91c1c; }

.quest-stage { position: relative; overflow: hidden; }

.particle {
  position: absolute;
  top: 20%;
  font-size: 1.2rem;
  pointer-events: none;
  animation: floatUp 0.85s ease forwards;
  z-index: 5;
}
@keyframes floatUp {
  0% { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(-60px) scale(1.3); }
}

.result-hero {
  text-align: center;
  font-size: 3rem;
  padding: 0.5rem;
  animation: bob 1s ease infinite;
}
.result-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin: 0.75rem 0;
}
.result-stat {
  background: #f0fdf4;
  border-radius: 12px;
  padding: 0.6rem;
  text-align: center;
  font-weight: 800;
}
.result-stat .big { font-size: 1.3rem; color: var(--good); }

.tags { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0.85rem; }
.tag {
  border: 2px solid #e2e8f0;
  border-radius: 999px;
  padding: 0.45rem 0.75rem;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
  background: #fff;
  font-family: inherit;
}
.tag.on {
  border-color: var(--accent);
  color: #1d4ed8;
  background: var(--accent-soft);
}

.partners { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 0.85rem; }
.partner-opt {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  text-align: left;
  border: 2px solid #e2e8f0;
  background: #fff;
  color: var(--text);
  border-radius: 14px;
  padding: 0.75rem 0.9rem;
  cursor: pointer;
  font-family: inherit;
  font-weight: 700;
}
.partner-opt .po-emoji { font-size: 1.75rem; }
.partner-opt .po-sub { font-size: 0.72rem; color: var(--muted); font-weight: 600; }
.partner-opt.on { border-color: var(--accent); background: #eff6ff; }

.nav {
  display: flex;
  gap: 0.4rem;
  margin-top: auto;
  padding-top: 0.75rem;
}
.nav button {
  flex: 1;
  background: #fff;
  border: 2px solid #e2e8f0;
  color: var(--muted);
  border-radius: 14px;
  padding: 0.65rem 0.25rem;
  font-size: 0.78rem;
  font-weight: 800;
  font-family: inherit;
  cursor: pointer;
}
.nav button.on {
  color: #fff;
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  border-color: transparent;
}

.list-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.7rem 0;
  border-bottom: 1px solid #f1f5f9;
}
.list-item:last-child { border-bottom: none; }
.list-icon {
  width: 2.5rem;
  height: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  border-radius: 12px;
  background: #f1f5f9;
  flex-shrink: 0;
}
.list-body { flex: 1; min-width: 0; }
.list-body strong { display: block; font-size: 0.95rem; }
.list-body .meta { color: var(--muted); font-size: 0.78rem; margin-top: 0.1rem; }
.list-mastery {
  font-size: 0.75rem;
  font-weight: 800;
  padding: 0.25rem 0.45rem;
  border-radius: 8px;
  background: #eff6ff;
  color: var(--accent);
  white-space: nowrap;
}
.list-mastery.weak { background: #fee2e2; color: var(--bad); }
.list-mastery.ok { background: #d1fae5; color: var(--good); }

.hidden { display: none !important; }
