/* 彩虹英語小學堂 — colorful, mobile-first, no external fonts */
:root {
  --sky: #3d9ad6;
  --sky-deep: #1f6fa8;
  --sun: #ffd166;
  --coral: #ff6b6b;
  --mint: #12c48b;
  --grape: #7b6cf6;
  --peach: #ff8c69;
  --cream: #fff7ec;
  --cream-2: #ffe9c7;
  --ink: #2c3144;
  --muted: #5c6478;
  --line: #eadfcf;
  --card: #ffffff;
  --ok: #0f9f6e;
  --bad: #e03131;
  --shadow: 0 10px 30px rgba(44, 49, 68, 0.1);
  --radius: 22px;
  --nav-h: 64px;
  --font: "Noto Sans TC", "PingFang TC", "Hiragino Sans TC", "Microsoft JhengHei",
    "Heiti TC", "Source Han Sans TC", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(900px 420px at -10% -10%, #ffe08a 0%, transparent 55%),
    radial-gradient(800px 480px at 110% 0%, #9ad7ff 0%, transparent 50%),
    radial-gradient(700px 400px at 100% 100%, #ffc2b3 0%, transparent 46%),
    var(--cream);
  min-height: 100vh;
  line-height: 1.65;
  font-size: 17px;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: radial-gradient(rgba(255,255,255,.55) 1px, transparent 1px);
  background-size: 22px 22px;
  opacity: .35;
  z-index: 0;
}
img { max-width: 100%; }
button, input { font-family: inherit; }
a { color: var(--sky-deep); }

.skip {
  position: absolute; left: -999px; top: 0;
  background: #000; color: #fff; padding: 8px 12px; z-index: 100;
}
.skip:focus { left: 8px; top: 8px; }

.wrap { width: min(1100px, calc(100% - 28px)); margin: 0 auto; }
main#app {
  position: relative;
  z-index: 1;
  min-height: 55vh;
  padding: 20px 0 112px;
}
main#app:focus { outline: none; }

/* Header */
.site-header {
  position: relative; z-index: 5;
  background: rgba(255,255,255,.78);
  backdrop-filter: blur(14px);
  border-bottom: 3px solid transparent;
  border-image: linear-gradient(90deg, #ff6b6b, #ffd166, #12c48b, #3d9ad6, #7b6cf6) 1;
  box-shadow: 0 2px 16px rgba(44,49,68,.06);
}
.header-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 10px 0;
}
.logo {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none; color: inherit;
}
.logo-mark {
  width: 48px; height: 48px; flex: none;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,.08));
}
.logo b { display: block; font-size: 1.12rem; letter-spacing: .02em; }
.logo small { color: var(--muted); font-size: .78rem; }

.star-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: #fff6d6; color: #8a5a00;
  border: 2px solid #ffd166; border-radius: 999px;
  padding: 6px 12px; font-weight: 800; text-decoration: none;
  box-shadow: 0 3px 0 #f0b429;
}
.star-chip:active { transform: translateY(2px); box-shadow: none; }

.nav-desktop { display: none; gap: 6px; flex-wrap: wrap; }
.nav-desktop a {
  text-decoration: none; color: var(--ink);
  padding: 8px 12px; border-radius: 999px; font-weight: 700; font-size: .95rem;
}
.nav-desktop a:hover, .nav-desktop a.active {
  background: #e8f5ff; color: var(--sky-deep);
}

.nav-bottom {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(6, 1fr);
  background: #fff;
  border-top: 2px solid var(--line);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  box-shadow: 0 -8px 24px rgba(44,49,68,.08);
}
.nav-bottom a {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  text-decoration: none; color: var(--muted);
  font-size: .68rem; font-weight: 800; padding: 4px 2px; border-radius: 12px;
}
.nav-bottom a span { font-size: 1.2rem; line-height: 1; }
.nav-bottom a.active { color: var(--sky-deep); background: #eef7ff; }

/* Hero & cards */
.hero {
  display: grid; gap: 22px; align-items: center;
  background: linear-gradient(145deg, #fff 0%, #fff3d4 55%, #d9f3ff 100%);
  border: 3px solid #fff; border-radius: 32px;
  padding: 26px 24px; box-shadow: var(--shadow);
  margin-bottom: 22px;
}
.hero h1 { margin: 0 0 8px; font-size: clamp(1.6rem, 4vw, 2.25rem); line-height: 1.25; }
.hero p { margin: 0 0 12px; color: var(--muted); }
.kicker {
  display: inline-block; background: #7b6cf6; color: #fff;
  font-weight: 800; font-size: .8rem; border-radius: 999px;
  padding: 4px 10px; margin-bottom: 10px;
}
.hero-art { justify-self: center; width: min(280px, 100%); }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }

.btn {
  appearance: none; border: 0; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 18px; border-radius: 16px; font-weight: 800;
  font-size: 1rem; text-decoration: none; color: #fff;
  background: var(--sky); box-shadow: 0 4px 0 var(--sky-deep);
  transition: transform .12s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(3px); box-shadow: none; }
.btn-sun { background: #f0b429; color: #4a3200; box-shadow: 0 4px 0 #c49012; }
.btn-mint { background: var(--mint); box-shadow: 0 4px 0 #0b8a62; }
.btn-coral { background: var(--coral); box-shadow: 0 4px 0 #cc4545; }
.btn-grape { background: var(--grape); box-shadow: 0 4px 0 #5648c7; }
.btn-ghost {
  background: #fff; color: var(--ink);
  border: 2px solid var(--line); box-shadow: 0 3px 0 #e2d6c3;
}
.btn[disabled], .btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: 1fr; }
.grid-3 { grid-template-columns: 1fr; }
.grid-4 { grid-template-columns: 1fr 1fr; }

.card, .theme-card, .feature, .story-card {
  background: var(--card); border-radius: var(--radius);
  border: 3px solid #fff; box-shadow: var(--shadow);
  padding: 18px;
}
.feature h3, .theme-card h3, .story-card h3 { margin: 8px 0 6px; }
.muted { color: var(--muted); }
.center { text-align: center; }

.feature { text-decoration: none; color: inherit; display: block; position: relative; overflow: hidden; }
.feature:hover { transform: translateY(-3px); }
.feature .ico {
  width: 52px; height: 52px; border-radius: 16px;
  display: grid; place-items: center; font-size: 1.6rem;
}
.feature.f1 .ico { background: #d8f1ff; }
.feature.f2 .ico { background: #ffe0e0; }
.feature.f3 .ico { background: #e2ffe8; }
.feature.f4 .ico { background: #eee6ff; }

.theme-card { text-decoration: none; color: inherit; display: block; }
.theme-card:hover, .story-card:hover, .feature:hover { outline: 3px solid #ffe08a; }
.theme-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.emoji-lg { font-size: 2rem; }
.bar { height: 10px; background: #f1e8da; border-radius: 999px; overflow: hidden; margin-top: 10px; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, #ffd166, #12c48b); border-radius: inherit; }

.badge {
  display: inline-block; font-size: .75rem; font-weight: 800;
  padding: 3px 8px; border-radius: 999px; background: #eef7ff; color: var(--sky-deep);
}
.badge.lv2 { background: #fff3d0; color: #8a5a00; }
.badge.lv3 { background: #ffe0e0; color: #9b1c1c; }

h2.page-title { margin: 4px 0 6px; font-size: clamp(1.4rem, 3vw, 1.9rem); }
.lead { margin: 0 0 18px; color: var(--muted); }

/* Flashcards */
.card-stage { perspective: 1200px; margin: 12px auto; max-width: 560px; }
.flash {
  position: relative; min-height: 320px; transform-style: preserve-3d;
  transition: transform .55s cubic-bezier(.2,.8,.2,1);
  cursor: pointer;
}
.flash.flipped { transform: rotateY(180deg); }
.flash-face {
  position: absolute; inset: 0; backface-visibility: hidden;
  background: #fff; border-radius: 28px; border: 4px solid #fff;
  box-shadow: var(--shadow); padding: 28px 22px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; gap: 8px;
}
.flash-face.back { transform: rotateY(180deg); background: linear-gradient(180deg, #fff, #eef9ff); }
.word-en { font-size: clamp(2.1rem, 7vw, 3.3rem); font-weight: 900; letter-spacing: .02em; margin: 0; line-height: 1.15; }
.ipa { color: var(--grape); font-weight: 700; }
.pos { background: #f3eefe; color: #4a3db0; border-radius: 999px; padding: 2px 10px; font-size: .85rem; font-weight: 800; }
.zh-lg { font-size: 2rem; font-weight: 900; margin: 0; color: var(--sky-deep); }
.example { font-size: 1.15rem; font-weight: 700; margin: 8px 0 0; }
.controls { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 14px; }
.dots { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin: 10px 0; }
.dots button {
  width: 14px; height: 14px; border-radius: 50%; border: 0; padding: 0;
  background: #e5dccc; cursor: pointer;
}
.dots button.on { background: var(--sky); transform: scale(1.2); }
.dots button.known { background: var(--mint); }

/* Quiz */
.q-card { max-width: 680px; margin: 0 auto; }
.q-num { font-weight: 800; color: var(--muted); }
.options { display: grid; gap: 10px; margin-top: 14px; }
.opt {
  text-align: left; background: #fff; border: 3px solid #efe6d6;
  border-radius: 16px; padding: 14px 16px; font-weight: 800; cursor: pointer;
  box-shadow: 0 3px 0 #efe6d6;
}
.opt:hover:not(:disabled) { border-color: var(--sky); }
.opt.correct { background: #d9f8ea; border-color: var(--ok); color: #065f46; }
.opt.wrong { background: #ffe1e1; border-color: var(--bad); color: #9b1c1c; }
.opt:disabled { cursor: default; }
.spell-input {
  width: 100%; font-size: 1.4rem; font-weight: 800; padding: 14px;
  border-radius: 16px; border: 3px solid #efe6d6; text-align: center;
}
.spell-input:focus { outline: none; border-color: var(--sky); }
.feedback { margin-top: 14px; padding: 12px 14px; border-radius: 14px; font-weight: 800; }
.feedback.ok { background: #d9f8ea; color: #065f46; }
.feedback.bad { background: #ffe1e1; color: #9b1c1c; }
.result { text-align: center; padding: 28px 12px; }
.result .big { font-size: 3.2rem; margin: 0; }
.speak-xl {
  width: 96px; height: 96px; border-radius: 50%; border: 0;
  background: #e8f5ff; font-size: 2.4rem; cursor: pointer;
  box-shadow: 0 5px 0 #b9dcf3; margin: 8px auto 14px; display: grid; place-items: center;
}

/* Games */
.board {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px;
  max-width: 640px; margin: 14px auto;
}
.mcard {
  aspect-ratio: 1; border: 0; border-radius: 16px; cursor: pointer;
  background: linear-gradient(160deg, #3d9ad6, #7b6cf6); color: #fff;
  font-weight: 900; font-size: clamp(.85rem, 2.6vw, 1.05rem);
  box-shadow: 0 4px 0 #35548a; padding: 8px;
}
.mcard .backface { display: none; }
.mcard.on, .mcard.match {
  background: #fff; color: var(--ink); box-shadow: 0 4px 0 #d7cbb6;
}
.mcard.on .backface, .mcard.match .backface { display: block; }
.mcard.match { background: #e5fff3; }
.mcard:disabled { cursor: default; }

.tiles, .slots { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 12px 0; }
.tile, .slot {
  min-width: 44px; min-height: 48px; padding: 8px 10px;
  border-radius: 12px; font-size: 1.3rem; font-weight: 900;
  border: 0; cursor: pointer;
}
.tile { background: #fff3c4; box-shadow: 0 3px 0 #e0c35a; }
.tile:disabled { opacity: .25; }
.slot { background: #fff; border: 3px dashed #e5dccc; min-width: 46px; }
.slot.filled { border-style: solid; border-color: var(--sky); }

.timer {
  font-size: 2rem; font-weight: 900; color: var(--coral);
  background: #fff; display: inline-block; padding: 4px 16px;
  border-radius: 999px; border: 3px solid #ffd3d3;
}

/* Stories */
.sentence {
  background: #fff; border-radius: 16px; padding: 12px 14px; margin: 8px 0;
  border: 2px solid #f0e6d6; cursor: pointer;
}
.sentence.current { border-color: var(--sky); background: #eef8ff; box-shadow: 0 0 0 4px #d4eeff; }
.sentence .en { font-size: 1.15rem; font-weight: 800; line-height: 1.8; }
.sentence .zh { color: var(--muted); font-size: .95rem; margin-top: 4px; }
.word-tip {
  appearance: none; background: transparent; border: 0; padding: 0 1px;
  font: inherit; font-weight: 800; color: inherit; cursor: pointer;
  border-bottom: 2px dotted #7b6cf6; border-radius: 0;
}
.word-tip:hover, .word-tip:focus { background: #fff3c4; border-radius: 6px; }
.word-pop {
  position: fixed; z-index: 50; background: #2c3144; color: #fff;
  padding: 8px 12px; border-radius: 12px; box-shadow: var(--shadow);
  font-size: .95rem; max-width: 240px; pointer-events: none;
}
.word-pop b { display: block; color: #ffd166; }

/* Progress */
.stat {
  background: #fff; border-radius: 18px; padding: 14px; text-align: center;
  box-shadow: var(--shadow);
}
.stat b { display: block; font-size: 1.8rem; }

.site-footer {
  position: relative; z-index: 1;
  padding: 20px 0 110px; color: var(--muted); text-align: center; font-size: .9rem;
}

.toast {
  position: fixed; left: 50%; bottom: 86px; transform: translateX(-50%);
  background: #2c3144; color: #fff; padding: 10px 16px; border-radius: 999px;
  z-index: 40; font-weight: 800; opacity: 0; pointer-events: none;
  transition: opacity .25s ease;
}
.toast.show { opacity: 1; }

.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 60; overflow: hidden; }
.confetti i {
  position: absolute; top: -12px; width: 10px; height: 16px; border-radius: 2px;
  animation: fall 1.6s linear forwards;
}
@keyframes fall {
  to { transform: translateY(110vh) rotate(420deg); opacity: .85; }
}

@media (min-width: 760px) {
  .hero { grid-template-columns: 1.15fr .85fr; padding: 34px 36px; }
  .grid-2 { grid-template-columns: 1fr 1fr; }
  .grid-3 { grid-template-columns: repeat(3, 1fr); }
  .grid-4 { grid-template-columns: repeat(4, 1fr); }
  .nav-desktop { display: flex; }
  .nav-bottom { display: none; }
  main#app { padding-bottom: 40px; }
  .site-footer { padding-bottom: 36px; }
  .toast { bottom: 28px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important; transition: none !important;
  }
  .flash { transition: none; }
}
