/* English World Next P2 — mobile-first styles.
 * Tokens: ocean blue #166B9A, coral #FF7A45, sunny #FFC93C,
 * cream #FFF8EE, dark text #17301F. Base width 375px-safe:
 * nothing exceeds 100% width, no horizontal scroll. */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, "PingFang SC", "Noto Sans SC", system-ui, sans-serif;
  background: #FFF8EE; color: #17301F; font-size: 16px; line-height: 1.5;
}
#app { max-width: 430px; margin: 0 auto; padding: 12px 16px 32px; min-height: 100vh; }
.topbar { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.logo { font-weight: 800; font-size: 19px; color: #166B9A; }
.logo span { color: #FF7A45; }
.demo-badge {
  background: #FFC93C; color: #17301F; font-size: 12px; font-weight: 700;
  padding: 2px 8px; border-radius: 999px; white-space: nowrap;
}
.card {
  background: #fff; border-radius: 20px; padding: 16px;
  box-shadow: 0 2px 10px rgba(22, 107, 154, 0.10); margin-bottom: 12px;
}
.card h2 { margin: 0 0 8px; font-size: 18px; }
.card h3 { margin: 12px 0 6px; font-size: 16px; }
.muted { color: #5a6b62; font-size: 14px; }
.btn {
  display: block; width: 100%; min-height: 52px; border: none; border-radius: 16px;
  font-size: 17px; font-weight: 700; cursor: pointer; padding: 10px 16px;
  margin: 8px 0; text-align: center;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: #FF7A45; color: #fff; }
.btn-blue { background: #166B9A; color: #fff; }
.btn-ghost { background: #EAF3F0; color: #166B9A; }
.btn:disabled { opacity: 0.45; cursor: default; transform: none; }
.btn-row { display: flex; gap: 8px; }
.btn-row .btn { margin: 4px 0; }
input[type="text"], input[type="password"] {
  width: 100%; min-height: 48px; border: 2px solid #D9E8E2; border-radius: 12px;
  padding: 8px 12px; font-size: 16px; margin: 6px 0;
}
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.chip {
  border: 2px solid #D9E8E2; background: #fff; border-radius: 999px;
  padding: 8px 14px; font-size: 14px; cursor: pointer; min-height: 40px;
}
.chip.on { background: #166B9A; color: #fff; border-color: #166B9A; }
.stat-row { display: flex; gap: 8px; }
.stat { flex: 1; background: #EAF3F0; border-radius: 14px; padding: 10px 8px; text-align: center; }
.stat b { display: block; font-size: 20px; color: #166B9A; }
.stat span { font-size: 12px; color: #5a6b62; }
.progress { height: 12px; background: #E7E0D2; border-radius: 999px; overflow: hidden; }
.progress i { display: block; height: 100%; background: #166B9A; border-radius: 999px; }
.hearts { font-size: 20px; letter-spacing: 2px; }
.hearts .lost { opacity: 0.25; }
/* Map path */
.map { position: relative; padding-left: 8px; }
.node {
  display: flex; align-items: center; gap: 12px; width: 100%;
  background: #fff; border: 2px solid #E7E0D2; border-radius: 18px;
  padding: 12px; margin: 0 0 10px; cursor: pointer; text-align: left;
  font-size: 16px; font-family: inherit; color: inherit;
}
.node .dot {
  width: 44px; height: 44px; border-radius: 50%; flex: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 800; background: #E7E0D2; color: #5a6b62;
}
.node.done { border-color: #166B9A; }
.node.done .dot { background: #166B9A; color: #fff; }
.node.current { border-color: #FF7A45; box-shadow: 0 0 0 3px rgba(255, 122, 69, 0.25); }
.node.current .dot { background: #FF7A45; color: #fff; animation: pulse 1.6s infinite; }
.node.locked { opacity: 0.6; }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.1); } }
/* Quiz */
.q-stem { font-size: 19px; font-weight: 700; margin: 8px 0; }
.q-pic { font-size: 64px; text-align: center; margin: 8px 0; }
.opt {
  display: block; width: 100%; min-height: 52px; text-align: left;
  background: #fff; border: 2px solid #D9E8E2; border-radius: 14px;
  padding: 10px 14px; margin: 8px 0; font-size: 16px; cursor: pointer;
  font-family: inherit; color: inherit;
}
.opt.sel { border-color: #166B9A; background: #EAF3F0; }
.opt.ok { border-color: #1d8a4f; background: #E3F5EA; }
.opt.bad { border-color: #d64545; background: #FDECEC; }
.tile {
  display: inline-block; min-height: 48px; border: 2px solid #166B9A;
  background: #fff; border-radius: 12px; padding: 10px 14px; margin: 4px;
  font-size: 16px; cursor: pointer; font-family: inherit;
}
.tile.used { opacity: 0.35; }
.built {
  min-height: 52px; border: 2px dashed #D9E8E2; border-radius: 12px;
  padding: 8px 10px; margin: 8px 0; font-size: 17px;
}
.feedback { border-radius: 16px; padding: 14px; margin: 12px 0; }
.feedback.ok { background: #E3F5EA; border: 2px solid #1d8a4f; }
.feedback.bad { background: #FDECEC; border: 2px solid #d64545; }
.feedback b { font-size: 17px; }
.modal-bg {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.45);
  display: flex; align-items: flex-end; justify-content: center; z-index: 10;
}
.modal {
  background: #fff; width: 100%; max-width: 430px; border-radius: 24px 24px 0 0;
  padding: 20px 16px 32px;
}
.yaya-row { display: flex; align-items: center; gap: 12px; }
.yaya-row p { margin: 0; }
.stars { font-size: 34px; letter-spacing: 6px; text-align: center; }
.stars .off { opacity: 0.25; }
@media (min-width: 700px) {
  #app { max-width: 720px; }
  .modal { border-radius: 24px; margin-bottom: 40px; }
}
/* P4.2 course map: same tokens as the rest of the app; no fixed
 * widths (375px-safe, grid fractions only). */
.dir-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.dir-card {
  background: #fff; border: 2px solid #E7E0D2; border-radius: 18px;
  padding: 14px 12px; cursor: pointer; text-align: left;
  font-size: 16px; font-family: inherit; color: inherit;
  display: flex; flex-direction: column; gap: 6px;
}
.dir-card:active { transform: scale(0.98); }
.lvl-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.badge {
  font-size: 13px; font-weight: 700; padding: 2px 10px; border-radius: 999px;
  background: #E7E0D2; color: #5a6b62; white-space: nowrap;
}
.badge.done { background: #166B9A; color: #fff; }
.badge.current { background: #FF7A45; color: #fff; }


/* P4.5 animation system: transform/opacity only (GPU-friendly, no
 * layout work), every animation <= 0.6s, none blocks input (the
 * elements stay clickable throughout). Triggers live in app.js and
 * follow the P4.4 character-state mapping: correct -> pop, wrong
 * -> shake, streak -> pulse, stars -> staggered pop, coin ->
 * bounce, newly unlocked node -> glow pulse. */
@keyframes p45-pop {
  0% { transform: scale(0.92); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}
@keyframes p45-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}
@keyframes p45-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.08); opacity: 0.85; }
}
@keyframes p45-star {
  0% { transform: scale(0.3); opacity: 0; }
  70% { transform: scale(1.25); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}
@keyframes p45-coin {
  0% { transform: translateY(8px) scale(0.8); opacity: 0; }
  60% { transform: translateY(-3px) scale(1.1); opacity: 1; }
  100% { transform: translateY(0) scale(1); opacity: 1; }
}
@keyframes p45-unlock {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.03); opacity: 0.8; }
}
.anim-pop { animation: p45-pop 0.35s ease-out; }
.anim-shake { animation: p45-shake 0.4s ease-in-out; }
.anim-pulse { animation: p45-pulse 0.6s ease-in-out infinite; }
.anim-star { animation: p45-star 0.5s ease-out both; display: inline-block; }
.anim-coin { animation: p45-coin 0.5s ease-out; display: inline-block; }
.anim-unlock { animation: p45-unlock 0.6s ease-in-out 2; }
.streak-badge {
  background: #FF7A45; color: #fff; font-size: 14px; font-weight: 700;
  padding: 2px 10px; border-radius: 999px; white-space: nowrap;
}
/* P4.5: respect the system reduced-motion setting everywhere. */
@media (prefers-reduced-motion: reduce) {
  .anim-pop, .anim-shake, .anim-pulse, .anim-star, .anim-coin, .anim-unlock {
    animation: none !important;
  }
}

/* P4.7: locked achievements render dimmed, never as unlocked. */
.ach-locked { opacity: .6; }
