/* ============================================================
   countfu · /practice/ web listening demo
   Components lifted from design/mockups/test-view.html and
   design/mockups/web-practice.html, retokenised onto the site's
   --color-* / --font-* names (the mockups use a shorter set).
   ============================================================ */

body.practice-page {
  min-height: 100dvh;
  background: radial-gradient(120% 60% at 50% -10%, #16100e 0%, #0b0807 60%) fixed;
  overflow-x: hidden;
}

.app {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  min-width: 0;
}

/* ---- start gate (web-only: unlocks audio autoplay) ---- */
.gate {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 32px 26px;
}
.seal-lg {
  width: 66px;
  height: 66px;
  display: block;
  filter: drop-shadow(0 14px 30px rgba(229, 72, 46, 0.55));
}
.seal-md { width: 44px; height: 44px; display: block; flex-shrink: 0; }
.seal-sm { width: 30px; height: 30px; display: block; flex-shrink: 0; }

.gate h2 {
  font-size: 25px;
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.22;
  margin-top: 22px;
}
.gate h2 .fu { color: var(--color-accent); }
.gate p {
  color: var(--color-text-muted);
  font-size: 14px;
  line-height: 1.6;
  margin-top: 13px;
  max-width: 252px;
}
.gate .startbtn {
  margin-top: 26px;
  width: 100%;
  max-width: 320px;
  padding: 16px;
  border-radius: 14px;
  background: var(--color-primary);
  border: none;
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  font-family: var(--font-sans);
  cursor: pointer;
  box-shadow: 0 14px 30px -12px rgba(229, 72, 46, 0.8);
}
.gate .fineprint { margin-top: 14px; font-size: 12px; color: var(--color-text-muted); }
.gate .fineprint b { color: var(--color-text); font-weight: 600; }

/* ---- question screen ---- */
.quiz { flex: 1; display: flex; flex-direction: column; min-height: 0; }

.topbar { display: flex; align-items: center; gap: 12px; padding: 12px 18px 0; }
.count {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--color-text-muted);
  flex-shrink: 0;
}
.segbar { flex: 1; display: flex; gap: 4px; align-items: center; }
.seg { flex: 1; height: 6px; border-radius: 3px; background: var(--color-surface-2); }
.seg.on { background: var(--color-accent); }

.content { flex: 1; display: flex; flex-direction: column; padding: 8px 18px 12px; min-height: 0; }
.instr { text-align: center; color: var(--color-text-muted); font-size: 13.5px; margin: 8px 0 12px; }

.player {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: 14px;
  padding: 10px 12px;
}
.play {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  flex-shrink: 0;
  border: none;
  background: radial-gradient(circle at 38% 32%, #f2603f, var(--color-primary) 65%, #b8331f);
  color: #fff;
  font-size: 17px;
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 6px 18px -6px rgba(229, 72, 46, 0.6);
}
.pbar { flex: 1; min-width: 0; }
.pbar .seek { height: 4px; border-radius: 2px; background: var(--color-border); overflow: hidden; }
.pbar .seek i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--color-text-muted);
  border-radius: 2px;
}
.pbar .time {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--color-text-muted);
  margin-top: 6px;
}

/* The chip is the visible control; a transparent native <select> sits on top so
   touch gets the OS wheel picker and keyboards get real focus, for free. */
.speed {
  position: relative;
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--color-text);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 6px 8px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.speed .cv { color: var(--color-text-muted); font-size: 9px; }
.speed:focus-within { border-color: var(--color-primary); }
.speed-select {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  border: none;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  /* 16px keeps iOS Safari from zooming the page on focus. */
  font-size: 16px;
}

.answer-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 12px 0;
}
.qtext { text-align: center; font-size: 16px; font-weight: 600; color: var(--color-text); }
.slots { display: flex; align-items: center; justify-content: center; gap: 5px; flex-wrap: nowrap; }
.slot {
  width: 34px;
  height: 52px;
  border-radius: 8px;
  border: 2px solid var(--color-border);
  background: var(--color-surface);
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 600;
  color: var(--color-text);
}
.slot.active { border-color: var(--color-primary); box-shadow: 0 0 0 3px rgba(229, 72, 46, 0.16); }
.slot.ok { border-color: var(--color-success); color: var(--color-success); background: rgba(34, 197, 94, 0.1); }
.slot.wrong {
  border-color: var(--color-error);
  color: var(--color-error);
  background: rgba(255, 45, 85, 0.14);
  box-shadow: 0 0 0 3px rgba(255, 45, 85, 0.16);
}

.bottom { flex-shrink: 0; }
.tbtn-wrap { display: flex; justify-content: center; margin-bottom: 9px; }
.tbtn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 13px;
  border-radius: 999px;
  background: transparent;
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-sans);
  cursor: pointer;
}
.actions { display: flex; justify-content: center; gap: 8px; }
.actions .btn {
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  border-radius: 11px;
  padding: 11px 10px;
  font-size: 13.5px;
  font-weight: 600;
  font-family: var(--font-sans);
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  cursor: pointer;
}
.actions .btn.primary { background: var(--color-primary); border-color: var(--color-primary); color: #fff; }
.actions .btn.util { background: var(--color-accent); border-color: var(--color-accent); color: #0f0b0a; }
.actions .btn.disabled { background: var(--color-surface-2); color: var(--color-text-muted); border-color: var(--color-border); opacity: 0.7; cursor: default; }
.actions .btn.util.disabled { background: var(--color-accent); border-color: var(--color-accent); color: #0f0b0a; opacity: 0.4; }
.actions .btn.primary.disabled { background: var(--color-primary); border-color: var(--color-primary); color: #fff; opacity: 0.4; }

.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 10px 0 8px; }
.key {
  height: 46px;
  border-radius: 12px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-text);
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 500;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.key.dim { color: #3a2f2a; background: var(--color-surface-2); border-color: transparent; cursor: default; }

.kbhint {
  text-align: center;
  font-size: 12px;
  color: var(--color-text-muted);
  margin-top: 16px;
  font-family: var(--font-mono);
}
.kbhint kbd {
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: 5px;
  padding: 2px 6px;
  color: var(--color-text);
  font-size: 11px;
}

/* ---- persistent app nudge banner ---- */
.nudgebar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 16px;
  background: var(--color-surface-2);
  border-top: 1px solid var(--color-border);
}
.nudgebar .nb-txt { flex: 1; text-align: left; line-height: 1.35; min-width: 0; }
.nudgebar .nb-txt b { display: block; font-size: 12.5px; font-weight: 700; color: var(--color-text); }
.nudgebar .nb-txt span { display: block; font-size: 11px; color: var(--color-text-muted); }
.nudgebar .nb-go {
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 700;
  color: #0f0b0a;
  background: var(--color-accent);
  border-radius: 8px;
  padding: 7px 11px;
  text-decoration: none;
}

/* Keypad + nudge bar on a 667px iPhone SE viewport is tight, so the bar
   collapses to a single line. */
@media (max-height: 700px) {
  .nudgebar .nb-txt span { display: none; }
}

/* ---- result screen (scrolls) ---- */
.score {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 24px 18px 32px;
  overflow-y: auto;
}
.ring {
  width: 150px;
  height: 150px;
  border-radius: 50%;
  position: relative;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.ring::before {
  content: "";
  position: absolute;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: var(--color-bg);
}
.ring .pct {
  position: relative;
  font-family: var(--font-mono);
  font-size: 34px;
  font-weight: 800;
  color: var(--color-text);
}
.score h2 { font-size: 20px; font-weight: 800; margin-top: 15px; }
.score .sub { color: var(--color-text-muted); font-size: 13px; margin-top: 5px; }

.alist { width: 100%; margin-top: 20px; text-align: left; }
.alist .lh-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.alist .lh {
  font-size: 11px;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  font-family: var(--font-mono);
  font-weight: 600;
}
.again-sm {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  color: var(--color-text);
  font-size: 11.5px;
  font-weight: 700;
  font-family: var(--font-sans);
  flex-shrink: 0;
  cursor: pointer;
}
.again-sm .rr { color: var(--color-accent); font-size: 12px; }
.arow {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 11px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  margin-bottom: 6px;
}
.arow .ai {
  width: 19px;
  height: 19px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 800;
  flex-shrink: 0;
  color: #0f0b0a;
}
.arow .ai.ok { background: var(--color-success); }
.arow .ai.no { background: var(--color-error); color: #fff; }
.arow .atxt { flex: 1; display: flex; align-items: baseline; gap: 9px; min-width: 0; flex-wrap: wrap; }
.arow .atxt b { font-family: var(--font-mono); font-size: 15px; font-weight: 700; color: var(--color-success); }
.arow .atxt .you { font-family: var(--font-mono); font-size: 11.5px; color: var(--color-error); }
.arow .aq {
  width: 25px;
  height: 25px;
  border-radius: 50%;
  border: 1px solid var(--color-border);
  background: transparent;
  color: var(--color-text-muted);
  display: grid;
  place-items: center;
  font-size: 11px;
  flex-shrink: 0;
  cursor: pointer;
}
.arow .ap {
  width: 29px;
  height: 29px;
  border-radius: 50%;
  border: none;
  background: var(--color-primary);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 10px;
  flex-shrink: 0;
  cursor: pointer;
}

/* ---- app pitch block on result ---- */
.pitch {
  width: 100%;
  margin-top: 22px;
  background: linear-gradient(180deg, var(--color-surface), var(--color-surface-2));
  border: 1px solid var(--color-border);
  border-radius: 18px;
  padding: 20px 17px 18px;
  text-align: center;
}
.pitch .pseal { display: flex; justify-content: center; margin-bottom: 12px; }
.pitch .ph { font-size: 15px; font-weight: 800; letter-spacing: -0.015em; }
.pitch .ph .fu { color: var(--color-accent); }
.pitch ul { margin-top: 14px; text-align: left; padding: 0; }
.pitch li {
  list-style: none;
  display: flex;
  gap: 9px;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--color-text);
  margin-bottom: 9px;
}
.pitch li:last-child { margin-bottom: 0; }
.pitch li .bt { color: var(--color-accent); flex-shrink: 0; font-size: 10px; line-height: 1.9; }
.appstore {
  margin-top: 17px;
  width: 100%;
  padding: 14px;
  border-radius: 13px;
  background: var(--color-text);
  color: #0f0b0a;
  font-weight: 700;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  text-decoration: none;
  cursor: pointer;
}

/* ---- transcript sheet ---- */
.scrim { position: fixed; inset: 0; background: rgba(8, 5, 4, 0.66); z-index: 20; }
.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 21;
  margin: 0 auto;
  max-width: 470px;
  background: linear-gradient(180deg, var(--color-surface), var(--color-surface-2));
  border-top: 1px solid var(--color-border);
  border-radius: 26px 26px 0 0;
  padding: 20px 22px 30px;
  box-shadow: 0 -20px 50px -20px rgba(0, 0, 0, 0.7);
}
.sheet .grab { width: 36px; height: 4px; border-radius: 2px; background: var(--color-border); margin: 0 auto 16px; }
.sheet .sh-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.sheet .sh-head h3 {
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  font-weight: 600;
}
.sheet .sh-head .x {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
  display: grid;
  place-items: center;
  font-size: 13px;
  cursor: pointer;
}
.tr-hanzi {
  font-family: var(--font-hanzi);
  font-size: 30px;
  line-height: 1.5;
  color: var(--color-text);
  word-break: break-word;
}
.tr-pinyin { font-style: italic; color: var(--color-accent); font-size: 15px; line-height: 1.6; margin-top: 8px; }
.tr-ans {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--color-border);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}
.tr-ans .k {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  font-family: var(--font-mono);
}
.tr-ans .v { font-family: var(--font-mono); font-size: 22px; font-weight: 700; color: var(--color-text); }

/* ---- desktop: same markup, same script, bounded card ---- */
@media (min-width: 720px) {
  body.practice-page { display: grid; place-items: center; padding: 24px; }
  .app {
    width: 470px;
    max-width: 100%;
    min-height: 0;
    max-height: calc(100dvh - 48px);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 22px;
    overflow: hidden;
    box-shadow: 0 30px 60px -25px rgba(0, 0, 0, 0.7);
  }
  .gate { padding: 44px 30px; }
  .topbar { padding: 20px 24px 0; }
  .content { padding: 4px 24px 20px; }
  .answer-area { flex: 0 0 auto; padding: 28px 0 24px; }
  .score { padding: 24px 24px 28px; }
}
