:root {
  --ink: #172033;
  --muted: #64748b;
  --paper: #fffdf4;
  --card: rgba(255, 255, 255, 0.92);
  --senna-black: #151515;
  --sun: #ffd166;
  --orange: #ff9f1c;
  --green: #06d6a0;
  --pink: #ef476f;
  --blue: #118ab2;
  --violet: #6d5dfc;
  --sky-a: #e0f7ff;
  --sky-b: #fff7cc;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  min-height: 100%;
  width: 100%;
  background: var(--senna-black);
  color: var(--ink);
  font-family: "Arial Rounded MT Bold", "Trebuchet MS", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  user-select: none;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.noscript-card {
  margin: 24px;
  border-radius: 28px;
  padding: 28px;
  background: white;
  color: #111827;
}

.app-shell,
.view {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  overflow: hidden;
}

.hidden {
  display: none !important;
}

.welcome-view {
  background:
    radial-gradient(circle at 18% 20%, rgba(255, 209, 102, 0.95), transparent 20%),
    radial-gradient(circle at 78% 26%, rgba(6, 214, 160, 0.5), transparent 23%),
    linear-gradient(135deg, #fff5c7, #dcf8ff 55%, #ffe0f1);
  padding: calc(18px + var(--safe-top)) calc(16px + var(--safe-right)) calc(18px + var(--safe-bottom)) calc(16px + var(--safe-left));
  display: grid;
  place-items: center;
}

.brand-ribbon {
  position: absolute;
  top: calc(14px + var(--safe-top));
  left: calc(14px + var(--safe-left));
  right: calc(14px + var(--safe-right));
  min-height: 50px;
  padding: 10px 156px 10px 14px;
  color: white;
  background: #111;
  border-radius: 18px;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.14);
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.brand-mark {
  font-weight: 1000;
  letter-spacing: 0.08em;
}

.brand-line {
  color: #e5e7eb;
  font-size: 0.86rem;
}

.parent-corner-btn,
.language-btn {
  position: absolute;
  top: calc(22px + var(--safe-top));
  z-index: 5;
  min-height: 44px;
  border: 0;
  border-radius: 999px;
  padding: 10px 14px;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.18);
  background: rgba(255, 255, 255, 0.93);
  color: #0f172a;
  font-weight: 900;
}

.parent-corner-btn {
  right: calc(92px + var(--safe-right));
}

.language-btn {
  right: calc(16px + var(--safe-right));
}

.welcome-card {
  width: min(94vw, 880px);
  min-height: min(760px, 82dvh);
  margin-top: 40px;
  border: 8px solid rgba(255, 255, 255, 0.68);
  border-radius: clamp(32px, 6vw, 64px);
  background: var(--card);
  box-shadow: 0 30px 80px rgba(15, 23, 42, 0.18);
  padding: clamp(22px, 5vw, 54px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: clamp(16px, 3vw, 28px);
  text-align: center;
  backdrop-filter: blur(18px);
}

.mascot-stage {
  position: relative;
  width: min(310px, 58vw);
  height: min(230px, 38vh);
  display: grid;
  place-items: center;
}

.sun-orbit {
  position: absolute;
  width: 84%;
  height: 84%;
  border: 10px dotted rgba(255, 159, 28, 0.42);
  border-radius: 999px;
  animation: rotateOrbit 20s linear infinite;
}

.mascot-lion {
  position: relative;
  z-index: 2;
  font-size: clamp(92px, 22vw, 178px);
  filter: drop-shadow(0 22px 18px rgba(15, 23, 42, 0.2));
  animation: lionBounce 2.6s ease-in-out infinite;
}

.sparkle {
  position: absolute;
  z-index: 3;
  font-size: clamp(24px, 7vw, 44px);
  animation: sparkleFloat 3.2s ease-in-out infinite;
}

.sparkle-one {
  left: 8%;
  top: 18%;
}

.sparkle-two {
  right: 9%;
  top: 24%;
  animation-delay: -0.8s;
}

.sparkle-three {
  right: 20%;
  bottom: 7%;
  animation-delay: -1.4s;
}

@keyframes rotateOrbit {
  to { transform: rotate(360deg); }
}

@keyframes lionBounce {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50% { transform: translateY(-16px) rotate(3deg); }
}

@keyframes sparkleFloat {
  0%, 100% { transform: translateY(0) scale(1); opacity: 0.78; }
  50% { transform: translateY(-14px) scale(1.15); opacity: 1; }
}

.welcome-card h1 {
  margin: 0;
  font-size: clamp(2.2rem, 7.8vw, 5.7rem);
  line-height: 0.95;
  letter-spacing: -0.06em;
  color: #111827;
}

.welcome-card p {
  margin: 0;
}

#welcomeSubtitle {
  font-size: clamp(1.05rem, 2.8vw, 1.45rem);
  color: var(--muted);
  font-weight: 800;
}

.place-grid {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(14px, 3vw, 28px);
}

.place-card {
  min-height: clamp(210px, 30dvh, 270px);
  border: 0;
  border-radius: clamp(26px, 4vw, 42px);
  padding: clamp(16px, 4vw, 34px);
  color: #111827;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 10px;
  box-shadow: 0 18px 30px rgba(15, 23, 42, 0.12), inset 0 -8px 0 rgba(0, 0, 0, 0.06);
  transition: transform 170ms ease, filter 170ms ease;
}

.place-card:active {
  transform: scale(0.96);
  filter: brightness(0.98);
}

.school-card {
  background: linear-gradient(145deg, #eff6ff, #bae6fd);
}

.home-card {
  background: linear-gradient(145deg, #fff7ed, #fed7aa);
}

.place-emoji {
  font-size: clamp(5rem, 15vw, 8.2rem);
}

.place-label {
  font-size: clamp(1.6rem, 5vw, 3rem);
  font-weight: 1000;
}

.place-micro {
  font-size: clamp(0.9rem, 2.5vw, 1.15rem);
  color: rgba(15, 23, 42, 0.62);
  font-weight: 900;
}

.privacy-note {
  max-width: 720px;
  color: #475569;
  font-size: clamp(0.88rem, 2.2vw, 1.05rem);
  font-weight: 800;
}

.attendance-view,
.game-view {
  background:
    radial-gradient(circle at 20% 18%, rgba(255, 255, 255, 0.58), transparent 20%),
    linear-gradient(160deg, var(--sky-a), var(--sky-b));
}

body.sunset-mode .game-view {
  background: linear-gradient(160deg, #ffd6a5, #ff9f80 48%, #6d5dfc);
}

body.night-mode .game-view,
.sleep-view {
  background: radial-gradient(circle at 50% 20%, #3b3486, #16133e 60%, #080711);
}

.kid-header {
  position: absolute;
  top: calc(16px + var(--safe-top));
  left: calc(16px + var(--safe-left));
  right: calc(16px + var(--safe-right));
  z-index: 4;
  min-height: 62px;
  padding: 10px;
  display: flex;
  align-items: center;
  gap: 14px;
  background: rgba(255, 255, 255, 0.8);
  border-radius: 22px;
  box-shadow: 0 16px 32px rgba(15, 23, 42, 0.12);
  backdrop-filter: blur(12px);
}

.kid-header strong {
  display: block;
  font-size: clamp(1.05rem, 3vw, 1.6rem);
}

.kid-header small {
  display: block;
  color: #64748b;
  font-weight: 900;
}

.kid-small-btn,
.hud-btn {
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 18px;
  background: #111827;
  color: white;
  font-size: 1.25rem;
  font-weight: 1000;
}

.soft-pill {
  margin-left: auto;
  padding: 9px 14px;
  border-radius: 999px;
  background: #fff7ed;
  color: #9a3412;
  font-weight: 1000;
}

.mirror-wrap {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: calc(90px + var(--safe-top)) 16px calc(84px + var(--safe-bottom));
}

.mirror-canvas {
  width: min(92vw, 720px);
  height: min(92vw, 720px);
  max-height: calc(100dvh - 180px);
  border-radius: 50%;
  box-shadow: 0 38px 90px rgba(15, 23, 42, 0.22);
  background: #fef3c7;
  border: 12px solid rgba(255, 255, 255, 0.86);
}

.skip-btn {
  position: absolute;
  bottom: calc(24px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  border: 0;
  border-radius: 999px;
  padding: 16px 22px;
  color: white;
  background: #111827;
  font-weight: 1000;
  box-shadow: 0 18px 30px rgba(15, 23, 42, 0.2);
}

.game-canvas {
  position: absolute;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  display: block;
}

.game-hud {
  position: absolute;
  top: calc(14px + var(--safe-top));
  left: calc(14px + var(--safe-left));
  right: calc(14px + var(--safe-right));
  z-index: 5;
  pointer-events: none;
  display: grid;
  grid-template-columns: 54px 1fr 54px;
  align-items: center;
  gap: 10px;
}

.game-hud > * {
  pointer-events: auto;
}

.hud-center {
  min-height: 54px;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  backdrop-filter: blur(12px);
  box-shadow: 0 14px 32px rgba(15, 23, 42, 0.12);
  overflow: hidden;
  padding: 8px 10px;
}

.timer-badge {
  padding: 8px 12px;
  border-radius: 999px;
  background: #111827;
  color: white;
  font-weight: 1000;
  font-variant-numeric: tabular-nums;
  flex: 0 0 auto;
}

.game-prompt {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: #0f172a;
  font-weight: 1000;
}

.journey-panel {
  position: absolute;
  z-index: 6;
  left: calc(14px + var(--safe-left));
  right: calc(14px + var(--safe-right));
  bottom: calc(14px + var(--safe-bottom));
  padding: 12px;
  min-height: 112px;
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 20px 48px rgba(15, 23, 42, 0.14);
  backdrop-filter: blur(16px);
  display: grid;
  grid-template-columns: 78px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}

.journey-mascot {
  width: 76px;
  height: 76px;
  display: grid;
  place-items: center;
  border-radius: 24px;
  background: #fff7ed;
  font-size: 3.4rem;
}

#journeyQuestion {
  display: block;
  font-size: clamp(1rem, 2.8vw, 1.55rem);
  letter-spacing: -0.02em;
}

#journeyMicro {
  display: block;
  color: #64748b;
  font-weight: 900;
  margin-top: 4px;
}

.journey-choices {
  display: flex;
  gap: 8px;
  align-items: center;
}

.journey-choice {
  min-width: 88px;
  min-height: 88px;
  border: 0;
  border-radius: 24px;
  padding: 8px;
  background: #f8fafc;
  box-shadow: inset 0 -5px 0 rgba(15, 23, 42, 0.08);
  display: flex;
  flex-direction: column;
  gap: 4px;
  justify-content: center;
  align-items: center;
  transition: transform 140ms ease;
}

.journey-choice:active {
  transform: scale(0.94);
}

.journey-choice span:first-child {
  font-size: 2.35rem;
}

.journey-choice span:last-child {
  font-size: 0.72rem;
  color: #475569;
  font-weight: 1000;
}

.sleep-view {
  display: grid;
  place-items: center;
  padding: 18px;
  color: white;
  text-align: center;
}

.sleep-card {
  width: min(92vw, 680px);
  padding: clamp(26px, 6vw, 56px);
  border-radius: clamp(32px, 6vw, 58px);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.sleep-moon {
  font-size: clamp(5rem, 20vw, 10rem);
  animation: sleepBreathe 4s ease-in-out infinite;
}

@keyframes sleepBreathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

.sleep-card h2 {
  margin: 16px 0 8px;
  font-size: clamp(2.2rem, 8vw, 5rem);
  line-height: 1;
}

.sleep-card p {
  color: #e0e7ff;
  font-size: clamp(1rem, 3vw, 1.3rem);
  font-weight: 800;
}

.parent-unlock-btn {
  border: 0;
  border-radius: 999px;
  padding: 16px 22px;
  color: #111827;
  background: white;
  font-weight: 1000;
}

.portal-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(2, 6, 23, 0.64);
  backdrop-filter: blur(10px);
  display: grid;
  place-items: center;
  padding: calc(18px + var(--safe-top)) calc(18px + var(--safe-right)) calc(18px + var(--safe-bottom)) calc(18px + var(--safe-left));
  overflow: auto;
  touch-action: auto;
}

.portal-card {
  width: min(96vw, 980px);
  max-height: 92dvh;
  overflow: auto;
  border-radius: 34px;
  background: #ffffff;
  box-shadow: 0 32px 90px rgba(0, 0, 0, 0.35);
  padding: clamp(18px, 4vw, 34px);
  color: #111827;
}

.portal-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
}

.portal-title {
  margin: 0;
  font-size: clamp(1.6rem, 4vw, 2.7rem);
  line-height: 1;
}

.portal-subtitle {
  margin: 6px 0 0;
  color: #64748b;
  font-weight: 800;
}

.close-portal {
  width: 46px;
  height: 46px;
  border: 0;
  border-radius: 16px;
  background: #f1f5f9;
  font-size: 1.2rem;
  font-weight: 1000;
}

.gate-box {
  border-radius: 28px;
  background: linear-gradient(145deg, #fff7ed, #eef2ff);
  padding: 22px;
  display: grid;
  gap: 12px;
}

.gate-problem {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 92px;
  border-radius: 24px;
  background: #111827;
  color: white;
  font-size: clamp(2rem, 8vw, 4rem);
  font-weight: 1000;
  letter-spacing: -0.05em;
}

.gate-input-row {
  display: flex;
  gap: 10px;
}

.gate-input-row input {
  min-width: 0;
  flex: 1;
  border: 3px solid #e2e8f0;
  border-radius: 18px;
  padding: 14px 16px;
  font-size: 1.5rem;
  font-weight: 900;
}

.primary-btn,
.secondary-btn,
.danger-btn {
  border: 0;
  border-radius: 18px;
  padding: 14px 16px;
  font-weight: 1000;
}

.primary-btn {
  background: #111827;
  color: white;
}

.secondary-btn {
  background: #e2e8f0;
  color: #111827;
}

.danger-btn {
  background: #fee2e2;
  color: #991b1b;
}

.portal-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 18px;
}

.metric-card,
.activity-card {
  border-radius: 26px;
  background: #f8fafc;
  padding: 18px;
}

.metric-card h3,
.activity-card h3 {
  margin: 0 0 12px;
}

.metric-row {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr) 50px;
  gap: 10px;
  align-items: center;
  margin: 12px 0;
  font-weight: 900;
}

.metric-bar-shell {
  height: 16px;
  border-radius: 999px;
  background: #e2e8f0;
  overflow: hidden;
}

.metric-bar-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #06d6a0, #118ab2);
  transition: width 500ms ease;
}

.event-list {
  padding-left: 20px;
  margin: 0;
}

.event-list li {
  margin: 8px 0;
  color: #334155;
  font-weight: 760;
}

.portal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.print-workbook {
  display: none;
}

@media (max-width: 720px) {
  .brand-ribbon {
    padding-right: 14px;
    bottom: auto;
  }

  .parent-corner-btn,
  .language-btn {
    top: auto;
    bottom: calc(16px + var(--safe-bottom));
  }

  .parent-corner-btn {
    right: calc(98px + var(--safe-right));
  }

  .language-btn {
    right: calc(16px + var(--safe-right));
  }

  .welcome-card {
    margin-top: 34px;
    min-height: min(760px, calc(100dvh - 116px));
  }

  .place-grid {
    grid-template-columns: 1fr;
  }

  .place-card {
    min-height: 155px;
  }

  .journey-panel {
    grid-template-columns: 60px minmax(0, 1fr);
  }

  .journey-mascot {
    width: 58px;
    height: 58px;
    font-size: 2.4rem;
  }

  .journey-choices {
    grid-column: 1 / -1;
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .journey-choice {
    min-width: 0;
    min-height: 76px;
  }

  .portal-grid {
    grid-template-columns: 1fr;
  }

  .metric-row {
    grid-template-columns: 1fr;
  }

  .gate-input-row {
    flex-direction: column;
  }
}

@media print {
  html,
  body {
    position: static;
    overflow: visible;
    background: white;
    color: #111827;
    touch-action: auto;
  }

  body > *:not(.print-workbook) {
    display: none !important;
  }

  .print-workbook {
    display: block !important;
    padding: 0;
    font-family: Arial, sans-serif;
  }

  .workbook-page {
    page-break-after: always;
    min-height: 100vh;
    padding: 18mm;
  }

  .workbook-cover {
    border: 4px solid #111827;
    border-radius: 18px;
    min-height: 240mm;
    display: grid;
    place-items: center;
    text-align: center;
    padding: 20mm;
  }

  .workbook-cover h1 {
    font-size: 38pt;
    margin: 0;
  }

  .workbook-cover p {
    font-size: 14pt;
  }

  .trace-symbol {
    font-size: 96pt;
    font-weight: 900;
    color: #d1d5db;
    letter-spacing: 12pt;
    border: 2px dashed #94a3b8;
    border-radius: 16px;
    padding: 8mm;
    min-height: 46mm;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .trace-line {
    height: 22mm;
    border-bottom: 2px dashed #9ca3af;
    margin: 8mm 0;
  }

  .workbook-task {
    border: 2px solid #111827;
    border-radius: 12px;
    padding: 8mm;
    margin: 8mm 0;
    font-size: 14pt;
  }
}

/* ==============================
   V2 Learning Way: guided daily path
   ============================== */
.learning-way-view {
  background:
    radial-gradient(circle at 12% 20%, rgba(255, 209, 102, 0.95), transparent 20%),
    radial-gradient(circle at 86% 18%, rgba(6, 214, 160, 0.38), transparent 22%),
    radial-gradient(circle at 72% 90%, rgba(239, 71, 111, 0.32), transparent 24%),
    linear-gradient(135deg, #e4fbff 0%, #fff8d4 48%, #ffe2f0 100%);
  padding: calc(18px + var(--safe-top)) calc(16px + var(--safe-right)) calc(18px + var(--safe-bottom)) calc(16px + var(--safe-left));
  display: grid;
  place-items: center;
}

.learning-bg-cloud {
  position: absolute;
  pointer-events: none;
  font-size: clamp(64px, 18vw, 180px);
  opacity: 0.22;
  filter: blur(1px);
  animation: sparkleFloat 6s ease-in-out infinite;
}

.cloud-a { left: 5vw; bottom: 8vh; }
.cloud-b { right: 7vw; top: 14vh; animation-delay: -2s; }

.learning-topbar {
  position: absolute;
  top: calc(16px + var(--safe-top));
  left: calc(16px + var(--safe-left));
  right: calc(16px + var(--safe-right));
  z-index: 3;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
}

.learning-title-wrap {
  background: rgba(255,255,255,0.84);
  border: 3px solid rgba(255,255,255,0.74);
  border-radius: 22px;
  padding: 10px 14px;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.12);
}

.learning-title-wrap strong {
  display: block;
  font-size: clamp(1rem, 3vw, 1.45rem);
  color: #111827;
}

.learning-title-wrap small {
  display: block;
  margin-top: 2px;
  color: #475569;
  font-weight: 800;
}

.learning-way-card {
  width: min(96vw, 1060px);
  max-height: calc(100dvh - 112px - var(--safe-top) - var(--safe-bottom));
  overflow: auto;
  overscroll-behavior: contain;
  margin-top: 72px;
  border: 8px solid rgba(255, 255, 255, 0.7);
  border-radius: clamp(28px, 5vw, 54px);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 30px 90px rgba(15, 23, 42, 0.18);
  padding: clamp(16px, 3.5vw, 38px);
  backdrop-filter: blur(18px);
}

.learning-hero-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: clamp(14px, 3vw, 26px);
  align-items: center;
}

.learning-hero-mascot {
  width: clamp(86px, 18vw, 150px);
  height: clamp(86px, 18vw, 150px);
  display: grid;
  place-items: center;
  border-radius: 36px;
  background: linear-gradient(135deg, #ffd166, #ff9f1c);
  box-shadow: 0 18px 30px rgba(255, 159, 28, 0.32);
  font-size: clamp(56px, 12vw, 100px);
  animation: lionBounce 3s ease-in-out infinite;
}

.context-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 999px;
  padding: 8px 13px;
  background: #111827;
  color: #fff;
  font-weight: 1000;
  letter-spacing: 0.02em;
}

.learning-hero-row h2 {
  margin: 10px 0 4px;
  color: #111827;
  font-size: clamp(2rem, 6vw, 4.4rem);
  line-height: 0.94;
  letter-spacing: -0.06em;
}

.learning-hero-row p {
  margin: 0;
  color: #475569;
  font-weight: 900;
  font-size: clamp(1rem, 2.8vw, 1.3rem);
}

.learning-path-grid {
  position: relative;
  margin-top: clamp(18px, 4vw, 34px);
  display: grid;
  grid-template-columns: repeat(5, minmax(132px, 1fr));
  gap: clamp(12px, 2.2vw, 20px);
}

.learning-path-grid::before {
  content: "";
  position: absolute;
  left: 4%;
  right: 4%;
  top: 50%;
  height: 12px;
  border-radius: 999px;
  background: repeating-linear-gradient(90deg, rgba(17,24,39,0.16) 0 18px, rgba(17,24,39,0.04) 18px 32px);
  transform: translateY(-50%);
  z-index: 0;
}

.learning-stop {
  position: relative;
  z-index: 1;
  min-height: 220px;
  border: 5px solid rgba(255, 255, 255, 0.88);
  border-radius: 34px;
  padding: 16px 12px;
  background: linear-gradient(180deg, #ffffff, #fff9e8);
  box-shadow: 0 18px 30px rgba(15, 23, 42, 0.12);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 8px;
  text-align: center;
  color: #111827;
  transform: translateY(0);
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

.learning-stop:nth-child(even) { transform: translateY(22px); }
.learning-stop:hover,
.learning-stop:focus-visible,
.learning-stop.active {
  transform: translateY(-8px) scale(1.03);
  border-color: #ffd166;
  box-shadow: 0 24px 40px rgba(255, 159, 28, 0.28);
  outline: none;
}
.learning-stop:nth-child(even):hover,
.learning-stop:nth-child(even):focus-visible,
.learning-stop:nth-child(even).active { transform: translateY(10px) scale(1.03); }

.learning-step-number {
  position: absolute;
  top: 10px;
  left: 12px;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: #111827;
  color: #fff;
  font-weight: 1000;
}

.learning-stop-emoji {
  display: block;
  font-size: clamp(48px, 8vw, 76px);
  filter: drop-shadow(0 9px 9px rgba(15, 23, 42, 0.14));
}

.learning-stop strong {
  font-size: clamp(1.05rem, 2.2vw, 1.34rem);
  line-height: 1.02;
}

.learning-stop small {
  color: #475569;
  font-weight: 900;
  line-height: 1.15;
}

.learning-stop em {
  margin-top: 4px;
  color: #0f766e;
  font-size: 0.78rem;
  font-style: normal;
  font-weight: 1000;
  line-height: 1.2;
}

.learning-coach-strip {
  margin-top: clamp(24px, 4vw, 42px);
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 12px;
  border-radius: 24px;
  padding: 14px 16px;
  background: #f0fdfa;
  color: #134e4a;
  border: 3px solid rgba(20, 184, 166, 0.18);
  font-weight: 1000;
}

.learning-coach-strip p { margin: 0; }

.learning-start-btn {
  width: 100%;
  margin-top: 18px;
  min-height: 72px;
  border: 0;
  border-radius: 24px;
  background: linear-gradient(135deg, #111827, #374151);
  color: #fff;
  font-size: clamp(1.25rem, 4vw, 2rem);
  font-weight: 1000;
  box-shadow: 0 20px 38px rgba(17, 24, 39, 0.24);
}

.lesson-badge,
.mission-badge {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  border-radius: 999px;
  padding: 6px 12px;
  background: rgba(255,255,255,0.85);
  color: #111827;
  font-weight: 1000;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.12);
}

.lesson-badge { max-width: min(76vw, 360px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mission-badge { background: #111827; color: #fff; }

.mission-glow {
  animation: missionGlow 1.6s ease-in-out;
}

@keyframes missionGlow {
  0%, 100% { box-shadow: 0 16px 34px rgba(15, 23, 42, 0.16); }
  45% { box-shadow: 0 0 0 10px rgba(255, 209, 102, 0.28), 0 26px 48px rgba(255, 159, 28, 0.38); }
}

@media (max-width: 900px) {
  .learning-way-card { margin-top: 84px; }
  .learning-path-grid {
    grid-template-columns: repeat(2, minmax(132px, 1fr));
  }
  .learning-path-grid::before { display: none; }
  .learning-stop,
  .learning-stop:nth-child(even) { min-height: 185px; transform: none; }
  .learning-stop:hover,
  .learning-stop:focus-visible,
  .learning-stop.active,
  .learning-stop:nth-child(even):hover,
  .learning-stop:nth-child(even):focus-visible,
  .learning-stop:nth-child(even).active { transform: scale(1.02); }
}

@media (max-width: 560px) {
  .learning-topbar { grid-template-columns: auto 1fr auto; gap: 7px; }
  .learning-title-wrap small { display: none; }
  .learning-hero-row { grid-template-columns: 1fr; text-align: center; justify-items: center; }
  .learning-path-grid { grid-template-columns: 1fr; }
  .learning-stop { min-height: 150px; }
}

/* ===== V3 app shell upgrades ===== */
body {
  background:
    radial-gradient(circle at 12% 12%, rgba(255,209,102,0.26), transparent 22%),
    radial-gradient(circle at 86% 8%, rgba(17,138,178,0.18), transparent 24%),
    #151515;
}

.app-home-card {
  min-height: min(820px, 86dvh);
  padding-bottom: calc(92px + var(--safe-bottom));
}

.home-native-bar {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.home-native-pill {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  border-radius: 999px;
  background: rgba(17,24,39,0.08);
  padding: 8px 12px;
  color: #334155;
  font-size: 0.82rem;
  font-weight: 900;
}

.home-native-dots {
  display: inline-flex;
  gap: 6px;
}

.home-native-dots i {
  width: 10px;
  height: 10px;
  display: block;
  border-radius: 999px;
  background: rgba(15,23,42,0.14);
}

.home-hero-grid {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(260px, 340px) 1fr;
  gap: clamp(18px, 4vw, 32px);
  align-items: center;
}

.home-character-panel {
  display: grid;
  gap: 14px;
}

.character-stage {
  position: relative;
  min-height: clamp(240px, 32vh, 320px);
  border-radius: 38px;
  background: linear-gradient(145deg, #fff5c7, #e0f2fe 60%, #fce7f3);
  overflow: hidden;
  display: grid;
  place-items: center;
  box-shadow: inset 0 -18px 30px rgba(255,255,255,0.62), 0 24px 44px rgba(15,23,42,0.12);
}

.character-asset {
  position: relative;
  z-index: 3;
  width: min(82%, 290px);
  max-height: 80%;
  object-fit: contain;
  filter: drop-shadow(0 20px 22px rgba(15,23,42,0.18));
}

.character-fallback {
  position: relative;
  z-index: 3;
  font-size: clamp(92px, 18vw, 164px);
  filter: drop-shadow(0 20px 22px rgba(15,23,42,0.18));
  animation: lionBounce 2.8s ease-in-out infinite;
}

.character-ring {
  position: absolute;
  inset: 12%;
  border-radius: 999px;
  border: 8px dashed rgba(255,255,255,0.5);
}

.ring-a { animation: rotateOrbit 16s linear infinite; }
.ring-b {
  inset: 20%;
  border-style: dotted;
  border-color: rgba(255,159,28,0.36);
  animation: rotateOrbit 12s linear infinite reverse;
}

.character-spark {
  position: absolute;
  z-index: 4;
  font-size: clamp(24px, 5vw, 38px);
  animation: sparkleFloat 3.2s ease-in-out infinite;
}

.spark-a { left: 14%; top: 16%; }
.spark-b { right: 16%; bottom: 14%; animation-delay: -1.2s; }

.character-slot-card {
  padding: 14px 16px;
  border-radius: 24px;
  background: rgba(255,255,255,0.78);
  border: 2px solid rgba(17,24,39,0.06);
  text-align: left;
}

.character-slot-card strong {
  display: block;
  font-size: 1.2rem;
  color: #0f172a;
}

.character-slot-card p {
  margin-top: 6px;
  color: #475569;
  font-weight: 800;
  line-height: 1.3;
}

.home-copy-panel {
  display: grid;
  gap: 16px;
  text-align: left;
}

.home-pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.home-pill {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(17,24,39,0.06);
  color: #0f172a;
  font-size: 0.82rem;
  font-weight: 1000;
}

.home-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.stat-card {
  min-height: 96px;
  border-radius: 24px;
  padding: 16px 14px;
  background: rgba(255,255,255,0.82);
  border: 2px solid rgba(17,24,39,0.06);
  display: grid;
  gap: 4px;
  place-items: center;
  text-align: center;
}

.stat-card strong {
  font-size: clamp(1.4rem, 4vw, 2.1rem);
  color: #0f172a;
}

.stat-card span {
  color: #475569;
  font-size: 0.82rem;
  font-weight: 900;
}

.quick-action-row {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.quick-action-btn,
.continue-play-btn {
  border: 0;
  border-radius: 24px;
  min-height: 64px;
  padding: 12px 14px;
  font-weight: 1000;
  box-shadow: 0 16px 28px rgba(15,23,42,0.08);
}

.quick-action-btn {
  background: rgba(255,255,255,0.88);
  color: #0f172a;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.quick-action-btn span:first-child {
  font-size: 1.35rem;
}

.continue-row {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: stretch;
}

.continue-card {
  border-radius: 28px;
  padding: 16px 18px;
  background: linear-gradient(135deg, rgba(17,24,39,0.96), rgba(51,65,85,0.96));
  color: white;
  text-align: left;
  box-shadow: 0 22px 42px rgba(17,24,39,0.18);
}

.continue-card strong {
  display: block;
  font-size: 1.1rem;
}

.continue-card p {
  margin-top: 6px;
  color: #dbeafe;
  font-weight: 800;
}

.continue-play-btn {
  min-width: 126px;
  background: linear-gradient(135deg, #06d6a0, #118ab2);
  color: white;
  font-size: 1rem;
}

.learning-hero-mascot-wrap,
.journey-mascot-wrap {
  position: relative;
  width: clamp(86px, 18vw, 150px);
  height: clamp(86px, 18vw, 150px);
  display: grid;
  place-items: center;
}

.learning-hero-mascot-wrap .character-asset,
.journey-mascot-wrap .character-asset {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.journey-mascot-wrap {
  width: clamp(72px, 12vw, 110px);
  height: clamp(72px, 12vw, 110px);
}

.sheet-modal {
  position: fixed;
  inset: 0;
  z-index: 40;
}

.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15,23,42,0.44);
  backdrop-filter: blur(10px);
}

.sheet-card {
  position: absolute;
  left: clamp(12px, 2vw, 24px);
  right: clamp(12px, 2vw, 24px);
  bottom: calc(88px + var(--safe-bottom));
  max-height: min(72dvh, 760px);
  overflow: auto;
  border-radius: 34px 34px 18px 18px;
  background: rgba(255,255,255,0.95);
  padding: 18px;
  box-shadow: 0 -16px 44px rgba(15,23,42,0.22);
}

.sheet-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.sheet-top strong {
  display: block;
  font-size: clamp(1.3rem, 3vw, 1.8rem);
}

.sheet-top p {
  margin: 6px 0 0;
  color: #475569;
  font-weight: 800;
}

.sheet-close-btn {
  border: 0;
  width: 42px;
  height: 42px;
  border-radius: 999px;
  background: rgba(17,24,39,0.08);
  font-size: 1.2rem;
}

.sheet-grid,
.reward-badge-grid {
  display: grid;
  gap: 18px;
  margin-top: 18px;
}

.sheet-section h3 {
  margin: 0 0 12px;
  color: #0f172a;
  font-size: 1rem;
}

.sheet-world-grid,
.reward-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.sheet-world-card,
.reward-summary-card,
.reward-badge-card {
  border: 0;
  border-radius: 24px;
  padding: 16px;
  background: linear-gradient(145deg, #ffffff, #eef8ff);
  box-shadow: 0 16px 28px rgba(15,23,42,0.08);
  text-align: left;
}

.sheet-world-card {
  min-height: 134px;
  display: grid;
  align-content: start;
  gap: 6px;
}

.sheet-world-emoji,
.reward-badge-emoji {
  font-size: 2rem;
}

.sheet-world-card strong,
.reward-badge-card strong {
  color: #0f172a;
  font-size: 1rem;
}

.sheet-world-card small,
.reward-badge-card p {
  color: #475569;
  font-weight: 800;
  line-height: 1.25;
}

.reward-summary-card {
  text-align: center;
  min-height: 100px;
  display: grid;
  place-items: center;
}

.reward-summary-card strong {
  font-size: clamp(1.5rem, 4vw, 2.2rem);
}

.reward-summary-card span {
  color: #475569;
  font-weight: 900;
}

.reward-badge-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.reward-badge-card {
  min-height: 144px;
  display: grid;
  align-content: start;
  gap: 8px;
  border: 2px solid rgba(15,23,42,0.04);
}

.reward-badge-card.is-active {
  background: linear-gradient(145deg, #fff7cc, #e0fff3);
  border-color: rgba(6,214,160,0.26);
}

.app-tabbar {
  position: fixed;
  left: max(12px, calc(12px + var(--safe-left)));
  right: max(12px, calc(12px + var(--safe-right)));
  bottom: max(10px, calc(10px + var(--safe-bottom)));
  z-index: 45;
  min-height: 72px;
  padding: 8px;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  border-radius: 26px;
  background: rgba(17,24,39,0.94);
  box-shadow: 0 18px 40px rgba(0,0,0,0.25);
}

.tab-btn {
  border: 0;
  border-radius: 18px;
  background: transparent;
  color: rgba(255,255,255,0.78);
  display: grid;
  place-items: center;
  gap: 2px;
  padding: 8px 4px;
  font-weight: 900;
}

.tab-btn span {
  font-size: 1.3rem;
  line-height: 1;
}

.tab-btn small {
  font-size: 0.72rem;
}

.tab-btn.active {
  background: rgba(255,255,255,0.12);
  color: white;
}

.tab-btn-primary {
  background: linear-gradient(135deg, #06d6a0, #118ab2);
  color: white;
}

@media (max-width: 900px) {
  .home-hero-grid {
    grid-template-columns: 1fr;
  }

  .home-copy-panel {
    text-align: center;
  }
}

@media (max-width: 680px) {
  .quick-action-row,
  .continue-row,
  .sheet-world-grid,
  .reward-summary-grid,
  .reward-badge-grid {
    grid-template-columns: 1fr;
  }

  .home-stats-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .brand-ribbon {
    padding-right: 128px;
  }

  .parent-corner-btn {
    right: calc(80px + var(--safe-right));
  }
}

@media (max-width: 520px) {
  .app-home-card {
    min-height: 100dvh;
    width: 100vw;
    margin-top: 0;
    border-width: 0;
    border-radius: 0;
    padding-top: 86px;
  }

  .welcome-view {
    padding: 0;
  }

  .brand-ribbon {
    top: calc(8px + var(--safe-top));
    left: calc(8px + var(--safe-left));
    right: calc(8px + var(--safe-right));
    min-height: 44px;
    border-radius: 16px;
  }

  .parent-corner-btn,
  .language-btn {
    top: calc(64px + var(--safe-top));
  }

  .character-stage {
    min-height: 220px;
  }

  .app-tabbar {
    gap: 4px;
    border-radius: 22px;
  }

  .tab-btn small {
    font-size: 0.64rem;
  }
}
