:root{
  --ease-snappy:cubic-bezier(0.22,1,0.36,1);
  --ease-bounce:cubic-bezier(0.34,1.56,0.64,1);
  --dur-fast:0.2s;
  --dur-med:0.32s;
  --dur-slow:0.5s;
  --shell-pad:clamp(0.85rem,2.2vw,1.5rem);
  --stage-max:42rem;
  --frame-max:72rem;
  --thai-scale:1.22;
  --thai-glyph-min:4rem;
  --thai-glyph-hero:clamp(4rem, 15vw, 7rem);
  --thai-glyph-pair:clamp(3.5rem, 12vw, 5.5rem);
  --chrome-bg:rgba(15,23,42,.82);
  --ink:#e2e8f0;
  --muted:#94a3b8;
  --line:rgba(51,65,85,.95);
  --accent:#fbbf24;
  --vvh:100vh;
  --vv-top:0px;
  --keyboard-inset:0px;
  --test-dock-height:10rem;
  --app-pad-bottom:0px;
}
.font-thai-looped{
  font-family:"Noto Serif Thai","Noto Sans Thai Looped",Tahoma,serif;
  font-weight:400;
}
.font-thai-modern{
  font-family:"Noto Sans Thai","Leelawadee UI",sans-serif;
  font-weight:400;
}
body, .app-body{
  font-family:Inter,system-ui,sans-serif;
  min-height:100vh;
  min-height:100dvh;
  margin:0;
  color:var(--ink);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(251,191,36,.08), transparent 55%),
    radial-gradient(900px 500px at 100% 0%, rgba(56,189,248,.06), transparent 50%),
    linear-gradient(180deg, #020617 0%, #0f172a 48%, #020617 100%);
  background-attachment:fixed;
}

/* —— Layout framework —— */
.app-shell{
  width:min(100%, var(--frame-max));
  margin:0 auto;
  min-height:100vh;
  min-height:100dvh;
  padding:var(--shell-pad);
  padding-bottom:max(calc(var(--shell-pad) + 1.25rem), var(--app-pad-bottom));
  display:flex;
  flex-direction:column;
  gap:0.85rem;
  box-sizing:border-box;
}
body.keyboard-open,
body.typing-focus{
  overflow:hidden;
}
body.keyboard-open .app-test-active,
body.typing-focus .app-test-active,
body.has-typed-dock .app-test-active{
  max-height:var(--vvh, 100dvh);
  min-height:0;
  overflow:hidden;
}
.shell-frame{
  display:flex;
  flex-direction:column;
  gap:0.85rem;
  flex:1;
  min-height:0;
}
.shell-chrome{
  display:flex;
  flex-wrap:wrap;
  align-items:center;
  justify-content:space-between;
  gap:0.5rem 1rem;
  padding:0.55rem 0.85rem;
  border:1px solid var(--line);
  border-radius:1rem;
  background:var(--chrome-bg);
  backdrop-filter:blur(10px);
}
.shell-chrome-compact{
  padding:0.4rem 0.75rem;
  font-size:0.85rem;
}
.shell-stage{
  flex:1;
  display:flex;
  flex-direction:column;
  justify-content:center;
  width:min(100%, var(--stage-max));
  margin-inline:auto;
  min-height:0;
}
.shell-stage-wide{
  width:min(100%, 58rem);
}
.shell-grid{
  display:grid;
  gap:0.85rem;
}
@media (min-width:900px){
  .shell-grid-dash{
    grid-template-columns:minmax(0,1.35fr) minmax(16rem,0.85fr);
    align-items:start;
  }
  .shell-grid-lessons{
    grid-template-columns:repeat(2, minmax(0,1fr));
  }
}
@media (min-width:1100px){
  .shell-grid-lessons{
    grid-template-columns:repeat(3, minmax(0,1fr));
  }
}
.panel{
  border:1px solid var(--line);
  border-radius:1.15rem;
  background:rgba(15,23,42,.72);
  padding:1rem 1.1rem;
}
.panel-quiet{
  background:rgba(2,6,23,.45);
}
.panel summary,
.panel-toggle{
  cursor:pointer;
  list-style:none;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:0.75rem;
  font-weight:600;
  color:#f1f5f9;
  user-select:none;
}
.panel summary::-webkit-details-marker{display:none}
.panel summary::after,
.panel-toggle .chevron{
  content:"";
  width:0.55rem;
  height:0.55rem;
  border-right:2px solid #94a3b8;
  border-bottom:2px solid #94a3b8;
  transform:rotate(45deg);
  transition:transform .18s var(--ease-snappy);
  flex:0 0 auto;
}
.panel[open] summary::after,
.panel-toggle[aria-expanded="true"] .chevron{
  transform:rotate(225deg);
}
.panel-body{margin-top:0.85rem}
.hero-brand{
  display:flex;
  flex-direction:column;
  gap:0.35rem;
}
.hero-brand h1{
  margin:0;
  font-size:clamp(2rem,4.5vw,2.85rem);
  font-weight:800;
  letter-spacing:-0.02em;
  line-height:1.1;
}
.hero-brand p{margin:0;color:var(--muted)}
.cta-stack{display:grid;gap:0.65rem}
@media (min-width:700px){
  .cta-stack-primary{
    grid-template-columns:1.4fr 1fr;
  }
}
.meta-row{
  display:flex;
  flex-wrap:wrap;
  align-items:center;
  gap:0.45rem 0.85rem;
  color:var(--muted);
  font-size:0.85rem;
}
.stat-inline{
  display:inline-flex;
  align-items:center;
  gap:0.35rem;
  padding:0.2rem 0.55rem;
  border-radius:999px;
  border:1px solid var(--line);
  background:rgba(2,6,23,.35);
  color:#cbd5e1;
  font-size:0.78rem;
  font-weight:600;
}

/* Thai glyphs: slightly larger than Latin UI; regular weight — never bold */
.thai-glyph{
  font-family:"Noto Serif Thai","Noto Sans Thai Looped",Tahoma,serif;
  font-size:calc(1em * var(--thai-scale));
  line-height:1.55;
  font-weight:400;
  display:inline-block;
  vertical-align:-0.08em;
  color:#f8fafc;
  overflow:visible;
}
.thai-glyph-title{
  font-size:calc(1.15em * var(--thai-scale));
  font-weight:400;
  vertical-align:-0.12em;
}
.thai-glyph-hero{
  display:block;
  font-size:var(--thai-glyph-hero);
  line-height:1.55;
  text-align:center;
  font-weight:400;
  overflow:visible;
  padding:0.2em 0.35em;
}
.thai-glyph-pair{
  font-size:var(--thai-glyph-pair);
  line-height:1.55;
  font-weight:400;
  overflow:visible;
  padding:0.15em 0.3em;
}
.font-thai-modern.thai-glyph,
.font-thai-modern.thai-glyph-hero,
.font-thai-modern.thai-glyph-pair,
.thai-glyph.font-thai-modern{
  font-family:"Noto Sans Thai","Leelawadee UI",sans-serif;
}
.thai-inline-list{
  display:flex;
  flex-wrap:wrap;
  gap:0.45rem 0.7rem;
  align-items:center;
}
.thai-inline-list .thai-glyph{
  font-size:clamp(1.65rem, 3.8vw, 2.15rem);
  font-weight:400;
  padding:0.35rem 0.55rem;
  border-radius:0.5rem;
  background:rgba(2,6,23,.45);
  border:1px solid rgba(51,65,85,.7);
  line-height:1.55;
  overflow:visible;
}

.test-stage-block{
  display:flex;
  flex-direction:column;
  justify-content:center;
  gap:1rem;
  flex:1;
  min-height:0;
  overflow-y:auto;
  -webkit-overflow-scrolling:touch;
}
.test-chrome-bar{
  display:flex;
  flex-wrap:wrap;
  align-items:center;
  justify-content:space-between;
  gap:0.5rem 0.75rem;
}
.test-meta.test-chrome-bar .stat-inline,
.test-stat{
  min-width:5.5rem;
  font-variant-numeric:tabular-nums;
  white-space:nowrap;
}
.test-stat:last-child{text-align:right}
.vol-label-fixed{
  display:inline-block;
  min-width:3.25rem;
  text-align:right;
  font-variant-numeric:tabular-nums;
}
.test-shell{
  display:flex;
  flex-direction:column;
  gap:0.75rem;
  min-height:min(100%, calc(var(--vvh, 100vh) - 2rem));
}
.test-shell-type .test-top{
  flex:0 1 auto;
  min-height:0;
  overflow-y:auto;
  -webkit-overflow-scrolling:touch;
}
.test-shell-type .test-body{
  flex:1 1 auto;
  min-height:0;
  display:flex;
  flex-direction:column;
  justify-content:center;
  overflow:hidden;
}
.test-input-bar{
  flex:0 0 auto;
  padding-top:0.35rem;
}
.test-type-dock{
  display:flex;
  flex-direction:column;
  gap:0.35rem;
  flex-shrink:0;
}
.test-type-dock .slide-actions{
  position:static;
  margin-top:0;
  padding:0;
  background:none;
}
.answer-input{
  font-size:1.125rem;
  line-height:1.35;
  touch-action:manipulation;
}

/* Mobile typed-answer layout — no lesson header, compact feedback, inline Go */
.test-compact{
  display:flex;
  flex-direction:column;
  gap:0.45rem;
  flex:1;
  min-height:0;
  max-height:var(--vvh, 100dvh);
  overflow:hidden;
}
@media (max-width:640px){
  .app-test-active.app-shell{
    padding:0.35rem var(--shell-pad);
    padding-bottom:max(0.35rem, env(safe-area-inset-bottom, 0px));
    gap:0.35rem;
    min-height:0;
    max-height:var(--vvh, 100dvh);
  }
  body.keyboard-open .test-compact-bar .hearts-bar,
  body.typing-focus .test-compact-bar .hearts-bar{
    display:none;
  }
  body.keyboard-open .fb-strip-detail,
  body.typing-focus .fb-strip-detail{
    display:-webkit-box;
    -webkit-line-clamp:2;
    -webkit-box-orient:vertical;
    overflow:hidden;
  }
}
.test-compact-bar{
  display:flex;
  align-items:center;
  gap:0.35rem 0.5rem;
  flex-wrap:nowrap;
  flex-shrink:0;
  position:relative;
  z-index:5;
  padding:0.35rem 0.55rem;
  border:1px solid var(--line);
  border-radius:0.75rem;
  background:var(--chrome-bg);
  font-size:0.78rem;
  color:var(--muted);
}
.test-compact-stat{
  font-variant-numeric:tabular-nums;
  white-space:nowrap;
  flex:0 0 auto;
}
.test-compact-bar .hearts-bar{
  flex:0 1 auto;
  min-width:0;
  padding:0.15rem 0.35rem;
}
.test-compact-bar .hearts-label{display:none}
.test-compact-exit{
  margin-left:auto;
  appearance:none;
  border:1px solid rgba(71,85,105,.7);
  border-radius:0.55rem;
  background:rgba(30,41,59,.95);
  color:#cbd5e1;
  font-size:0.75rem;
  font-weight:600;
  padding:0.35rem 0.55rem;
  flex:0 0 auto;
  cursor:pointer;
  position:relative;
  z-index:30;
  pointer-events:auto;
}
.test-compact-main{
  flex:1 1 auto;
  min-height:0;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  overflow-y:auto;
  -webkit-overflow-scrolling:touch;
  padding:0.15rem 0;
}
.test-compact-main .thai-glyph-hero{
  margin-bottom:0!important;
  font-size:clamp(2.75rem, 14vw, 4rem)!important;
  line-height:1.2;
}
body.typing-focus .test-compact-main .thai-glyph-hero,
body.keyboard-open .test-compact-main .thai-glyph-hero{
  font-size:clamp(2.25rem, 11vw, 3rem)!important;
}
.test-compact-input-row{
  display:flex;
  align-items:stretch;
  gap:0.45rem;
  flex-shrink:0;
}
.test-compact-input-row .answer-input{
  flex:1 1 auto;
  min-width:0;
  padding:0.65rem 0.85rem;
  font-size:1.05rem;
  border-radius:0.85rem;
}
.test-compact-submit{
  appearance:none;
  border:none;
  border-radius:0.85rem;
  background:#fbbf24;
  color:#020617;
  font-weight:700;
  font-size:0.95rem;
  padding:0 1rem;
  min-width:3.25rem;
  flex:0 0 auto;
  cursor:pointer;
}
.test-compact-input-row.is-pinned{
  box-shadow:0 -8px 24px rgba(2, 6, 23, 0.85);
}

#typed-input-dock{
  display:none;
  position:fixed;
  left:50%;
  transform:translateX(-50%);
  width:min(calc(100% - 2 * var(--shell-pad)), var(--frame-max));
  bottom:0;
  z-index:10000;
  padding:0.35rem 0 max(0.35rem, env(safe-area-inset-bottom, 0px));
  background:linear-gradient(to top, #020617 94%, rgba(2, 6, 23, 0));
  box-sizing:border-box;
}
#typed-input-dock.is-active{
  display:block;
}
.fullscreen-banner{
  border:1px solid rgba(251,191,36,.45);
  border-radius:0.85rem;
  background:rgba(251,191,36,.08);
  padding:0.65rem 0.85rem;
  color:#fde68a;
  margin-bottom:0.45rem;
  flex-shrink:0;
}
body.has-typed-dock .fullscreen-banner{
  display:none;
}
.fullscreen-banner-title{
  display:block;
  font-weight:700;
  font-size:0.9rem;
}
.fullscreen-banner-sub{
  display:block;
  margin-top:0.2rem;
  font-size:0.78rem;
  color:#cbd5e1;
}
body.has-typed-dock .test-compact{
  padding-bottom:0.25rem;
}

@media (max-width:640px){
  .lesson-rail.screen-with-actions{
    max-height:100dvh;
    gap:0.45rem;
  }
  .lesson-rail .lesson-stage{
    justify-content:flex-start;
    overflow-y:auto;
    -webkit-overflow-scrolling:touch;
    padding-top:0.15rem;
  }
  .lesson-rail .hint-footer{display:none}
  .lesson-rail .shell-chrome{padding:0.35rem 0.55rem;font-size:0.78rem}
  .lesson-rail .slide-actions{padding:0.35rem 0 calc(0.25rem + env(safe-area-inset-bottom,0px))}
  .lesson-rail .slide-action{min-height:2.5rem;padding:0.65rem 0.75rem;font-size:0.88rem}
  .flip-scene,.flip-card{min-height:min(30vh,11rem)}
  .flip-face{padding:0.85rem 0.9rem;gap:0.45rem}
  .symbol-duo{
    gap:0.45rem;
    margin:0.25rem 0;
    grid-template-columns:repeat(2,minmax(0,1fr));
  }
  .symbol-duo .thai-glyph-hero,
  .teach-card .thai-glyph-hero,
  .symbol-card .thai-glyph-hero{
    font-size:clamp(2.25rem,13vw,3rem);
    min-height:1.15em;
    padding:0.1em 0.2em;
  }
  .teach-card{padding:0.75rem 0.85rem}
  .teach-card h3{font-size:1.05rem}
  .slide-body h1{font-size:1.65rem}
  .intro-pill{font-size:0.75rem}
  .lesson-rail .slide-body{max-width:100%}
}
@media (max-width:640px) and (max-height:520px){
  .teach-card .symbol-example{display:none}
  .symbol-duo{grid-template-columns:1fr}
  .flip-scene,.flip-card{min-height:min(26vh,9.5rem)}
  .lesson-rail .shell-grid{grid-template-columns:1fr!important}
  .slide-body.space-y-5{gap:0.65rem!important}
}
.fb-strip{
  flex-shrink:0;
  border-radius:0.65rem;
  padding:0.45rem 0.65rem;
  font-size:0.78rem;
  line-height:1.35;
  text-align:left;
  display:flex;
  flex-direction:column;
  gap:0.15rem;
}
.fb-strip-ok{
  background:#047857;
  border:1px solid #059669;
  color:#ecfdf5;
}
.fb-strip-bad{
  background:#be123c;
  border:1px solid #e11d48;
  color:#fff1f2;
}
.fb-strip-label{
  font-weight:700;
  margin-right:0.35rem;
}
.fb-strip-detail strong{color:#fff}

.reading-feedback{
  margin-top:0.45rem;
  display:flex;
  flex-direction:column;
  gap:0.35rem;
}
.reading-mistake-headline{
  font-size:0.82rem;
  line-height:1.4;
  color:#fecaca;
  font-weight:600;
}
.reading-mistake-right{
  font-size:0.78rem;
  color:#6ee7b7;
}
.reading-breakdown{
  list-style:none;
  margin:0.45rem 0 0;
  padding:0;
  display:flex;
  flex-direction:column;
  gap:0.35rem;
}
.reading-unit{
  display:flex;
  flex-wrap:wrap;
  align-items:baseline;
  gap:0.35rem 0.5rem;
  font-size:0.78rem;
  line-height:1.35;
  padding:0.35rem 0.45rem;
  border-radius:0.55rem;
  background:rgba(15,23,42,.55);
}
.reading-unit-ok .reading-unit-icon{color:#34d399}
.reading-unit-bad{
  background:rgba(127,29,29,.35);
  border:1px solid rgba(248,113,113,.35);
}
.reading-unit-bad .reading-unit-icon{color:#fb7185}
.reading-unit-label{
  font-weight:600;
  color:#e2e8f0;
  flex:1 1 auto;
  min-width:8rem;
}
.reading-unit-detail{color:#94a3b8}
.reading-unit-detail strong{color:#fff}
.fb-card .reading-breakdown{margin-top:0.65rem}
.fb-strip .reading-breakdown .reading-unit{font-size:0.72rem;padding:0.25rem 0.4rem}

html:fullscreen,
html:-webkit-full-screen{
  height:100%;
  background:#020617;
}
html:fullscreen body,
html:-webkit-full-screen body{
  min-height:100%;
}
html:fullscreen .app-shell,
html:-webkit-full-screen .app-shell{
  max-height:100%;
  min-height:100%;
  padding-bottom:max(var(--shell-pad), env(safe-area-inset-bottom, 0px));
}
@media (display-mode:standalone){
  .app-shell{
    padding-top:max(var(--shell-pad), env(safe-area-inset-top, 0px));
    padding-bottom:max(calc(var(--shell-pad) + 1.25rem), env(safe-area-inset-bottom, 0px));
  }
}

.dash-aside{display:flex;flex-direction:column;gap:0.75rem}
.lesson-rail{
  display:flex;
  flex-direction:column;
  gap:0.75rem;
  flex:1;
  min-height:0;
}
.lesson-stage{
  flex:1;
  display:flex;
  flex-direction:column;
  justify-content:center;
  width:min(100%, var(--stage-max));
  margin-inline:auto;
  min-height:0;
  overflow-x:hidden;
  overflow-y:auto;
  -webkit-overflow-scrolling:touch;
}
.lesson-stage-wide{width:min(100%, 56rem)}
.lesson-stage-contrast{width:min(100%, 48rem)}
.lessons-level{margin:0}
.lessons-level h2{
  margin:0 0 0.65rem;
  font-size:0.8rem;
  font-weight:700;
  letter-spacing:0.12em;
  text-transform:uppercase;
  color:var(--accent);
}
.lesson-card{
  text-align:left;
  width:100%;
  border:1px solid var(--line);
  border-radius:1rem;
  background:rgba(15,23,42,.72);
  padding:0.95rem 1rem;
  color:inherit;
}
.lesson-card[disabled],
.lesson-card.is-locked{
  opacity:0.55;
  cursor:not-allowed;
}
.lesson-card-top{
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap:0.75rem;
}
.lesson-card-meta{color:var(--muted);font-size:0.8rem;margin-top:0.15rem}
.lesson-card-syms{
  margin-top:0.55rem;
  display:flex;
  flex-wrap:wrap;
  gap:0.35rem;
}
.progress-head{margin:0}
.stat-list{display:grid;gap:0.55rem;font-size:0.9rem}
.stat-list-row{display:flex;justify-content:space-between;gap:0.75rem;color:#cbd5e1}
.stat-list-row span:first-child{color:var(--muted)}
.hint-footer{
  margin:0;
  text-align:center;
  color:#64748b;
  font-size:0.75rem;
  flex-shrink:0;
}
.screen-with-actions{
  max-height:calc(100dvh - 2 * var(--shell-pad));
  overflow:hidden;
}
.slide-actions{
  display:flex;
  flex-wrap:wrap;
  align-items:stretch;
  gap:0.5rem;
  flex-shrink:0;
  position:sticky;
  bottom:0;
  z-index:30;
  margin-top:auto;
  padding:0.55rem 0 calc(0.35rem + env(safe-area-inset-bottom, 0px));
  background:linear-gradient(to top, rgba(2,6,23,.98) 55%, rgba(2,6,23,.82) 78%, rgba(2,6,23,0));
}
.slide-action{
  appearance:none;
  border:2px solid transparent;
  border-radius:1rem;
  font-weight:600;
  font-size:0.95rem;
  line-height:1.2;
  padding:0.85rem 1rem;
  min-height:2.85rem;
  cursor:pointer;
  transition:transform 0.12s var(--ease-snappy), background .15s, border-color .15s, box-shadow .15s;
}
.slide-action:active{transform:scale(0.975)}
.slide-action:focus-visible{
  border-color:#fbbf24;
  box-shadow:0 0 0 2px rgba(251,191,36,.25);
  outline:none;
}
.slide-action:disabled,
.slide-action[aria-disabled="true"]{
  opacity:0.4;
  cursor:not-allowed;
  transform:none;
}
.slide-action-ghost{
  background:rgba(30,41,59,.95);
  color:#e2e8f0;
  border-color:rgba(71,85,105,.7);
}
.slide-action-secondary{
  background:rgba(30,41,59,.95);
  color:#f8fafc;
  border-color:rgba(71,85,105,.7);
  flex:1 1 7rem;
}
.slide-action-primary{
  background:#fbbf24;
  color:#020617;
  flex:1 1 9rem;
  font-weight:700;
}
@media (max-width:420px){
  .slide-actions{gap:0.4rem}
  .slide-action{padding:0.8rem 0.75rem;font-size:0.9rem}
}
.symbol-duo{
  display:grid;
  grid-template-columns:repeat(2, minmax(9.5rem, 1fr));
  gap:1rem;
  text-align:center;
  margin:0.85rem 0;
  width:100%;
  max-width:36rem;
  margin-inline:auto;
  overflow:visible;
}
.symbol-card{
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  min-width:9.5rem;
  min-height:7.5rem;
  padding:1.1rem 1.25rem 1.25rem;
  border-radius:1rem;
  border:1px solid var(--line);
  background:rgba(2,6,23,.55);
  overflow:visible;
}
.symbol-duo-label{
  font-size:0.7rem;
  color:var(--muted);
  margin:0 0 0.55rem;
  letter-spacing:0.06em;
  text-transform:uppercase;
  font-family:Inter,system-ui,sans-serif;
  font-weight:600;
}
.teach-card{
  overflow:visible;
  max-width:min(100%, 42rem);
  margin-inline:auto;
  width:100%;
  padding:1.25rem 1.35rem 1.4rem;
}
.teach-card h3{margin:0 0 0.65rem;font-size:1.25rem;font-weight:700}
.teach-card .teach-copy{margin:0;color:#cbd5e1;font-size:1.05rem;line-height:1.55}
/* Isolated letter / word cards — large, regular weight, no crop */
.symbol-duo .thai-glyph-hero,
.teach-card .thai-glyph-hero,
.symbol-card .thai-glyph-hero{
  display:block;
  font-size:var(--thai-glyph-hero);
  min-height:1.55em;
  line-height:1.55;
  text-align:center;
  font-weight:400;
  color:#f8fafc;
  margin:0;
  padding:0.35em 0.45em;
  overflow:visible;
}
.symbol-duo .thai-glyph-pair,
.teach-card .thai-glyph-pair,
.symbol-card .thai-glyph-pair{
  display:block;
  font-size:var(--thai-glyph-pair);
  min-height:1.55em;
  line-height:1.55;
  text-align:center;
  font-weight:400;
  color:#f8fafc;
  margin:0;
  padding:0.3em 0.4em;
  overflow:visible;
}

/* 3D playing-card flip for lesson word reveals */
.flip-scene{
  perspective:1400px;
  perspective-origin:50% 50%;
  width:min(100%, 42rem);
  margin:0 auto;
  min-height:min(58vh, 28rem);
  /* Clip mid-flip projection so ancestors don't grow a scrollbar and jitter. */
  overflow:hidden;
  isolation:isolate;
}
.flip-card{
  position:relative;
  width:100%;
  min-height:min(58vh, 28rem);
  transform-style:preserve-3d;
  transition:transform 0.7s var(--ease-snappy);
  will-change:transform;
}
.flip-card.is-flipped{transform:rotateY(180deg)}
.flip-face,
.flip-face.panel{
  position:absolute;
  inset:0;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:0.75rem;
  padding:1.35rem 1.4rem;
  /* Opaque face — translucent panels defeat backface-visibility and show the mirrored back. */
  background:#0f172a;
  border:1px solid var(--line);
  border-radius:1.15rem;
  backface-visibility:hidden;
  -webkit-backface-visibility:hidden;
  overflow:hidden;
  text-align:center;
  transform-style:preserve-3d;
}
.flip-front{transform:rotateY(0deg) translateZ(1px)}
.flip-back{transform:rotateY(180deg) translateZ(1px)}
.flip-kicker{
  margin:0;
  font-size:0.72rem;
  letter-spacing:0.12em;
  text-transform:uppercase;
  color:var(--muted);
  font-weight:700;
}
.flip-hint{margin:0.35rem 0 0;color:var(--muted);font-size:0.95rem}
.flip-roman{
  margin:0.15rem 0 0;
  font-size:clamp(1.35rem, 3.5vw, 1.85rem);
  font-weight:700;
  color:#fbbf24;
}
.flip-meaning{
  margin:0.15rem 0 0;
  font-size:clamp(1.2rem, 3vw, 1.55rem);
  color:#f1f5f9;
  display:flex;
  align-items:center;
  justify-content:center;
  gap:0.45rem;
}
.flip-emoji{font-size:1.45em;line-height:1}
.flip-explain{
  margin:0.35rem 0 0;
  color:#94a3b8;
  font-size:0.98rem;
  line-height:1.45;
  max-width:28rem;
}
.intro-pill{
  display:inline-block;
  margin-top:0.5rem;
  padding:0.2rem 0.55rem;
  border-radius:0.5rem;
  background:rgba(30,41,59,.9);
  font-size:0.75rem;
  text-transform:capitalize;
  color:#cbd5e1;
}
@media (max-width:899px){
  .shell-stage,.lesson-stage{width:100%}
  .shell-grid-dash{grid-template-columns:1fr}
}

@keyframes confetti-fall{0%{transform:translateY(-10vh) rotate(0deg);opacity:1}100%{transform:translateY(110vh) rotate(720deg);opacity:0}}
@keyframes fade-up{from{opacity:0;transform:translateY(16px)}to{opacity:1;transform:translateY(0)}}
@keyframes fade-in{from{opacity:0}to{opacity:1}}
@keyframes slide-in-right{from{opacity:0;transform:translateX(32px)}to{opacity:1;transform:translateX(0)}}
@keyframes slide-in-left{from{opacity:0;transform:translateX(-32px)}to{opacity:1;transform:translateX(0)}}
@keyframes pop-in{from{opacity:0;transform:scale(0.9)}to{opacity:1;transform:scale(1)}}
@keyframes pop-bounce{0%{opacity:0;transform:scale(0.55)}65%{transform:scale(1.07)}100%{opacity:1;transform:scale(1)}}
@keyframes feedback-in{from{opacity:0;transform:translateY(-10px) scale(0.94)}to{opacity:1;transform:translateY(0) scale(1)}}
@keyframes score-reveal{0%{opacity:0;transform:scale(0.45)}70%{transform:scale(1.06)}100%{opacity:1;transform:scale(1)}}
@keyframes score-glow{0%,100%{text-shadow:0 0 0 transparent}50%{text-shadow:0 0 24px rgba(52,211,153,.45)}}
@keyframes shimmer{0%{background-position:-200% center}100%{background-position:200% center}}
@keyframes progress-pulse{0%,100%{box-shadow:0 0 0 0 rgba(251,191,36,0)}50%{box-shadow:0 0 10px 1px rgba(251,191,36,.35)}}
@keyframes screen-shake{0%,100%{transform:translateX(0)}18%{transform:translateX(-7px)}36%{transform:translateX(7px)}54%{transform:translateX(-5px)}72%{transform:translateX(5px)}86%{transform:translateX(-2px)}}
@keyframes flash-punch-green{0%{background:rgba(16,185,129,0)}12%{background:rgba(16,185,129,.55)}100%{background:rgba(16,185,129,0)}}
@keyframes flash-punch-red{0%{background:rgba(244,63,94,0)}12%{background:rgba(244,63,94,.58)}100%{background:rgba(244,63,94,0)}}
@keyframes flash-punch-green-big{0%{background:rgba(16,185,129,0)}14%{background:rgba(16,185,129,.65)}100%{background:rgba(16,185,129,0)}}
@keyframes flash-punch-red-big{0%{background:rgba(244,63,94,0)}14%{background:rgba(244,63,94,.65)}100%{background:rgba(244,63,94,0)}}
@keyframes test-enter{0%{opacity:0;transform:translateY(22px) scale(.9)}65%{transform:translateY(-3px) scale(1.02)}100%{opacity:1;transform:translateY(0) scale(1)}}
@keyframes feedback-success{0%{opacity:0;transform:translateY(-14px) scale(.82)}55%{transform:translateY(3px) scale(1.05)}100%{opacity:1;transform:translateY(0) scale(1)}}
@keyframes feedback-fail{0%{opacity:0;transform:scale(.94)}12%{opacity:1;transform:translateX(-8px) scale(1)}28%{transform:translateX(7px)}44%{transform:translateX(-5px)}60%{transform:translateX(4px)}76%{transform:translateX(-2px)}100%{transform:translateX(0) scale(1)}}
@keyframes score-bump{0%{transform:scale(1)}35%{transform:scale(1.35);color:#34d399}70%{transform:scale(.95)}100%{transform:scale(1)}}
@keyframes score-dip{0%{transform:scale(1)}25%{transform:scale(.85);color:#fb7185}55%{transform:scale(1.08)}100%{transform:scale(1)}}
@keyframes thai-pop{0%{opacity:0;transform:scale(.68) translateY(18px)}55%{transform:scale(1.08) translateY(-4px)}100%{opacity:1;transform:scale(1) translateY(0)}}
@keyframes heart-break{
  0%{transform:scale(1);filter:none}
  35%{transform:scale(1.45) rotate(-8deg);color:#fb7185;text-shadow:0 0 12px rgba(251,113,133,.8)}
  70%{transform:scale(.85) rotate(6deg);color:#64748b}
  100%{transform:scale(1);color:#334155;filter:grayscale(1)}
}
@keyframes heart-pulse{
  0%,100%{transform:scale(1)}
  50%{transform:scale(1.08)}
}
@keyframes death-in{
  0%{opacity:0;transform:scale(1.15) translateY(12px)}
  40%{opacity:1;transform:scale(.97) translateY(0)}
  100%{opacity:1;transform:scale(1)}
}
@keyframes death-burst{
  0%{opacity:.9;transform:scale(.4)}
  60%{opacity:.55;transform:scale(1.35)}
  100%{opacity:0;transform:scale(1.8)}
}
@keyframes screen-shake-hard{
  0%,100%{transform:translate(0,0)}
  10%{transform:translate(-12px,4px)}
  20%{transform:translate(14px,-6px)}
  30%{transform:translate(-10px,-4px)}
  40%{transform:translate(12px,8px)}
  50%{transform:translate(-8px,2px)}
  60%{transform:translate(10px,-6px)}
  70%{transform:translate(-6px,4px)}
  80%{transform:translate(6px,-2px)}
  90%{transform:translate(-3px,1px)}
}
@keyframes flash-death{
  0%{background:rgba(244,63,94,0)}
  8%{background:rgba(244,63,94,.75)}
  22%{background:rgba(15,23,42,.55)}
  40%{background:rgba(244,63,94,.45)}
  100%{background:rgba(244,63,94,0)}
}

.screen-flash{position:fixed;inset:0;pointer-events:none;z-index:9998;background:transparent}
.screen-flash.flash-success{animation:flash-punch-green .9s cubic-bezier(0.16,1,0.3,1) both}
.screen-flash.flash-fail{animation:flash-punch-red .9s cubic-bezier(0.16,1,0.3,1) both}
.screen-flash.flash-success-big{animation:flash-punch-green-big 1.4s cubic-bezier(0.16,1,0.3,1) both}
.screen-flash.flash-fail-big{animation:flash-punch-red-big 1.4s cubic-bezier(0.16,1,0.3,1) both}
.screen-flash.flash-death{animation:flash-death 1.35s cubic-bezier(0.16,1,0.3,1) both}
body.screen-shake{animation:screen-shake .42s ease both}
body.screen-shake-hard{animation:screen-shake-hard .9s ease both}

.hearts-bar{
  display:inline-flex;
  align-items:center;
  gap:.2rem;
  padding:.2rem .55rem;
  border-radius:999px;
  background:rgba(15,23,42,.75);
  border:1px solid rgba(51,65,85,.9);
}
.hearts-bar-perfect{border-color:rgba(251,191,36,.45)}
.hearts-bar-danger{
  border-color:rgba(251,113,133,.7);
  box-shadow:0 0 0 1px rgba(251,113,133,.25);
  animation:heart-pulse 0.7s ease-in-out infinite;
}
.hearts-bar-danger .hearts-label{color:#fb7185}
.heart{
  font-size:1.25rem;
  line-height:1;
  display:inline-block;
  transition:color .2s var(--ease-snappy), transform .2s var(--ease-bounce);
}
.heart-live{
  color:#f43f5e;
  animation:heart-pulse 1.6s ease-in-out infinite;
  text-shadow:0 0 8px rgba(244,63,94,.35);
}
.heart-dead{
  color:#334155;
  filter:grayscale(1);
  opacity:.85;
}
.heart-break{animation:heart-break .55s var(--ease-snappy) both}
.hearts-label{
  margin-left:.35rem;
  font-size:.7rem;
  font-weight:700;
  letter-spacing:.04em;
  color:#94a3b8;
  text-transform:uppercase;
  min-width:5.75rem;
  text-align:center;
  font-variant-numeric:tabular-nums;
  white-space:nowrap;
}
.death-screen{
  position:relative;
  min-height:70vh;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  text-align:center;
  gap:1rem;
  overflow:hidden;
  animation:death-in .45s var(--ease-bounce) both;
}
.death-burst{
  position:absolute;
  width:min(80vw,22rem);
  height:min(80vw,22rem);
  border-radius:50%;
  background:radial-gradient(circle,rgba(244,63,94,.55),transparent 68%);
  animation:death-burst 1.2s var(--ease-snappy) both;
  pointer-events:none;
}
.death-title{
  position:relative;
  font-size:clamp(2.2rem,8vw,3.2rem);
  font-weight:800;
  color:#fb7185;
  text-shadow:0 0 24px rgba(244,63,94,.45);
}
.death-sub{position:relative;color:#e2e8f0;font-size:1.05rem;max-width:20rem}
.death-score{position:relative;color:#94a3b8;font-size:.9rem}

.fb-card{
  border:1px solid transparent;
  border-radius:1rem;
  padding:1rem 1.1rem;
  display:flex;
  flex-direction:column;
  align-items:center;
  text-align:center;
  gap:.55rem;
}
.fb-card-ok{
  background:#047857;
  border-color:#059669;
  color:#ecfdf5;
}
.fb-card-bad{
  background:#be123c;
  border-color:#e11d48;
  color:#fff1f2;
}
.fb-emoji{
  font-size:clamp(2.4rem,10vw,3.4rem);
  line-height:1;
  filter:drop-shadow(0 4px 10px rgba(0,0,0,.25));
}
.fb-body{width:100%}
.fb-label{font-weight:700;font-size:1rem;color:#fff}
.fb-thai{
  font-size:calc(1.35rem * var(--thai-scale));
  margin-left:.25rem;
  vertical-align:middle;
  color:#fff;
}
.fb-answer{font-size:.95rem;margin-top:.2rem}
.fb-meaning{
  margin-top:.45rem;
  font-size:1.05rem;
  font-weight:600;
  color:#fff;
  opacity:.95;
}

.confetti-piece{position:fixed;width:10px;height:10px;top:-10px;animation:confetti-fall 3s ease-in forwards;z-index:9999;pointer-events:none}
.mastery-dot{width:8px;height:8px;border-radius:50%;display:inline-block;transition:background .25s var(--ease-snappy),transform .25s var(--ease-bounce)}
.mastery-dot.filled{background:#34d399}
.mastery-dot.empty{background:#334155}

.anim-screen{animation:fade-up var(--dur-med) var(--ease-snappy) both}
.anim-stagger>*{animation:fade-up var(--dur-med) var(--ease-snappy) both}
.anim-stagger>*:nth-child(1){animation-delay:0ms}
.anim-stagger>*:nth-child(2){animation-delay:50ms}
.anim-stagger>*:nth-child(3){animation-delay:100ms}
.anim-stagger>*:nth-child(4){animation-delay:150ms}
.anim-stagger>*:nth-child(5){animation-delay:200ms}
.anim-stagger>*:nth-child(6){animation-delay:250ms}
.anim-stagger>*:nth-child(7){animation-delay:300ms}
.anim-stagger>*:nth-child(8){animation-delay:350ms}
.anim-stagger>*:nth-child(9){animation-delay:400ms}
.anim-stagger>*:nth-child(10){animation-delay:450ms}
.anim-stagger>*:nth-child(11){animation-delay:500ms}
.anim-stagger>*:nth-child(12){animation-delay:550ms}

.anim-stagger-tight>*{animation:pop-in var(--dur-fast) var(--ease-snappy) both}
.anim-stagger-tight>*:nth-child(1){animation-delay:0ms}
.anim-stagger-tight>*:nth-child(2){animation-delay:60ms}
.anim-stagger-tight>*:nth-child(3){animation-delay:120ms}
.anim-stagger-tight>*:nth-child(4){animation-delay:180ms}

.anim-slide-forward .slide-body{animation:slide-in-right var(--dur-med) var(--ease-snappy) both}
.anim-slide-back .slide-body{animation:slide-in-left var(--dur-med) var(--ease-snappy) both}
.anim-slide-fade .slide-body{animation:fade-up var(--dur-med) var(--ease-snappy) both}

.anim-thai{animation:thai-pop .38s var(--ease-bounce) both}
.anim-card{animation:pop-in var(--dur-med) var(--ease-snappy) both}
.anim-reveal{animation:fade-up var(--dur-med) var(--ease-snappy) both}
.anim-test-content{animation:test-enter .36s var(--ease-bounce) both}
.anim-opt{animation:fade-up .28s var(--ease-snappy) both}

.anim-feedback{animation:feedback-in 0.22s var(--ease-snappy) both}
.anim-feedback-wrong{animation:feedback-fail .48s var(--ease-snappy) both}
.anim-feedback-correct{animation:feedback-success .38s var(--ease-bounce) both}
.anim-score-bump{animation:score-bump .45s var(--ease-bounce) both;display:inline-block}
.anim-score-dip{animation:score-dip .42s var(--ease-snappy) both;display:inline-block}

.anim-progress{overflow:hidden}
.anim-progress>div{transition:width 0.55s var(--ease-snappy);animation:progress-pulse 0.6s var(--ease-snappy) both}

.anim-results{animation:fade-in 0.2s ease both}
.anim-results-pass .anim-score{animation:score-reveal 0.62s var(--ease-bounce) both,score-glow 1.4s ease 0.5s 2}
.anim-results-fail .anim-score{animation:score-reveal 0.48s var(--ease-snappy) both}
.anim-result-item{animation:fade-up var(--dur-med) var(--ease-snappy) both}
.anim-result-summary{animation:fade-up var(--dur-slow) var(--ease-snappy) both}
.anim-result-summary .anim-missed-row{animation:fade-up 0.28s var(--ease-snappy) both}
.anim-result-summary .anim-missed-row:nth-child(2){animation-delay:80ms}
.anim-result-summary .anim-missed-row:nth-child(3){animation-delay:130ms}
.anim-result-summary .anim-missed-row:nth-child(4){animation-delay:180ms}
.anim-result-summary .anim-missed-row:nth-child(5){animation-delay:230ms}
.anim-result-summary .anim-missed-row:nth-child(6){animation-delay:280ms}

.test-option{outline:none;transition:transform 0.12s var(--ease-snappy),background .15s,border-color .15s,box-shadow .15s}
.test-option-selected{background:#334155!important;border:2px solid #fbbf24!important;box-shadow:0 0 0 2px rgba(251,191,36,.25)}
.test-option:focus-visible{outline:2px solid #fbbf24;outline-offset:2px}
.test-option:active{transform:scale(0.975)}
.test-option-thai{font-size:clamp(calc(3.5rem * var(--thai-scale)),calc(12vw * var(--thai-scale)),calc(5rem * var(--thai-scale)));line-height:1.45;font-weight:400;padding-top:1.5rem;padding-bottom:1.5rem;overflow:visible}
.prompt-thai{
  font-size:clamp(calc(2.75rem * var(--thai-scale)), calc(10vw * var(--thai-scale)), calc(4.5rem * var(--thai-scale)));
  line-height:1.45;
  font-weight:400;
  color:#f1f5f9;
  display:inline-block;
  vertical-align:middle;
  margin:0 .12em;
  overflow:visible;
}
.prompt-thai-hero{
  font-size:clamp(calc(3.5rem * var(--thai-scale)), calc(14vw * var(--thai-scale)), calc(5.5rem * var(--thai-scale)));
  line-height:1.45;
  font-weight:400;
  color:#f8fafc;
  overflow:visible;
  padding:0.2em 0.25em;
}
.kb-btn{outline:none;transition:transform 0.12s var(--ease-snappy),background .15s,border-color .15s,box-shadow .15s;border:2px solid transparent}
.kb-btn.kb-selected,.kb-btn:focus-visible{border-color:#fbbf24!important;box-shadow:0 0 0 2px rgba(251,191,36,.25)}
.kb-btn:active{transform:scale(0.975)}
.slide-shell{min-height:calc(100dvh - 2 * var(--shell-pad));display:flex;flex-direction:column;gap:0.75rem;overflow:visible}
.slide-body{flex:1;display:flex;flex-direction:column;justify-content:center;min-height:0;overflow:visible}

@keyframes contrast-glow{
  0%,100%{box-shadow:0 0 0 0 rgba(251,191,36,.15), inset 0 0 0 1px rgba(251,191,36,.35)}
  50%{box-shadow:0 0 28px 2px rgba(251,191,36,.28), inset 0 0 0 1px rgba(251,191,36,.7)}
}
.contrast-slide{
  border:3px solid rgba(251,191,36,.85);
  border-radius:1.25rem;
  padding:1.25rem 1rem 1.35rem;
  background:linear-gradient(165deg, rgba(251,191,36,.16), rgba(15,23,42,.95) 42%, rgba(244,63,94,.08));
  animation:contrast-glow 2.4s ease-in-out infinite;
  display:flex;
  flex-direction:column;
  gap:1rem;
}
.contrast-banner{
  margin:0 auto;
  width:fit-content;
  padding:.35rem .85rem;
  border-radius:.5rem;
  background:#fbbf24;
  color:#0f172a;
  font-size:.75rem;
  font-weight:800;
  letter-spacing:.14em;
  text-transform:uppercase;
}
.contrast-title{
  text-align:center;
  font-size:clamp(2.4rem,10vw,3.5rem);
  font-weight:400;
  line-height:1.45;
  color:#f8fafc;
  font-family:"Noto Serif Thai","Noto Sans Thai Looped",Tahoma,serif;
  overflow:visible;
}
.contrast-vs{
  display:inline-block;
  margin:0 .35rem;
  font-family:Inter,system-ui,sans-serif;
  font-size:.45em;
  font-weight:800;
  letter-spacing:.12em;
  vertical-align:middle;
  color:#fbbf24;
  text-transform:uppercase;
}
.contrast-tip{
  text-align:center;
  color:#e2e8f0;
  font-size:1.05rem;
  line-height:1.45;
  max-width:36rem;
  margin:0 auto;
}
.contrast-pair-grid{display:grid;grid-template-columns:1fr 1fr;gap:.75rem}
.contrast-glyph-card{
  text-align:center;
  border-radius:1rem;
  padding:1.15rem 1rem 1.25rem;
  background:rgba(2,6,23,.75);
  overflow:visible;
  min-width:0;
}
.contrast-glyph-a{border:2px solid rgba(52,211,153,.55)}
.contrast-glyph-b{border:2px solid rgba(251,113,133,.65)}
.contrast-sound-label{
  font-size:.7rem;
  font-weight:700;
  letter-spacing:.12em;
  text-transform:uppercase;
  margin-bottom:.35rem;
}
.contrast-glyph-a .contrast-sound-label{color:#34d399}
.contrast-glyph-b .contrast-sound-label{color:#fb7185}
.contrast-glyph{
  font-size:clamp(4.5rem,18vw,7rem);
  line-height:1.45;
  font-weight:400;
  color:#f8fafc;
  overflow:visible;
  padding:0.2em 0.25em;
}
.contrast-glyph-sm{
  font-size:clamp(2.4rem,8vw,3.5rem);
  line-height:1.45;
  font-weight:400;
  color:#cbd5e1;
  margin-top:.15rem;
  overflow:visible;
  padding:0.15em 0.2em;
}
.contrast-meta{color:#94a3b8;font-size:.85rem;margin-top:.55rem}
.contrast-roman{color:#f1f5f9;font-size:1.35rem;font-weight:800;margin-top:.15rem}
.contrast-notch{
  text-align:center;
  font-weight:700;
  font-size:1rem;
  color:#fcd34d;
  background:rgba(251,191,36,.12);
  border:1px solid rgba(251,191,36,.45);
  border-radius:.75rem;
  padding:.65rem .9rem;
}
.contrast-compare-grid{display:grid;grid-template-columns:1fr 1fr;gap:.5rem}
.contrast-compare-item{
  text-align:center;
  background:rgba(15,23,42,.9);
  border:1px solid #334155;
  border-radius:.85rem;
  padding:.7rem .4rem;
}
.contrast-compare-thai{font-size:clamp(2rem,7vw,2.75rem);line-height:1.45;font-weight:400;color:#f8fafc;overflow:visible;padding:0.15em}
.contrast-compare-thai-sm{font-size:clamp(1.4rem,4.5vw,1.85rem);line-height:1.45;font-weight:400;color:#94a3b8;margin-top:.1rem;overflow:visible}
.contrast-compare-roman{color:#fbbf24;font-weight:800;font-size:1.15rem;margin-top:.35rem}
.contrast-compare-note{color:#64748b;font-size:.7rem;margin-top:.15rem}
.contrast-footer{
  text-align:center;
  font-size:.95rem;
  font-weight:700;
  color:#fde68a;
}
@media (min-width:640px){
  .contrast-slide{padding:1.5rem 1.35rem 1.6rem;gap:1.15rem}
}

@media (prefers-reduced-motion:reduce){
  *,*::before,*::after{animation-duration:.01ms!important;animation-iteration-count:1!important;transition-duration:.01ms!important}
}
