/* Kids English AI — Lesson Mode v2 (premium mobile-first)
 * AIDesigner v2 (run b74e3ec0) ベース → vanilla CSS 移植
 * 実 Puku mascot + 実 lesson illustrations を使用
 * 3D skeuomorphic button + soft animations
 */

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

:root {
  --pk-cream: #fdf7f0;
  --pk-cream-warm: #f5ebe0;
  --pk-coral: #ff8a65;
  --pk-coral-dark: #d84315;
  --pk-mint: #a5d6a7;
  --pk-mint-dark: #66bb6a;
  --pk-mint-deep: #4ca050;
  --pk-gold: #ffd54f;
  --pk-gold-dark: #f57f17;
  --pk-brown: #3e2723;
  --pk-brown-light: #5d4037;
  --pk-pink-bg: #fff0f5;
  --pk-green-bg: #f0fdf4;
  --pk-yellow-bg: #fffbe7;
  --pk-text: #3e2723;
}

/* ────────────────────────────────────────────────────────── */
/* Root overlay                                                */
/* ────────────────────────────────────────────────────────── */
.lesson-mode {
  position: fixed;
  inset: 0;
  background: var(--pk-cream);
  background-image: radial-gradient(circle at 50% 30%, rgba(165, 214, 167, 0.12) 0%, transparent 60%);
  font-family: 'Plus Jakarta Sans', -apple-system, sans-serif;
  color: var(--pk-text);
  z-index: 100;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}
.lesson-mode.hidden { display: none; }
.lesson-mode :is(.ja, .lesson-mission, .lesson-card-ja, .complete-ja, h2, h3) {
  font-family: 'M PLUS Rounded 1c', -apple-system, sans-serif;
}

/* ────────────────────────────────────────────────────────── */
/* 3D Skeuomorphic Button (press into the page)               */
/* ────────────────────────────────────────────────────────── */
.btn-3d {
  position: relative;
  border: none;
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.15s cubic-bezier(0.175, 0.885, 0.32, 1.275),
              box-shadow 0.15s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  -webkit-tap-highlight-color: transparent;
}
.btn-3d.coral {
  background-color: var(--pk-coral);
  box-shadow: 0 8px 0 var(--pk-coral-dark), inset 0 3px 0 rgba(255,255,255,0.4);
  color: white;
  text-shadow: 0 2px 0 rgba(0,0,0,0.1);
}
.btn-3d.mint {
  background-color: var(--pk-mint);
  box-shadow: 0 8px 0 var(--pk-mint-dark), inset 0 3px 0 rgba(255,255,255,0.4);
  color: var(--pk-brown);
}
.btn-3d.white {
  background-color: white;
  box-shadow: 0 8px 0 #e0e0e0, inset 0 3px 0 rgba(255,255,255,0.9);
  color: var(--pk-brown);
}
.btn-3d.gold {
  background-color: var(--pk-gold);
  box-shadow: 0 8px 0 var(--pk-gold-dark), inset 0 3px 0 rgba(255,255,255,0.4);
  color: var(--pk-brown);
}
.btn-3d:active {
  transform: translateY(8px);
  box-shadow: 0 0 0 transparent, inset 0 3px 0 rgba(255,255,255,0.2) !important;
}

/* ────────────────────────────────────────────────────────── */
/* Animations                                                  */
/* ────────────────────────────────────────────────────────── */
@keyframes pk-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}
@keyframes pk-pulse-ring {
  0% { transform: scale(0.85); opacity: 0.6; }
  100% { transform: scale(1.6); opacity: 0; }
}
@keyframes pk-bounce-rotate {
  0% { transform: translateY(0) rotate(0deg); }
  20% { transform: translateY(-20px) rotate(5deg); }
  40% { transform: translateY(0) rotate(-5deg); }
  60% { transform: translateY(-10px) rotate(3deg); }
  80% { transform: translateY(0) rotate(-2deg); }
  100% { transform: translateY(0) rotate(0deg); }
}
@keyframes pk-confetti {
  0% { transform: translateY(-100px) rotate(0deg); opacity: 1; }
  100% { transform: translateY(800px) rotate(720deg); opacity: 0; }
}
@keyframes pk-sound-bar {
  0%, 100% { transform: scaleY(0.4); }
  50% { transform: scaleY(1); }
}
@keyframes pk-star-reveal {
  0% { transform: scale(0) rotate(-45deg); opacity: 0; }
  60% { transform: scale(1.3) rotate(15deg); opacity: 1; }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}
.pk-float { animation: pk-float 4s ease-in-out infinite; }
.pk-happy-dance { animation: pk-bounce-rotate 1.5s infinite; }
.pk-pulse-ring { position: relative; }
.pk-pulse-ring::before {
  content: '';
  position: absolute; inset: -16px;
  border-radius: 50%;
  background: rgba(255, 138, 101, 0.35);
  z-index: -1;
  animation: pk-pulse-ring 2s cubic-bezier(0.215, 0.61, 0.355, 1) infinite;
}

/* ────────────────────────────────────────────────────────── */
/* Sound bars (audio playing indicator)                        */
/* ────────────────────────────────────────────────────────── */
.sound-bars {
  display: inline-flex; gap: 4px; align-items: center;
  height: 32px;
}
.sound-bars span {
  display: inline-block;
  width: 4px; height: 100%;
  background: var(--pk-coral);
  border-radius: 2px;
  transform-origin: center;
  animation: pk-sound-bar 0.8s ease-in-out infinite;
}
.sound-bars span:nth-child(2) { animation-delay: 0.15s; }
.sound-bars span:nth-child(3) { animation-delay: 0.3s; }

/* ────────────────────────────────────────────────────────── */
/* View transitions                                            */
/* ────────────────────────────────────────────────────────── */
.lesson-view {
  height: 100%;
  display: flex;
  flex-direction: column;
}
.lesson-view[hidden] { display: none; }

/* ────────────────────────────────────────────────────────── */
/* HOME / Lesson selector                                      */
/* ────────────────────────────────────────────────────────── */
.lesson-home-header {
  display: flex; align-items: center;
  padding: 28px 24px 16px;
  gap: 16px;
}
.lesson-home-back {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 6px 0 #e0e0e0, inset 0 3px 0 rgba(255,255,255,0.9);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.75rem; color: var(--pk-brown); font-weight: 900;
  border: none; cursor: pointer;
}
.lesson-home-back:active { transform: translateY(6px); box-shadow: 0 0 0 transparent !important; }
.lesson-home-title {
  font-size: 1.75rem; font-weight: 900;
  margin: 0;
  color: var(--pk-brown);
}
.lesson-home-title-sub {
  font-size: 0.95rem; opacity: 0.6; font-weight: 700;
  margin: 0;
  margin-top: 2px;
}
.lesson-cards {
  flex: 1;
  display: flex; flex-direction: column;
  gap: 20px;
  padding: 8px 20px 24px;
  overflow-y: auto;
}
.lesson-card {
  position: relative;
  display: flex; align-items: center; gap: 16px;
  padding: 20px;
  border-radius: 32px;
  background: white;
  border: 2px solid white;
  box-shadow: 0 8px 0 #e0e0e0, 0 2px 4px rgba(0,0,0,0.04);
  cursor: pointer; text-align: left;
  font-family: inherit;
  overflow: hidden;
  transition: transform 0.15s, box-shadow 0.15s;
}
.lesson-card:active { transform: translateY(6px); box-shadow: 0 2px 0 #e0e0e0 !important; }
.lesson-card[data-theme="family"] { background: var(--pk-pink-bg); }
.lesson-card[data-theme="family"] { box-shadow: 0 8px 0 #f8bbd0, 0 2px 4px rgba(0,0,0,0.04); }
.lesson-card[data-theme="colors"] { background: var(--pk-yellow-bg); box-shadow: 0 8px 0 #fff59d, 0 2px 4px rgba(0,0,0,0.04); }
.lesson-card[data-theme="animals"] { background: var(--pk-green-bg); box-shadow: 0 8px 0 #c8e6c9, 0 2px 4px rgba(0,0,0,0.04); }
.lesson-card-thumb {
  width: 84px; height: 84px;
  flex-shrink: 0;
  border-radius: 24px;
  background: white;
  box-shadow: 0 2px 6px rgba(0,0,0,0.06);
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.lesson-card-thumb img { width: 100%; height: 100%; object-fit: cover; }
.lesson-card-text {
  flex: 1; z-index: 2;
}
.lesson-card-en {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 1.6rem; font-weight: 900;
  color: var(--pk-brown); margin: 0;
  letter-spacing: -0.02em;
}
.lesson-card-ja {
  font-size: 0.95rem; font-weight: 700;
  color: var(--pk-brown); opacity: 0.6;
  margin: 2px 0 0;
}
.lesson-card-arrow {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--pk-coral);
  color: white;
  font-size: 1.25rem; font-weight: 900;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 0 var(--pk-coral-dark);
}
.lesson-free-talk-cta {
  width: calc(100% - 40px);
  margin: 0 20px 28px;
  padding: 22px 24px;
  border-radius: 32px;
  background: var(--pk-mint);
  box-shadow: 0 10px 0 var(--pk-mint-dark);
  display: flex; align-items: center; gap: 16px;
  color: var(--pk-brown);
  font-family: inherit;
  border: none; cursor: pointer;
  position: relative; overflow: hidden;
}
.lesson-free-talk-cta:active { transform: translateY(8px); box-shadow: 0 2px 0 var(--pk-mint-dark) !important; }
.lesson-free-talk-cta .fa-mic {
  width: 52px; height: 52px;
  border-radius: 50%;
  background: rgba(255,255,255,0.3);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
}
.lesson-free-talk-cta-text { text-align: left; }
.lesson-free-talk-cta-text .en {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 1.4rem; font-weight: 900; display: block;
}
.lesson-free-talk-cta-text .ja {
  font-size: 0.95rem; font-weight: 700; opacity: 0.7;
}

/* ────────────────────────────────────────────────────────── */
/* PLAYER (in-lesson)                                          */
/* ────────────────────────────────────────────────────────── */
.lesson-player-top {
  display: flex; align-items: center;
  padding: 20px 24px 12px;
  gap: 12px;
  z-index: 10;
}
.lesson-exit {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: rgba(255,255,255,0.85);
  color: var(--pk-brown);
  font-size: 1.5rem; font-weight: 900;
  display: flex; align-items: center; justify-content: center;
  border: none; cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,0.06);
  flex-shrink: 0;
}
.lesson-exit:active { background: var(--pk-coral); color: white; }
.lesson-progress-track {
  flex: 1;
  display: flex; gap: 6px;
  align-items: center;
}
.lesson-progress-seg {
  height: 12px;
  background: rgba(0,0,0,0.08);
  border-radius: 999px;
  flex: 1;
}
.lesson-progress-seg.done { background: var(--pk-mint-dark); }
.lesson-progress-seg.current { background: var(--pk-mint-dark); box-shadow: 0 0 0 3px rgba(102,187,106,0.25); }
.lesson-cam-pip {
  width: 56px; height: 76px;
  border-radius: 12px;
  background: #000;
  overflow: hidden;
  position: relative;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}
.lesson-cam-pip video {
  width: 100%; height: 100%; object-fit: cover;
  transform: scaleX(-1);
}
.lesson-cam-pip::after {
  content: '';
  position: absolute; bottom: 4px; left: 4px;
  width: 8px; height: 8px;
  background: #ef4444;
  border: 1.5px solid white;
  border-radius: 50%;
  animation: pk-pulse 1.5s infinite;
}
@keyframes pk-pulse { 0%,100% { opacity: 1 } 50% { opacity: 0.3 } }

.lesson-mission {
  background: var(--pk-gold);
  color: var(--pk-brown);
  font-weight: 800;
  padding: 12px 24px;
  border-radius: 999px;
  box-shadow: 0 4px 0 var(--pk-gold-dark);
  margin: 12px auto 0;
  display: inline-flex; gap: 8px; align-items: center;
  transform: rotate(-2deg);
  font-size: 1.05rem;
}
.lesson-mission .en {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 0.75rem;
  font-weight: 700;
  opacity: 0.7;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* Slide content */
.lesson-slide {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 20px 32px;
  position: relative;
}

/* slide_type: introduce / assessment — large center image + word */
.slide-hero-image {
  width: 220px; height: 220px;
  background: white;
  border-radius: 40px;
  box-shadow: 0 12px 24px rgba(0,0,0,0.08), inset 0 2px 0 rgba(255,255,255,0.9);
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  position: relative;
  animation: pk-float 4s ease-in-out infinite;
}
.slide-hero-image img {
  width: 88%; height: 88%; object-fit: contain;
}
.slide-hero-word {
  margin-top: 24px;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 3rem; font-weight: 900;
  color: var(--pk-brown);
  letter-spacing: -0.02em;
  text-transform: capitalize;
  text-shadow: 0 4px 0 rgba(0,0,0,0.04);
}
.slide-hero-ja {
  font-size: 1.05rem; font-weight: 700;
  color: var(--pk-brown); opacity: 0.55;
  margin-top: 2px;
}

/* Audio replay button + sound bars cluster */
.slide-audio-cluster {
  position: absolute;
  top: 12px; right: 24px;
  display: flex; align-items: center; gap: 12px;
}
.slide-audio-cluster .sound-bars { height: 24px; }
.slide-audio-replay {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--pk-coral);
  color: white;
  font-size: 1.5rem;
  display: flex; align-items: center; justify-content: center;
  border: none; cursor: pointer;
  box-shadow: 0 6px 0 var(--pk-coral-dark), inset 0 2px 0 rgba(255,255,255,0.3);
}
.slide-audio-replay:active { transform: translateY(6px); box-shadow: 0 0 0 var(--pk-coral-dark) !important; }

/* slide_type: choice_2 — 2 large image cards */
.slide-question {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 1.5rem; font-weight: 800;
  text-align: center; color: var(--pk-brown);
  margin: 0 0 24px;
}
.slide-question-ja {
  font-size: 0.95rem; font-weight: 700;
  opacity: 0.6; margin-bottom: 6px;
  text-align: center;
}
.slide-choice-row {
  display: flex; gap: 16px;
  width: 100%; max-width: 480px;
  margin: 0 auto;
}
.slide-choice {
  flex: 1;
  background: white;
  border: 4px solid white;
  border-radius: 32px;
  aspect-ratio: 1;
  padding: 20px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  box-shadow: 0 8px 0 #e0e0e0, 0 2px 4px rgba(0,0,0,0.04);
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.2s;
  -webkit-tap-highlight-color: transparent;
  font-family: inherit;
}
.slide-choice:active { transform: translateY(6px); box-shadow: 0 2px 0 #e0e0e0 !important; }
.slide-choice img { width: 100%; height: 100%; object-fit: contain; }
.slide-choice.correct {
  border-color: var(--pk-mint-dark);
  background: #e8f5e9;
  box-shadow: 0 8px 0 var(--pk-mint-dark), 0 2px 4px rgba(0,0,0,0.04);
}
.slide-choice.incorrect {
  border-color: #ef9a9a;
  background: #ffebee;
  box-shadow: 0 8px 0 #ef9a9a;
}

/* slide_type: tpr — full hero + glow */
.slide-tpr-target {
  width: 240px; height: 240px;
  border-radius: 50%;
  background: white;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  position: relative;
  box-shadow: 0 16px 0 var(--pk-mint-dark), 0 4px 16px rgba(0,0,0,0.08);
  border: 6px solid var(--pk-mint);
  transition: transform 0.15s, box-shadow 0.15s;
  padding: 20px;
}
.slide-tpr-target:active { transform: translateY(10px); box-shadow: 0 6px 0 var(--pk-mint-dark) !important; }
.slide-tpr-target img { width: 100%; height: 100%; object-fit: contain; }

/* slide_type: review_song */
.slide-song-card {
  background: linear-gradient(135deg, var(--pk-gold) 0%, var(--pk-coral) 100%);
  color: white;
  padding: 32px 24px;
  border-radius: 32px;
  box-shadow: 0 12px 24px rgba(255,138,101,0.3);
  text-align: center;
  max-width: 380px;
}
.slide-song-card .icon {
  font-size: 3rem;
  margin-bottom: 8px;
}
.slide-song-card .lyric {
  font-family: 'M PLUS Rounded 1c', sans-serif;
  font-size: 1.6rem; font-weight: 900;
  line-height: 1.4;
  text-shadow: 0 2px 0 rgba(0,0,0,0.15);
}

/* Mascot Puku — bottom corner, real image */
.lesson-mascot {
  position: absolute;
  bottom: 8px; right: 16px;
  width: 110px; height: 110px;
  pointer-events: none;
  z-index: 30;
  filter: drop-shadow(0 8px 8px rgba(76,160,80,0.25));
}
.lesson-mascot img {
  width: 100%; height: 100%; object-fit: contain;
  transform-origin: bottom center;
}
.lesson-mascot.talking img {
  animation: pk-float 1.5s ease-in-out infinite, mascot-talk-bob 0.4s ease-in-out infinite alternate;
}
@keyframes mascot-talk-bob {
  0% { transform: scale(1) translateY(0); }
  100% { transform: scale(1.03) translateY(-2px); }
}
.lesson-mascot.celebrating img {
  animation: pk-bounce-rotate 1.5s infinite;
}
.lesson-mascot-bubble {
  position: absolute;
  bottom: 110%;
  right: 50%;
  transform: translateX(50%);
  background: white;
  border: 2px solid var(--pk-mint);
  padding: 10px 16px;
  border-radius: 18px;
  box-shadow: 0 4px 8px rgba(0,0,0,0.08);
  color: var(--pk-brown);
  font-weight: 800;
  font-size: 0.95rem;
  white-space: nowrap;
  pointer-events: none;
}
.lesson-mascot-bubble.hidden { display: none; }
.lesson-mascot-bubble::after {
  content: '';
  position: absolute;
  top: 100%; left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: white;
}

/* ────────────────────────────────────────────────────────── */
/* COMPLETE / Celebration                                      */
/* ────────────────────────────────────────────────────────── */
.lesson-complete {
  background: linear-gradient(135deg, #FFE082 0%, var(--pk-cream) 100%);
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}
.complete-sunburst {
  position: absolute; inset: 0;
  background: repeating-conic-gradient(from 0deg, transparent 0deg 18deg, rgba(255,255,255,0.18) 18deg 36deg);
  z-index: 0;
}
.complete-confetti { position: absolute; inset: 0; pointer-events: none; z-index: 1; }
.complete-confetti span {
  position: absolute;
  width: 14px; height: 14px;
  border-radius: 3px;
  animation: pk-confetti 3s linear infinite;
}
.complete-content {
  position: relative; z-index: 2;
  display: flex; flex-direction: column; align-items: center;
  padding: 0 24px;
}
.complete-mascot {
  width: 160px; height: 160px;
  margin-bottom: 12px;
}
.complete-mascot img {
  width: 100%; height: 100%; object-fit: contain;
  animation: pk-bounce-rotate 1.5s infinite;
}
.complete-stars {
  display: flex; justify-content: center; gap: 14px;
  margin: 8px 0 24px;
}
.complete-star {
  font-size: 5rem;
  color: var(--pk-gold);
  filter: drop-shadow(0 8px 0 var(--pk-gold-dark));
  opacity: 0;
  animation: pk-star-reveal 0.7s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  line-height: 1;
}
.complete-star.s1 { animation-delay: 0.1s; }
.complete-star.s2 { animation-delay: 0.4s; font-size: 6rem; margin-top: -8px; }
.complete-star.s3 { animation-delay: 0.7s; }
.complete-star.dim { opacity: 0.3 !important; filter: drop-shadow(0 6px 0 rgba(245,127,23,0.5)) grayscale(0.3); }

.complete-heading {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 3.5rem; font-weight: 900;
  margin: 0 0 6px;
  text-align: center; color: var(--pk-coral-dark);
  text-shadow: 0 4px 0 rgba(0,0,0,0.06);
  letter-spacing: -0.02em;
  transform: rotate(-2deg);
}
.complete-ja {
  font-size: 1.3rem; font-weight: 700;
  color: var(--pk-brown); opacity: 0.7;
  margin: 0 0 32px;
}
.complete-actions {
  display: flex; flex-direction: column; gap: 14px;
  width: 100%; max-width: 320px;
}
.complete-actions .btn-3d {
  height: 76px;
  border-radius: 32px;
  font-size: 1.4rem; font-weight: 900;
  letter-spacing: 0.02em;
}

/* ────────────────────────────────────────────────────────── */
/* Responsive — mobile portrait fine-tuning                   */
/* ────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .lesson-home-title { font-size: 1.5rem; }
  .lesson-card-en { font-size: 1.35rem; }
  .slide-hero-image { width: 180px; height: 180px; }
  .slide-hero-word { font-size: 2.4rem; }
  .slide-choice { border-radius: 24px; padding: 16px; }
  .slide-tpr-target { width: 200px; height: 200px; }
  .lesson-mascot { width: 90px; height: 90px; bottom: 4px; right: 8px; }
  .complete-heading { font-size: 2.6rem; }
  .complete-star { font-size: 3.8rem; }
  .complete-star.s2 { font-size: 4.6rem; }
}

@media (min-width: 768px) {
  /* tablet landscape - constrain max width */
  .lesson-cards, .lesson-free-talk-cta { max-width: 640px; margin-left: auto; margin-right: auto; }
  .slide-hero-image { width: 280px; height: 280px; }
  .slide-hero-word { font-size: 4rem; }
  .slide-choice-row { max-width: 640px; gap: 24px; }
  .lesson-mascot { width: 140px; height: 140px; bottom: 16px; right: 32px; }
  .complete-mascot { width: 200px; height: 200px; }
  .complete-heading { font-size: 4.5rem; }
}
