:root {
  --bg-top: #fff7ed;
  --bg-mid: #ffe4e6;
  --bg-bottom: #e0f2fe;
  --card: rgba(255, 255, 255, 0.92);
  --text: #312e81;
  --muted: #64748b;
  --primary: #fb7185;
  --primary-strong: #e11d48;
  --secondary: #38bdf8;
  --secondary-soft: #e0f2fe;
  --accent: #fbbf24;
  --ok: #10b981;
  --bad: #ef4444;
  --border: rgba(255, 255, 255, 0.7);
  --shadow: 0 18px 40px rgba(148, 163, 184, 0.22);
  --radius: 1.4rem;
  font-family: "Hiragino Maru Gothic ProN", "PingFang SC", "Noto Sans SC", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  min-height: 100%;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.9), transparent 30%),
    linear-gradient(180deg, var(--bg-top), var(--bg-mid) 42%, var(--bg-bottom));
  background-attachment: fixed;
}

body {
  padding:
    max(12px, env(safe-area-inset-top))
    max(12px, env(safe-area-inset-right))
    max(18px, env(safe-area-inset-bottom))
    max(12px, env(safe-area-inset-left));
  overflow-x: hidden;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  position: relative;
  z-index: 2;
}

.hidden {
  display: none !important;
}

.sky-decor {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.cloud,
.spark {
  position: absolute;
  display: block;
}

.cloud {
  width: 9rem;
  height: 3.2rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.45);
  filter: blur(2px);
  animation: drift 18s linear infinite;
}

.cloud-a { top: 5%; left: -12%; }
.cloud-b { top: 24%; right: -12%; animation-duration: 22s; }
.cloud-c { top: 63%; left: -16%; animation-duration: 26s; }

.spark {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(255,255,255,0.95), rgba(255,255,255,0));
  animation: twinkle 3s ease-in-out infinite;
}

.spark-a { top: 18%; left: 16%; }
.spark-b { top: 40%; right: 18%; animation-delay: 0.7s; }
.spark-c { top: 72%; left: 24%; animation-delay: 1.4s; }

@keyframes drift {
  from { transform: translateX(0); }
  to { transform: translateX(120vw); }
}

@keyframes twinkle {
  0%, 100% { opacity: 0.25; transform: scale(0.8); }
  50% { opacity: 0.95; transform: scale(1.25); }
}

.topbar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.brand {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.logo {
  width: 3rem;
  height: 3rem;
  display: grid;
  place-items: center;
  font-size: 1.9rem;
  background: rgba(255, 255, 255, 0.7);
  border-radius: 1rem;
  box-shadow: var(--shadow);
  animation: bob 2.4s ease-in-out infinite;
}

@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

.brand-title {
  font-size: 1.05rem;
  font-weight: 900;
  letter-spacing: 0.02em;
}

.brand-sub {
  font-size: 0.79rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.icon-btn {
  border: none;
  background: rgba(255, 255, 255, 0.88);
  border-radius: 999px;
  width: 2.55rem;
  height: 2.55rem;
  font-size: 1.15rem;
  box-shadow: var(--shadow);
  cursor: pointer;
}

.screen {
  animation: fade-up 0.32s ease;
}

@keyframes fade-up {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.card,
.badge-panel,
.map-panel,
.stat-card {
  background: var(--card);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.card,
.badge-panel,
.map-panel {
  border-radius: var(--radius);
}

.hero,
.player-card,
.lesson {
  padding: 1.15rem;
}

.hero-art {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  margin-bottom: 0.8rem;
}

.hero-mascot,
.player-badge {
  width: 4.4rem;
  height: 4.4rem;
  border-radius: 1.4rem;
  display: grid;
  place-items: center;
  font-size: 2.2rem;
  background: linear-gradient(145deg, #fff1f2, #e0f2fe);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.hero-bubble,
.coach-line {
  flex: 1;
  background: linear-gradient(135deg, #ffffff, #fff7ed);
  border-radius: 1.15rem;
  padding: 0.85rem 0.95rem;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.55;
}

.hero h1,
.player-copy h2,
.lesson h2 {
  margin: 0;
}

.hero h1 {
  font-size: 1.5rem;
  margin-bottom: 0.4rem;
}

.hero-showcase {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
  margin: 0.8rem 0 0.2rem;
}

.mini-card {
  padding: 0.75rem;
  border-radius: 1.05rem;
  background: linear-gradient(145deg, rgba(255,255,255,0.9), rgba(255,255,255,0.55));
  border: 1px solid rgba(255,255,255,0.75);
}

.mini-card span,
.mini-card strong,
.mini-card small {
  display: block;
}

.mini-card span {
  font-size: 1.2rem;
  margin-bottom: 0.2rem;
}

.mini-card small {
  margin-top: 0.2rem;
  color: var(--muted);
  line-height: 1.4;
}

.lead,
.story,
.question {
  line-height: 1.6;
}

.lead {
  color: var(--muted);
  margin-top: 0;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin: 0.9rem 0 0.6rem;
}

.chips span,
.eyebrow,
.reward-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.32rem 0.7rem;
  font-size: 0.78rem;
  font-weight: 800;
}

.chips span {
  background: #fff1f2;
  color: var(--primary-strong);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.38rem;
  margin: 1rem 0 0.2rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.field input {
  border: 2px solid #fecdd3;
  border-radius: 1rem;
  padding: 0.78rem 0.9rem;
  font-size: 1rem;
  background: rgba(255, 255, 255, 0.92);
  outline: none;
}

.field input:focus {
  border-color: var(--primary);
}

.btn {
  width: 100%;
  border: none;
  border-radius: 999px;
  padding: 0.82rem 1.1rem;
  font-size: 0.98rem;
  font-weight: 800;
  margin-top: 0.55rem;
  cursor: pointer;
}

.btn.primary {
  color: #fff;
  background: linear-gradient(135deg, var(--primary), #fb923c);
  box-shadow: 0 14px 24px rgba(251, 113, 133, 0.28);
}

.btn.soft {
  color: #0f172a;
  background: linear-gradient(135deg, #fff7ed, #dbeafe);
}

.btn.ghost {
  color: var(--primary-strong);
  background: rgba(255, 255, 255, 0.6);
  border: 2px dashed #fda4af;
}

.btn.compact {
  margin-top: 0;
}

.btn.back {
  width: auto;
  margin-bottom: 0.75rem;
}

.fineprint,
.hint {
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.55;
}

.player-head {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

.player-copy {
  min-width: 0;
}

.eyebrow {
  background: #fff1f2;
  color: var(--primary-strong);
  margin-bottom: 0.35rem;
}

.player-copy h2 {
  font-size: 1.25rem;
}

.player-copy p {
  margin: 0.28rem 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.progress-panel {
  margin-top: 1rem;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  gap: 0.6rem;
  align-items: center;
  font-size: 0.84rem;
  margin-bottom: 0.5rem;
}

.progress-meta span {
  color: var(--muted);
  text-align: right;
}

.progress-track {
  width: 100%;
  height: 0.78rem;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.7);
}

.progress-fill {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #fda4af, #38bdf8);
  transition: width 0.25s ease;
}

.reminder {
  margin-top: 0.95rem;
  padding: 0.78rem 0.9rem;
  border-radius: 1rem;
  background: linear-gradient(135deg, #fef3c7, #fff7ed);
  color: #92400e;
  font-size: 0.88rem;
}

.quick-actions {
  margin-top: 0.9rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}

.mood-bar {
  margin-top: 0.85rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.mood-pill,
.status-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.42rem 0.78rem;
  border-radius: 999px;
  background: rgba(255,255,255,0.75);
  font-size: 0.76rem;
  font-weight: 800;
  color: var(--text);
}

.status-chip {
  background: #fff1f2;
  color: var(--primary-strong);
}

.status-chip.soft {
  background: #eff6ff;
  color: #0369a1;
}

.stats-grid {
  margin-top: 0.9rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.7rem;
}

.stat-card {
  padding: 0.9rem;
  border-radius: 1.2rem;
}

.stat-card span {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
}

.stat-card strong {
  display: block;
  margin-top: 0.25rem;
  font-size: 1.08rem;
}

.badge-panel,
.map-panel {
  margin-top: 0.95rem;
  padding: 0.95rem;
}

.map-meter {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin: -0.15rem 0 0.9rem;
}

.meter-dot {
  width: 0.8rem;
  height: 0.8rem;
  border-radius: 999px;
  background: #fda4af;
  box-shadow: 0 0 0 0 rgba(251, 113, 133, 0.45);
  animation: pulse-dot 1.8s infinite;
}

.meter-line {
  flex: 1;
  position: relative;
  height: 0.5rem;
  border-radius: 999px;
  background: rgba(255,255,255,0.75);
  overflow: hidden;
}

.meter-line::after {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--fill, 0%);
  background: linear-gradient(90deg, #fb7185, #38bdf8);
  border-radius: inherit;
}

.meter-note {
  font-size: 0.75rem;
  color: var(--muted);
}

@keyframes pulse-dot {
  0% { box-shadow: 0 0 0 0 rgba(251, 113, 133, 0.4); }
  70% { box-shadow: 0 0 0 12px rgba(251, 113, 133, 0); }
  100% { box-shadow: 0 0 0 0 rgba(251, 113, 133, 0); }
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}

.section-head h3 {
  margin: 0;
  font-size: 1rem;
}

.section-head span {
  color: var(--muted);
  font-size: 0.76rem;
  text-align: right;
}

.badge-strip {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.65rem;
}

.badge-item {
  border: none;
  text-align: left;
  padding: 0.85rem;
  border-radius: 1.05rem;
  background: #f8fafc;
  color: #94a3b8;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.badge-item.unlocked {
  background: linear-gradient(145deg, #fff1f2, #eff6ff);
  color: var(--text);
}

.badge-item.active {
  outline: 3px solid rgba(251, 113, 133, 0.3);
}

.badge-item:hover,
.badge-item:active {
  transform: translateY(-2px);
}

.badge-icon {
  display: block;
  font-size: 1.4rem;
  margin-bottom: 0.35rem;
}

.badge-item strong,
.badge-item small {
  display: block;
}

.badge-item small {
  margin-top: 0.22rem;
  color: var(--muted);
}

.path {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.path li button {
  width: 100%;
  border: none;
  border-radius: 1.1rem;
  padding: 0.92rem 0.95rem;
  display: flex;
  align-items: center;
  gap: 0.8rem;
  text-align: left;
  background: #fff;
  box-shadow: 0 10px 22px rgba(148, 163, 184, 0.14);
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.path li button:hover,
.path li button:active {
  transform: translateY(-2px);
  box-shadow: 0 16px 28px rgba(148, 163, 184, 0.18);
}

.path li button.focus {
  background: linear-gradient(135deg, #fff7ed, #ffffff);
  outline: 2px solid rgba(251, 113, 133, 0.28);
}

.path li button.done {
  background: linear-gradient(135deg, #ecfccb, #ffffff);
}

.path li button:disabled {
  opacity: 0.55;
  cursor: default;
}

.path .badge {
  font-size: 1.5rem;
}

.path .meta {
  flex: 1;
}

.path .meta strong,
.path .meta span {
  display: block;
}

.path .meta span {
  font-size: 0.79rem;
  color: var(--muted);
  margin-top: 0.18rem;
}

.path .meta .star-line {
  color: #f59e0b;
  letter-spacing: 0.08em;
  font-weight: 800;
}

.footer-actions {
  margin-top: 1rem;
}

.lesson-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.lesson-status {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin: 0.55rem 0 0.8rem;
}

.tag {
  margin: 0;
  color: var(--primary-strong);
  font-size: 0.8rem;
  font-weight: 800;
}

.reward-pill {
  background: #fff7ed;
  color: #c2410c;
}

.story {
  margin-top: 0.7rem;
}

.coach-line {
  margin: 0.9rem 0 0.85rem;
}

.question {
  font-weight: 800;
}

.options,
.order-row {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.pair-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.7rem;
}

.pair-col {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.pair-item {
  border: 2px solid #e2e8f0;
  border-radius: 1rem;
  background: #fff;
  padding: 0.8rem 0.85rem;
  text-align: left;
  font-size: 0.92rem;
  cursor: pointer;
  transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease;
}

.pair-item.soft {
  background: #f8fafc;
}

.pair-item.selected {
  border-color: var(--primary);
  background: #fff1f2;
}

.pair-item.done {
  border-color: #86efac;
  background: #f0fdf4;
}

.pair-item:hover,
.pair-item:active {
  transform: translateY(-1px);
}

.fill-wrap {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
  background: rgba(255, 255, 255, 0.92);
  border: 2px solid #e2e8f0;
  border-radius: 1rem;
  padding: 0.8rem 0.9rem;
}

.fill-prefix {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.95rem;
  color: var(--muted);
}

.fill-input {
  flex: 1;
  min-width: 8rem;
  border: none;
  outline: none;
  background: transparent;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 1rem;
  color: var(--text);
}

.opt,
.order-item {
  background: #fff;
  border: 2px solid #e2e8f0;
  border-radius: 1rem;
  padding: 0.82rem 0.9rem;
  font-size: 0.95rem;
  text-align: left;
  cursor: pointer;
  transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease;
}

.opt:hover,
.opt:active,
.order-item:hover,
.order-item:active {
  transform: translateY(-1px) scale(1.01);
}

.opt.selected,
.order-item.selected {
  border-color: var(--primary);
  background: #fff1f2;
}

.order-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.idx {
  width: 1.7rem;
  height: 1.7rem;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--secondary-soft);
  color: #0369a1;
  font-weight: 800;
}

.actions {
  margin-top: 0.8rem;
}

.toast {
  margin-top: 0.8rem;
  font-weight: 800;
}

.toast.ok {
  color: var(--ok);
}

.toast.bad {
  color: var(--bad);
}

.celebration {
  position: fixed;
  inset: 0;
  z-index: 9;
  display: grid;
  place-items: center;
  pointer-events: none;
}

.celebration::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 20% 20%, rgba(255,255,255,0.8), transparent 18%),
    radial-gradient(circle at 80% 28%, rgba(255,241,242,0.9), transparent 18%),
    radial-gradient(circle at 30% 75%, rgba(219,234,254,0.9), transparent 18%),
    radial-gradient(circle at 74% 72%, rgba(254,240,138,0.85), transparent 18%);
  opacity: 0;
}

.celebration-inner {
  position: relative;
  padding: 1rem 1.3rem;
  border-radius: 1.2rem;
  background: rgba(255,255,255,0.86);
  border: 1px solid rgba(255,255,255,0.85);
  box-shadow: var(--shadow);
  transform: scale(0.82);
  opacity: 0;
  text-align: center;
}

.burst {
  font-size: 2rem;
  margin-bottom: 0.25rem;
}

.celebration.show::before {
  animation: flash-bg 1.1s ease;
}

.celebration.show .celebration-inner {
  animation: pop-card 1.1s ease;
}

.celebration.show .burst {
  animation: burst-spin 1.1s ease;
}

@keyframes pop-card {
  0% { opacity: 0; transform: scale(0.72) translateY(16px); }
  20% { opacity: 1; transform: scale(1.04) translateY(0); }
  80% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(0.96) translateY(-8px); }
}

@keyframes flash-bg {
  0% { opacity: 0; }
  20% { opacity: 1; }
  100% { opacity: 0; }
}

@keyframes burst-spin {
  0% { transform: scale(0.7) rotate(0deg); }
  35% { transform: scale(1.15) rotate(18deg); }
  100% { transform: scale(1) rotate(-8deg); }
}

.modal {
  border: none;
  padding: 0;
  width: min(420px, calc(100vw - 1.6rem));
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.modal::backdrop {
  background: rgba(15, 23, 42, 0.28);
}

.modal-inner {
  padding: 1rem 1rem 1.1rem;
  background: #fff;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}

.modal-head h3 {
  margin: 0;
}

.lb {
  list-style: none;
  padding: 0;
  margin: 0.8rem 0 0;
  max-height: 52vh;
  overflow: auto;
}

.lb li {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.65rem 0;
  border-bottom: 1px solid #f1f5f9;
  font-size: 0.9rem;
}

.lb li.me {
  background: #fff7ed;
  border-radius: 0.8rem;
  padding-left: 0.45rem;
  padding-right: 0.45rem;
}

.rk {
  width: 1.7rem;
  font-weight: 900;
  color: var(--primary-strong);
}

.lb-name {
  flex: 1;
}

.lb-side {
  color: var(--muted);
  font-size: 0.78rem;
  text-align: right;
}

.share-url {
  margin: 0.7rem 0 0.4rem;
  padding: 0.8rem;
  border-radius: 1rem;
  background: #f8fafc;
  word-break: break-all;
  font-size: 0.82rem;
  color: var(--muted);
}

@media (max-width: 420px) {
  .quick-actions,
  .stats-grid,
  .badge-strip,
  .hero-showcase,
  .pair-grid {
    grid-template-columns: 1fr;
  }

  .section-head,
  .progress-meta {
    flex-direction: column;
    align-items: flex-start;
  }

  .progress-meta span,
  .section-head span {
    text-align: left;
  }
}
