:root {
  --ink: #2f1f7a;
  --soft-ink: #6b5f99;
  --purple: #7b4dff;
  --purple-deep: #5c29e6;
  --teal: #20c9c0;
  --gold: #ffc533;
  --cream: #fff8ec;
  --card: rgba(255, 255, 255, 0.82);
  --border: #dcc9ff;
  --shadow: 0 10px 30px rgba(91, 41, 230, 0.16);
  --radius: 28px;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: "Fredoka", system-ui, sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at 20% 0%, #fff6ff 0%, #ece2ff 40%, #d8c8ff 75%, #c7b2ff 100%) fixed;
  min-height: 100vh;
  overflow-x: hidden;
}

img { max-width: 100%; display: block; }

/* twinkling stars behind everything */
.sky { position: fixed; inset: 0; pointer-events: none; z-index: 0; }
.star { position: absolute; color: var(--gold); opacity: .55; animation: twinkle 3.5s ease-in-out infinite; font-size: 22px; }
.star:nth-child(even) { color: #b48cff; }
.s1 { top: 12%; left: 6%; } .s2 { top: 22%; right: 9%; animation-delay: .8s; }
.s3 { top: 58%; left: 4%; animation-delay: 1.6s; } .s4 { top: 70%; right: 6%; animation-delay: .4s; }
.s5 { top: 88%; left: 40%; animation-delay: 2.2s; } .s6 { top: 40%; left: 48%; animation-delay: 1.2s; font-size: 14px; }
@keyframes twinkle { 50% { opacity: .15; transform: scale(.8) rotate(12deg); } }

main, .nav, .footer { position: relative; z-index: 1; }
main { max-width: 1080px; margin: 0 auto; padding: 0 16px 48px; }

/* nav */
.nav { display: flex; align-items: center; justify-content: space-between; max-width: 1080px; margin: 0 auto; padding: 14px 16px; gap: 12px; }
.nav-brand img { height: 52px; width: auto; }
.nav-actions { display: flex; align-items: center; gap: 10px; }
.lang-picker { display: flex; align-items: center; gap: 4px; background: var(--card); border: 2px solid var(--border); border-radius: 999px; padding: 6px 10px; }
.lang-picker select { border: 0; background: transparent; font: inherit; color: var(--ink); font-weight: 600; cursor: pointer; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 999px; padding: 14px 28px; cursor: pointer;
  font: 600 18px "Fredoka", sans-serif; color: #fff; text-decoration: none;
  background: linear-gradient(90deg, #a24bff, var(--purple-deep) 45%, #18a7ff);
  box-shadow: 0 6px 0 rgba(66, 22, 170, .35), 0 10px 24px rgba(92, 41, 230, .3);
  transition: transform .15s ease, box-shadow .15s ease;
}
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(66, 22, 170, .35); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn-small { padding: 10px 18px; font-size: 16px; }
.btn-ghost { background: #3e2370; box-shadow: 0 5px 0 rgba(30, 10, 70, .35); }
.btn-teal { background: linear-gradient(90deg, #12a99f, var(--teal)); box-shadow: 0 5px 0 rgba(10, 110, 100, .35); }

.card { background: var(--card); border: 2px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); backdrop-filter: blur(6px); }

/* hero */
.hero { text-align: center; padding: 24px 0 8px; }
.hero-logo { width: min(360px, 80vw); margin: 0 auto 8px; filter: drop-shadow(0 10px 18px rgba(91, 41, 230, .25)); animation: bob 4s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-8px) rotate(-1deg); } }
h1, h2 { line-height: 1.1; }
.hero h1 { font-size: clamp(32px, 5.5vw, 54px); margin: 8px auto; max-width: 820px; color: var(--purple-deep);
  text-shadow: 0 3px 0 #fff, 0 6px 16px rgba(91, 41, 230, .2); }
.lead { font-size: clamp(17px, 2.2vw, 21px); color: var(--soft-ink); max-width: 720px; margin: 10px auto 22px; line-height: 1.45; }
.hero-actions { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.hint { color: var(--soft-ink); font-size: 15px; }
.hero-clouds { display: flex; justify-content: center; gap: 18px; margin-top: 18px; }
.hero-clouds img { width: 92px; animation: bob 3.6s ease-in-out infinite; }
.hero-clouds img:nth-child(2) { animation-delay: .6s; width: 110px; }
.hero-clouds img:nth-child(3) { animation-delay: 1.2s; }

/* features */
.features, .how { margin-top: 48px; text-align: center; }
.features h2, .how h2 { font-size: clamp(26px, 4vw, 38px); color: var(--purple-deep); }
.feature-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 18px; margin-top: 18px; }
.feature { padding: 22px; }
.feature img { width: 120px; height: 110px; object-fit: contain; margin: 0 auto 8px; }
.feature h3 { margin: 6px 0; font-size: 22px; }
.feature p { margin: 0; color: var(--soft-ink); line-height: 1.45; }

/* how + link */
.steps { list-style: none; padding: 0; margin: 18px auto; max-width: 620px; display: grid; gap: 10px; text-align: left; }
.steps li { display: flex; align-items: center; gap: 12px; background: var(--card); border: 2px solid var(--border); border-radius: 999px; padding: 10px 16px; font-size: 18px; }
.step-n { flex: 0 0 34px; height: 34px; border-radius: 50%; background: var(--purple); color: #fff; display: grid; place-items: center; font-weight: 700; }
.link-card { max-width: 620px; margin: 22px auto 0; padding: 24px; }
.link-card h3 { margin: 0 0 14px; font-size: 24px; }
.link-row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.link-row input {
  flex: 1 1 240px; min-width: 0; border: 3px solid var(--border); border-radius: 999px; padding: 14px 20px;
  font: 600 22px "Fredoka", sans-serif; letter-spacing: 2px; text-transform: uppercase; color: var(--purple-deep); background: #fff;
}
.link-row input:focus { outline: none; border-color: var(--purple); }
.link-status { min-height: 24px; margin: 12px 0 0; color: var(--soft-ink); }
.link-status.error { color: #d0453c; }

/* dashboard */
.profile { display: flex; align-items: center; gap: 18px; padding: 18px 22px; margin-top: 8px; flex-wrap: wrap; }
.avatar { width: 96px; height: 96px; border-radius: 50%; object-fit: cover; background: #fff; border: 4px solid #fff; box-shadow: var(--shadow); }
.profile-text { flex: 1 1 220px; }
.profile-text h1 { margin: 0; font-size: clamp(26px, 4vw, 36px); color: var(--purple-deep); }
.profile-text p { margin: 4px 0 0; color: var(--soft-ink); font-size: 18px; }
.keep-going { text-align: center; color: var(--soft-ink); margin: 18px auto; max-width: 640px; }

.languages { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 18px; }
.lang-card { position: relative; overflow: hidden; padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.lang-card .landmark { position: absolute; right: -14px; top: -6px; width: 150px; opacity: .95; pointer-events: none; }
.lang-head { display: flex; align-items: center; gap: 12px; position: relative; }
.lang-head .flag { width: 46px; height: 46px; border-radius: 50%; box-shadow: 0 3px 8px rgba(0,0,0,.15); }
.lang-head h2 { margin: 0; font-size: 28px; }
.level-pill { align-self: flex-start; position: relative; background: var(--cream); border: 2px solid #ffe2a8; border-radius: 999px; padding: 6px 14px; font-weight: 600; }
.level-pill b { color: var(--purple-deep); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; position: relative; }
.stat { background: rgba(255,255,255,.9); border: 2px solid var(--border); border-radius: 18px; padding: 10px 6px; text-align: center; }
.stat b { display: block; font-size: 24px; color: var(--purple-deep); }
.stat span { font-size: 14px; color: var(--soft-ink); }
.stat.streak b { color: #ff7a1a; }
.last { margin: 0; color: var(--soft-ink); font-size: 15px; }
.empty { text-align: center; padding: 28px; color: var(--soft-ink); font-size: 18px; }

/* words */
.words-view { margin-top: 18px; }
.words-view h2 { color: var(--purple-deep); font-size: clamp(26px, 4vw, 36px); margin: 16px 0; }
.word-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 16px; }
.word-card { padding: 14px; display: flex; flex-direction: column; gap: 6px; }
.word-art { aspect-ratio: 1; border-radius: 20px; background: var(--cream); border: 2px solid #ffe2a8; display: grid; place-items: center; overflow: hidden; }
.word-art img { width: 86%; height: 86%; object-fit: contain; }
.word-top { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.word-card h3 { margin: 4px 0 0; font-size: 24px; color: var(--purple-deep); word-break: break-word; }
.speak { flex: 0 0 auto; width: 42px; height: 42px; border-radius: 50%; border: 0; cursor: pointer; font-size: 19px; color: #fff;
  background: linear-gradient(135deg, #a24bff, var(--purple-deep)); box-shadow: 0 4px 0 rgba(66, 22, 170, .35); }
.phonetic { color: var(--purple); font-size: 14px; }
.translation { color: #0b7a6f; font-weight: 600; }
.room { align-self: flex-start; background: #efe6ff; border-radius: 999px; padding: 2px 10px; font-size: 13px; color: var(--soft-ink); }
.phrase { margin: 4px 0 0; font-size: 15px; color: var(--ink); }
.phrase small { display: block; color: var(--soft-ink); }

/* practice: report + exercises */
.btn-gold { background: linear-gradient(90deg, #ff9d1a, var(--gold)); color: #4a2a00; box-shadow: 0 5px 0 rgba(170, 100, 0, .35); }
.lang-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; position: relative; }
.lang-actions .btn { padding: 12px 10px; font-size: 16px; }
.score-chip { align-self: flex-start; background: #e6fff9; color: #0b7a6f; border-radius: 999px; padding: 2px 10px; font-size: 13px; font-weight: 600; }
.practice-view { margin-top: 18px; }
.practice-view > h2 { color: var(--purple-deep); font-size: clamp(26px, 4vw, 36px); margin: 16px 0; }
.section-title { color: var(--purple-deep); font-size: 24px; margin: 26px 0 12px; }
.report-card { padding: 18px 20px; }
.report-card h3 { margin: 0 0 12px; font-size: 22px; }
.report-card .hint { margin: 10px 0 0; }
.center { text-align: center; display: block; margin-top: 12px; }

.exercise-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.ex-card { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 18px 14px; text-align: center; cursor: pointer;
  font: inherit; color: var(--ink); transition: transform .15s ease, border-color .15s ease; }
.ex-card:hover:not(:disabled) { transform: translateY(-3px); border-color: var(--purple); }
.ex-card:disabled { cursor: not-allowed; opacity: .6; }
.ex-card b { font-size: 20px; color: var(--purple-deep); }
.ex-card span:not(.ex-icon) { color: var(--soft-ink); font-size: 15px; line-height: 1.35; }
.ex-card .ex-why { color: #d0453c; font-size: 13px; }
.ex-card .ex-why:empty { display: none; }
.ex-icon { font-size: 34px; }
.ex-mix { background: linear-gradient(135deg, rgba(255,255,255,.95), #f3ecff); border-color: var(--purple); }

.improve-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.improve-card { display: flex; gap: 14px; padding: 14px; }
.improve-art { flex: 0 0 96px; height: 96px; border-radius: 18px; background: var(--cream); border: 2px solid #ffe2a8; display: grid; place-items: center; overflow: hidden; }
.improve-art img { width: 86%; height: 86%; object-fit: contain; }
.improve-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.improve-body h3 { margin: 0; font-size: 22px; color: var(--purple-deep); word-break: break-word; }
.improve-body .btn { align-self: flex-start; margin-top: 4px; }
.meter { position: relative; height: 20px; border-radius: 999px; background: #efe6ff; overflow: hidden; }
.meter i { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, #ff9d1a, var(--gold)); border-radius: 999px; }
.meter span { position: relative; font-size: 12px; font-weight: 600; padding-left: 10px; line-height: 20px; }
.issues, .heard, .tip { margin: 0; font-size: 14px; color: var(--soft-ink); }
.heard { font-style: italic; }
.tip { background: var(--cream); border-radius: 12px; padding: 6px 10px; color: var(--ink); }
.mastered h3 { color: var(--purple-deep); margin: 22px 0 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { background: #e6fff9; color: #0b7a6f; border-radius: 999px; padding: 6px 12px; font-weight: 600; }

.exercise { max-width: 640px; margin: 0 auto; padding: 18px 20px 22px; }
.ex-top { display: flex; align-items: center; gap: 12px; }
.ex-quit { border: 0; background: #efe6ff; color: var(--ink); width: 36px; height: 36px; border-radius: 50%; cursor: pointer; font-size: 16px; }
.ex-bar { flex: 1; height: 14px; background: #efe6ff; border-radius: 999px; overflow: hidden; }
.ex-bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #a24bff, #18a7ff); border-radius: 999px; transition: width .3s ease; }
.ex-count { font-weight: 600; color: var(--soft-ink); min-width: 48px; text-align: right; }
.ex-stage { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; padding: 16px 0 4px; }
.ex-stage h2 { margin: 4px 0; color: var(--purple-deep); font-size: 26px; }
.ex-art { width: 170px; height: 170px; border-radius: 24px; background: var(--cream); border: 2px solid #ffe2a8; display: grid; place-items: center; overflow: hidden; }
.ex-art img { width: 86%; height: 86%; object-fit: contain; }
.options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; margin-top: 6px; }
.option, .tok { font: 600 20px "Fredoka", sans-serif; color: var(--ink); background: #fff; border: 3px solid var(--border); border-radius: 18px;
  padding: 14px 10px; cursor: pointer; transition: transform .1s ease, border-color .15s ease; word-break: break-word; }
.option:hover, .tok:hover { border-color: var(--purple); transform: translateY(-1px); }
.option.right, .order-built.right { border-color: #20b26b; background: #e3fff0; }
.option.wrong, .order-built.wrong { border-color: #e2574c; background: #ffeceb; }
.big-speaker { width: 110px; height: 110px; border-radius: 50%; border: 0; cursor: pointer; font-size: 46px; color: #fff;
  background: linear-gradient(135deg, #a24bff, var(--purple-deep)); box-shadow: 0 6px 0 rgba(66, 22, 170, .35); }
.say-word { display: flex; align-items: center; gap: 10px; }
.say-word b { font-size: 34px; color: var(--purple-deep); }
.mic { width: 96px; height: 96px; border-radius: 50%; border: 0; cursor: pointer; font-size: 40px; margin-top: 6px;
  background: linear-gradient(135deg, #12a99f, var(--teal)); box-shadow: 0 6px 0 rgba(10, 110, 100, .35); }
.mic.on { animation: pulse 1s ease-in-out infinite; background: linear-gradient(135deg, #ff6a5c, #ff9d1a); }
@keyframes pulse { 50% { transform: scale(1.08); box-shadow: 0 0 0 14px rgba(255, 106, 92, .18); } }
.order-built { min-height: 64px; width: 100%; display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; align-items: center;
  padding: 10px; border: 3px dashed var(--border); border-radius: 18px; background: rgba(255,255,255,.7); }
.order-bank { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.tok { font-size: 18px; padding: 10px 14px; }
.ex-feedback { min-height: 28px; text-align: center; font-weight: 600; margin: 10px 0 4px; }
.ex-feedback.good { color: #13894f; }
.ex-feedback.bad { color: #d0453c; }
.ex-feedback.warn { color: #c46a00; }
.ex-actions { display: flex; justify-content: center; gap: 10px; }
.done-score { font-size: 24px; font-weight: 600; margin: 0; }
.done-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-top: 6px; }

.footer { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 24px 16px 36px; color: var(--soft-ink); }
.footer img { height: 34px; width: auto; }

@media (max-width: 560px) {
  .nav-brand img { height: 42px; }
  .btn { font-size: 17px; padding: 12px 22px; }
  .lang-card .landmark { width: 110px; }
  .word-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .word-card { padding: 10px; }
  .word-card h3 { font-size: 19px; }
  .speak { width: 36px; height: 36px; font-size: 16px; }
  .profile { justify-content: center; text-align: center; }
  .improve-list { grid-template-columns: 1fr; }
  .improve-art { flex-basis: 76px; height: 76px; }
  .exercise-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .ex-card { padding: 14px 10px; }
  .ex-card span:not(.ex-icon) { font-size: 13px; }
  .exercise { padding: 14px 12px 18px; }
  .option { font-size: 17px; padding: 12px 8px; }
  .ex-art { width: 140px; height: 140px; }
}
