:root {
  --ink: #141414;
  --paper: #fff8ea;
  --paper-2: #fff1d0;
  --white: #ffffff;
  --yellow: #ffd23f;
  --red: #ee4035;
  --blue: #2e86de;
  --green: #3bb273;
  --purple: #7e57c2;
  --orange: #ff7a1a;
  --muted: #5d5346;
  --shadow: 5px 5px 0 var(--ink);
  --shadow-sm: 3px 3px 0 var(--ink);
  --radius: 14px;
  --f-head: 'Rubik', 'Arial Black', system-ui, sans-serif;
  --f-body: 'Nunito', 'Segoe UI', system-ui, sans-serif;
  --f-bubble: 'Pangolin', 'Comic Sans MS', 'Segoe Print', cursive;
  --f-sfx: 'Bangers', 'Impact', var(--f-head);
  --fs-line: 1.18rem;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  color: var(--ink);
  font-family: var(--f-body);
  background-color: var(--paper);
  background-image: radial-gradient(rgba(20, 20, 20, .07) 1.4px, transparent 1.6px);
  background-size: 14px 14px;
}
body.kids { --fs-line: 1.42rem; }
a { color: inherit; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 10px 20px;
  background: var(--yellow);
  border-bottom: 4px solid var(--ink);
}
.logo { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.logo-bubble {
  display: grid; place-items: center; width: 46px; height: 46px; font-size: 26px;
  background: var(--white); border: 3px solid var(--ink); border-radius: 50%; box-shadow: var(--shadow-sm);
  transform: rotate(-8deg);
}
.logo-text { display: grid; grid-template-columns: auto auto; align-items: baseline; line-height: 1; }
.logo-text b { font: 900 1.6rem/1 var(--f-head); letter-spacing: -.5px; }
.logo-text i { font: 400 1.7rem/1 var(--f-sfx); font-style: normal; color: var(--red); letter-spacing: 1px; -webkit-text-stroke: 1px var(--ink); }
.logo-text small { grid-column: 1 / -1; font-weight: 800; font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; margin-top: 3px; }
.toggles { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.seg { display: inline-flex; border: 3px solid var(--ink); border-radius: 12px; overflow: hidden; background: var(--white); box-shadow: var(--shadow-sm); }
.seg button { border: 0; background: transparent; padding: 7px 12px; font-weight: 900; font-size: .9rem; cursor: pointer; white-space: nowrap; }
.seg button + button { border-left: 3px solid var(--ink); }
.seg button.on { background: var(--ink); color: var(--yellow); }

.voice-warn {
  margin: 14px auto 0; width: min(1200px, calc(100% - 32px));
  padding: 12px 16px; background: #ffe3de; border: 3px solid var(--ink); border-radius: var(--radius);
  font-weight: 700; box-shadow: var(--shadow-sm);
}
.voice-warn a { font-weight: 900; }

main { flex: 1; width: min(1200px, calc(100% - 32px)); margin: 0 auto; padding: 22px 0 40px; }
.foot {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 20px;
  padding: 14px 20px; border-top: 4px solid var(--ink); background: var(--white); font-size: .82rem; color: var(--muted);
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 8px 16px;
  background: var(--white); color: var(--ink);
  border: 3px solid var(--ink); border-radius: 12px; box-shadow: var(--shadow-sm);
  font-weight: 900; font-size: 1rem; text-decoration: none; cursor: pointer;
  transition: transform .08s, box-shadow .08s, background .15s;
  user-select: none;
}
.btn:hover { background: var(--paper-2); }
.btn:active { transform: translate(3px, 3px); box-shadow: 0 0 0 var(--ink); }
.btn.primary { background: var(--blue); color: var(--white); }
.btn.accent { background: var(--red); color: var(--white); }
.btn.good { background: var(--green); color: var(--white); }
.btn.yellow { background: var(--yellow); }
.btn.ghost { box-shadow: none; }
.btn.on { background: var(--ink); color: var(--yellow); }
.btn.icon { width: 44px; padding: 0; font-size: 1.2rem; }
.btn[aria-disabled="true"], .btn:disabled { opacity: .35; pointer-events: none; }

/* ---------- home ---------- */
.hero {
  display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 24px; align-items: center;
  margin-bottom: 28px;
}
.hero h1 { font: 900 clamp(2.1rem, 5vw, 3.6rem)/1 var(--f-head); margin: 0 0 12px; letter-spacing: -1px; }
.hero h1 span { display: inline-block; background: var(--red); color: var(--white); padding: 0 12px 4px; border: 4px solid var(--ink); box-shadow: var(--shadow); transform: rotate(-2deg); }
.hero p { font-size: 1.12rem; margin: 0 0 16px; max-width: 58ch; }
.steps { display: grid; gap: 10px; }
.step {
  display: flex; gap: 12px; align-items: center;
  background: var(--white); border: 3px solid var(--ink); border-radius: var(--radius); padding: 10px 14px; box-shadow: var(--shadow-sm);
  font-weight: 700;
}
.step b { font-size: 1.6rem; }
.stat-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.stat { font: 900 1.05rem var(--f-head); background: var(--white); border: 3px solid var(--ink); border-radius: 999px; padding: 6px 14px; box-shadow: var(--shadow-sm); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 24px; }
.card {
  display: flex; flex-direction: column;
  background: var(--white); border: 4px solid var(--ink); border-radius: 18px; box-shadow: 7px 7px 0 var(--ink);
  overflow: hidden; transition: transform .15s;
}
.card:hover { transform: translateY(-3px) rotate(-.4deg); }
.cover { display: block; border-bottom: 4px solid var(--ink); background: var(--yellow); line-height: 0; }
.cover svg { width: 100%; height: auto; display: block; }
.card-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.meta { font-size: .78rem; font-weight: 900; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.card h3 { font: 900 1.35rem/1.15 var(--f-head); margin: 0; }
.card .sub { margin: 0; font-weight: 700; color: var(--blue); }
.card .sum { margin: 4px 0; font-size: .95rem; }
.card-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: auto; padding-top: 6px; }
.photo-status { font-size: .8rem; font-weight: 800; color: var(--muted); }
.card-acts { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; margin-top: 8px; }
.stars { font-size: 1.35rem; letter-spacing: 2px; color: #d8cfbd; -webkit-text-stroke: 1px var(--ink); }
.stars .f { color: var(--yellow); }

.note {
  margin-top: 30px; padding: 16px 18px; background: var(--white);
  border: 3px dashed var(--ink); border-radius: var(--radius); font-size: .95rem;
}
.note code, .settings code { background: var(--paper-2); padding: 1px 6px; border-radius: 6px; font-size: .9em; }

/* ---------- panels ---------- */
.panel-frame {
  position: relative; background: var(--white);
  border: 4px solid var(--ink); border-radius: 6px; box-shadow: var(--shadow); overflow: hidden; line-height: 0;
}
.panel-frame canvas, .panel-frame svg { display: block; width: 100%; height: auto; }
.panel-frame.big canvas { max-height: 72vh; object-fit: contain; background: var(--white); }
.panel-frame.loading { min-height: 160px; background: repeating-linear-gradient(45deg, #fff, #fff 10px, #f3ead6 10px, #f3ead6 20px); }

/* ---------- reader ---------- */
.reader-top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.reader-top h2 { font: 900 clamp(1.3rem, 3vw, 1.9rem)/1.1 var(--f-head); margin: 0; flex: 1 1 260px; }
.reader-top h2 small { display: block; font: 700 .95rem var(--f-body); color: var(--blue); margin-top: 2px; }
.dots { display: flex; gap: 6px; flex-wrap: wrap; }
.dot {
  display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%;
  border: 3px solid var(--ink); background: var(--white); font-weight: 900; text-decoration: none; font-size: .9rem;
}
.dot.on { background: var(--red); color: var(--white); transform: scale(1.12); }
.dot.seen:not(.on) { background: var(--paper-2); }

.reader-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 26px; align-items: start; }
.stage { position: sticky; top: 90px; display: grid; gap: 16px; }
.stage-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 14px; align-items: start; }
.panel-label { font: 900 .82rem var(--f-head); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }

.minimap { width: 150px; }
.mm-wrap { position: relative; border: 3px solid var(--ink); border-radius: 6px; overflow: hidden; line-height: 0; box-shadow: var(--shadow-sm); }
.mm-wrap canvas { width: 100%; height: auto; display: block; opacity: .75; }
.mm-rect {
  position: absolute; display: grid; place-items: center; line-height: 1;
  border: 2px solid rgba(20, 20, 20, .55); background: rgba(255, 255, 255, .15);
  font: 900 .75rem var(--f-head); text-decoration: none; color: var(--ink); text-shadow: 0 0 3px #fff, 0 0 3px #fff;
}
.mm-rect:hover { background: rgba(255, 210, 63, .45); }
.mm-rect.on { border: 3px solid var(--red); background: rgba(238, 64, 53, .25); }
.nophoto {
  line-height: 1.35; font-size: .85rem; font-weight: 700; padding: 10px 12px;
  background: var(--white); border: 3px dashed var(--ink); border-radius: 10px;
}
.nophoto.big { font-size: 1rem; padding: 22px; }

.script { display: grid; gap: 14px; }
.line { display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 4px 12px; align-items: start; }
.who { grid-row: span 2; display: grid; justify-items: center; gap: 4px; text-align: center; }
.ava {
  display: grid; place-items: center; width: 58px; height: 58px; font-size: 30px;
  background: var(--c, #ccc); border: 3px solid var(--ink); border-radius: 50%; box-shadow: var(--shadow-sm);
  transition: transform .2s;
}
.nm { font: 900 .78rem/1.1 var(--f-head); word-break: break-word; }
.nm small { display: block; font: 700 .7rem var(--f-body); color: var(--muted); }
.bubble {
  position: relative; background: var(--white);
  border: 3px solid var(--ink); border-radius: 22px; padding: 12px 16px;
  box-shadow: var(--shadow-sm); transition: background .2s, transform .2s;
}
.bubble::before {
  content: ''; position: absolute; left: -14px; top: 20px; width: 20px; height: 18px;
  background: var(--white); border-left: 3px solid var(--ink); border-bottom: 3px solid var(--ink);
  transform: skewY(-35deg); transition: background .2s;
}
.line.sfx .bubble { background: var(--yellow); border-radius: 6px; transform: rotate(-1deg); }
.line.sfx .bubble::before { background: var(--yellow); }
.line.sfx .prim { font-family: var(--f-sfx); letter-spacing: 1.5px; font-size: calc(var(--fs-line) * 1.25); }
.line.narr .bubble { border-radius: 4px; background: #fff3c4; }
.line.narr .bubble::before { display: none; }
.prim { margin: 0; font: 400 var(--fs-line)/1.35 var(--f-bubble); }
.sec { margin: 6px 0 0; font-weight: 700; color: #3c5a99; font-size: calc(var(--fs-line) * .78); line-height: 1.35; transition: filter .25s; }
.hidden-tr { filter: blur(6px); cursor: pointer; user-select: none; }
.hidden-tr .w { pointer-events: none; }
.acts { display: flex; gap: 8px; flex-wrap: wrap; }
.play {
  display: inline-flex; align-items: center; gap: 6px; min-height: 38px; padding: 4px 12px;
  border: 3px solid var(--ink); border-radius: 999px; background: var(--white); font-weight: 900; cursor: pointer;
  box-shadow: 2px 2px 0 var(--ink);
}
.play:active { transform: translate(2px, 2px); box-shadow: none; }
.play .lang { font: 900 .72rem var(--f-head); background: var(--ink); color: var(--yellow); border-radius: 5px; padding: 2px 5px; }
.play.alt .lang { background: var(--blue); color: var(--white); }
.line.speaking .bubble { background: #fff6b8; transform: scale(1.02); }
.line.speaking .bubble::before { background: #fff6b8; }
.line.speaking .ava { transform: scale(1.12) rotate(-6deg); animation: bob .45s ease-in-out infinite alternate; }
@keyframes bob { to { transform: scale(1.12) rotate(6deg) translateY(-3px); } }

.w { cursor: pointer; border-radius: 5px; transition: background .12s; }
.w:hover { background: #ffe9a3; }
.w.on { background: var(--yellow); box-shadow: 0 0 0 2px var(--yellow); }

.controls { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; padding-top: 8px; border-top: 3px dashed rgba(20, 20, 20, .25); }
.controls .grow { flex: 1; }

.word-pop {
  position: absolute; z-index: 60; min-width: 180px; max-width: 280px;
  background: var(--white); border: 3px solid var(--ink); border-radius: 14px; box-shadow: var(--shadow-sm);
  padding: 10px 12px; display: grid; gap: 4px;
  animation: pop .15s ease-out;
}
.word-pop b { font: 400 1.35rem var(--f-bubble); }
.word-pop .tr { font-weight: 800; color: var(--blue); }
.word-pop .src { font-size: .78rem; color: var(--muted); }
.word-pop .none { color: var(--muted); font-size: .9rem; }
@keyframes pop { from { transform: scale(.85); opacity: 0; } }

.vocab-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.chip {
  display: inline-flex; gap: 6px; align-items: baseline; padding: 5px 10px;
  border: 2px solid var(--ink); border-radius: 999px; background: var(--white); cursor: pointer; font-size: .9rem;
}
.chip b { font-family: var(--f-bubble); font-weight: 400; font-size: 1.05rem; }
.chip:hover { background: #ffe9a3; }
details.vocab { background: var(--white); border: 3px solid var(--ink); border-radius: var(--radius); padding: 10px 14px; }
details.vocab summary { font: 900 1rem var(--f-head); cursor: pointer; }

/* ---------- quiz ---------- */
.quiz { max-width: 860px; margin: 0 auto; }
.q-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.q-head h2 { font: 900 1.4rem var(--f-head); margin: 0; }
.bar { height: 18px; border: 3px solid var(--ink); border-radius: 999px; background: var(--white); overflow: hidden; margin-bottom: 18px; }
.bar i { display: block; height: 100%; background: repeating-linear-gradient(-45deg, var(--green), var(--green) 10px, #34a067 10px, #34a067 20px); transition: width .35s; }
.q-card { background: var(--white); border: 4px solid var(--ink); border-radius: 20px; box-shadow: 8px 8px 0 var(--ink); padding: 22px; }
.q-type { display: inline-block; font: 900 .78rem var(--f-head); letter-spacing: .08em; text-transform: uppercase; background: var(--purple); color: var(--white); border-radius: 6px; padding: 3px 8px; }
.q-title { font: 900 clamp(1.3rem, 3vw, 1.75rem)/1.2 var(--f-head); margin: 8px 0 16px; }
.q-prompt { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; margin-bottom: 18px; }
.q-prompt .say { font: 400 clamp(1.3rem, 3.2vw, 1.9rem)/1.3 var(--f-bubble); flex: 1 1 300px; background: #fffbe8; border: 3px solid var(--ink); border-radius: 20px; padding: 12px 16px; }
.q-prompt .say.big { font-size: clamp(2rem, 6vw, 3.2rem); text-align: center; }
.big-play {
  width: 82px; height: 82px; flex: 0 0 auto; border-radius: 50%; font-size: 2.1rem;
  border: 4px solid var(--ink); background: var(--yellow); box-shadow: var(--shadow); cursor: pointer;
}
.big-play:active { transform: translate(4px, 4px); box-shadow: none; }
.big-play.pulse { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.07); } }
.blank { display: inline-block; min-width: 3.5em; border-bottom: 4px solid var(--red); color: var(--red); text-align: center; }

.opts { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.opts.wide { grid-template-columns: 1fr; }
.opts.pics { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.opt {
  position: relative; display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 12px 16px; text-align: left;
  background: var(--white); border: 3px solid var(--ink); border-radius: 16px; box-shadow: var(--shadow-sm);
  font-weight: 800; font-size: 1.1rem; cursor: pointer; transition: transform .08s, background .15s;
}
body.kids .opt { font-size: 1.3rem; min-height: 76px; }
.opt:hover { background: #fff6d6; }
.opt:active { transform: translate(3px, 3px); box-shadow: none; }
.opt .ava { width: 50px; height: 50px; font-size: 26px; box-shadow: none; }
.opt.word { justify-content: center; font: 400 1.55rem var(--f-bubble); }
.opt.pic { padding: 8px; flex-direction: column; }
.opt.pic .panel-frame { width: 100%; box-shadow: none; border-width: 3px; }
.opt .badge {
  position: absolute; top: -12px; left: -12px; z-index: 2; display: grid; place-items: center;
  width: 40px; height: 40px; border-radius: 50%; background: var(--red); color: var(--white);
  border: 3px solid var(--ink); font: 900 1.2rem var(--f-head);
}
.opt.good { background: #c8f3d6; border-color: #11632e; }
.opt.bad { background: #ffd0cb; animation: shake .35s; }
.opt.dim { opacity: .5; }
.opts.locked .opt { pointer-events: none; }
@keyframes shake { 20%, 60% { transform: translateX(-7px); } 40%, 80% { transform: translateX(7px); } }

.type-row { display: flex; gap: 10px; flex-wrap: wrap; }
.type-row input {
  flex: 1 1 220px; min-height: 56px; padding: 8px 16px; font: 400 1.6rem var(--f-bubble);
  border: 3px solid var(--ink); border-radius: 14px; background: #fffdf5;
}
.letters { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.letters button { width: 46px; height: 46px; border: 3px solid var(--ink); border-radius: 10px; background: var(--white); font: 400 1.4rem var(--f-bubble); cursor: pointer; }

.feedback {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-top: 18px; padding: 14px 16px;
  border: 3px solid var(--ink); border-radius: 16px; font-weight: 800; font-size: 1.1rem;
  animation: pop .2s ease-out;
}
.feedback.ok { background: #c8f3d6; }
.feedback.no { background: #ffe0dc; }
.feedback .msg { flex: 1 1 240px; }
.feedback .msg em { font: 400 1.2rem var(--f-bubble); font-style: normal; }

.result { text-align: center; }
.result .big-stars { font-size: clamp(3rem, 10vw, 5rem); letter-spacing: 8px; -webkit-text-stroke: 2px var(--ink); color: #e6dcc7; }
.result .big-stars .f { color: var(--yellow); }
.result h2 { font: 900 2rem var(--f-head); margin: 6px 0; }
.result .score { font: 900 1.3rem var(--f-head); }
.mistakes { text-align: left; margin: 20px 0; display: grid; gap: 10px; }
.mistake { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 3px solid var(--ink); border-radius: 12px; background: #fffbe8; }
.mistake span { flex: 1; }
.row-center { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* ---------- editor ---------- */
.editor-head { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.editor-head h2 { font: 900 1.5rem var(--f-head); margin: 0; flex: 1 1 260px; }
.editor-grid { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 22px; align-items: start; }
.edit-stage { position: relative; border: 4px solid var(--ink); border-radius: 6px; line-height: 0; touch-action: none; user-select: none; background: #eee; }
.edit-stage img { width: 100%; height: auto; display: block; pointer-events: none; }
.erect { position: absolute; border: 3px dashed var(--blue); background: rgba(46, 134, 222, .12); cursor: move; }
.erect.on { border: 3px solid var(--red); background: rgba(238, 64, 53, .14); z-index: 2; }
.erect .num {
  position: absolute; left: 4px; top: 4px; display: grid; place-items: center; width: 26px; height: 26px; line-height: 1;
  border-radius: 50%; background: var(--ink); color: var(--yellow); font: 900 .85rem var(--f-head);
}
.erect .hd { position: absolute; width: 16px; height: 16px; background: var(--yellow); border: 2px solid var(--ink); }
.erect .hd.nw { left: -9px; top: -9px; cursor: nwse-resize; }
.erect .hd.ne { right: -9px; top: -9px; cursor: nesw-resize; }
.erect .hd.sw { left: -9px; bottom: -9px; cursor: nesw-resize; }
.erect .hd.se { right: -9px; bottom: -9px; cursor: nwse-resize; }
.edit-side { position: sticky; top: 90px; display: grid; gap: 14px; }
.edit-preview .panel-frame { box-shadow: var(--shadow-sm); }
.edit-side textarea { width: 100%; min-height: 140px; font: 12px/1.4 Consolas, monospace; border: 3px solid var(--ink); border-radius: 10px; padding: 8px; }
.hint { font-size: .9rem; color: var(--muted); margin: 0; }

/* ---------- settings ---------- */
.settings { max-width: 900px; margin: 0 auto; display: grid; gap: 18px; }
.settings h2 { font: 900 1.8rem var(--f-head); margin: 0; }
.box { background: var(--white); border: 4px solid var(--ink); border-radius: 18px; box-shadow: var(--shadow); padding: 18px 20px; }
.box h3 { font: 900 1.2rem var(--f-head); margin: 0 0 10px; }
.voice-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; }
.voice-row { display: grid; gap: 6px; }
.voice-row label { font-weight: 900; }
.voice-row .pick { display: flex; gap: 8px; }
.voice-row select, .settings input[type="range"] { flex: 1; min-width: 0; }
select { min-height: 44px; border: 3px solid var(--ink); border-radius: 10px; padding: 4px 8px; font: inherit; background: var(--white); }
.check { display: flex; gap: 10px; align-items: center; font-weight: 800; min-height: 44px; }
.check input { width: 22px; height: 22px; accent-color: var(--ink); }
.settings ol { margin: 0; padding-left: 22px; line-height: 1.6; }

.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 100; }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .hero, .reader-grid, .editor-grid { grid-template-columns: 1fr; }
  .stage, .edit-side { position: static; }
  .topbar { padding: 8px 16px; }
}
@media (max-width: 560px) {
  .toggles { width: 100%; justify-content: space-between; }
  .seg button { padding: 6px 8px; font-size: .8rem; }
  .stage-row { grid-template-columns: 1fr; }
  .minimap { width: 120px; }
  .line { grid-template-columns: 50px minmax(0, 1fr); }
  .ava { width: 46px; height: 46px; font-size: 24px; }
  .q-card { padding: 16px; }
  .card-acts { grid-template-columns: 1fr 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ================= v2: training modes ================= */
.btn.small { min-height: 38px; padding: 4px 10px; font-size: .88rem; box-shadow: 2px 2px 0 var(--ink); }
.btn.big { min-height: 60px; padding: 10px 26px; font-size: 1.2rem; }
.center { text-align: center; justify-content: center; }
.seg.wrap { flex-wrap: wrap; }
.seg.wrap button { flex: 1 1 auto; }
.card-acts2 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 6px; }

.sec-title { font: 900 clamp(1.5rem, 3.5vw, 2.1rem)/1.1 var(--f-head); margin: 38px 0 14px; }
.sec-sub { font: 900 1.15rem var(--f-head); margin: 24px 0 10px; }
.train-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.train-tile {
  display: grid; gap: 2px; padding: 14px 16px; text-decoration: none;
  background: var(--white); border: 3px solid var(--ink); border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
a.train-tile:hover { background: #fff6d6; }
.train-tile b { font-size: 2rem; line-height: 1; }
.train-tile span { font: 900 1.05rem var(--f-head); }
.train-tile small { color: var(--muted); font-weight: 700; }
.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.badge-item {
  display: grid; justify-items: center; text-align: center; gap: 2px; padding: 12px 8px;
  background: #f1ebdd; border: 3px dashed #b9ad95; border-radius: var(--radius); color: #8a7f6b;
}
.badge-item .bi { font-size: 2.1rem; filter: grayscale(1); opacity: .45; }
.badge-item b { font: 900 .9rem var(--f-head); }
.badge-item small { font-size: .74rem; line-height: 1.2; }
.badge-item.got { background: #fff6c9; border: 3px solid var(--ink); color: var(--ink); box-shadow: var(--shadow-sm); }
.badge-item.got .bi { filter: none; opacity: 1; }

/* pronunciation */
.line .rec-out { grid-column: 2; }
.rec-out:empty { display: none; }
.rec-out.center { display: flex; justify-content: center; margin: 10px 0; }
.rec-msg, .rec-res {
  display: inline-block; padding: 8px 12px; border: 2px solid var(--ink); border-radius: 12px; background: var(--white); font-weight: 700;
}
.rec-msg.live { background: #ffe3de; animation: pulse 1s ease-in-out infinite; }
.rec-res small { display: block; color: var(--muted); font-weight: 700; margin-top: 2px; }
.rec-res.s3 { background: #c8f3d6; }
.rec-res.s2 { background: #e6f7c9; }
.rec-res.s1 { background: #fff3c4; }
.rec-res.s0 { background: #ffe0dc; }
.rec-res .stars { font-size: 1.1rem; }
.play.mic { background: #ffe3de; }
.rec-on { background: var(--red) !important; color: var(--white); animation: pulse 1s ease-in-out infinite; }

/* flashcards */
.cards-view, .pairs-view, .role-view { max-width: 1000px; margin: 0 auto; }
.cards-view { max-width: 720px; }
.flash-wrap { perspective: 1200px; margin: 6px 0 18px; }
.flash {
  position: relative; display: block; width: 100%; min-height: 280px; padding: 0; border: 0; background: none; cursor: pointer;
  transform-style: preserve-3d; transition: transform .5s cubic-bezier(.3, 1.4, .5, 1);
}
.flash.flipped { transform: rotateY(180deg); }
.face {
  position: absolute; inset: 0; display: grid; place-content: center; gap: 12px; padding: 26px; text-align: center;
  background: var(--white); border: 4px solid var(--ink); border-radius: 22px; box-shadow: 8px 8px 0 var(--ink);
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
}
.face.back { transform: rotateY(180deg); background: #e8f3ff; }
.face-tag { position: absolute; top: 12px; left: 14px; font: 900 .8rem var(--f-head); background: var(--ink); color: var(--yellow); border-radius: 6px; padding: 3px 7px; }
.face-tag.alt { background: var(--blue); color: var(--white); }
.fw { font: 400 clamp(2.2rem, 7vw, 3.6rem)/1.1 var(--f-bubble); word-break: break-word; }
.fex { font-size: 1.05rem; color: var(--muted); font-weight: 700; max-width: 46ch; margin: 0 auto; }
.flip-hint { color: var(--muted); font-weight: 700; }
.grade { margin: 14px 0 6px; }
.boxes { display: flex; gap: 8px; justify-content: center; align-items: end; height: 110px; margin: 18px auto 0; max-width: 420px; }
.box-col { flex: 1; height: 100%; display: grid; grid-template-rows: 1fr auto auto; justify-items: center; font-size: .75rem; }
.box-col i { align-self: end; width: 100%; border: 2px solid var(--ink); border-radius: 6px 6px 0 0; background: var(--yellow); }
.box-col.b0 i { background: #e0d6c2; } .box-col.b1 i { background: #ffab91; } .box-col.b2 i { background: #ffd180; }
.box-col.b4 i, .box-col.b5 i { background: var(--green); }

/* memory pairs */
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-top: 14px; }
.tiles.kids { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.tile { position: relative; aspect-ratio: 4 / 3; padding: 0; border: 0; background: none; cursor: pointer; perspective: 800px; }
.tile-in { position: absolute; inset: 0; transform-style: preserve-3d; transition: transform .4s; }
.tile.open .tile-in, .tile.done .tile-in { transform: rotateY(180deg); }
.tile-back, .tile-front {
  position: absolute; inset: 0; display: grid; place-content: center; padding: 6px; text-align: center;
  border: 3px solid var(--ink); border-radius: 14px; box-shadow: var(--shadow-sm);
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
}
.tile-back { background: repeating-linear-gradient(45deg, var(--purple), var(--purple) 10px, #6f47b8 10px, #6f47b8 20px); color: var(--white); font: 900 2.2rem var(--f-head); }
.tile-front { transform: rotateY(180deg); font: 400 clamp(.95rem, 2.4vw, 1.35rem)/1.15 var(--f-bubble); word-break: break-word; }
.tile-front.no { background: #fff6c9; }
.tile-front.uk { background: #e3f0ff; }
.tile-front small { font: 900 .65rem var(--f-head); color: var(--muted); }
.tile.done .tile-front { background: #c8f3d6; border-color: #11632e; }
.tile.done { animation: pop .3s ease-out; }

/* role play */
.your-turn { font: 900 1.2rem var(--f-head); color: var(--white); background: var(--red); border: 3px solid var(--ink); border-radius: 12px; padding: 8px 14px; box-shadow: var(--shadow-sm); animation: pulse 1.3s ease-in-out infinite; }
.bubble.mine { background: #fff6b8; }
.bubble.mine .prim { font-size: calc(var(--fs-line) * 1.2); }

@media (max-width: 560px) {
  .tiles, .tiles.kids { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .card-acts2 { grid-template-columns: repeat(3, 1fr); }
  .btn.big { min-height: 52px; padding: 8px 16px; }
}

/* static SEO content (visible until the app starts) */
.seo-static { max-width: 900px; line-height: 1.55; }
.seo-static h1 { font: 900 clamp(2rem, 5vw, 3rem)/1.05 var(--f-head); }
.seo-static h2 { font: 900 1.5rem var(--f-head); margin-top: 28px; }
.seo-static h3 { font: 900 1.15rem var(--f-head); margin-bottom: 4px; }
.seo-static article { background: var(--white); border: 3px solid var(--ink); border-radius: var(--radius); padding: 4px 16px; margin: 12px 0; }
.foot .made { font-weight: 900; color: var(--ink); }
