/* Hospitality English — one column, phone first.
   English text: Atkinson Hyperlegible Next (letters that can't be confused).
   Learner's language: the phone's own fonts (Thai, Vietnamese etc. render correctly). */

@font-face {
  font-family: "Atkinson Hyperlegible Next Variable";
  font-style: normal; font-display: swap; font-weight: 200 800;
  src: url(fonts/atkinson-hyperlegible-next-latin-ext-wght-normal.woff2) format("woff2-variations");
  unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF;
}
@font-face {
  font-family: "Atkinson Hyperlegible Next Variable";
  font-style: normal; font-display: swap; font-weight: 200 800;
  src: url(fonts/atkinson-hyperlegible-next-latin-wght-normal.woff2) format("woff2-variations");
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}

:root {
  --ink: #1b2a33;
  --paper: #f2f4f1;
  --surface: #ffffff;
  --line: #d6dfda;
  --muted: #5b6b73;
  --lobby: #1e5b4e;
  --lobby-ink: #ffffff;
  --brass: #b8892a;
  --brass-soft: #f1e3bf;
  --plate: #22343f;
  --plate-ink: #e9eeeb;
  --good: #1e7a52;
  --good-soft: #dff1e7;
  --bad: #b9473a;
  --bad-soft: #f8e3df;
  --focus: #2f6fd0;
  --font-en: "Atkinson Hyperlegible Next Variable", "Atkinson Hyperlegible", system-ui, sans-serif;
  --font-native: system-ui, -apple-system, "Segoe UI", "Noto Sans", "Noto Sans Thai", "Leelawadee UI", Thonburi, Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ink: #e6ece9;
    --paper: #111a20;
    --surface: #18242c;
    --line: #2c3c46;
    --muted: #9badb5;
    --lobby: #3b9a83;
    --lobby-ink: #08130f;
    --brass: #d9aa45;
    --brass-soft: #3a3020;
    --plate: #0b1216;
    --plate-ink: #e6ece9;
    --good: #4cc08a;
    --good-soft: #15342a;
    --bad: #ef7a6c;
    --bad-soft: #3a1f1c;
    --focus: #7fb0ff;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; background: var(--paper); color: var(--ink);
  font-family: var(--font-native); font-size: 17px; line-height: 1.5;
}
:lang(th), :lang(lo), :lang(km), :lang(my) { line-height: 1.7; }
.en, [lang="en"] { font-family: var(--font-en); }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.hidden { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.app { max-width: 560px; margin: 0 auto; padding: 0 16px 48px; }

/* ---------------------------------------------------------------- header */
.top {
  display: flex; align-items: center; gap: 10px; padding: 14px 0 10px;
}
.brand { font-family: var(--font-en); font-weight: 760; font-size: 1.05rem; letter-spacing: -0.01em; flex: 1; min-width: 0; line-height: 1.2; }
.lang-select {
  appearance: none; border: 1px solid var(--line); background: var(--surface); border-radius: 999px;
  padding: 7px 30px 7px 14px; font-size: .9rem; max-width: 46vw;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 15px) 52%, calc(100% - 10px) 52%; background-size: 5px 5px; background-repeat: no-repeat;
}
.chip-btn {
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 7px 14px;
  font-size: .9rem; cursor: pointer; white-space: nowrap;
}

/* ---------------------------------------------------------------- buttons */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%;
  min-height: 56px; padding: 12px 18px; border-radius: 14px; border: 1px solid transparent;
  font-weight: 650; font-size: 1.02rem; cursor: pointer; text-align: center; text-decoration: none;
}
.btn-primary { background: var(--lobby); color: var(--lobby-ink); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-quiet { background: var(--surface); border-color: var(--line); color: var(--ink); }
.btn-quiet:hover { border-color: var(--muted); }
.btn[disabled] { opacity: .55; cursor: default; }
.btn-row { display: grid; gap: 10px; }
.link { background: none; border: 0; padding: 6px 0; color: var(--lobby); font-weight: 600; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

/* ---------------------------------------------------------------- welcome */
.welcome h1 { font-family: var(--font-en); font-size: clamp(2.1rem, 9vw, 2.9rem); line-height: 1.05; letter-spacing: -0.02em; margin: 28px 0 10px; font-weight: 780; }
.welcome .lead { color: var(--muted); margin: 0 0 26px; font-size: 1.05rem; }
.welcome h2 { font-size: 1rem; margin: 0 0 10px; }
.lang-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 24px; }
.lang-grid button {
  min-height: 60px; border-radius: 14px; border: 2px solid var(--line); background: var(--surface);
  font-size: 1.05rem; cursor: pointer; padding: 8px 12px;
}
.lang-grid button[aria-pressed="true"] { border-color: var(--lobby); box-shadow: inset 0 0 0 1px var(--lobby); font-weight: 650; }
.welcome .note { font-size: .9rem; color: var(--muted); text-align: center; margin: 6px 0 18px; }

/* ---------------------------------------------------------------- lift panel (levels) */
.plate {
  background: var(--plate); color: var(--plate-ink); border-radius: 22px; padding: 18px 18px 20px;
  margin: 6px 0 16px;
}
.plate-display {
  display: flex; align-items: baseline; gap: 12px; padding: 4px 6px 14px; border-bottom: 1px solid rgba(255,255,255,.12); margin-bottom: 16px;
}
.plate-display .floor {
  font-family: var(--font-en); font-variant-numeric: tabular-nums; font-weight: 700; font-size: 2.6rem; line-height: 1;
  color: var(--brass); min-width: 1.4ch;
}
.plate-display .lvl-name { font-weight: 700; font-size: 1.1rem; line-height: 1.3; }
.plate-display .lvl-desc { font-size: .9rem; opacity: .8; line-height: 1.4; }
.lift {
  display: grid; grid-template-columns: repeat(2, auto); justify-content: center; gap: 14px 34px;
  direction: ltr;
}
.lift-btn {
  position: relative; width: 74px; height: 74px; border-radius: 50%; cursor: pointer;
  border: 3px solid var(--brass); background: radial-gradient(circle at 35% 30%, #3a4f5b, #1a2830 70%);
  color: var(--plate-ink); font-family: var(--font-en); font-size: 1.7rem; font-weight: 700;
  display: grid; place-items: center; transition: box-shadow .15s ease, background .15s ease;
}
.lift-btn .state { position: absolute; right: -6px; bottom: -4px; width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center; font-size: .8rem; background: var(--plate); border: 2px solid var(--brass); }
.lift-btn.passed { background: radial-gradient(circle at 35% 30%, #f6dc93, var(--brass) 75%); color: #2b2210; }
.lift-btn.locked { border-color: #55646d; color: #7d8b93; cursor: pointer; }
.lift-btn.locked .state { border-color: #55646d; }
.lift-btn[aria-pressed="true"] { box-shadow: 0 0 0 4px var(--plate), 0 0 0 7px var(--plate-ink); }
.lift-legend { text-align: center; font-size: .85rem; opacity: .75; margin-top: 14px; }

.locked-note, .paywall {
  background: var(--surface); border: 1px dashed var(--line); border-radius: 14px; padding: 14px 16px; color: var(--muted);
}
.paywall strong { color: var(--ink); display: block; }
.meter { height: 6px; border-radius: 3px; background: rgba(255,255,255,.14); overflow: hidden; margin-top: 8px; }
.meter i { display: block; height: 100%; background: var(--brass); }

/* choices: mode, topic, activity + start button */
.choices { display: grid; gap: 18px; }
.choices fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.choices legend, .choices .legend { display: block; font-weight: 700; font-size: .98rem; margin: 0 0 8px; padding: 0; }
.radio-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.radio-list { display: grid; gap: 8px; }
.radio-card {
  position: relative; display: grid; grid-template-columns: 22px 1fr; gap: 10px; align-items: start;
  min-height: 60px; padding: 12px; border-radius: 14px; border: 2px solid var(--line); background: var(--surface); cursor: pointer;
}
.radio-card input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.radio-card .dot {
  width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--muted); margin-top: 1px;
  display: grid; place-items: center; background: var(--surface);
}
.radio-card.checked { border-color: var(--lobby); box-shadow: inset 0 0 0 1px var(--lobby); }
.radio-card.checked .dot { border-color: var(--lobby); }
.radio-card.checked .dot::after { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--lobby); }
.radio-card:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
.rc-text { display: grid; gap: 2px; }
.rc-text strong { font-size: .98rem; line-height: 1.3; }
.rc-text small { color: var(--muted); font-size: .8rem; line-height: 1.35; }
.start-grid { display: grid; grid-template-columns: 1fr minmax(118px, 36%); gap: 10px; align-items: stretch; }
.start-btn { height: 100%; min-height: 120px; font-size: 1.08rem; line-height: 1.3; padding: 12px; }
@media (max-width: 340px) { .start-grid { grid-template-columns: 1fr; } .start-btn { min-height: 60px; } }
.select[disabled] { opacity: .55; }
.select {
  width: 100%; min-height: 50px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface);
  padding: 10px 12px;
}
.stats { display: flex; gap: 18px; color: var(--muted); font-size: .88rem; margin-top: 18px; flex-wrap: wrap; }
.guest-banner {
  display: grid; gap: 10px; justify-items: start; background: var(--brass-soft);
  border-radius: 14px; padding: 12px 14px; margin: 4px 0 14px; font-size: .9rem;
}
.guest-banner .chip-btn { background: var(--surface); }

/* ---------------------------------------------------------------- quiz */
.quiz-top { display: flex; align-items: center; gap: 12px; padding: 14px 0 6px; }
.close { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-size: 1.3rem; line-height: 1; }
.progress { flex: 1; height: 10px; border-radius: 5px; background: var(--line); overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--brass); width: 0; transition: width .25s ease; }
.counter { font-size: .85rem; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.instruction { font-weight: 650; font-size: 1.05rem; margin: 18px 0 12px; }
.prompt {
  background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 22px 18px;
  min-height: 132px; display: grid; place-items: center; text-align: center; margin-bottom: 16px; gap: 10px;
}
.prompt .big { font-size: clamp(1.5rem, 6.5vw, 2.1rem); line-height: 1.25; font-weight: 700; overflow-wrap: anywhere; }
.prompt .mid { font-size: clamp(1.2rem, 5vw, 1.45rem); line-height: 1.35; font-weight: 650; }
.prompt .sub { color: var(--muted); font-size: 1rem; }
.prompt .digits { font-family: var(--font-en); font-variant-numeric: tabular-nums; font-size: clamp(2.4rem, 12vw, 3.4rem); font-weight: 760; }
.prompt .speaker { font-size: .82rem; color: var(--muted); }
.audio-row { display: flex; gap: 14px; align-items: center; justify-content: center; }
.play {
  width: 92px; height: 92px; border-radius: 50%; border: 4px solid var(--brass); background: var(--brass-soft);
  display: grid; place-items: center; cursor: pointer; color: var(--ink);
}
.play svg { width: 40px; height: 40px; }
.play.playing { background: var(--brass); color: #2b2210; }
.play { position: relative; }
.play.is-loading::after {
  content: ""; position: absolute; inset: -9px; border-radius: 50%;
  border: 3px solid transparent; border-top-color: var(--brass); animation: spin 1s linear infinite;
}
.slow.is-loading, .mini-play.is-loading { opacity: .6; }
@keyframes spin { to { transform: rotate(360deg); } }
.audio-status { min-height: 1.4em; margin: 0; font-size: .9rem; color: var(--muted); text-align: center; }
.slow { min-height: 48px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); padding: 0 16px; cursor: pointer; font-weight: 600; display: flex; gap: 6px; align-items: center; }
.slow svg { width: 20px; height: 20px; }

.options { display: grid; gap: 10px; }
.opt {
  display: grid; grid-template-columns: 34px 1fr; align-items: center; gap: 12px; width: 100%; min-height: 60px;
  padding: 10px 14px; border-radius: 14px; border: 2px solid var(--line); background: var(--surface);
  text-align: left; cursor: pointer; font-size: 1.08rem; line-height: 1.35;
}
.opt .key { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; font-family: var(--font-en); font-weight: 700; font-size: .9rem; background: var(--paper); color: var(--muted); }
.opt:hover:not([disabled]) { border-color: var(--muted); }
.opt[disabled] { cursor: default; }
.opt.correct { border-color: var(--good); background: var(--good-soft); }
.opt.correct .key { background: var(--good); color: #fff; }
.opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
.opt.wrong .key { background: var(--bad); color: #fff; }
.opt.dim { opacity: .55; }
.kbd-hint { font-size: .8rem; color: var(--muted); text-align: center; margin-top: 14px; }

.feedback {
  margin-top: 14px; background: var(--surface); border: 2px solid var(--line); border-radius: 18px;
  padding: 16px; display: grid; gap: 10px;
}
.feedback.good { border-color: var(--good); }
.feedback.bad { border-color: var(--bad); }
.verdict { font-weight: 760; font-size: 1.15rem; display: flex; align-items: center; gap: 8px; }
.verdict.good { color: var(--good); }
.verdict.bad { color: var(--bad); }
.fb-line { display: flex; gap: 12px; align-items: flex-start; }
.fb-emoji { font-size: 2rem; line-height: 1; }
.fb-en { font-size: 1.15rem; font-weight: 700; }
.fb-native { color: var(--muted); }
.fb-guest { font-size: .9rem; color: var(--muted); }
.fb-actions { display: grid; grid-template-columns: auto 1fr; gap: 10px; }
.fb-actions .slow { min-height: 56px; }

/* ---------------------------------------------------------------- result */
.result-head { text-align: center; padding: 26px 0 8px; }
.score { font-family: var(--font-en); font-variant-numeric: tabular-nums; font-size: 4.2rem; font-weight: 780; line-height: 1; letter-spacing: -0.03em; }
.score small { font-size: 1.6rem; color: var(--muted); font-weight: 600; }
.result-msg { font-size: 1.08rem; margin: 12px 0 4px; }
.unlocked { display: inline-block; margin-top: 10px; background: var(--brass-soft); border-radius: 999px; padding: 6px 14px; font-weight: 650; }
.mistakes { list-style: none; padding: 0; margin: 18px 0; display: grid; gap: 10px; }
.mistakes li { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; display: grid; gap: 4px; }
.mistakes .was { color: var(--bad); text-decoration: line-through; text-decoration-thickness: 1px; }
.mistakes .right { font-weight: 700; color: var(--good); }
.mistakes .q { font-size: .88rem; color: var(--muted); }
.mistakes .row { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.mini-play { flex: none; width: 40px; height: 40px; border-radius: 50%; border: 2px solid var(--brass); background: var(--brass-soft); cursor: pointer; display: grid; place-items: center; }
.mini-play svg { width: 18px; height: 18px; }

/* ---------------------------------------------------------------- forms */
.form { display: grid; gap: 14px; margin-top: 16px; }
.field { display: grid; gap: 6px; }
.field label { font-weight: 600; font-size: .95rem; }
.field input { min-height: 52px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); padding: 10px 14px; }
.error { color: var(--bad); font-weight: 600; min-height: 1.2em; }
.page-title { font-size: 1.4rem; margin: 18px 0 4px; }

.toast {
  position: fixed; left: 50%; top: 14px; transform: translateX(-50%); background: var(--ink); color: var(--paper);
  padding: 10px 16px; border-radius: 12px; z-index: 20; max-width: 90vw; font-size: .95rem;
}
.loading { text-align: center; color: var(--muted); padding: 60px 0; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
@media (min-width: 600px) {
  .app { padding-top: 10px; }
  .lift-btn { width: 82px; height: 82px; }
}
