/* Practice chapters for the English book (site/english/lib/practice.js), cloned from the French player's sheet: same palette,
   guide, cards and classes. Load before ../lib/english.css (the typed and tap cards of the book's helpers). */
:root {
  --page: #0f1613; --board: #1d2b27; --panel: #22322d; --edge: #3a5047;
  --chalk: #ece8dc; --dim: #9aaba3; --faint: #5d7068;
  --task: #f0b45a; --quiz: #86c9e8; --good: #8fd6b0; --bad: #f08c7a;
  --ui: "Avenir Next", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --book: "Iowan Old Style", Palatino, Georgia, serif;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --acc: var(--quiz);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--page); }
body { min-height: 100dvh; display: flex; flex-direction: column; color: var(--chalk); font: 20px/1.4 var(--ui);
  background: radial-gradient(ellipse 80% 60% at 50% 40%, #1f2f2a, var(--page) 80%); overflow-x: hidden; -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
button:focus-visible, a:focus-visible { outline: 3px solid var(--task); outline-offset: 3px; }
[hidden] { display: none !important; }
kbd { display: inline-block; min-width: 1.5em; padding: 0 .4em; margin-left: .5em; border: 1.5px solid currentColor; border-radius: 6px; font: 600 .7em/1.5 var(--ui); text-align: center; vertical-align: .12em; opacity: .6; }
.w { font-family: var(--book); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

#app { flex: 1; display: flex; flex-direction: column; min-width: 0; }

/* ---------- top bar ---------- */
.hud { display: flex; align-items: center; gap: 14px; padding: 8px clamp(12px, 3vw, 32px); background: rgba(22, 33, 29, .86); border-bottom: 1px solid #2a3b35; min-height: 62px; position: relative; z-index: 3; }
.back { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 999px; border: 1.5px solid var(--edge); color: var(--dim); font-size: 16px; font-weight: 600; text-decoration: none; background: none; white-space: nowrap; }
.back:hover { color: var(--chalk); border-color: var(--dim); }
.back svg { width: 14px; height: 14px; fill: currentColor; }
.hudmid { flex: 1; display: flex; align-items: center; justify-content: center; gap: 16px; min-width: 0; }
.hud .mascot { width: 62px; height: 43px; flex: none; }
.rname { font: 500 24px/1.1 var(--book); white-space: nowrap; }
.rname small { display: block; font: 600 12px/1.3 var(--ui); letter-spacing: .14em; text-transform: uppercase; color: var(--acc); }
.dots { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: center; }
.grp { display: flex; gap: 5px; padding: 4px 8px; border-radius: 999px; }
.grp.cur { background: rgba(236, 232, 220, .08); }
.dot { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--faint); transition: background .3s, border-color .3s, transform .3s var(--ease); }
.dot.ok { background: var(--good); border-color: var(--good); }
.dot.miss { background: var(--bad); border-color: var(--bad); }
.dot.now { border-color: var(--chalk); transform: scale(1.35); animation: now 1.4s ease-in-out infinite; }
.dot.again { border-style: dashed; }
@keyframes now { 50% { box-shadow: 0 0 0 5px rgba(236, 232, 220, .14); } }
.hudr { display: flex; align-items: center; gap: 10px; }
.streak { display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; border-radius: 999px; border: 1.5px solid var(--task); color: var(--task); font-weight: 700; font-size: 17px; white-space: nowrap; }
.streak.pop { animation: pop .45s var(--ease); }
.streak[hidden] { display: none; }
.iconbtn { width: 44px; height: 44px; border-radius: 50%; border: 1.5px solid var(--edge); background: none; display: grid; place-items: center; color: var(--dim); }
.iconbtn:hover { color: var(--chalk); border-color: var(--dim); }
.iconbtn svg { width: 22px; height: 22px; }
.iconbtn[aria-pressed="false"] { color: var(--faint); }

/* ---------- the guide ---------- */
.mascot { display: block; overflow: visible; }
.mascot .mbody { transform-box: view-box; transform-origin: 60px 46px; animation: bob 3.4s ease-in-out infinite; }
.mascot .pupil { transform-box: fill-box; transform-origin: center; animation: blink 5s infinite; }
.mascot .joy, .mascot .flat { display: none; }
.mascot.happy .pupil { display: none; }
.mascot.happy .joy { display: inline; }
.mascot.happy .mbody { animation: hop .55s ease-out 2, bob 3.4s ease-in-out 1.1s infinite; }
.mascot.oops .eyes { transform: translate(-3px, 4px); }
.mascot.oops .smile { display: none; }
.mascot.oops .flat { display: inline; }
.mascot.oops .mbody { animation: wobble .5s ease-in-out, bob 3.4s ease-in-out .5s infinite; }
.mascot.draw .loop { stroke-dasharray: 1 1; animation: draw 1.3s cubic-bezier(.6, 0, .3, 1) .15s backwards; }
.mascot.draw .face { animation: pop .45s var(--ease) 1.25s backwards; transform-box: view-box; transform-origin: 60px 44px; }
@keyframes draw { from { stroke-dashoffset: 1; } }
@keyframes bob { 50% { transform: translateY(-3px) rotate(-2deg); } }
@keyframes blink { 0%, 93%, 100% { transform: scaleY(1); } 96% { transform: scaleY(.1); } }
@keyframes hop { 40% { transform: translateY(-12px) rotate(4deg); } }
@keyframes wobble { 25% { transform: rotate(-8deg); } 75% { transform: rotate(6deg); } }
@keyframes pop { 0% { transform: scale(.3); opacity: 0; } 70% { transform: scale(1.3); } }
@keyframes shake { 20% { transform: translateX(-8px); } 40% { transform: translateX(8px); } 60% { transform: translateX(-5px); } 80% { transform: translateX(5px); } }
@keyframes rise { from { opacity: 0; transform: translateY(16px); } }
@keyframes cardin { from { opacity: 0; transform: translateY(22px) scale(.985); } }
@keyframes fbin { from { opacity: 0; transform: translateY(6px); } }
@keyframes star { 0% { transform: scale(0) rotate(-40deg); opacity: 0; } 65% { transform: scale(1.35) rotate(8deg); opacity: 1; } 100% { transform: scale(1) rotate(0); opacity: 1; } }
@keyframes glow { 50% { box-shadow: 0 0 0 7px rgba(240, 180, 90, .2); } }

/* ---------- screen + cards ---------- */
#screen { flex: 1; display: flex; align-items: center; justify-content: center; padding: clamp(8px, 2vh, 26px) clamp(12px, 3vw, 32px); }
.card { width: min(1100px, 100%); padding: clamp(14px, 2.4vh, 26px) clamp(16px, 2.6vw, 34px); border-radius: 22px; background: rgba(34, 50, 45, .97); border: 1.5px solid var(--edge); border-left: 7px solid var(--acc);
  box-shadow: 0 14px 44px rgba(0, 0, 0, .35); animation: cardin .26s var(--ease); position: relative; }
.qhead { display: flex; align-items: center; gap: 12px; min-height: 34px; }
.prompt { margin: 0; font-size: clamp(20px, 3vh, 28px); line-height: 1.3; }
.tag { padding: 3px 12px; border-radius: 999px; background: var(--task); color: #2b2008; font: 700 13px/1.4 var(--ui); letter-spacing: .08em; text-transform: uppercase; white-space: nowrap; }
.timer { margin-left: auto; font: 700 26px/1 var(--ui); font-variant-numeric: tabular-nums; color: var(--task); white-space: nowrap; }
.timer small { font: 600 14px var(--ui); color: var(--dim); margin-left: 10px; }
.stim { display: flex; flex-direction: column; align-items: center; gap: 10px; margin: clamp(8px, 1.8vh, 20px) 0; min-height: 40px; }
.stim:empty { display: none; }
.stim .row { display: flex; align-items: center; justify-content: center; gap: 22px; flex-wrap: wrap; }
.bigpic { width: clamp(110px, 24vh, 250px); height: clamp(110px, 24vh, 250px); }
.smallpic { width: clamp(90px, 17vh, 170px); height: clamp(90px, 17vh, 170px); }
.sit { padding: 16px 30px; border-radius: 22px; border: 2px dashed var(--edge); font-size: clamp(22px, 3.6vh, 34px); text-align: center; max-width: 780px; }
.sit small { display: block; font: 600 13px var(--ui); letter-spacing: .14em; text-transform: uppercase; color: var(--dim); margin-bottom: 4px; }
.say { font: 500 clamp(40px, 8vh, 72px)/1.1 var(--book); text-align: center; }
.claim { color: var(--dim); font-size: clamp(20px, 3vh, 28px); text-align: center; }
.claim b { color: var(--chalk); font-weight: 600; }
.listen { display: inline-flex; align-items: center; gap: 10px; padding: 10px 24px; border-radius: 999px; border: 2px solid var(--quiz); background: transparent; color: var(--chalk); font-size: clamp(20px, 3vh, 26px); font-weight: 600; }
.listen svg { width: 28px; height: 28px; color: var(--quiz); }
.listen:hover { background: rgba(134, 201, 232, .12); }
.listen.ring svg { animation: glow 1s ease-in-out 2; }
.listen.pulse { animation: glow 1.6s ease-in-out 3; }

/* options */
.opts { display: grid; gap: clamp(10px, 1.8vh, 18px); justify-content: center; margin-top: clamp(6px, 1.4vh, 16px); }
.opts.pics { grid-template-columns: repeat(var(--cols, 4), var(--ph, 190px)); }
.opts.words { grid-template-columns: repeat(var(--cols, 2), minmax(0, 1fr)); }
.opts.yn { grid-template-columns: repeat(2, minmax(0, 240px)); }
.opt { position: relative; display: flex; align-items: center; justify-content: center; gap: 4px; padding: 10px 18px; min-height: 64px; border-radius: 20px; border: 2px solid var(--edge); background: rgba(29, 43, 39, .9); color: var(--chalk); text-align: center; transition: border-color .15s, transform .15s var(--ease), background .15s; }
.opt:hover:not(:disabled) { border-color: var(--dim); transform: translateY(-2px); }
.opt:active:not(:disabled) { transform: scale(.97); }
.opt kbd { position: absolute; left: 10px; top: 8px; margin: 0; font-size: 14px; }
.opts.pics .opt { aspect-ratio: 1; padding: 8px; }
.opts.pics .opt img { width: 100%; height: 100%; display: block; pointer-events: none; }
.opts.words .opt { font: 500 clamp(26px, 4.6vh, 40px)/1.1 var(--book); padding: 10px 44px; min-height: clamp(64px, 11vh, 100px); }
.opts.words .opt.en { font: 500 clamp(22px, 3.6vh, 30px)/1.2 var(--ui); }
.opts.yn .opt { flex-direction: column; font: 500 clamp(30px, 5.4vh, 48px)/1.1 var(--book); min-height: clamp(70px, 12vh, 110px); }
.opts.yn .opt small { font: 600 14px var(--ui); color: var(--dim); letter-spacing: .1em; text-transform: uppercase; }
.opts.yn .opt.yes { border-color: rgba(143, 214, 176, .5); }
.opts.yn .opt.no { border-color: rgba(240, 140, 122, .5); }
.opt.good { border-color: var(--good); background: rgba(143, 214, 176, .14); box-shadow: 0 0 0 4px rgba(143, 214, 176, .3); animation: pop .4s var(--ease); }
.opt.bad { border-color: var(--bad); color: var(--bad); animation: shake .4s; }
.opt.bad img { opacity: .4; }
.opt:disabled:not(.good) { cursor: default; }
.opt:disabled:not(.good):not(.bad) { opacity: .5; }

/* hint line + footer */
.hint { min-height: 2.9em; margin: 10px 0 0; padding: 0; font-size: clamp(17px, 2.4vh, 21px); color: var(--chalk); display: flex; align-items: center; justify-content: center; text-align: center; }
.hint:empty::before { content: ""; }
.hint > span { animation: fbin .25s var(--ease); }
.hint.ok { color: var(--good); }
.hint.no > span::before { content: "✗ "; color: var(--bad); font-weight: 700; }
.hint.ok > span::before { content: "✓ "; font-weight: 700; }
.hint .w { font-size: 1.12em; }
.bar { display: flex; align-items: center; gap: 16px; margin-top: 6px; color: var(--dim); font-size: 15px; min-height: 54px; }
.bar .keys { flex: 1; }
.bar .keys kbd { margin: 0 .2em 0 .5em; }
.btn { padding: 11px 30px; border-radius: 999px; border: 0; background: var(--chalk); color: var(--board); font-weight: 700; font-size: 21px; white-space: nowrap; transition: transform .2s var(--ease); }
.btn:hover { transform: translateY(-2px); }
.btn.go { background: var(--quiz); color: #10242e; }
.btn.quiet { background: transparent; color: var(--dim); border: 1.5px solid var(--edge); font-weight: 600; }
.btn.quiet:hover { color: var(--chalk); border-color: var(--dim); }
.btn.big { font-size: 28px; padding: 16px 44px; }
.btn.pulse { animation: glow 1.6s ease-in-out infinite; }
.btn kbd { opacity: .55; }

/* the typing box (the engine's .box, which english.css builds on) and the helpers' cards inside a practice card */
.box { height: 52px; margin: 0 6px; padding: 0 6px; border: 0; border-bottom: 3px solid var(--quiz); border-radius: 8px 8px 0 0; background: rgba(236, 232, 220, .07); color: var(--chalk); font: 32px var(--book); text-align: center; vertical-align: -6px; }
.box:focus { outline: none; background: rgba(134, 201, 232, .16); }
.box.good { border-color: var(--good); }
.box.bad { border-color: var(--bad); }
.box:disabled { opacity: 1; }
.tbody { width: 100%; display: flex; flex-direction: column; align-items: center; }
.tbody.en-tap .en-toks { max-width: 1000px; }

/* sort the words: a pool of word blocks, two pattern boxes */
.pool { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; max-width: 960px; }
.blk { display: inline-flex; align-items: center; min-height: clamp(54px, 8.4vh, 70px); padding: 6px 22px; border-radius: 16px; border: 2px solid var(--edge); background: var(--board); color: var(--chalk); font: 500 clamp(24px, 4vh, 34px) var(--book); }
.blk kbd { margin: 0 .6em 0 0; font-family: var(--ui); }
.blk:hover:not(:disabled) { border-color: var(--dim); }
.blk.on { border-color: var(--quiz); box-shadow: 0 0 0 4px rgba(134, 201, 232, .25); animation: pop .3s var(--ease); }
.blk:disabled { opacity: .22; cursor: default; }
.bins { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: clamp(10px, 2vw, 22px); width: min(960px, 100%); margin-top: clamp(8px, 1.6vh, 16px); }
.bin { display: flex; flex-direction: column; align-items: center; gap: 8px; min-height: clamp(110px, 20vh, 180px); padding: 12px 16px; border-radius: 20px; border: 2px dashed var(--edge); background: rgba(29, 43, 39, .6); }
.bin:hover { border-color: var(--dim); }
.bin.shake { animation: shake .4s; }
.bin-head { display: inline-flex; align-items: center; gap: 4px; font: 500 clamp(24px, 4vh, 34px) var(--book); color: var(--task); }
.bin-head kbd { margin: 0 .5em 0 0; font-family: var(--ui); color: var(--dim); }
.bin-words { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 14px; font: 500 clamp(20px, 3.2vh, 26px) var(--book); color: var(--good); }
.bin-w { animation: pop .3s var(--ease); }
.bin-w.miss { color: var(--bad); }

/* interstitial / start / finish */
.big { text-align: center; }
.card.big { padding: clamp(20px, 4vh, 44px) clamp(18px, 3vw, 44px); display: flex; flex-direction: column; align-items: center; gap: clamp(8px, 1.8vh, 16px); }
.kick { margin: 0; font-size: 15px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; color: var(--acc); }
.title { margin: 0; font: 500 clamp(44px, 10vh, 84px)/1.05 var(--book); text-wrap: balance; }
.title i { color: var(--task); }
.lede { margin: 0; max-width: 34em; color: var(--dim); font-size: clamp(18px, 2.8vh, 24px); }
.rdone { display: flex; align-items: center; gap: 12px; padding: 6px 18px; border-radius: 999px; background: rgba(143, 214, 176, .1); color: var(--good); font-weight: 700; font-size: 18px; }
.rdone .dot { width: 10px; height: 10px; }
.ricon { width: clamp(54px, 9vh, 84px); height: clamp(54px, 9vh, 84px); color: var(--acc); }
.card.big .mascot { width: clamp(120px, 20vh, 190px); height: auto; }
.card.big > * { animation: rise .6s var(--ease) backwards; }
.card.big > :nth-child(2) { animation-delay: .08s; } .card.big > :nth-child(3) { animation-delay: .16s; } .card.big > :nth-child(4) { animation-delay: .24s; } .card.big > :nth-child(5) { animation-delay: .32s; }
.links { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; align-items: center; margin-top: 4px; }
.links a, .links button { text-decoration: none; }
.stars { display: flex; gap: 12px; justify-content: center; }
.stars svg { width: clamp(54px, 10vh, 84px); height: clamp(54px, 10vh, 84px); }
.stars .on { fill: var(--task); stroke: var(--task); animation: star .6s var(--ease) backwards; }
.stars .off { fill: none; stroke: var(--faint); }
.stars svg { stroke-width: 2; stroke-linejoin: round; }
.stats { display: flex; gap: clamp(18px, 4vw, 48px); justify-content: center; flex-wrap: wrap; }
.stats div { text-align: center; }
.stats b { display: block; font: 500 clamp(30px, 5.6vh, 46px)/1.1 var(--book); }
.stats span { color: var(--dim); font-size: 15px; letter-spacing: .06em; }
.newbest { color: var(--task); font-weight: 700; font-size: 18px; }
.chips { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; max-width: 900px; }
.chip { display: inline-flex; align-items: center; gap: 8px; padding: 6px 16px; border-radius: 999px; border: 1.5px solid var(--edge); background: transparent; font: 500 22px var(--book); }
.chip:hover { border-color: var(--quiz); }
.chip svg { width: 18px; height: 18px; flex: none; color: var(--quiz); }
.chip.long { font-size: 18px; text-align: left; }
.chiphead { color: var(--dim); font-size: 16px; margin: 0; }

/* toast + leave overlay + bursts */
.toast { position: fixed; left: 0; right: 0; margin: 0 auto; width: max-content; bottom: 11%; z-index: 6; padding: 12px 34px; border-radius: 999px; background: var(--task); color: #2b2008; font: 700 clamp(24px, 4vh, 36px) var(--ui); pointer-events: none; animation: star .55s var(--ease) backwards; white-space: nowrap; }
.toast.out { opacity: 0; transition: opacity .35s, transform .35s; transform: translateY(14px); }
.veil { position: fixed; inset: 0; z-index: 8; display: grid; place-items: center; background: rgba(15, 22, 19, .8); }
.veil .card { width: min(560px, 92vw); text-align: center; display: flex; flex-direction: column; gap: 14px; align-items: center; }
.bit { position: fixed; z-index: 7; width: 10px; height: 10px; border-radius: 50%; pointer-events: none; }

@media (max-width: 900px) {
  .hud { gap: 8px; flex-wrap: wrap; }
  .hudmid { order: 3; flex-basis: 100%; }
  .back span { display: none; }
}
@media (max-height: 760px) {
  .hud { min-height: 54px; padding-top: 5px; padding-bottom: 5px; }
  .hud .mascot { width: 52px; height: 36px; }
  .hint { min-height: 2.4em; margin-top: 4px; }
  .bar { min-height: 46px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001s !important; animation-iteration-count: 1 !important; transition-duration: .001s !important; }
}
