:root {
  --violet: #7c5cff; --violet-d: #5a3fd6;
  --green: #3ecf6e; --green-d: #27a650;
  --red: #ff5d73; --red-d: #d93c53;
  --yellow: #ffd43b; --orange: #ff9f1c; --orange-d: #d97d00;
  --ink: #2b2350; --muted: #8a84a8; --card: #fff; --line: #e8e4fb;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: 'Nunito', 'Trebuchet MS', system-ui, sans-serif; font-weight: 600; color: var(--ink);
  background: linear-gradient(180deg, #8fd3ff 0%, #c9b8ff 55%, #ffd6ec 100%) fixed;
  overflow-x: hidden;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }

.sky { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 0; }
.sky i { position: absolute; font-style: normal; font-size: 70px; opacity: .75; animation: drift 60s linear infinite; }
.sky i:nth-child(1) { top: 6%; left: -15%; }
.sky i:nth-child(2) { top: 30%; left: -15%; font-size: 46px; animation-duration: 85s; animation-delay: -30s; }
.sky i:nth-child(3) { top: 62%; left: -15%; font-size: 90px; animation-duration: 110s; animation-delay: -70s; opacity: .5; }
@keyframes drift { to { transform: translateX(135vw); } }

#app { position: relative; z-index: 1; max-width: 520px; margin: 0 auto; padding: 16px 16px 40px; min-height: 100vh; display: flex; flex-direction: column; }
.loading { margin: auto; font-size: 80px; animation: bob 1s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-14px) rotate(-6deg); } }

.card { background: var(--card); border-radius: 28px; padding: 22px; box-shadow: 0 10px 0 rgba(90, 63, 214, .18), 0 18px 40px rgba(60, 40, 140, .18); }
.card + .card { margin-top: 18px; }
h1 { font-weight: 900; font-size: 30px; margin: 0 0 6px; }
h2 { font-weight: 900; font-size: 20px; margin: 0 0 12px; }
.muted { color: var(--muted); }
.center { text-align: center; }

/* Кнопки-«леденцы» */
.btn {
  display: block; width: 100%; padding: 16px 20px; border-radius: 20px; font-weight: 900; font-size: 20px; color: #fff;
  background: var(--violet); box-shadow: 0 6px 0 var(--violet-d); transition: transform .08s, box-shadow .08s, filter .15s; text-align: center;
}
.btn:active { transform: translateY(5px); box-shadow: 0 1px 0 var(--violet-d); }
.btn.go { background: var(--green); box-shadow: 0 6px 0 var(--green-d); font-size: 26px; padding: 20px; }
.btn.go:active { box-shadow: 0 1px 0 var(--green-d); }
.btn.soft { background: #f1edff; color: var(--violet-d); box-shadow: 0 6px 0 #d9d1fb; }
.btn.soft:active { box-shadow: 0 1px 0 #d9d1fb; }
.btn[disabled] { filter: grayscale(.9) opacity(.55); pointer-events: none; }
.btn + .btn { margin-top: 14px; }
.link { color: var(--muted); text-decoration: underline; font-size: 15px; padding: 10px; display: block; margin: 6px auto 0; }
.icon-btn { width: 46px; height: 46px; border-radius: 16px; background: rgba(255, 255, 255, .7); font-size: 22px; }

/* Вход */
.hero { text-align: center; margin: 6vh 0 22px; color: #fff; text-shadow: 0 3px 0 rgba(60, 40, 140, .35); }
.hero .fox { font-size: 96px; display: inline-block; animation: bob 2.4s ease-in-out infinite; text-shadow: none; }
.hero h1 { font-size: 44px; margin: 0; }
.hero p { margin: 4px 0 0; font-size: 18px; font-weight: 800; }
.name-input { width: 100%; padding: 16px 18px; border-radius: 18px; border: 3px solid var(--line); font-size: 22px; font-weight: 800; text-align: center; outline: none; margin-bottom: 14px; }
.name-input:focus { border-color: var(--violet); }
.chips { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 16px; }
.chip { padding: 10px 16px; border-radius: 999px; background: #f1edff; color: var(--violet-d); font-weight: 800; border: 3px solid transparent; }
.chip.on { background: var(--violet); color: #fff; }
.err { color: var(--red-d); font-weight: 800; min-height: 22px; margin-top: 10px; text-align: center; }

/* Дом */
.top { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.top .hi { flex: 1; color: #fff; font-weight: 900; font-size: 24px; text-shadow: 0 2px 0 rgba(60, 40, 140, .35); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px; }
.stat { background: #f7f5ff; border-radius: 18px; padding: 10px 6px; text-align: center; }
.stat b { display: block; font-size: 24px; font-weight: 900; }
.stat span { font-size: 13px; color: var(--muted); font-weight: 800; }
.level { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.level .medal { font-size: 40px; }
.level .txt { flex: 1; }
.level .txt b { font-weight: 900; }
.bar { height: 16px; border-radius: 999px; background: #ece8ff; overflow: hidden; margin-top: 6px; }
.bar > i { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--yellow), var(--orange)); transition: width .5s cubic-bezier(.3, 1.4, .5, 1); }
.courses { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 18px; }
.course { padding: 12px 8px; border-radius: 18px; background: #f7f5ff; border: 3px solid transparent; font-weight: 900; text-align: center; }
.course small { display: block; color: var(--muted); font-weight: 800; }
.course.on { border-color: var(--violet); background: #efe9ff; }
.done-box { text-align: center; padding: 6px 0; }
.done-box .big { font-size: 64px; }
.badges { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.badge { aspect-ratio: 1; border-radius: 18px; background: #fff6d6; display: grid; place-items: center; font-size: 30px; position: relative; }
.badge.off { background: #f1f0f6; filter: grayscale(1); opacity: .45; }
.tip { text-align: center; font-size: 14px; color: var(--muted); margin-top: 10px; min-height: 20px; font-weight: 800; }

/* Игра */
.gbar { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.gbar .bar { flex: 1; margin: 0; height: 18px; background: rgba(255, 255, 255, .6); }
.gbar .bar > i { background: linear-gradient(90deg, #7ef0a0, var(--green)); }
.hearts { font-size: 20px; letter-spacing: 1px; white-space: nowrap; }
.hearts .lost { filter: grayscale(1); opacity: .35; }
.combo { position: absolute; right: 18px; top: -14px; background: var(--orange); color: #fff; font-weight: 900; padding: 4px 12px; border-radius: 999px; box-shadow: 0 4px 0 var(--orange-d); animation: pop .35s; }
.stage { position: relative; animation: slide .3s ease-out; }
@keyframes slide { from { opacity: 0; transform: translateX(30px); } }
@keyframes pop { 0% { transform: scale(.3); } 70% { transform: scale(1.2); } }
.task { font-weight: 900; color: var(--muted); font-size: 16px; text-transform: uppercase; letter-spacing: .5px; margin-bottom: 10px; text-align: center; }
.emoji { font-size: 92px; line-height: 1.1; text-align: center; }
.word { font-size: 40px; font-weight: 900; text-align: center; word-break: break-word; line-height: 1.15; }
.word.sm { font-size: 30px; }
.tr { font-size: 22px; text-align: center; color: var(--muted); font-weight: 800; margin-top: 4px; }
.say { display: block; margin: 12px auto; width: 64px; height: 64px; border-radius: 50%; background: #e7f6ff; font-size: 30px; box-shadow: 0 5px 0 #bfe3f9; }
.say:active { transform: translateY(4px); box-shadow: 0 1px 0 #bfe3f9; }
.say.big { width: 110px; height: 110px; font-size: 54px; }
.opts { display: grid; gap: 12px; margin-top: 18px; }
.opt { padding: 16px; border-radius: 18px; border: 3px solid var(--line); background: #fff; font-weight: 800; font-size: 22px; box-shadow: 0 5px 0 var(--line); transition: transform .08s; }
.opt:active { transform: translateY(3px); }
.opt.ok { background: #dcfbe6; border-color: var(--green); box-shadow: 0 5px 0 var(--green-d); animation: pop .3s; }
.opt.no { background: #ffe3e7; border-color: var(--red); box-shadow: 0 5px 0 var(--red-d); animation: shake .35s; }
.opts.locked .opt { pointer-events: none; }
@keyframes shake { 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }
.slots, .tiles { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 16px; min-height: 56px; }
.tile { min-width: 46px; height: 54px; padding: 0 10px; border-radius: 14px; background: #fff; border: 3px solid var(--line); box-shadow: 0 4px 0 var(--line); font-size: 26px; font-weight: 900; }
.tile.used { visibility: hidden; }
.slots .tile { background: #efe9ff; border-color: var(--violet); box-shadow: 0 4px 0 var(--violet-d); }
.slots .tile.empty { background: #f7f5ff; border-style: dashed; border-color: var(--line); box-shadow: none; pointer-events: none; }
.slots.ok .tile { background: #dcfbe6; border-color: var(--green); box-shadow: 0 4px 0 var(--green-d); }
.slots.no .tile { background: #ffe3e7; border-color: var(--red); box-shadow: 0 4px 0 var(--red-d); }
.feedback { margin-top: 16px; padding: 14px; border-radius: 18px; font-weight: 900; text-align: center; font-size: 18px; }
.feedback.ok { background: #dcfbe6; color: var(--green-d); }
.feedback.no { background: #ffe3e7; color: var(--red-d); }
.feedback b { font-size: 24px; display: block; color: var(--ink); }
.feedback .btn { margin-top: 12px; }

/* Микрофон */
.mic-box { text-align: center; margin-top: 14px; }
.mic { width: 92px; height: 92px; border-radius: 50%; background: var(--orange); box-shadow: 0 7px 0 var(--orange-d); font-size: 42px; position: relative; }
.mic:active { transform: translateY(5px); box-shadow: 0 2px 0 var(--orange-d); }
.mic.rec { background: var(--red); box-shadow: 0 7px 0 var(--red-d); }
.mic.rec::after { content: ''; position: absolute; inset: -10px; border-radius: 50%; border: 5px solid var(--red); animation: ring 1s ease-out infinite; }
.mic.busy { filter: grayscale(.6); pointer-events: none; animation: bob 1s infinite; }
@keyframes ring { to { transform: scale(1.5); opacity: 0; } }
.mic-msg { margin-top: 12px; font-weight: 800; min-height: 26px; font-size: 17px; }
.mic-msg.ok { color: var(--green-d); }
.mic-msg.no { color: var(--red-d); }

/* Итоги */
.result .big { font-size: 96px; text-align: center; animation: pop .5s; }
.rows { margin: 14px 0; }
.row { display: flex; justify-content: space-between; padding: 10px 14px; border-radius: 14px; background: #f7f5ff; font-weight: 800; margin-bottom: 8px; animation: slide .4s backwards; }
.row b { color: var(--orange-d); }
.total { text-align: center; font-size: 34px; font-weight: 900; color: var(--orange-d); margin: 6px 0 16px; }
.newbadge { display: flex; gap: 12px; align-items: center; background: #fff6d6; border-radius: 18px; padding: 12px; margin-bottom: 10px; animation: pop .5s; }
.newbadge i { font-size: 40px; font-style: normal; }
.newbadge b { display: block; font-weight: 900; }
.relearn { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 10px 0 16px; }
.relearn span { background: #ffe3e7; border-radius: 999px; padding: 6px 12px; font-weight: 800; }

/* Окошко */
.modal { position: fixed; inset: 0; background: rgba(43, 35, 80, .55); display: grid; place-items: center; padding: 16px; z-index: 20; }
.modal .card { width: 100%; max-width: 440px; animation: pop .25s; }
.goal-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 18px; }
.goal-grid .chip { padding: 12px 4px; text-align: center; }

#fx { position: fixed; inset: 0; pointer-events: none; z-index: 30; overflow: hidden; }
#fx i { position: absolute; top: -50px; font-style: normal; font-size: 30px; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(540deg); } }
#fx .fly { top: 45%; left: 50%; font-size: 26px; font-weight: 900; color: var(--orange-d); animation: fly 1s ease-out forwards; text-shadow: 0 2px 0 #fff; }
@keyframes fly { to { transform: translate(-50%, -160px); opacity: 0; } }

@media (max-width: 380px) { .word { font-size: 32px; } .emoji { font-size: 76px; } .opt { font-size: 19px; padding: 13px; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
