:root {
  --text-scale: 1;
  --teal: #0d3235;
  --aqua: #006573;
  --aqua-soft: #2a8a96;
  --orange: #ff9d14;
  --ink: #143033;
  --muted: #8a8f90;
  --line: #e6e6e6;
  --paper: #f7f4ee;
  --warm-paper: #f4f1ea;
  --white: #ffffff;
  --charcoal: #1a2b2e;
  --logo-yellow: #ffdc2a;
  --logo-red: #e6301a;
  --red: #d12626;
  --locked-bg: #ebe6de;
  --locked-text: #b0b0b0;
  --press: #ebe6de;
  --switch-off: #d9ddde;
  --guide: #8d8d8d;
  --paper-border: #e7e1d6;
  --group-border: #d9d9d9;
  --tab-line: #ececec;
}

html.dark {
  --teal: #f7f4ee;
  --aqua: #006573;
  --aqua-soft: #2a8a96;
  --orange: #ff9d14;
  --ink: #f7f4ee;
  --muted: #a8b0b1;
  --line: #2c4548;
  --paper: #0b1c1e;
  --warm-paper: #1a383c;
  --white: #122a2d;
  --charcoal: #f7f4ee;
  --logo-yellow: #ffdc2a;
  --logo-red: #e6301a;
  --red: #ff5a5a;
  --locked-bg: #162e31;
  --locked-text: #7a8587;
  --press: #1a383c;
  --switch-off: #2c4548;
  --guide: #6a7d80;
  --paper-border: #2c4548;
  --group-border: #2c4548;
  --tab-line: #2c4548;
}


html.font-md { --text-scale: 1.25; }
html.font-lg { --text-scale: 1.5; }

/* Large text needs taller buttons when a label would spill out.
   Medium gets the same only where a single line no longer fits. */
html.font-lg .g-actions .btn,
html.font-md .g-actions .btn,
html.font-lg .lantern-ready-words,
html.font-md .lantern-ready-words {
  white-space: normal;
}

html.font-lg .btn,
html.font-lg .btn-wide,
html.font-lg .sentence-choice,
html.font-lg .pinyin-choice,
html.font-lg .level,
html.font-lg .drawer-item {
  height: auto;
  white-space: normal;
}

html.font-lg .btn-wide {
  width: min(360px, 100%);
  padding: 16px 22px;
}

html.font-lg .back,
html.font-lg .drawer-back {
  width: 72px;
  height: 72px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

html.font-md .drawer-close,
html.font-lg .drawer-close {
  width: calc(40px * var(--text-scale));
  height: calc(40px * var(--text-scale));
}

html.font-lg .sentence-choice,
html.font-lg .pinyin-choice {
  padding: 16px 18px;
}

html.font-md .btn-wide,
html.font-md .sentence-choice,
html.font-md .pinyin-choice {
  height: auto;
  white-space: normal;
}



* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: system-ui, "Segoe UI", "PingFang SC", "Noto Sans CJK SC", "Noto Serif CJK SC", "Microsoft YaHei", sans-serif;
}

button, input { font-family: inherit; }

.phone {
  position: relative;
  overflow-x: hidden;
  box-sizing: border-box;
  width: 100%;
  max-width: 430px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--paper);
  /* WeChat mini-program web-view with navigationStyle: default.
     The native title bar is already on, so this only clears the device
     safe area (notch, Dynamic Island, Android status bar). constant()
     is the name iOS used before 11.2; env() replaces it where it exists.
     Do not add a fixed px value here. */
  padding-top: constant(safe-area-inset-top);
  padding-top: env(safe-area-inset-top);
}

.top-bar {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  gap: 4px;
  padding: 10px 10px 2px;
  min-height: 52px;
}

.top-bar::after {
  content: "";
  width: 44px;
  height: 44px;
}

.menu-btn {
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  border: 0;
  background: transparent;
  color: var(--teal);
  border-radius: 10px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.menu-btn:active {
  background: var(--press);
}

.menu-lines {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 22px;
  height: 18px;
}

.menu-lines span {
  display: block;
  height: 2.5px;
  width: 100%;
  border-radius: 2px;
  background: currentColor;
}

.logo-wide {
  width: 100%;
  height: auto;
  display: block;
  object-fit: contain;
}

.top-bar .logo-wide {
  width: 100%;
  max-width: 260px;
  max-height: 64px;
  margin: 0 auto;
  justify-self: center;
}

.drawer-root {
  /* Stay inside the phone column (WeChat mini-program width), not the desktop window. */
  position: absolute;
  inset: 0;
  z-index: 200;
  pointer-events: none;
  visibility: hidden;
}

.drawer-root.open {
  pointer-events: auto;
  visibility: visible;
}

.drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  opacity: 0;
  transition: opacity 220ms ease;
}

.drawer-root.open .drawer-backdrop {
  opacity: 1;
}

.drawer {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(300px, 82%);
  background: var(--paper);
  color: var(--ink);
  border-right: 1px solid var(--line);
  box-shadow: 8px 0 24px rgba(0, 0, 0, 0.22);
  transform: translateX(-105%);
  transition: transform 220ms ease;
  padding: 12px 14px 24px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  box-sizing: border-box;
  overflow-x: hidden;
  overflow-y: auto;
}

.drawer-root.open .drawer {
  transform: translateX(0);
}

/* display:flex on .drawer-panel overrides the HTML hidden attribute */
.drawer-panel[hidden] {
  display: none !important;
}

.drawer-close {
  align-self: flex-end;
  width: 40px;
  height: 40px;
  border: 0;
  background: transparent;
  color: var(--teal);
  font-size: calc(28px * var(--text-scale));
  line-height: 1;
  cursor: pointer;
  border-radius: 10px;
}

.drawer-close:active {
  background: var(--press);
}

.drawer-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
}

.drawer-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--teal);
  font-size: calc(17px * var(--text-scale));
  font-weight: 650;
  text-align: left;
  padding: 12px 10px;
  border-radius: 12px;
  cursor: pointer;
}

.drawer-item:active {
  background: var(--press);
}

.drawer-icon {
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  color: currentColor;
}

.drawer-back {
  width: 44px;
  height: 44px;
  border: 0;
  background: transparent;
  color: var(--teal);
  font-size: calc(26px * var(--text-scale));
  line-height: 1;
  cursor: pointer;
  border-radius: 10px;
  align-self: flex-start;
  margin: 0 0 2px -6px;
}

.drawer-back:active {
  background: var(--press);
}

.drawer-title {
  margin: 0 6px 12px;
  font-size: calc(22px * var(--text-scale));
  font-weight: 700;
  color: var(--teal);
  text-align: left;
  flex: none;
}

.drawer-switch {
  margin: 4px 6px 0;
}

.font-size-block {
  display: flex;
  flex-direction: column;
}

.font-size-toggle {
  justify-content: space-between;
}

.font-size-chevron {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  transition: transform 160ms ease;
}

.font-size-toggle[aria-expanded="true"] .font-size-chevron {
  transform: rotate(180deg);
}

.font-size-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 0 8px 8px 18px;
}

.font-size-panel[hidden] {
  display: none;
}


.program-back-row {
  margin: 8px 16px 0;
  text-align: center;
}

.program-back {
  color: var(--aqua);
  font-size: calc(15px * var(--text-scale));
  font-weight: 600;
  text-decoration: none;
}

a.level {
  color: inherit;
  text-decoration: none;
  box-sizing: border-box;
}

a.back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

h1 {
  margin: 18px 16px 12px;
  text-align: center;
  font-size: calc(28px * var(--text-scale));
  font-weight: 700;
  color: var(--teal);
}

h2 {
  margin: 0;
  font-size: calc(22px * var(--text-scale));
  font-weight: 700;
  color: var(--teal);
  text-align: center;
  flex: 1;
}

.char-nav-title {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
}

.char-nav-icons {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.char-star {
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #143033;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  line-height: 0;
}

.char-star svg {
  width: 22px;
  height: 22px;
  display: block;
}

.char-star .star-path {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linejoin: round;
}

.char-star.on {
  color: #ff9d14;
}

.char-star.on .star-path {
  fill: currentColor;
  stroke: none;
}

/* Dark paper hides the deep aqua. Definition and score pages use AquaSoft. */
html.dark .char-score,
html.dark .report-row b,
html.dark .tab.on,
html.dark #screen-learn .text-link,
html.dark #screen-report .text-link {
  color: var(--aqua-soft);
}

html.dark .tab.on {
  border-bottom-color: var(--aqua-soft);
}

html.dark .char-star:not(.on) {
  color: #efe6d6;
}

.char-ban {
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #143033;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  line-height: 0;
}

.char-ban svg {
  width: 22px;
  height: 22px;
  display: block;
}

.char-ban .ban-ring {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
}

.char-ban .ban-slash {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
}

.char-ban.on {
  color: #e6301a;
}

html.dark .char-ban:not(.on) {
  color: #efe6d6;
}

.stack { padding: 4px 16px 24px; }

.due-level {
  display: block;
  width: calc(100% - 32px);
  margin: 0 16px 16px;
}

.level {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  text-align: left;
  border-radius: 14px;
  padding: 14px 16px;
  margin: 0 0 10px;
  border: 1px solid var(--line);
  background: var(--white);
  color: var(--teal);
  box-shadow: 0 4px 5px -4px rgba(0, 0, 0, 0.72);
}

.level.open { cursor: pointer; }
.level.open:active { background: var(--press); }

.level .name { font-size: calc(18px * var(--text-scale)); font-weight: 700; display: block; }
.level .sub { display: block; margin-top: 2px; color: var(--muted); font-size: calc(14px * var(--text-scale)); font-weight: 500; }

/* Text + progress bar column inside a group card. */
.level-main { display: block; min-width: 0; flex: 1 1 auto; }
.level .bar {
  display: block;
  height: 4px;
  border-radius: 2px;
  background: var(--line);
  margin-top: 9px;
  overflow: hidden;
}
.level .bar-fill {
  display: block;
  height: 100%;
  border-radius: 2px;
  background: var(--aqua);
}

/* Lesson card: "Lesson N" left + word count right on one row,
   hanzi preview line below, progress bar under that. */
.level .lesson-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.level .lesson-top .name { flex: 0 0 auto; }
.level .count {
  color: var(--muted);
  font-size: calc(14px * var(--text-scale));
  font-weight: 500;
  white-space: nowrap;
}
.level .lesson-chars {
  display: block;
  margin-top: 4px;
  color: var(--ink);
  font-size: calc(15px * var(--text-scale));
  line-height: 1.5;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Practice All card on the lessons screen. */
.level.practice-all-card {
  border-color: var(--aqua);
  border-width: 2px;
  padding: 13px 15px;
}

/* Practice All: segmented word-count selector in the options screen. */
.practice-count-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  margin: 0 0 10px;
  background: var(--white);
}
.practice-count-label {
  font-size: calc(15px * var(--text-scale));
  font-weight: 700;
  color: var(--teal);
}
.count-choices {
  display: flex;
  gap: 8px;
}
.count-choice {
  font-size: calc(14px * var(--text-scale));
  font-weight: 650;
  color: var(--teal);
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 14px;
  cursor: pointer;
}
.count-choice.on {
  background: var(--aqua);
  border-color: var(--aqua);
  color: #fff;
}

/* Continue card: primary "jump back in" button on the groups screen. */
.level.continue-card {
  background: var(--aqua);
  border-color: var(--aqua);
}
.level.continue-card .name { color: #fff; }
.level.continue-card .sub { color: rgba(255, 255, 255, 0.85); }
.continue-arrow {
  flex: 0 0 auto;
  padding-left: 12px;
  color: #fff;
  font-size: 18px;
}

/* Programs home: the flagship card gets slightly bigger presence. */
.program-hero { padding: 20px 16px; }
.program-hero .name { font-size: calc(22px * var(--text-scale)); }

.level.locked {
  background: var(--locked-bg);
  border-color: var(--locked-bg);
  color: var(--locked-text);
  cursor: default;
}

.lock {
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
}

.nav {
  display: flex;
  align-items: center;
  padding: 8px 10px 4px;
  min-height: 48px;
}

.back {
  width: 52px;
  height: 52px;
  border: 0;
  background: transparent;
  color: var(--teal);
  font-size: calc(28px * var(--text-scale));
  line-height: 1;
  cursor: pointer;
  border-radius: 10px;
}

.group-card {
  margin: 8px 16px 12px;
  border: 1px solid var(--group-border);
  border-radius: 16px;
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--white);
}

.g-title { font-size: calc(22px * var(--text-scale)); font-weight: 700; color: var(--teal); }
.g-sub { color: var(--muted); margin-top: 4px; font-size: calc(15px * var(--text-scale)); }

.g-actions { display: flex; flex-direction: column; gap: 8px; }

.g-actions .btn { white-space: nowrap; }

.btn {
  background: var(--aqua);
  color: #fff;
  border: 0;
  border-radius: 20px;
  padding: 10px 18px;
  font-size: calc(16px * var(--text-scale));
  font-weight: 650;
  cursor: pointer;
  min-width: 92px;
  box-shadow: 3px 5px 0 #000;
}

.btn:active { filter: brightness(1.15); }

.btn-wide {
  display: block;
  width: min(280px, 100%);
  margin: 8px auto 0;
  padding: 14px 18px;
  border-radius: 22px;
  font-size: calc(17px * var(--text-scale));
}


.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 4px 16px 0;
  font-weight: 650;
  color: var(--teal);
}

/* Best score shown beside each skill switch on the options screen. */
.skill-high {
  margin-left: auto;
  margin-right: 12px;
  font-size: 13px;
  white-space: nowrap;
}
.skill-high .high-lab { color: var(--aqua-soft); }
/* Percentages share a fixed-width, right-aligned slot so every row lines up. */
.skill-high .high-val {
  display: inline-block;
  min-width: 3.2em;
  text-align: right;
  color: var(--orange);
  font-weight: 700;
  font-style: italic;
}
/* A perfect 100% shows in aqua (aqua soft in dark mode). */
.skill-high .high-val.is-perfect { color: var(--aqua); }
html.dark .skill-high .high-val.is-perfect { color: var(--aqua-soft); }
/* Scores under 70% show in alert red. */
.skill-high .high-val.is-low { color: var(--red); }

/* Practice options: section headings (Write / Read / Listen). */
.option-group-head {
  margin: 20px 16px 2px;
  font-size: calc(12px * var(--text-scale));
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.option-group-head:first-of-type { margin-top: 10px; }

/* Skill switch rows: name + high score on one line, description below. */
.switch-copy { display: block; min-width: 0; flex: 1 1 auto; }
.switch-title {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}
.skill-desc {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: calc(13px * var(--text-scale));
  font-weight: 500;
}
/* The lantern score is not a percentage and has no fixed maximum. */
#high-lantern .high-val { color: var(--aqua); min-width: 0; }
html.dark #high-lantern .high-val { color: var(--aqua-soft); }

.switch-control {
  position: relative;
  display: inline-flex;
  width: 48px;
  height: 28px;
  flex: 0 0 48px;
}

.switch-control input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.switch-track {
  display: block;
  width: 48px;
  height: 28px;
  padding: 3px;
  border-radius: 999px;
  background: var(--switch-off);
  cursor: pointer;
  transition: background-color 160ms ease;
}

.switch-knob {
  display: block;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.22);
  transform: translateX(0);
  transition: transform 160ms ease;
}

.switch-control input:checked + .switch-track {
  background: var(--aqua);
}

.switch-control input:checked + .switch-track .switch-knob {
  transform: translateX(20px);
}

.switch-control input:focus-visible + .switch-track {
  outline: 2px solid #006573;
  outline-offset: 2px;
}

.fine {
  margin: 6px 16px 10px;
  color: var(--muted);
  font-size: calc(13px * var(--text-scale));
}

.notice {
  margin: 0 16px 10px;
  padding: 12px 14px;
  background: var(--warm-paper);
  border-radius: 12px;
  color: var(--ink);
  font-size: calc(15px * var(--text-scale));
}

.notice.alert {
  color: var(--red);
  font-weight: 650;
}

.word-list { padding: 0 16px 28px; }

.word {
  width: 100%;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  column-gap: 12px;
  align-items: center;
  text-align: left;
  border-radius: 14px;
  padding: 14px 16px;
  margin: 0 0 10px;
  border: 1px solid var(--line);
  background: var(--white);
  color: inherit;
  font-size: calc(16px * var(--text-scale));
  box-shadow: 0 4px 5px -4px rgba(0, 0, 0, 0.72);
  cursor: pointer;
}

.word:active { background: var(--press); }

.btn-practice {
  min-width: 0;
  padding: 8px 14px;
  font-size: calc(15px * var(--text-scale));
}

.word .n {
  grid-column: 1;
  grid-row: 1;
  justify-self: center;
  align-self: center;
  flex: none;
  width: 44px;
  height: 44px;
  min-width: 44px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: transparent;
  color: var(--ink);
  font-size: calc(16px * var(--text-scale));
  font-weight: 700;
  line-height: 1;
}

.word.learned .n {
  background: var(--aqua);
  color: #fff;
}

/* Learned check mark in the word list. */
.word .word-learned-mark {
  color: var(--aqua);
  font-size: calc(15px * var(--text-scale));
  font-weight: 900;
  line-height: 1;
}

.word .word-icons {
  grid-column: 3;
  grid-row: 1;
  align-self: center;
  justify-self: end;
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  line-height: 0;
}

.word .word-star,
.word .word-ban {
  width: 22px;
  height: 22px;
  min-width: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
  overflow: visible;
}

.word .word-star {
  color: #ff9d14;
}

.word .word-ban {
  color: #e6301a;
}

.word .word-star svg,
.word .word-ban svg {
  width: 22px;
  height: 22px;
  min-width: 22px;
  min-height: 22px;
  display: block;
  flex: none;
}

.word.banned .n,
.word.banned.learned .n {
  background: transparent;
  color: transparent;
}


.word.stared-entry .n {
  background: transparent;
  color: #ff9d14;
  padding: 0;
}

.word.stared-entry .n svg {
  width: 40px;
  height: 40px;
  display: block;
}

.word.stared-entry .hz {
  font-size: calc(20px * var(--text-scale));
  font-weight: 700;
  color: var(--teal);
}

.level.stared-group {
  /* inherits .level space-between: text left, star right */
}

.level.stared-group .stared-group-mark {
  flex: 0 0 52px;
  width: 52px;
  height: 52px;
  min-width: 52px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #ff9d14;
  margin-left: auto;
  flex-shrink: 0;
}

.level.stared-group .stared-group-mark svg {
  width: 48px !important;
  height: 48px !important;
  min-width: 48px;
  min-height: 48px;
  display: block;
  flex: none;
}

.level.banned-group {
  /* inherits .level space-between: text left, ban icon right */
}

.level.banned-group .banned-group-mark {
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  min-width: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #e6301a;
  margin-left: auto;
  flex-shrink: 0;
}

.level.banned-group .banned-group-mark svg {
  width: 40px !important;
  height: 40px !important;
  min-width: 40px;
  min-height: 40px;
  display: block;
  flex: none;
}

.level.exam-group {
  border-color: var(--teal);
  border-style: dashed;
}

.level.exam-group .exam-group-mark {
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  min-width: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--teal);
}

.level.exam-group .exam-group-mark svg {
  width: 32px !important;
  height: 32px !important;
  min-width: 32px;
  min-height: 32px;
  display: block;
  flex: none;
}

.scramble-tip {
  margin: 0 0 10px;
  text-align: center;
}

.scramble-built {
  min-height: calc(48px * var(--text-scale));
  margin: 0 0 14px;
  padding: 8px 12px;
  border: 2px solid var(--group-border);
  border-radius: 12px;
  font-size: calc(26px * var(--text-scale));
  font-weight: 650;
  color: var(--teal);
  text-align: center;
  line-height: 1.3;
  word-break: break-all;
}

.scramble-tiles {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

.scramble-tile {
  padding: 10px 14px;
  border: 2px solid var(--group-border);
  border-radius: 12px;
  background: var(--white);
  font-size: calc(24px * var(--text-scale));
  font-weight: 650;
  color: var(--ink);
  cursor: pointer;
  transition: opacity .18s ease, border-color .18s ease, background .18s ease;
}

.scramble-tile:active { transform: scale(.96); }

.scramble-tile.is-used {
  opacity: .35;
  border-color: var(--teal);
  cursor: default;
}

.scramble-tile.is-wrong {
  border-color: #e6301a;
  background: rgba(230, 48, 26, .12);
}


.word-copy {
  grid-column: 2;
  grid-row: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 0;
}

.word .hz { font-size: calc(26px * var(--text-scale)); color: var(--ink); line-height: 1.15; }
.word .py { color: var(--ink); }
.word .en {
  color: var(--muted);
  margin-left: 0;
  padding-left: 0;
}
.word .tag { font-size: calc(12px * var(--text-scale)); color: var(--teal); font-weight: 650; margin-left: 8px; }

.word-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 18px 8px;
}

#py { font-size: calc(28px * var(--text-scale)); font-weight: 700; color: var(--teal); }
.word .py { font-size: calc(16px * var(--text-scale)); font-weight: 650; color: var(--ink); }
.en { font-size: calc(16px * var(--text-scale)); color: var(--muted); margin-top: 2px; }

.speaker {
  width: 56px;
  height: 56px;
  border: 0;
  border-radius: 0;
  background: transparent;
  cursor: pointer;
  display: grid;
  place-items: center;
  flex: 0 0 56px;
  box-shadow: none;
  /* Match writing ink: always dark stroke color. */
  color: #143033;
  padding: 0;
}

.speaker:active { opacity: 0.65; }

.speaker svg { width: 36px; height: 36px; display: block; }

/* On dark chrome, icon stays writing-ink dark would vanish — use the warm writing paper color instead so it still reads as “the writing.” */
html.dark .speaker {
  color: #efe6d6;
  box-shadow: none;
}

.paper {
  position: relative;
  width: calc(100% - 32px);
  margin: 4px auto 8px;
  aspect-ratio: 1;
  background: var(--warm-paper);
  border-radius: 18px;
  border: 1px solid var(--paper-border);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.guides {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.guides line {
  stroke: var(--guide);
  stroke-width: 0.7;
  stroke-dasharray: 1.15 1.35;
  stroke-linecap: round;
}

#writer {
  position: absolute;
  inset: 0;
}

#writer svg {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}



.hint {
  margin: 8px 18px 0;
  text-align: center;
  font-size: calc(17px * var(--text-scale));
  color: var(--teal);
  min-height: 1.3em;
}

.status {
  margin: 4px 18px 20px;
  text-align: center;
  color: var(--muted);
  font-size: calc(14px * var(--text-scale));
  min-height: 1.2em;
}

.done-block {
  padding: 48px 24px 32px;
  text-align: center;
}

.done-title {
  font-size: calc(40px * var(--text-scale));
  margin: 0 0 8px;
}

.done-sub {
  margin: 0 0 28px;
  color: var(--muted);
  font-size: calc(20px * var(--text-scale));
}

.report-date {
  margin-left: auto;
  color: var(--muted);
  font-size: calc(14px * var(--text-scale));
  font-weight: 600;
}

.nav { position: relative; }
.report-date { position: absolute; right: 16px; }

.report-set {
  margin: 8px 16px 0;
  text-align: center;
  color: var(--muted);
  font-size: calc(15px * var(--text-scale));
}

.report-rows {
  margin: 12px 20px 8px;
  border-top: 1px solid var(--line);
}

.report-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 4px;
  border-bottom: 1px solid var(--line);
  font-size: calc(17px * var(--text-scale));
  color: var(--ink);
}

.report-row b {
  font-weight: 700;
  color: var(--aqua);
}

.report-actions {
  padding: 18px 20px 28px;
  text-align: center;
}

.report-actions .btn-wide { margin-top: 12px; }

.text-link {
  display: inline-block;
  margin-top: 16px;
  background: none;
  border: 0;
  color: var(--aqua);
  font-size: calc(17px * var(--text-scale));
  font-weight: 700;
  cursor: pointer;
}

.word.open { cursor: pointer; }

.char-level {
  display: block;
  margin: 4px 0 0;
  text-align: center;
  color: var(--muted);
}

.char-hero {
  margin: 8px 0 0;
  text-align: center;
  font-size: calc(72px * var(--text-scale));
  line-height: 1.1;
  color: var(--ink);
}

.char-hero.is-long,
.learn-hero.is-long,
.flash-hanzi.is-long {
  font-size: calc(56px * var(--text-scale));
}

.pinyin-choice.is-long {
  font-size: calc(24px * var(--text-scale));
}

.listen-choice.is-long {
  font-size: calc(24px * var(--text-scale));
}

.listen-choice.is-longer {
  font-size: calc(20px * var(--text-scale));
}

.char-reads {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin: 8px 16px 4px;
  font-size: calc(22px * var(--text-scale));
  font-weight: 700;
  color: var(--ink);
}

.char-tabs {
  display: flex;
  justify-content: center;
  gap: 48px;
  margin: 16px 16px 0;
  border-bottom: 1px solid var(--tab-line);
}

.tab {
  background: none;
  border: 0;
  border-bottom: 3px solid transparent;
  padding: 8px 4px 10px;
  font-size: calc(17px * var(--text-scale));
  font-weight: 650;
  color: var(--muted);
  cursor: pointer;
}

.tab.on {
  color: var(--aqua);
  border-bottom-color: var(--aqua);
}

.char-panel {
  padding: 8px 20px 0;
  color: var(--ink);
  font-size: calc(16px * var(--text-scale));
  line-height: 1.45;
}

.char-panel h3 {
  margin: 18px 0 6px;
  font-size: calc(18px * var(--text-scale));
  color: var(--teal);
}

.char-panel p { margin: 0 0 10px; }

.part {
  display: grid;
  grid-template-columns: 48px 72px 1fr;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
}

.part-hz { font-size: calc(32px * var(--text-scale)); }
.part-py { color: var(--ink); }
.part-en { color: var(--muted); }

.ex-hz { font-size: calc(22px * var(--text-scale)); margin-top: 4px; }
.ex-py { color: var(--ink); }
.ex-en { color: var(--muted); margin: 0; }

.ex-hz-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 4px 0 0;
}

.ex-hz-row .ex-hz {
  flex: 1;
  min-width: 0;
  margin: 0;
}

#char-ex-en {
  margin: 0 0 10px;
}

.ex-en-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 10px;
}

.ex-en-row .ex-en {
  flex: 1;
  min-width: 0;
}

.speaker-sm {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  margin: 0;
}

.speaker-sm svg {
  width: 22px;
  height: 22px;
}

.char-score {
  font-size: calc(22px * var(--text-scale));
  font-weight: 700;
  color: var(--aqua);
}

.char-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

#screen-char {
  padding-bottom: 150px;
}

#screen-char .char-actions {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(430px, 100%);
  background: var(--paper);
  border-top: 1px solid var(--line);
  padding: 8px 16px 18px;
  z-index: 5;
}

.char-actions .btn-wide {
  margin-top: 8px;
}

#screen-learn:not([hidden]) {
  min-height: 100vh;
}

#screen-learn {
  padding-bottom: 168px;
}

.learn-hero {
  margin: 12px 16px 0;
  text-align: center;
  font-size: calc(72px * var(--text-scale));
  line-height: 1.1;
  color: var(--ink);
}

.learn-py {
  margin: 8px 16px 4px;
  text-align: center;
  font-size: calc(28px * var(--text-scale));
  font-weight: 700;
  color: var(--ink);
}

.learn-panel {
  padding: 12px 22px 0;
  color: var(--ink);
  font-size: calc(16px * var(--text-scale));
  line-height: 1.45;
}

.learn-panel h3 {
  margin: 22px 0 8px;
  font-size: calc(15px * var(--text-scale));
  font-weight: 700;
  color: var(--teal);
}

#learn-def {
  margin: 0;
  font-size: calc(22px * var(--text-scale));
  font-weight: 650;
  color: var(--ink);
  line-height: 1.35;
}

.learn-panel .ex-hz {
  font-size: calc(26px * var(--text-scale));
  margin: 0 0 6px;
  color: var(--ink);
}

.learn-actions {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(430px, 100%);
  background: var(--paper);
  border-top: 1px solid var(--line);
  padding: 12px 20px 28px;
  text-align: center;
  z-index: 5;
}

.learn-teach {
  display: block;
  width: 100%;
  margin: 0 auto;
  padding: 14px 18px;
  border-radius: 999px;
  font-size: calc(17px * var(--text-scale));
  font-weight: 650;
}

.learn-actions .text-link {
  display: block;
  width: 100%;
  margin-top: 18px;
  background: none;
  border: 0;
  box-shadow: none;
  color: var(--aqua);
}

html.dark .level.locked .lock path {
  fill: currentColor;
}

html.dark .btn {
  box-shadow: 3px 5px 0 #000;
}

html.dark .level,
html.dark .word {
  box-shadow: 0 4px 5px -4px rgba(0, 0, 0, 0.85);
}

html.dark .switch-knob {
  background: #f7f4ee;
}

/* Writing square stays light paper with dark ink in both themes. */
html.dark .paper {
  /* Slightly warmer than light-mode paper so it sits softer on night chrome. */
  background: #efe6d6;
  border-color: #e0d4c2;
  color: #143033;
}
html.dark .guides line {
  stroke: #8d8d8d;
}

.btn.btn-disabled,
.btn:disabled {
  background: var(--paper);
  color: var(--ink);
  box-shadow: 3px 5px 0 #000;
  border: 2px solid var(--ink);
  cursor: default;
  filter: none;
  pointer-events: none;
  box-sizing: border-box;
}
html.dark .btn.btn-disabled,
html.dark .btn:disabled {
  background: var(--paper);
  color: var(--ink);
  box-shadow: 3px 5px 0 #000;
  border: 2px solid var(--ink);
}

#btn-char-learn[hidden] {
  display: none !important;
}

.test-options-actions {
  margin: 20px 16px 28px;
}

/* Flash card — Definitions */
.btn-outline {
  background: var(--paper);
  color: var(--aqua);
  border: 2px solid var(--aqua);
  border-radius: 20px;
  padding: 10px 18px;
  font-size: calc(16px * var(--text-scale));
  font-weight: 650;
  cursor: pointer;
  min-width: 92px;
  box-shadow: 3px 5px 0 #000;
  box-sizing: border-box;
}

.btn-outline:active { filter: brightness(1.08); }

html.dark .btn-outline {
  background: var(--white);
  color: var(--teal);
  border-color: var(--aqua-soft);
}

.btn.btn-deep-teal {
  /* Deep teal — fixed so dark mode text-color --teal does not wash it out */
  background: #0d3235;
  color: #fff;
}

.btn.btn-deep-teal:active { filter: brightness(1.12); }

html.dark .btn.btn-deep-teal {
  background: #0d3235;
  color: #fff;
}

#screen-flash {
  padding-bottom: 120px;
  min-height: 100vh;
}

.flash-card {
  margin: 8px 16px 0;
  padding: 20px 18px 24px;
  background: var(--white);
  border: 1px solid var(--group-border);
  border-radius: 18px;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.04);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  min-height: 360px;
  display: flex;
  flex-direction: column;
}

.flash-card:focus-visible {
  outline: 2px solid var(--aqua);
  outline-offset: 2px;
}

.flash-top {
  flex: 1 1 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 12px 8px 20px;
}

.flash-hanzi {
  font-size: calc(72px * var(--text-scale));
  line-height: 1.1;
  color: var(--ink);
  font-weight: 500;
}

.flash-py {
  margin-top: 10px;
  font-size: calc(26px * var(--text-scale));
  font-weight: 700;
  color: var(--ink);
}

.flash-divider {
  height: 1px;
  background: var(--line);
  margin: 0 4px;
}

.flash-bottom {
  flex: 1 1 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px 8px 8px;
  min-height: 120px;
}

.flash-prompt {
  margin: 0;
  font-size: calc(22px * var(--text-scale));
  font-weight: 650;
  color: var(--ink);
  line-height: 1.35;
}

.flash-prompt-em {
  color: var(--logo-red);
}

html.dark .flash-prompt-em {
  color: var(--red);
}

.flash-answer {
  margin: 0;
  font-size: calc(24px * var(--text-scale));
  font-weight: 650;
  color: var(--ink);
  line-height: 1.35;
}

.flash-actions {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(430px, 100%);
  display: flex;
  gap: 12px;
  justify-content: center;
  padding: 12px 16px 20px;
  background: var(--paper);
  border-top: 1px solid var(--line);
  z-index: 5;
  box-sizing: border-box;
}

.flash-actions .btn,
.flash-actions .btn-outline,
.flash-actions .btn-deep-teal {
  flex: 1 1 0;
  max-width: 180px;
  padding: 14px 12px;
  border-radius: 22px;
  font-size: calc(17px * var(--text-scale));
}

.switch-row + .switch-row {
  margin-top: 14px;
}

/* Learned only filters the test. It is not another skill. */
#learned-only-row {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

#char-stats h3 {
  margin-top: 18px;
}

#char-stats h3:first-child {
  margin-top: 0;
}


#screen-pinyin {
  padding-bottom: 40px;
  min-height: 100vh;
}

.pinyin-card {
  margin: 8px 16px 0;
  padding: 20px 18px 24px;
  background: var(--white);
  border: 1px solid var(--group-border);
  border-radius: 18px;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.04);
}

.pinyin-prompt {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 16px 8px 28px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 20px;
}

.pinyin-py-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
}

.pinyin-py {
  font-size: calc(34px * var(--text-scale));
  font-weight: 700;
  color: var(--ink);
  line-height: 1.2;
}

.pinyin-en {
  margin-top: 10px;
  font-size: calc(20px * var(--text-scale));
  font-weight: 650;
  color: var(--muted);
  line-height: 1.35;
}

.pinyin-choices {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.pinyin-choice {
  display: block;
  width: 100%;
  min-width: 0;
  padding: 14px 16px;
  border-radius: 18px;
  font-size: calc(28px * var(--text-scale));
  font-weight: 650;
  line-height: 1.2;
  border: 2px solid transparent;
  box-sizing: border-box;
}

.pinyin-choice:disabled {
  cursor: default;
  opacity: 1;
  filter: none;
}

.pinyin-choice.is-correct,
.pinyin-choice.is-correct:disabled {
  background: var(--aqua);
  color: #fff;
  border: 2px solid #0a9b6e;
  box-shadow: 0 0 0 3px rgba(10, 155, 110, 0.35);
  opacity: 1;
  filter: none;
}

.pinyin-choice.is-wrong,
.pinyin-choice.is-wrong:disabled {
  background: #d12626;
  color: #fff;
  border: 2px solid #d12626;
  box-shadow: none;
  opacity: 1;
  filter: none;
}

.pinyin-choice.is-muted,
.pinyin-choice.is-muted:disabled {
  background: #c9c5bc;
  color: #5e6465;
  border: 2px solid #b3aea6;
  box-shadow: none;
  opacity: 1;
  filter: none;
}

html.dark .pinyin-choice.is-correct,
html.dark .pinyin-choice.is-correct:disabled {
  background: var(--aqua);
  color: #fff;
  border-color: #0a9b6e;
}

html.dark .pinyin-choice.is-wrong,
html.dark .pinyin-choice.is-wrong:disabled {
  background: #d12626;
  color: #fff;
  border-color: #d12626;
}

html.dark .pinyin-choice.is-muted,
html.dark .pinyin-choice.is-muted:disabled {
  background: #24383b;
  color: #8e9899;
  border-color: #1b2e31;
}

#screen-listen {
  padding-bottom: 40px;
  min-height: 100vh;
}

.listen-card {
  margin: 8px 16px 0;
  padding: 22px 18px 24px;
  background: var(--white);
  border: 1px solid var(--group-border);
  border-radius: 18px;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.04);
}

.listen-play {
  display: grid;
  place-items: center;
  width: 88px;
  height: 88px;
  margin: 2px auto 20px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--aqua);
  color: #fff;
  box-shadow: 3px 5px 0 #000;
  cursor: pointer;
}

.listen-play:active { filter: brightness(1.15); }

.listen-play svg {
  width: 42px;
  height: 42px;
  display: block;
}

.slisten-play {
  display: grid;
  place-items: center;
  width: 108px;
  height: 108px;
  margin: 2px auto 20px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--aqua);
  color: #fff;
  box-shadow: 3px 5px 0 #000;
  cursor: pointer;
}

.slisten-play:active { filter: brightness(1.15); }

.slisten-play svg {
  width: 52px;
  height: 52px;
  display: block;
}

#screen-sentence {
  padding-bottom: 40px;
  min-height: 100vh;
}

.sentence-card {
  margin: 8px 16px 0;
  padding: 20px 18px 24px;
  background: var(--white);
  border: 1px solid var(--group-border);
  border-radius: 18px;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.04);
}

.sentence-prompt {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  text-align: left;
  padding: 12px 4px 24px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 20px;
}

.sentence-en-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sentence-en {
  flex: 1;
  min-width: 0;
  font-size: calc(22px * var(--text-scale));
  font-weight: 650;
  color: var(--ink);
  line-height: 1.4;
}

.sentence-choices {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sentence-choice {
  display: block;
  width: 100%;
  min-width: 0;
  padding: 14px 16px;
  border-radius: 18px;
  font-size: calc(20px * var(--text-scale));
  font-weight: 650;
  line-height: 1.35;
  border: 2px solid transparent;
  box-sizing: border-box;
  text-align: left;
  white-space: normal;
}

.sentence-choice:disabled {
  cursor: default;
  opacity: 1;
  filter: none;
}

.sentence-choice.is-correct,
.sentence-choice.is-correct:disabled {
  background: var(--aqua);
  color: #fff;
  border: 2px solid #0a9b6e;
  box-shadow: 0 0 0 3px rgba(10, 155, 110, 0.35);
  opacity: 1;
  filter: none;
}

.sentence-choice.is-wrong,
.sentence-choice.is-wrong:disabled {
  background: #d12626;
  color: #fff;
  border: 2px solid #d12626;
  box-shadow: none;
  opacity: 1;
  filter: none;
}

.sentence-choice.is-muted,
.sentence-choice.is-muted:disabled {
  background: #c9c5bc;
  color: #5e6465;
  border: 2px solid #b3aea6;
  box-shadow: none;
  opacity: 1;
  filter: none;
}

html.dark .sentence-choice.is-correct,
html.dark .sentence-choice.is-correct:disabled {
  background: var(--aqua);
  color: #fff;
  border-color: #0a9b6e;
}

html.dark .sentence-choice.is-wrong,
html.dark .sentence-choice.is-wrong:disabled {
  background: #d12626;
  color: #fff;
  border-color: #d12626;
}

html.dark .sentence-choice.is-muted,
html.dark .sentence-choice.is-muted:disabled {
  background: #24383b;
  color: #8e9899;
  border-color: #1b2e31;
}

.choice-next {
  margin: 18px 0 0;
  text-align: center;
  font-size: calc(16px * var(--text-scale));
  font-weight: 650;
  color: var(--aqua);
}

#flash-next.choice-next {
  flex: 1 1 auto;
  margin: 0;
  padding: 14px 12px;
}

.backup-heading {
  font-size: calc(18px * var(--text-scale));
  line-height: 1.25;
  padding-right: 8px;
}

.backup-actions {
  margin: 18px 16px 0;
}

.backup-actions .btn-wide {
  width: 100%;
  max-width: 280px;
}

.backup-status {
  margin: 14px 20px 0;
  text-align: center;
  font-size: calc(15px * var(--text-scale));
  font-weight: 650;
  color: var(--aqua);
}

.backup-status.is-error {
  color: var(--red);
}

.backup-lead,
.backup-phone {
  margin: 22px 24px 0;
  color: var(--ink);
  font-size: calc(15px * var(--text-scale));
  line-height: 1.45;
}

.backup-lead p,
.backup-phone p {
  margin: 0 0 8px;
}

.backup-phone {
  margin-top: 28px;
  color: var(--muted);
  font-size: calc(14px * var(--text-scale));
}

.backup-phone-icon {
  display: block;
  width: 42px;
  height: 42px;
  margin: 0 auto 12px;
  color: var(--aqua);
}

.lantern-title {
  margin-top: 8px;
  margin-bottom: 16px;
}

#screen-lantern-fall[hidden],
#screen-lantern-write[hidden],
#screen-lantern-points[hidden],
#screen-lantern-over[hidden] {
  display: none !important;
}

#screen-lantern-fall,
#screen-lantern-write,
#screen-lantern-points,
#screen-lantern-over {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 30;
  width: 100%;
  max-width: 430px;
  margin: 0 auto;
  overflow: hidden;
  color: #f4efe4;
  background: #081c1e;
}

#screen-lantern-fall,
#screen-lantern-write,
#screen-lantern-points {
  display: flex;
  flex-direction: column;
}

.lantern-points {
  position: relative;
  z-index: 2;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  padding: 24px 16px 18vh;
}

.lantern-point {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.lantern-point-label {
  margin: 0;
  color: var(--orange);
  font-size: calc(28px * var(--text-scale));
  font-weight: 700;
  line-height: 1.15;
  text-align: center;
}

.lantern-point-bubble {
  margin: 0;
  min-width: 72px;
  padding: 5px 16px 6px;
  border-radius: 999px;
  background: var(--orange);
  color: #061214;
  font-size: calc(18px * var(--text-scale));
  font-weight: 800;
  line-height: 1.2;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.lantern-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: #081c1e url("https://media.abcsqueeze.cn/img/lantern-forest.jpg?v=2") center center / cover no-repeat;
}

.lantern-bg.is-close {
  background-size: 175% auto;
  background-position: 50% 0%;
}

.lantern-night {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: rgba(8, 28, 30, 0.4);
  pointer-events: none;
}

.lantern-night-deep {
  background: rgba(8, 28, 30, 0.55);
}

.lantern-top {
  position: relative;
  z-index: 6;
  display: flex;
  align-items: center;
  min-height: 56px;
  padding-top: env(safe-area-inset-top);
}

.lantern-ready {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  pointer-events: auto;
}

.lantern-ready[hidden] {
  display: none !important;
}

.lantern-ready-count {
  margin: 0;
  min-height: 1.05em;
  font-size: clamp(84px, 24vw, 120px);
  font-weight: 750;
  line-height: 0.95;
  color: #f7f4ee;
  text-shadow: 0 2px 0 rgba(8, 28, 30, 0.28), 0 10px 28px rgba(8, 28, 30, 0.45);
}

.lantern-ready-count.is-fading {
  animation-name: lantern-count-fade;
  animation-timing-function: linear;
  animation-fill-mode: forwards;
}

.lantern-ready-words {
  margin: 0;
  width: 100%;
  padding: 0 10px;
  text-align: center;
  white-space: nowrap;
  font-size: clamp(34px, 9.4vw, 52px);
  font-weight: 750;
  letter-spacing: 0.01em;
  color: #f7f4ee;
  text-shadow: 0 2px 0 rgba(8, 28, 30, 0.28), 0 10px 28px rgba(8, 28, 30, 0.45);
}

@keyframes lantern-count-fade {
  0% { opacity: 1; }
  22% { opacity: 1; }
  100% { opacity: 0; }
}

.lantern-back {
  color: #f4efe4;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
}

.lantern-clock {
  flex: 1;
  margin-right: 52px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-size: calc(22px * var(--text-scale));
  font-weight: 750;
  letter-spacing: 0.04em;
  color: #f4efe4;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

.lantern-stage {
  position: relative;
  z-index: 2;
  flex: 1;
  min-height: 0;
}

.lantern-piece {
  position: absolute;
  top: 0;
  left: 50%;
  width: 168px;
  transform: translate(-50%, 0);
  filter: drop-shadow(0 16px 18px rgba(0, 0, 0, 0.35));
}

.lantern-cap {
  position: relative;
  height: 22px;
  margin-bottom: -2px;
}

.lantern-ring {
  position: absolute;
  top: 0;
  left: 50%;
  width: 12px;
  height: 8px;
  margin-left: -6px;
  border: 2px solid #e7c27a;
  border-radius: 6px 6px 0 0;
  box-shadow: 0 0 8px rgba(255, 180, 60, 0.45);
}

.lantern-cap-bar {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 46px;
  height: 8px;
  margin-left: -23px;
  border-radius: 3px;
  background: linear-gradient(#f0d7a0, #c9842e);
  box-shadow: 0 1px 0 rgba(255, 236, 190, 0.8);
}

.lantern-body {
  position: relative;
  width: 148px;
  height: 136px;
  margin: 0 auto;
  border-radius: 16px;
  border: 2px solid rgba(255, 220, 160, 0.9);
  background:
    radial-gradient(circle at 50% 38%, #ffe1a3 0%, #ffb03a 38%, #f27800 72%, #e25c00 100%);
  box-shadow:
    0 0 28px rgba(255, 140, 30, 0.55),
    inset 0 0 22px rgba(255, 244, 210, 0.45);
  display: grid;
  place-items: center;
}

.lantern-corner {
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 244, 214, 0.92);
  pointer-events: none;
}

.lantern-corner.tl { top: 8px; left: 8px; border-right: 0; border-bottom: 0; border-radius: 4px 0 0 0; }
.lantern-corner.tr { top: 8px; right: 8px; border-left: 0; border-bottom: 0; border-radius: 0 4px 0 0; }
.lantern-corner.bl { bottom: 8px; left: 8px; border-right: 0; border-top: 0; border-radius: 0 0 0 4px; }
.lantern-corner.br { bottom: 8px; right: 8px; border-left: 0; border-top: 0; border-radius: 0 0 4px 0; }

.lantern-char {
  position: relative;
  z-index: 1;
  width: 108px;
  height: 108px;
  pointer-events: none;
}

.lantern-char svg {
  display: block;
  width: 100%;
  height: 100%;
}

.lantern-choices {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.lantern-choice {
  width: 148px;
  min-height: 46px;
  border: 0;
  border-radius: 10px;
  padding: 8px 10px;
  background: linear-gradient(#ffc15a, #f07a00);
  color: #0B1C1E;
  font-size: calc(18px * var(--text-scale));
  font-weight: 700;
  letter-spacing: 0.01em;
  box-shadow:
    0 8px 16px rgba(0, 0, 0, 0.28),
    inset 0 1px 0 rgba(255, 236, 190, 0.65);
  cursor: pointer;
}

.lantern-choice:active { filter: brightness(1.08); }

.lantern-choice.is-wrong,
.lantern-choice.is-wrong:disabled {
  background: #9d2d2d;
  color: #0B1C1E;
  box-shadow: none;
  cursor: default;
}

.lantern-tassel {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 6px;
}

.lantern-tassel-knot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #e7c27a;
}

.lantern-tassel-body {
  width: 26px;
  height: 18px;
  margin-top: -2px;
  border-radius: 3px 3px 8px 8px;
  background: linear-gradient(#ffb03a, #e25c00);
  box-shadow: 0 0 12px rgba(255, 140, 30, 0.45);
}

.lantern-bar {
  position: relative;
  z-index: 3;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  align-items: end;
  padding: 10px 18px calc(12px + env(safe-area-inset-bottom));
  background: rgba(6, 18, 20, 0.92);
  color: #f4efe4;
}

.lantern-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 64px;
}

.mini-lantern {
  position: relative;
  width: 36px;
  height: 34px;
  margin-top: 8px;
  border-radius: 6px;
  border: 1px solid rgba(255, 220, 160, 0.85);
  background: radial-gradient(circle at 50% 40%, #ffe1a3, #f27800 70%, #e25c00);
  color: #fffaf2;
  display: grid;
  place-items: center;
  font-size: calc(16px * var(--text-scale));
  font-weight: 800;
  box-shadow: 0 0 10px rgba(255, 140, 30, 0.55);
}

.mini-lantern::before {
  content: "";
  position: absolute;
  top: -7px;
  left: 50%;
  width: 16px;
  height: 5px;
  margin-left: -8px;
  border-radius: 2px;
  background: linear-gradient(#f0d7a0, #c9842e);
}

.lantern-stat-label,
.lantern-pause-label {
  margin-top: 4px;
  font-size: calc(13px * var(--text-scale));
  line-height: 1.1;
  color: rgba(244, 239, 228, 0.82);
}

.lantern-score-wrap {
  display: grid;
  place-items: center;
  align-self: center;
  font-size: calc(32px * var(--text-scale));
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}

.lantern-pause {
  justify-self: end;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 64px;
  border: 0;
  background: transparent;
  color: #f4efe4;
  padding: 0;
  cursor: pointer;
}

.lantern-pause-icon {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
}

.lantern-pause-icon svg {
  width: 28px;
  height: 28px;
  display: block;
}

#screen-lantern-fall.is-paused .lantern-choice {
  pointer-events: none;
}

.lantern-paper-wrap {
  position: relative;
  z-index: 2;
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
}

.lantern-paper {
  position: relative;
  width: min(78vw, 320px, 46vh);
  aspect-ratio: 1;
  background: transparent;
}

.lantern-paper .guides {
  position: absolute;
  inset: 8%;
  width: 84%;
  height: 84%;
}

.lantern-paper .guides line {
  stroke: rgba(244, 239, 228, 0.42);
  stroke-width: 0.6;
}

.lantern-bracket {
  position: absolute;
  z-index: 3;
  width: 22px;
  height: 22px;
  border: 2px solid rgba(244, 239, 228, 0.8);
  pointer-events: none;
}

.lantern-bracket.tl { top: 0; left: 0; border-right: 0; border-bottom: 0; }
.lantern-bracket.tr { top: 0; right: 0; border-left: 0; border-bottom: 0; }
.lantern-bracket.bl { bottom: 0; left: 0; border-right: 0; border-top: 0; }
.lantern-bracket.br { bottom: 0; right: 0; border-left: 0; border-top: 0; }

#lantern-writer {
  position: absolute;
  inset: 0;
}

#lantern-writer svg {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

#screen-lantern-write.is-paused #lantern-writer {
  pointer-events: none;
}

.lantern-write-panel {
  position: relative;
  z-index: 3;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-rows: auto auto;
  gap: 10px 16px;
  align-items: center;
  padding: 8px 18px calc(16px + env(safe-area-inset-bottom));
}

.lantern-speak {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 0;
  background: transparent;
  color: #f4efe4;
  font-size: calc(22px * var(--text-scale));
  font-weight: 750;
  padding: 0;
  cursor: pointer;
}

.lantern-speak svg {
  width: 28px;
  height: 28px;
  display: block;
}

.lantern-gloss {
  margin: 0;
  color: #f4efe4;
  font-size: calc(16px * var(--text-scale));
  line-height: 1.35;
}

.lantern-bonus strong {
  display: block;
  font-size: calc(28px * var(--text-scale));
  font-weight: 750;
  line-height: 1;
}

.lantern-bonus span {
  display: block;
  margin-top: 4px;
  font-size: calc(13px * var(--text-scale));
  color: rgba(244, 239, 228, 0.82);
}

.lantern-write-panel .lantern-pause {
  grid-column: 2;
  grid-row: 2;
}

#screen-lantern-over {
  display: grid;
  place-items: center;
}

.lantern-over-card {
  position: relative;
  z-index: 2;
  width: min(340px, calc(100% - 36px));
  padding: 28px 22px 24px;
  text-align: center;
}

.lantern-over-title {
  margin: 0 0 18px;
  font-size: calc(40px * var(--text-scale));
  color: #f4efe4;
}

.lantern-over-row {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 28px;
}

.lantern-over-score {
  font-size: calc(36px * var(--text-scale));
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}

.lantern-over-time {
  font-size: calc(18px * var(--text-scale));
  color: rgba(244, 239, 228, 0.88);
}

.lantern-finish {
  margin-top: 28px;
}

.lantern-over-luck {
  margin: 18px 0 0;
  font-size: calc(22px * var(--text-scale));
  font-weight: 700;
  line-height: 1.3;
  color: #f7f4ee;
}

/* ---- game help (?) overlays ---- */

.help-btn {
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid var(--aqua);
  background: transparent;
  color: var(--aqua);
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  margin-left: auto;
}

.topbar .help-btn {
  margin-left: auto;
}

.dark .help-btn {
  border-color: var(--aqua-soft);
  color: var(--aqua-soft);
}

.lantern-top {
  display: flex;
  justify-content: flex-start;
  gap: 12px;
}

.lantern-help-btn {
  margin-left: 0;
  border-color: var(--logo-yellow);
  color: var(--logo-yellow);
}

.help-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1200;
  padding: 18px;
}

.help-overlay[hidden] {
  display: none;
}

.help-card {
  background: var(--paper);
  color: var(--ink);
  width: 100%;
  max-width: 430px;
  max-height: 82vh;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.28);
  overflow: hidden;
}

.help-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 0;
}

.help-head h3 {
  margin: 0;
  font-size: calc(18px * var(--text-scale));
}

.help-close {
  border: 0;
  background: transparent;
  font-size: 26px;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  padding: 2px 6px;
}

.help-body {
  padding: 10px 18px 6px;
  overflow-y: auto;
  font-size: calc(15px * var(--text-scale));
  line-height: 1.55;
}

.help-body h4 {
  margin: 14px 0 6px;
  font-size: calc(15px * var(--text-scale));
  text-transform: none;
  letter-spacing: 0;
}

.help-body ul {
  margin: 6px 0 10px;
  padding-left: 20px;
}

.help-body li {
  margin: 4px 0;
}

.help-body b {
  color: var(--aqua);
}

.dark .help-body b {
  color: var(--aqua-soft);
}

.help-got {
  margin: 8px 16px 16px;
}
