/* Nǐ Hǎo, Shanghai — UI styles. Pixel-flavoured panels over a crisp canvas. */

:root {
  --ink: #2b1d2a;
  --ink-soft: #5a4a58;
  --paper: #fbf1dc;
  --paper-2: #f3e3c3;
  --paper-3: #e7d2a9;
  --red: #d63c3a;
  --red-dk: #9f2b2f;
  --gold: #f2c14e;
  --gold-dk: #c2912e;
  --green: #3f9a4f;
  --line2: #8cc63e;
  --line2-dk: #5f8f1e;
  --blue: #3d7fc4;
  --teal: #2b9a8d;
  --st-discovered: #3d7fc4;
  --st-practiced: #e09a2a;
  --st-mastered: #3f9a4f;
  --shadow: 0 4px 0 var(--ink);
  --radius: 10px;
  --hz: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Source Han Sans SC", "Microsoft YaHei", "Heiti SC", sans-serif;
  --ui: ui-rounded, "SF Pro Rounded", "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #17131d;
  color: var(--ink);
  font-family: var(--ui);
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

#game {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

#ui {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}
#ui > * { pointer-events: auto; }
#ui > .hud, #ui > .toasts { pointer-events: none; }
/* a toast shown a moment before a conversation or the tablet opened must not
   sit on top of it (new ones already wait: Hud.flushToasts) */
#ui:has(> .enc, > .phone-wrap, > .mm-wrap, > .modal-wrap) > .toasts { visibility: hidden; }

.hidden { display: none !important; }
body.hide-py .py { display: none !important; }
/* English translations off (pause menu / Settings): only Chinese reaches you */
body.hide-en :is(.dlg-en, .enc-en, .ann-en, .led-en, .hud-loc .en, .en-tr, .h-en, .w-line .w-en, .enc-cmds [data-cmd="translate"]) { display: none !important; }
.zh, [class*="hz"] { font-family: var(--hz); }

kbd {
  display: inline-block;
  font: 700 10px/1 var(--ui);
  padding: 3px 5px 2px;
  border-radius: 4px;
  border: 1.5px solid currentColor;
  opacity: 0.7;
  vertical-align: middle;
  margin-left: 4px;
}

button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; }
button:focus-visible, input:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

.btn {
  border: 2.5px solid var(--ink);
  border-radius: 8px;
  padding: 9px 16px;
  font-weight: 800;
  font-size: 15px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 3px 0 var(--ink);
  transition: transform 0.06s, box-shadow 0.06s;
}
.btn:active { transform: translateY(3px); box-shadow: 0 0 0 var(--ink); }
.btn.primary { background: var(--red); color: #fff; }
.btn.primary kbd { color: #fff; }
.btn.ghost { background: var(--paper); }
.btn.danger { background: #fff; color: var(--red-dk); border-color: var(--red-dk); box-shadow: 0 3px 0 var(--red-dk); }

.badge {
  display: inline-block;
  font: 800 10px/1 var(--ui);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 4px 6px 3px;
  border-radius: 999px;
  background: var(--paper-3);
  color: var(--ink);
  white-space: nowrap;
}
.badge.lvl-1 { background: #ffe0d6; color: #a2352a; }
.badge.lvl-2 { background: #fff0c4; color: #8a6112; }
.badge.lvl-3 { background: #dcecff; color: #2a5e98; }
.badge.lvl-4 { background: #e3f3df; color: #2f7a3a; }
.badge.lvl-0 { background: #e6e0f2; color: #5a4a80; }
.badge.st-discovered { background: #dcebfa; color: #25598f; }
.badge.st-practiced { background: #fde8c6; color: #8b5a0c; }
.badge.st-mastered { background: #d7f0da; color: #226b30; }
.badge.st-unknown { background: #eee; color: #666; }

/* ------------------------------------------------------------ title --- */
/* Same design language as the landing page (site/): warm paper, Chinese
   red, gold, Line 2 green; Bricolage Grotesque + Plus Jakarta Sans + Noto
   Serif SC (loaded in index.html, with system fallbacks offline). */

.title {
  --t-paper: #fff8ec;
  --t-paper-2: #fbf1dc;
  --t-paper-4: #e7d2a9;
  --t-ink: #2b1d2a;
  --t-ink-soft: #5a4a58;
  --t-muted: #86757f;
  --t-red: #d63c3a;
  --t-red-hi: #e9544f;
  --t-red-dk: #9f2b2f;
  --t-gold: #f2c14e;
  --t-jade: #8cc63e;
  --t-jade-dk: #5f8f1e;
  --t-night: #1c1622;
  --t-night-2: #2a2133;
  --t-bar-h: 68px;
  --t-display: 'Bricolage Grotesque', var(--ui);
  --t-body: 'Plus Jakarta Sans', var(--ui);
  --t-serif: 'Noto Serif SC', 'Songti SC', 'STSong', 'SimSun', serif;
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: var(--t-paper);
  font-family: var(--t-body);
  color: var(--t-ink-soft);
  user-select: none;
}
.title.t-shake { animation: t-shake 260ms ease-out; }
@keyframes t-shake {
  20% { transform: translate(3px, -2px); }
  45% { transform: translate(-3px, 2px); }
  70% { transform: translate(2px, 1px); }
}

/* plain top bar, as on the website */
.t-bar {
  position: absolute; top: 0; left: 0; right: 0; z-index: 2;
  height: calc(var(--t-bar-h) + env(safe-area-inset-top)); padding-top: env(safe-area-inset-top);
  background: var(--t-paper); border-bottom: 1.5px solid var(--t-paper-4);
}
.t-bar-in {
  height: 100%; max-width: 1560px; margin: 0 auto;
  padding: 0 max(28px, env(safe-area-inset-right)) 0 max(28px, env(safe-area-inset-left));
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.t-brand { display: flex; align-items: center; gap: 12px; }
.t-brand b { font: 800 19px/1 var(--t-display); color: var(--t-ink); letter-spacing: -0.01em; }
.t-seal {
  width: 38px; height: 38px; display: grid; place-items: center; transform: rotate(-6deg);
  background: var(--t-red); color: var(--t-paper); border-radius: 9px; font: 900 14px/1 var(--t-serif);
}
.t-link {
  font: 700 14px/1 var(--t-body); color: var(--t-ink); text-decoration: none;
  padding: 10px 16px; border-radius: 999px; border: 1.5px solid var(--t-paper-4); background: var(--t-paper);
  transition: border-color 160ms ease, background-color 160ms ease;
}
.t-link:hover { border-color: var(--t-ink); background: #fff; }

/* the hero: title and buttons on the left, the game itself on the right */
.t-hero {
  position: absolute; left: 0; right: 0; bottom: 0; top: calc(var(--t-bar-h) + env(safe-area-inset-top));
  width: min(1560px, 100%); margin: 0 auto; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--t-paper-4) transparent;
  display: grid; grid-template-columns: minmax(330px, clamp(430px, 31vw, 500px)) minmax(0, 1fr); gap: clamp(28px, 4.2vw, 72px);
  align-items: center; align-content: center;
  padding: 24px max(28px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(28px, env(safe-area-inset-left));
}
.t-card { min-width: 0; animation: t-rise 700ms 40ms cubic-bezier(.2, .8, .2, 1) both; }
@keyframes t-fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.t-seal-xl {
  display: grid; place-items: center; width: 76px; height: 76px; margin-bottom: 26px; border-radius: 18px;
  background: var(--t-red); color: var(--t-paper); font: 900 28px/1 var(--t-serif);
  transform: rotate(-6deg); box-shadow: 0 14px 26px -16px rgba(43, 29, 42, 0.55);
}
.t-card > .t-seal-xl { animation: t-stamp-xl 700ms cubic-bezier(.16, 1, .3, 1) 100ms both; }
@keyframes t-stamp-xl { from { opacity: 0; transform: rotate(-16deg) scale(1.45); } to { opacity: 1; transform: rotate(-6deg) scale(1); } }
.t-zh { margin: 0 0 12px; font: 900 clamp(48px, 6.2vw, 98px)/1 var(--t-serif); color: var(--t-red); letter-spacing: 0.02em; white-space: nowrap; }
.t-en { margin: 0; font: 800 clamp(24px, 2.6vw, 40px)/1.1 var(--t-display); color: var(--t-ink); letter-spacing: -0.02em; text-wrap: balance; }
.t-en em { font-style: normal; color: var(--t-jade-dk); }

/* the five stages as a little metro line */
.t-route { list-style: none; margin: 28px 0 6px; padding: 0; max-width: 420px; display: grid; grid-template-columns: repeat(5, 1fr); position: relative; }
.t-route::before { content: ''; position: absolute; left: 10%; right: 10%; top: 10px; height: 6px; border-radius: 999px; background: var(--t-paper-4); }
.t-route li { position: relative; display: flex; flex-direction: column; align-items: center; gap: 5px; }
.t-route i {
  width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  background: var(--t-paper); border: 4px solid var(--t-paper-4);
  font: normal 800 11px/1 var(--t-display); color: var(--t-muted);
}
.t-route small { font-weight: 700; font-size: 11px; color: var(--t-muted); }
.t-route li.done i { background: var(--t-jade); border-color: var(--t-jade); color: #fff; }
.t-route li.here i { border-color: var(--t-ink); color: var(--t-ink); animation: t-here 1.8s ease-in-out infinite; }
.t-route li.here small { color: var(--t-ink); }
@keyframes t-here { 50% { box-shadow: 0 0 0 6px rgba(242, 193, 78, 0.45); } }

.t-save { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; margin: 14px 0 0; font-size: 14px; font-weight: 600; }
.t-save b { color: var(--t-ink); }
.t-save span::before { content: '·'; margin-right: 10px; color: var(--t-paper-4); }

.t-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 24px; max-width: 440px; }
.t-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px; flex: 1 1 auto;
  font: 700 16px/1 var(--t-body); padding: 16px 24px; border-radius: 999px; cursor: pointer;
  border: 2px solid transparent; transition: transform 160ms ease, background-color 160ms ease;
}
.t-btn:hover { transform: translateY(-2px); }
.t-btn:active { transform: none; }
.t-btn:focus-visible, .t-thumb:focus-visible, .t-link:focus-visible { outline: 3px solid var(--t-gold); outline-offset: 3px; }
.t-btn kbd { font: 700 11px/1 var(--t-body); padding: 4px 6px; border-radius: 6px; background: rgba(255, 248, 236, 0.2); color: inherit; border: 0; box-shadow: none; }
.t-red { background: var(--t-red); color: var(--t-paper); }
.t-red:hover { background: var(--t-red-dk); }
.t-line { background: transparent; color: var(--t-ink); border-color: var(--t-ink); }
.t-line:hover { background: var(--t-ink); color: var(--t-paper); }
.t-line.t-warn { border-color: var(--t-red); color: var(--t-red); }
.t-arr { transition: transform 160ms ease; }
.t-btn:hover .t-arr { transform: translateX(3px); }
.t-tip { display: flex; align-items: center; gap: 8px; margin: 16px 0 0; font-size: 13.5px; color: var(--t-muted); font-weight: 600; }
.t-tip svg { width: 18px; height: 18px; flex: none; color: var(--t-red); }

/* the cast: the game's own sprites standing on one ground line */
.t-cast { list-style: none; position: relative; max-width: 460px; margin: 46px 0 0; padding: 0; display: flex; justify-content: space-between; align-items: flex-end; }
.t-cast::before { content: ''; position: absolute; left: -6px; right: -6px; top: 97px; height: 2px; border-radius: 2px; background: var(--t-paper-4); }
.t-who {
  position: relative; display: flex; flex-direction: column; align-items: center; padding: 0 6px 2px;
  border: 0; border-radius: 10px; background: none; color: inherit; font: inherit; cursor: pointer;
}
.t-fig { height: 96px; display: flex; align-items: flex-end; gap: 3px; }
.t-fig canvas { display: block; width: 48px; height: 96px; image-rendering: pixelated; }
.t-kits .t-fig canvas { width: 39px; height: 36px; }
.t-who b { margin-top: 12px; font: 900 17px/1 var(--t-serif); color: var(--t-ink); letter-spacing: 0.04em; transition: color 160ms ease; }
.t-who small { margin-top: 5px; font: 700 11.5px/1 var(--t-body); color: var(--t-muted); }
.t-who:hover b, .t-who.talking b { color: var(--t-red); }
.t-who:focus-visible { outline: 3px solid var(--t-gold); outline-offset: 2px; }
/* what they say: the game's speech bubble */
.t-bubble {
  position: absolute; left: 50%; bottom: calc(100% - 6px); z-index: 2;
  display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 7px 12px 8px; white-space: nowrap;
  background: #fff; border: 2px solid var(--t-ink); border-radius: 12px; box-shadow: 0 6px 14px -8px rgba(43, 29, 42, 0.5);
  opacity: 0; visibility: hidden; transform: translate(-50%, 6px) scale(0.94); transform-origin: 50% 100%;
  transition: opacity 160ms ease, transform 220ms cubic-bezier(.2, .8, .2, 1), visibility 0s 220ms;
  pointer-events: none;
}
.t-bubble::after {
  content: ''; position: absolute; left: 50%; bottom: -7px; width: 10px; height: 10px; margin-left: -5px;
  background: #fff; border: solid var(--t-ink); border-width: 0 2px 2px 0; transform: rotate(45deg);
}
.t-bubble span { font: 800 16px/1.15 var(--hz); color: var(--t-ink); }
.t-bubble small { font: 600 11.5px/1 var(--t-body); color: var(--t-ink-soft); }
.t-who.talking .t-bubble { opacity: 1; visibility: visible; transform: translate(-50%, 0); transition: opacity 160ms ease, transform 260ms cubic-bezier(.2, .8, .2, 1), visibility 0s; }

/* a small paper label (the character creator's heading) */
.t-pill {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px;
  background: var(--t-paper-2); border: 1.5px solid var(--t-paper-4);
  font-weight: 700; font-size: 12.5px; color: var(--t-ink-soft);
}
.t-pill i { width: 8px; height: 8px; border-radius: 50%; background: var(--t-jade); }

/* the game screen, in the website's dark frame: the scenes play here */
.t-show {
  margin: 0; min-width: 0; width: 100%; justify-self: center;
  /* never taller than the space under the bar (screen + thumbnails + caption) */
  max-width: calc((100dvh - var(--t-bar-h) - 200px) * 16 / 9 + 18px);
  animation: t-rise 800ms 160ms cubic-bezier(.2, .8, .2, 1) both;
}
@keyframes t-rise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
.t-screen { background: var(--t-night); padding: 9px; border-radius: 18px; box-shadow: 0 28px 56px -34px rgba(28, 22, 34, 0.7); }
.t-shot { position: relative; aspect-ratio: 16 / 9; border-radius: 10px; overflow: hidden; background: var(--t-night-2); }
.t-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.t-thumbs { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; margin-top: 12px; }
.t-thumb {
  padding: 0; border: 2px solid transparent; border-radius: 8px; overflow: hidden; cursor: pointer;
  background: var(--t-night-2); opacity: 0.5; transition: opacity 180ms ease, border-color 180ms ease;
}
.t-thumb canvas { display: block; width: 100%; aspect-ratio: 16 / 9; opacity: 0; transition: opacity 400ms ease; }
.t-thumb.ready canvas { opacity: 1; }
.t-thumb:hover { opacity: 0.85; }
.t-thumb[aria-pressed='true'] { opacity: 1; border-color: var(--t-red); }
.t-cap { margin: 12px 2px 0; font: 600 15px/1.45 var(--t-body); color: var(--t-ink-soft); }
.t-cap b { font-weight: 800; color: var(--t-ink); }
.t-cap b span { font: 900 1.06em/1 var(--t-serif); color: var(--t-red); margin-right: 3px; }
.t-cap.on { animation: t-fade 500ms cubic-bezier(.2, .8, .2, 1) both; }

/* leaving: the columns part, the bar lifts */
.title.t-leaving .t-card { animation: t-out 420ms cubic-bezier(.5, 0, .75, 0) forwards; }
.title.t-leaving .t-show { animation: t-out-r 420ms cubic-bezier(.5, 0, .75, 0) forwards; }
.title.t-leaving .t-bar { animation: t-up 380ms cubic-bezier(.5, 0, .75, 0) forwards; }
@keyframes t-out { to { opacity: 0; transform: translateX(-50px); filter: blur(4px); } }
@keyframes t-out-r { to { opacity: 0; transform: translateX(50px); filter: blur(4px); } }
@keyframes t-up { to { opacity: 0; transform: translateY(-24px); } }

/* the big seal only where there's room for it above the title */
@media (max-height: 899px) { .t-seal-xl { display: none; } }

/* the character creator takes the hero's place */
.title.t-creating .t-hero { display: none; }

/* phones in landscape and other short screens */
@media (max-height: 560px) {
  .title { --t-bar-h: 50px; }
  .t-bar-in { padding: 0 max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left)); }
  .t-seal { width: 30px; height: 30px; font-size: 12px; border-radius: 8px; }
  .t-brand b { font-size: 16px; }
  .t-link { padding: 7px 12px; font-size: 13px; }
  .t-hero { gap: 22px; padding: 10px max(16px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
  .t-seal-xl, .t-thumbs, .t-tip { display: none; }
  .t-zh { margin-bottom: 6px; font-size: clamp(32px, 5.4vw, 46px); }
  .t-en { font-size: clamp(16px, 2.3vw, 20px); }
  .t-route { margin: 12px 0 2px; }
  .t-route i { width: 22px; height: 22px; border-width: 3px; font-size: 10px; }
  .t-route::before { top: 8px; height: 5px; }
  .t-route small { font-size: 10px; }
  .t-save { margin-top: 8px; font-size: 12.5px; }
  .t-actions { margin-top: 12px; gap: 8px; }
  .t-btn { padding: 11px 16px; font-size: 15px; }
  .t-show { max-width: calc((100dvh - var(--t-bar-h) - 64px) * 16 / 9 + 12px); }
  .t-screen { padding: 6px; border-radius: 14px; }
  .t-shot { border-radius: 8px; }
  .t-cap { margin-top: 8px; font-size: 12.5px; }
  .t-hero { grid-template-columns: minmax(300px, 0.9fr) minmax(0, 1fr); }
  .t-cast { margin-top: 14px; max-width: 360px; }
  .t-cast::before { top: 65px; }
  .t-fig { height: 64px; }
  .t-fig canvas { width: 32px; height: 64px; }
  .t-kits .t-fig canvas { width: 26px; height: 24px; }
  .t-who b { margin-top: 7px; font-size: 13px; }
  .t-who small { display: none; }
  .t-bubble span { font-size: 14px; }
}
/* narrow windows: one column, the screen under the buttons */
@media (max-width: 720px) and (min-height: 561px) {
  .t-hero { grid-template-columns: minmax(0, 1fr); align-content: start; }
  .t-seal-xl { display: none; }
  .t-show { max-width: 560px; }
}

/* ---- "Create your character" (same paper card, wider) */
.t-create {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 3;
  width: min(700px, calc(100% - 32px)); max-height: calc(100% - 24px); overflow: auto; padding: 28px 30px 22px;
  background: var(--t-paper); border: 1.5px solid var(--t-paper-4); border-radius: 28px;
  box-shadow: 0 30px 70px -34px rgba(43, 29, 42, 0.45);
  animation: t-pop 420ms cubic-bezier(.2, .8, .2, 1) both;
}
@keyframes t-pop { from { opacity: 0; transform: translate(-50%, -46%) scale(0.97); } to { opacity: 1; transform: translate(-50%, -50%); } }
.title.t-leaving .t-create { animation: t-out-c 420ms cubic-bezier(.5, 0, .75, 0) forwards; }
@keyframes t-out-c { to { opacity: 0; transform: translate(-50%, -50%) scale(0.94); filter: blur(4px); } }
.t-create.cc-shake { animation: cc-shake 360ms ease; }
@keyframes cc-shake { 25% { transform: translate(calc(-50% - 8px), -50%); } 75% { transform: translate(calc(-50% + 8px), -50%); } }
.cc-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.cc-back { width: 36px; height: 36px; border-radius: 50%; border: 1.5px solid var(--t-paper-4); background: var(--t-paper-2); color: var(--t-ink); font: 700 15px/1 var(--t-body); cursor: pointer; }
.cc-back:hover { background: var(--t-ink); color: var(--t-paper); }
.cc-grid { display: grid; grid-template-columns: 220px 1fr; gap: 24px; margin-top: 18px; align-items: start; }
.cc-preview { margin: 0; display: flex; flex-direction: column; gap: 12px; }
.cc-stage { position: relative; aspect-ratio: 1; border-radius: 22px; background: radial-gradient(circle at 50% 38%, #fff 0, var(--t-paper-2) 62%); border: 1.5px solid var(--t-paper-4); overflow: hidden; }
.cc-portrait { position: absolute; left: 8%; top: 6%; width: 84%; height: 84%; image-rendering: pixelated; }
.cc-walk { position: absolute; right: 8px; bottom: 6px; width: 40px; height: 80px; image-rendering: pixelated; filter: drop-shadow(0 3px 0 rgba(43, 29, 42, 0.15)); }
.cc-preview figcaption { display: flex; flex-direction: column; gap: 2px; padding: 0 2px; }
.cc-zh { font: 900 20px/1.25 var(--t-serif); color: var(--t-red); word-break: break-word; }
.cc-py { font-size: 13px; font-weight: 700; color: var(--t-ink-soft); }
.cc-en { font-size: 12.5px; color: var(--t-muted); font-weight: 600; }
.cc-form { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.cc-field { display: flex; flex-direction: column; gap: 6px; }
.cc-field > span { font: 800 14px/1.2 var(--t-display); color: var(--t-ink); }
.cc-field > span i { font: 700 12px/1 var(--t-serif); font-style: normal; color: var(--t-muted); margin-left: 4px; }
.cc-name, .cc-country {
  font: 700 16px/1.2 var(--t-body); color: var(--t-ink); background: #fff; border: 2px solid var(--t-paper-4);
  border-radius: 14px; padding: 11px 14px; width: 100%; box-sizing: border-box; outline: none;
}
.cc-name:focus, .cc-country:focus { border-color: var(--t-ink); }
.cc-country { appearance: none; -webkit-appearance: none; padding-right: 36px; cursor: pointer;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%232b1d2a' stroke-width='2'/%3E%3C/svg%3E") no-repeat right 14px center; }
.cc-looks { display: flex; flex-direction: column; gap: 8px; }
.cc-row { display: grid; grid-template-columns: 44px repeat(4, 1fr); gap: 8px; align-items: stretch; }
.cc-row > b { grid-row: span 1; display: flex; flex-direction: column; align-items: center; justify-content: center; font: 900 20px/1 var(--t-serif); color: var(--t-ink); }
.cc-row > span { display: none; }
.cc-look { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px 6px; border-radius: 16px; border: 2px solid var(--t-paper-4); background: var(--t-paper-2); cursor: pointer; transition: transform 140ms ease, border-color 140ms ease; }
.cc-look:hover { transform: translateY(-2px); }
.cc-look canvas { width: 28px; height: 56px; image-rendering: pixelated; }
.cc-look small { font: 700 11px/1 var(--t-body); color: var(--t-muted); }
.cc-look.on { border-color: var(--t-red); background: #fff; box-shadow: 0 6px 16px -10px rgba(214, 60, 58, 0.9); }
.cc-look.on small { color: var(--t-red); }
.cc-go:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
@media (max-width: 620px) {
  .cc-grid { grid-template-columns: 1fr; }
  .cc-preview { flex-direction: row; align-items: center; }
  .cc-stage { width: 110px; flex: none; }
}
@media (max-height: 560px) {
  .t-create { top: 50%; bottom: auto; transform: translate(-50%, -50%); width: min(720px, calc(100% - 24px)); padding: 12px 16px 12px; }
  @keyframes t-pop { from { opacity: 0; transform: translate(-50%, -46%); } to { opacity: 1; transform: translate(-50%, -50%); } }
  .t-create .t-pill { display: inline-flex; }
  .cc-grid { grid-template-columns: 150px 1fr; gap: 14px; margin-top: 8px; }
  .cc-preview { flex-direction: column; }
  /* a 4:3 preview (portrait kept square) so the card fits a phone held sideways */
  .cc-stage { width: 100%; aspect-ratio: 4 / 3; }
  .cc-portrait { left: 50%; top: 5%; width: auto; height: 90%; aspect-ratio: 1; transform: translateX(-50%); }
  .cc-preview { gap: 8px; }
  .cc-zh { font-size: 15px; }
  .cc-py { font-size: 12px; }
  .cc-en { font-size: 11.5px; }
  .cc-form { gap: 8px; }
  .cc-name, .cc-country { padding: 8px 12px; font-size: 15px; border-radius: 12px; }
  .cc-look { padding: 4px 2px; flex-direction: row; justify-content: center; gap: 6px; }
  .cc-look canvas { width: 18px; height: 36px; }
  .cc-row > b { font-size: 16px; }
  .t-create .t-actions { margin-top: 8px; }
  .title.t-creating .t-bar { display: none; }
  .cc-head .t-pill { padding: 4px 10px; font-size: 11.5px; }
  .cc-back { width: 30px; height: 30px; font-size: 13px; }
  .cc-field { gap: 4px; }
  .cc-field > span { font-size: 13px; }
  .cc-looks, .cc-row { gap: 6px; }
  .cc-look canvas { width: 14px; height: 28px; }
  .t-create .t-btn { padding: 9px 16px; }
}

/* ------------------------------------------------- entering the game --- */

.t-enter { position: absolute; inset: 0; z-index: 50; pointer-events: auto; overflow: hidden; }
.t-flood {
  position: absolute; inset: 0; background: #d63c3a;
  clip-path: circle(0% at 50% 50%);
  transition: clip-path 760ms cubic-bezier(.65, 0, .35, 1);
}
.t-enter.t-flooded .t-flood { clip-path: circle(75% at 50% 50%); }
.t-stamp {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center;
  font-family: 'Plus Jakarta Sans', var(--ui);
}
.t-seal-big {
  width: 150px; height: 150px; display: grid; place-items: center; border-radius: 30px;
  background: #d63c3a; color: #fff8ec; font: 900 54px/1 'Noto Serif SC', 'Songti SC', serif;
  box-shadow: 0 0 0 8px #fff8ec, 0 26px 60px -20px rgba(0, 0, 0, 0.7);
  opacity: 0; transform: scale(2.6) rotate(-18deg);
}
.t-enter.t-stamped .t-seal-big { animation: t-stamp 420ms cubic-bezier(.3, 1.4, .5, 1) forwards; }
@keyframes t-stamp {
  0% { opacity: 0; transform: scale(2.6) rotate(-18deg); }
  55% { opacity: 1; transform: scale(0.9) rotate(-4deg); }
  100% { opacity: 1; transform: scale(1) rotate(-6deg); }
}
/* on the red flood the seal turns paper-coloured */
.t-enter.t-flooded .t-seal-big { background: #fff8ec; color: #d63c3a; box-shadow: 0 0 0 8px rgba(255, 248, 236, 0.25); transition: background-color 400ms 300ms, color 400ms 300ms, box-shadow 400ms 300ms; }
.t-stamp b, .t-stamp small { opacity: 0; transform: translateY(10px); transition: opacity 500ms 550ms, transform 500ms 550ms; color: #fff8ec; }
.t-stamp b { font: 900 34px/1 'Noto Serif SC', 'Songti SC', serif; letter-spacing: 0.08em; margin-top: 10px; }
.t-stamp small { font-weight: 700; font-size: 15px; opacity: 0; color: rgba(255, 248, 236, 0.8); }
.t-enter.t-flooded .t-stamp b, .t-enter.t-flooded .t-stamp small { opacity: 1; transform: none; }
.t-enter.t-opening { pointer-events: none; }
.t-enter.t-opening .t-flood { clip-path: circle(0% at 50% 50%); transition: clip-path 900ms cubic-bezier(.7, 0, .3, 1); }
.t-enter.t-opening .t-stamp { animation: t-away 820ms cubic-bezier(.6, 0, .4, 1) forwards; }
@keyframes t-away {
  30% { opacity: 1; transform: translate(-50%, -50%) scale(1.08); }
  to { opacity: 0; transform: translate(-50%, -50%) scale(0.2) rotate(8deg); }
}
@media (max-height: 560px) {
  .t-seal-big { width: 104px; height: 104px; font-size: 38px; border-radius: 22px; }
  .t-stamp b { font-size: 26px; }
}
@media (prefers-reduced-motion: reduce) {
  .t-card, .t-card > *, .t-bar, .t-show, .t-cap, .t-route li.here i { animation: none !important; }
  .t-bubble { transition: none; }
  .t-flood { transition-duration: 200ms; }
}

/* ---------------------------------------------------------- hanzi text --- */

.hz-word {
  cursor: pointer;
  border-bottom: 2px dotted rgba(43, 29, 42, 0.25);
  border-radius: 2px;
  transition: background 0.15s;
}
.hz-word:hover { background: rgba(242, 193, 78, 0.35); }
.hz-word.st-discovered { border-bottom-color: var(--st-discovered); }
.hz-word.st-practiced { border-bottom-color: var(--st-practiced); }
.hz-word.st-mastered { border-bottom: 2px solid var(--st-mastered); }
.hz-word.is-new { animation: newword 1.6s ease-out; }
@keyframes newword {
  0%, 40% { background: rgba(242, 193, 78, 0.7); box-shadow: 0 0 0 3px rgba(242, 193, 78, 0.5); }
  100% { background: transparent; box-shadow: none; }
}
.hz-hidden { visibility: hidden; }

.word-pop {
  position: fixed;
  z-index: 50;
  background: var(--paper);
  border: 2.5px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 10px 12px;
  display: none;
  pointer-events: auto;
}
.word-pop.open { display: block; animation: pop 0.14s ease-out; }
@keyframes pop { from { transform: scale(0.92); } }
.wp-top { display: flex; align-items: center; justify-content: space-between; }
.wp-hz { font: 700 34px/1.1 var(--hz); }
.wp-say { border: 2px solid var(--ink); background: var(--gold); border-radius: 999px; width: 34px; height: 34px; }
.wp-py { font-weight: 800; color: var(--red-dk); }
.wp-en { font-size: 14px; margin: 2px 0 8px; }
.wp-meta { display: flex; gap: 6px; }

/* ---------------------------------------------------------- dialogue --- */

.dialog {
  position: absolute;
  left: 50%;
  bottom: max(18px, calc(env(safe-area-inset-bottom) / var(--uiz, 1)));
  transform: translateX(-50%);
  width: min(780px, calc(100vw - 24px));
  min-height: 118px;
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: 12px;
  box-shadow: 0 5px 0 var(--ink), inset 0 0 0 3px var(--paper-2);
  padding: 16px 22px 18px;
  cursor: pointer;
  animation: dlgIn 0.16s ease-out;
}
@keyframes dlgIn { from { transform: translate(-50%, 10px); } }
.dlg-speaker {
  position: absolute;
  top: -16px;
  left: 18px;
  background: var(--red);
  color: #fff;
  font: 800 14px/1 var(--hz);
  padding: 7px 12px 6px;
  border: 2.5px solid var(--ink);
  border-radius: 8px;
}
.dlg-hz { font: 600 clamp(24px, 3.4vw, 32px)/1.35 var(--hz); letter-spacing: 0.04em; margin-top: 4px; }
.dlg-py { color: var(--red-dk); font-weight: 700; font-size: 15px; margin-top: 2px; }
.dlg-en { color: var(--ink-soft); font-size: 14px; margin-top: 4px; }
.dlg-text { font-size: 17px; line-height: 1.45; font-weight: 600; }
.is-narration .dlg-text { font-style: normal; }
.dlg-next {
  position: absolute;
  right: 16px;
  bottom: 8px;
  font-size: 14px;
  opacity: 0;
}
.dlg-next.show { opacity: 1; animation: blink 0.9s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.dlg-choices { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.dlg-choices:empty { display: none; }
.dlg-choice {
  text-align: left;
  border: 2.5px solid var(--ink);
  background: #fff;
  border-radius: 8px;
  padding: 8px 12px;
  font: 700 16px/1.3 var(--hz);
}
.dlg-choice kbd { margin: 0 8px 0 0; }
.dlg-choice.sel, .dlg-choice:hover { background: var(--gold); }

/* --------------------------------------------------------------- HUD --- */

.hud { position: absolute; inset: 0; }
.hud-tl { position: absolute; top: 14px; left: 14px; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.hud-loc {
  background: var(--paper);
  border: 3px solid var(--ink);
  border-left: 10px solid var(--red);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 8px 14px 7px;
  display: grid;
  grid-template-columns: auto auto;
  column-gap: 10px;
  transform: translateX(-120%);
  transition: transform 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
.hud-loc.show { transform: none; }
.hud-loc .zh { font: 900 24px/1.1 var(--hz); grid-row: span 2; align-self: center; }
.hud-loc .py { font-weight: 800; font-size: 12px; color: var(--red-dk); }
.hud-loc .en { font-size: 12px; font-weight: 700; color: var(--ink-soft); }
.hud-obj {
  background: rgba(251, 241, 220, 0.94);
  border: 2.5px solid var(--ink);
  border-radius: 999px;
  padding: 6px 14px 6px 8px;
  font-size: 13px;
  font-weight: 700;
  max-width: min(460px, 70vw);
  display: flex;
  gap: 6px;
  align-items: center;
  box-shadow: 0 3px 0 var(--ink);
}
.hud-tr { position: absolute; top: 14px; right: 14px; display: flex; gap: 10px; align-items: center; }
.hud-money {
  background: var(--paper);
  border: 2.5px solid var(--ink);
  border-radius: 999px;
  padding: 7px 14px;
  font-weight: 800;
  box-shadow: 0 3px 0 var(--ink);
}
.hud-phone {
  pointer-events: auto;
  position: relative;
  background: var(--ink);
  color: #fff;
  border: 2.5px solid var(--ink);
  border-radius: 12px;
  padding: 7px 10px;
  font-size: 20px;
  box-shadow: 0 3px 0 #000;
}
.hud-watch {
  pointer-events: auto;
  background: var(--ink);
  color: #fff;
  border: 2.5px solid var(--ink);
  border-radius: 12px;
  padding: 7px 10px;
  font-size: 20px;
  box-shadow: 0 3px 0 #000;
  cursor: pointer;
}
.hud-watch kbd { font-size: 10px; }
.hud-pause {
  pointer-events: auto;
  background: var(--paper);
  color: var(--ink);
  border: 2.5px solid var(--ink);
  border-radius: 12px;
  width: 40px;
  height: 40px;
  font: 800 16px/1 var(--ui);
  box-shadow: 0 3px 0 var(--ink);
  cursor: pointer;
}
.hud-pause:hover { background: var(--gold); }
.hud-pause { display: grid; place-items: center; padding: 0; }
/* the pause icon: two bars in CSS (iOS would draw ⏸ as a grey emoji tile) */
.pz { display: block; width: 0.72em; height: 0.84em; box-sizing: border-box; border-left: 0.26em solid currentColor; border-right: 0.26em solid currentColor; border-radius: 1px; }
.enc-cmds [data-cmd="pause"] { display: inline-grid; place-items: center; }
.enc-cmds [data-cmd="pause"] .pz { font-size: 13px; }
.hud-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  background: var(--red);
  color: #fff;
  font: 800 11px/1 var(--ui);
  border: 2px solid var(--ink);
  border-radius: 999px;
  padding: 3px 6px;
  animation: bump 0.4s ease-out;
}
@keyframes bump { 50% { transform: scale(1.35); } }
.hud-prompt {
  position: absolute;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  background: rgba(43, 29, 42, 0.88);
  color: #fff;
  border-radius: 999px;
  padding: 7px 14px 7px 8px;
  font-weight: 800;
  font-size: 14px;
  white-space: nowrap;
}
.hud-prompt kbd { margin: 0 8px 0 0; background: var(--gold); color: var(--ink); opacity: 1; border-color: var(--ink); }
.hud-help {
  position: absolute;
  left: 14px;
  bottom: 12px;
  color: rgba(255, 248, 235, 0.8);
  font-size: 11px;
  font-weight: 700;
  text-shadow: 0 1px 0 #000;
  animation: fadeOut 1s 25s forwards;
}
@keyframes fadeOut { to { opacity: 0; } }
/* the dialogue box sits over the bottom-left corner: no key hints under it */
#ui:has(.dialog:not(.hidden)) .hud-help { visibility: hidden; }
/* ---- metro: trip pill, card balance, in-car LED board ---- */
.hud-trip {
  background: rgba(30, 38, 52, 0.92);
  color: #fff;
  border: 2.5px solid var(--ink);
  border-radius: 12px;
  padding: 5px 12px 5px 8px;
  display: flex;
  gap: 8px;
  align-items: center;
  max-width: min(460px, 72vw);
  box-shadow: 0 3px 0 var(--ink);
}
.hud-trip-ic { font-size: 16px; }
.hud-trip-t { display: flex; flex-direction: column; line-height: 1.25; }
.hud-trip-t .zh { font: 800 14px/1.3 var(--hz); }
.hud-trip-t small { font-size: 11px; font-weight: 700; opacity: 0.8; }
.hud-card {
  background: #eaf4ff;
  border: 2.5px solid var(--ink);
  border-radius: 999px;
  padding: 7px 12px;
  font-weight: 800;
  box-shadow: 0 3px 0 var(--ink);
  display: flex;
  gap: 6px;
  align-items: center;
}
.hud-card.neg b { color: var(--red); }
.hud-bike {
  pointer-events: auto;
  display: flex; align-items: center; gap: 6px;
  background: var(--paper); color: var(--ink);
  border: 2.5px solid var(--ink); border-radius: 999px;
  padding: 5px 12px; font-size: 18px; line-height: 1;
  box-shadow: 0 3px 0 var(--ink); cursor: pointer;
}
.hud-bike.on { background: #2b9a8d; color: #fff; }
.hud-bike.off { opacity: 0.55; }
.hud-bike kbd { font-size: 10px; }

.hud.riding .hud-tl { display: none; }
.hud-led {
  --line: var(--line2);
  position: absolute;
  top: 12px;
  left: 14px;
  width: min(560px, calc(100vw - 290px));
  background: #0c0f16;
  color: #f4f1e6;
  border: 3px solid var(--ink);
  border-radius: 12px;
  box-shadow: 0 4px 0 var(--ink), inset 0 0 0 2px #262c3a;
  padding: 8px 12px 10px;
  font-weight: 700;
  pointer-events: none;
}
.led-top { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.led-num {
  background: var(--line);
  color: #fff;
  border-radius: 6px;
  padding: 2px 8px;
  font: 900 15px/1.2 var(--ui);
}
.led-toward { font: 800 15px/1.2 var(--hz); }
.led-toward small { font: 700 11px var(--ui); opacity: 0.7; margin-left: 4px; }
.led-ff { margin-left: auto; font-size: 11px; color: #8a93a8; }
.led-ff kbd { color: #c9d1e2; }
.hud-led.ff .led-ff { color: var(--gold); }
.led-main { display: flex; align-items: baseline; gap: 12px; margin-top: 4px; }
.led-phase { color: #ffb347; font: 800 14px/1.1 var(--hz); display: flex; flex-direction: column; min-width: 64px; }
.led-phase small { font: 700 10px var(--ui); opacity: 0.8; }
.led-hz { font: 900 34px/1.1 var(--hz); color: #ffe27a; text-shadow: 0 0 10px rgba(255, 210, 90, 0.35); }
.led-sub { display: flex; flex-direction: column; font-size: 12px; }
.led-py { color: #a8e27a; }
.led-en { opacity: 0.85; }
.led-meta { display: flex; gap: 12px; font-size: 12px; margin-top: 2px; color: #c9d1e2; align-items: center; min-height: 18px; }
.led-meta i {
  font-style: normal;
  background: var(--c);
  color: #fff;
  border-radius: 4px;
  padding: 0 5px;
  margin-left: 3px;
  font-weight: 900;
}
.led-dest { margin-left: auto; }
.led-strip { display: flex; margin-top: 6px; position: relative; }
.led-strip::before { content: ''; position: absolute; left: 10px; right: 10px; top: 5px; height: 4px; background: var(--line); border-radius: 2px; }
.led-stn { flex: 1; display: flex; flex-direction: column; align-items: center; position: relative; min-width: 0; }
.led-stn i { width: 12px; height: 12px; border-radius: 50%; background: #fff; border: 2px solid var(--line); }
.led-stn em { font: 700 11px/1.3 var(--hz); font-style: normal; color: #c9d1e2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.led-stn.cur i { background: #ff5a4f; border-color: #fff; animation: ledBlink 0.9s steps(2) infinite; }
.led-stn.cur em { color: #ffe27a; }
.led-stn.dest em::before { content: '🎯'; }
@keyframes ledBlink { 50% { opacity: 0.35; } }
.hud-led:not(.hidden) ~ .hud-announce { top: 172px; }
@media (max-width: 720px) {
  .hud-led { top: 64px; left: 50%; transform: translateX(-50%); width: 94vw; padding: 6px 8px 8px; }
  .led-hz { font-size: 26px; }
  .led-toward small, .led-ff { display: none; }
  .hud-led:not(.hidden) ~ .hud-announce { top: 210px; }
}

.hud-announce {
  position: absolute;
  top: 76px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(20, 30, 20, 0.9);
  color: #fff;
  border: 3px solid var(--line2);
  border-radius: 12px;
  padding: 10px 20px;
  text-align: center;
  pointer-events: auto;
  animation: dlgIn 0.2s ease-out;
}
.ann-tag { font-size: 11px; font-weight: 800; color: var(--line2); letter-spacing: 0.1em; }
.ann-hz { font: 700 28px/1.3 var(--hz); }
.ann-py { color: #d6f2a8; font-weight: 700; font-size: 13px; }
.ann-en { font-size: 13px; opacity: 0.85; }
.hud-announce .hz-word { border-bottom-color: rgba(255, 255, 255, 0.4); }

.toasts {
  position: absolute;
  top: 70px;
  right: 14px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  z-index: 30;
}
.toast {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: min(380px, 80vw);
  background: var(--paper);
  border: 2.5px solid var(--ink);
  border-radius: 10px;
  box-shadow: 0 3px 0 var(--ink);
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
  animation: toastIn 0.25s cubic-bezier(0.2, 0.9, 0.3, 1.3);
}
.toast b.zh { font-size: 16px; }
.toast .nw { white-space: nowrap; }
.toast.gold { background: #fff3c9; border-color: var(--gold-dk); }
.toast.out { opacity: 0; transform: translateX(20px); transition: all 0.5s; }
.toast-ic { font-size: 18px; }
@keyframes toastIn { from { transform: translateX(40px); } }

.modal-wrap {
  position: absolute;
  inset: 0;
  background: rgba(20, 12, 28, 0.6);
  display: grid;
  place-items: center;
  z-index: 40;
  animation: fadeIn 0.2s;
}
@keyframes fadeIn { from { background-color: transparent; } }
.modal {
  width: min(560px, calc(100vw - 28px));
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: 14px;
  box-shadow: 0 6px 0 var(--ink);
  padding: 22px 24px;
  animation: pop 0.25s ease-out;
}
.modal h2 { margin: 0 0 12px; font: 900 30px/1.2 var(--hz); }
.modal h2 small { display: block; font: 700 14px/1.4 var(--ui); color: var(--ink-soft); margin-top: 4px; }
.modal-body p { font-size: 14px; line-height: 1.5; margin: 10px 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
.sc-stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.sc-stats div { background: #fff; border: 2px solid var(--ink); border-radius: 10px; text-align: center; padding: 8px 4px; }
.sc-stats b { display: block; font-size: 24px; }
.sc-stats span { font-size: 11px; font-weight: 700; color: var(--ink-soft); }
.sc-next { background: #fff3c9; border-radius: 8px; padding: 8px 10px; }
.sc-tip { color: var(--ink-soft); }

/* ---------------------------------------------------------- encounter --- */

.enc {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}
.enc-plate {
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 8px 12px 9px;
  min-width: 250px;
  animation: plateIn 0.5s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
.enc-plate.npc { position: absolute; top: 16px; left: 16px; }
.enc-plate.me { align-self: flex-end; margin: 0 18px 12px 0; animation-name: plateInR; }
@keyframes plateIn { from { transform: translateX(-40px); } }
@keyframes plateInR { from { transform: translateX(40px); } }
.plate-name { display: flex; gap: 10px; align-items: baseline; }
.plate-name .zh { font: 900 20px/1.1 var(--hz); }
.plate-name .role { font-size: 11px; font-weight: 700; color: var(--ink-soft); }
.meter { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: center; margin-top: 6px; }
.meter label { font: 900 9px/1 var(--ui); letter-spacing: 0.08em; background: var(--ink); color: var(--gold); padding: 3px 5px; border-radius: 3px; }
.bar { height: 10px; background: #3a2d3a; border: 2px solid var(--ink); border-radius: 99px; overflow: hidden; min-width: 130px; }
.bar i { display: block; height: 100%; width: 100%; border-radius: 99px; transition: background 0.3s; }
.bar i.ok { background: linear-gradient(#7fd66b, #3f9a4f); }
.bar i.mid { background: linear-gradient(#ffd66b, #d9a12a); }
.bar i.low { background: linear-gradient(#ff8a7a, #c8342e); }
.bar.conf i { background: linear-gradient(#8fd1ff, #3d7fc4); width: 0; }
.meter-num { font-size: 11px; font-weight: 800; }
.plate-wallet { font-size: 12px; font-weight: 800; margin-top: 4px; text-align: right; font-family: var(--hz); }

.enc-panel {
  position: relative;
  background: var(--paper);
  border-top: 4px solid var(--ink);
  box-shadow: 0 -4px 0 rgba(0, 0, 0, 0.25);
  /* % of the full-screen .enc, not vh/vw: those shrink with the UI zoom */
  padding: 14px max(16px, calc((100% - 980px) / 2)) 10px;
  max-height: 66%;
  overflow-y: auto;
  animation: panelIn 0.35s ease-out;
}
@keyframes panelIn { from { transform: translateY(24px); } }
.enc-line { position: relative; background: #fff; border: 2.5px solid var(--ink); border-radius: 10px; padding: 14px 16px 10px; }
.enc-speaker {
  position: absolute;
  top: -13px;
  left: 12px;
  background: var(--red);
  color: #fff;
  font: 800 12px/1 var(--hz);
  padding: 5px 9px 4px;
  border: 2px solid var(--ink);
  border-radius: 6px;
}
.enc-hz { font: 600 clamp(26px, 3.8vw, 38px)/1.3 var(--hz); letter-spacing: 0.05em; min-height: 1.3em; }
.enc-py { color: var(--red-dk); font-weight: 800; font-size: 15px; margin-top: 4px; }
.enc-en { color: var(--ink-soft); font-size: 14px; margin-top: 2px; }
.listen-ph { color: var(--ink-soft); font-size: 0.8em; }
.listen-ph small { font: 600 12px var(--ui); margin-left: 8px; }
.enc-me {
  display: flex;
  align-items: baseline;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 8px;
}
.enc-me-tag { background: var(--blue); color: #fff; font: 800 12px/1 var(--hz); padding: 5px 8px 4px; border-radius: 6px; border: 2px solid var(--ink); }
.enc-me-hz { font: 700 24px/1.2 var(--hz); background: #dcebfa; border: 2px solid var(--ink); border-radius: 10px 10px 2px 10px; padding: 4px 12px; }
.enc-me-py { color: #25598f; font-weight: 700; font-size: 13px; }
.enc-task { font-size: 14px; font-weight: 700; margin: 10px 2px 8px; color: var(--ink-soft); line-height: 1.4; }
.enc-task::before { content: "🎯 "; }
.enc-task:empty { display: none; }

/* Conversation tools: a small strip on the top edge of the speech box,
   opposite the speaker's name tag (keyboard shortcuts live in the tooltips). */
.enc-cmds { position: absolute; top: -14px; right: 10px; display: flex; gap: 4px; }
.enc-cmds button {
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 6px;
  padding: 3px 8px 2px;
  min-width: 30px;
  font: 800 12px/1.25 var(--ui);
  color: var(--ink);
  cursor: pointer;
}
.enc-cmds button:hover { background: var(--gold); }
.enc-cmds button[data-cmd="leave"] { margin-left: 6px; color: var(--ink-soft); }
.enc-cmds kbd { display: none; }
.enc.used-hint .enc-cmds button[data-cmd="hint"] { background: #fff3c9; }
.is-result .enc-line, .is-result .enc-me, .is-result .enc-task, .is-result .enc-step, .is-result .enc-cmds { display: none; }

/* steps */
.step-choice { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 8px; }
.opt {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: #fff;
  border: 2.5px solid var(--ink);
  border-radius: 10px;
  box-shadow: 0 3px 0 var(--ink);
  /* side padding keeps the text clear of the number badge and the 🔊 button */
  padding: 10px 24px 8px;
  text-align: center;
}
.opt:hover:not(:disabled) { background: #fff7de; transform: translateY(-1px); }
.opt kbd { position: absolute; top: 6px; left: 6px; margin: 0; }
.o-hz { font: 700 26px/1.2 var(--hz); }
.o-py { font-size: 13px; font-weight: 700; color: var(--red-dk); }
.o-say { position: absolute; top: 4px; right: 6px; font-size: 14px; opacity: 0.6; }
.o-say:hover { opacity: 1; }
.opt.right { background: #d7f0da; border-color: var(--green); animation: pulse 0.5s; }
.opt.wrong { background: #ffe0dc; border-color: var(--red); animation: shake 0.4s; opacity: 0.7; }
.opt.eliminated { opacity: 0.3; text-decoration: line-through; }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
@keyframes pulse { 50% { transform: scale(1.05); } }

.build-answer {
  min-height: 70px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  background: var(--paper-2);
  border: 2.5px dashed var(--ink-soft);
  border-radius: 10px;
  padding: 8px;
}
.build-ph { color: var(--ink-soft); font-size: 13px; font-weight: 600; padding: 0 6px; }
.build-punct { font: 700 28px/1 var(--hz); }
.build-bank { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; justify-content: center; }
.tile {
  position: relative;
  min-width: 58px;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  background: #fff;
  border: 2.5px solid var(--ink);
  border-radius: 8px;
  box-shadow: 0 3px 0 var(--ink);
  padding: 6px 10px 5px;
  transition: transform 0.08s;
}
.tile:hover { transform: translateY(-2px); }
.tile kbd { position: absolute; top: -9px; left: -7px; margin: 0; background: var(--paper); opacity: 1; font-size: 9px; }
.t-hz { font: 700 26px/1.1 var(--hz); }
.t-py { font-size: 12px; font-weight: 700; color: var(--red-dk); }
.tile.ghost { visibility: hidden; }
.tile.good { background: #d7f0da; border-color: var(--green); }
.tile.bad { background: #ffe0dc; border-color: var(--red); animation: shake 0.4s; }
.tile.hinted { animation: glow 0.9s ease-in-out infinite; background: #fff3c9; }
@keyframes glow { 50% { box-shadow: 0 3px 0 var(--ink), 0 0 0 6px rgba(242, 193, 78, 0.7); } }
.build-actions { display: flex; gap: 8px; justify-content: flex-end; }
.build-actions .btn { padding: 7px 12px; font-size: 14px; }

.step-select .l2-note {
  display: inline-flex;
  gap: 10px;
  align-items: baseline;
  background: #eef9e0;
  border: 2.5px solid var(--line2-dk);
  border-radius: 12px 12px 12px 2px;
  padding: 6px 12px;
  margin-bottom: 10px;
}
.l2-note.hinted { animation: glow 0.9s ease-in-out infinite; }
.l2-from { font-weight: 800; font-size: 13px; }
.l2-msg { font: 700 24px/1.2 var(--hz); }
.l2-py { color: var(--line2-dk); font-weight: 700; font-size: 13px; }
.l2-track { overflow-x: auto; padding: 16px 6px 4px; }
.l2-inner {
  position: relative;
  display: flex;
  justify-content: space-between;
  gap: 4px;
  padding-left: 30px;
  min-width: max-content;
}
.l2-line {
  position: absolute;
  left: 30px;
  right: 30px;
  top: 7px;
  height: 10px;
  background: var(--line2);
  border: 2px solid var(--line2-dk);
  border-radius: 99px;
}
.l2-line span {
  position: absolute;
  left: -30px;
  top: 50%;
  transform: translateY(-50%);
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--line2);
  border: 2.5px solid var(--ink);
  color: #fff;
  font-weight: 900;
  display: grid;
  place-items: center;
}
.l2-stn {
  position: relative;
  flex: 1 0 auto;
  min-width: 84px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  background: none;
  border: none;
  padding: 0 2px 6px;
  border-radius: 10px;
}
.l2-stn kbd { position: absolute; top: -14px; margin: 0; font-size: 9px; }
.l2-dot { width: 22px; height: 22px; border-radius: 50%; background: #fff; border: 3px solid var(--ink); margin-bottom: 4px; }
.l2-hz { font: 700 20px/1.1 var(--hz); white-space: nowrap; }
.l2-py { font-size: 11px; font-weight: 700; color: var(--ink-soft); white-space: nowrap; }
.l2-here { font: 800 10px/1 var(--hz); background: var(--red); color: #fff; padding: 3px 5px; border-radius: 4px; }
.l2-stn.here .l2-dot { background: var(--red); }
.l2-stn:hover .l2-dot { background: var(--gold); }
.l2-stn:hover { background: rgba(242, 193, 78, 0.2); }
.l2-stn.right .l2-dot { background: var(--green); }
.l2-stn.right { background: #d7f0da; }
.l2-stn.wrong { animation: shake 0.4s; background: #ffe0dc; }
.l2-stn.hinted .l2-dot { animation: glow 0.9s infinite; background: var(--gold); }

.step-pay .pay-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.pay-wallet { font: 800 14px var(--hz); background: #fff; border: 2px solid var(--ink); border-radius: 8px; padding: 6px 10px; }
.pay-coins { display: flex; flex-wrap: wrap; gap: 10px; }
.money {
  position: relative;
  border: 2.5px solid var(--ink);
  box-shadow: 0 3px 0 var(--ink);
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-weight: 900;
}
.money kbd { position: absolute; top: -9px; left: -6px; margin: 0; background: var(--paper); color: var(--ink); opacity: 1; font-size: 9px; }
.money small { font: 700 11px var(--hz); }
.money.coin { width: 62px; height: 62px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fbfbfb, #c9ccd2 60%, #9aa0aa); }
.money.note { width: 86px; height: 52px; border-radius: 6px; color: #fff; }
.money.note.five { background: linear-gradient(135deg, #9a6ac8, #6a3f9a); }
.money.note.ten { background: linear-gradient(135deg, #4a6fb0, #2a3f7a); }
.money.small { transform: scale(0.72); margin: -8px -6px; }
.pay-tray {
  flex: 1;
  min-height: 60px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  background: var(--paper-2);
  border: 2.5px dashed var(--ink-soft);
  border-radius: 10px;
  padding: 6px 10px;
}
.pay-total { font: 900 22px var(--ui); min-width: 120px; text-align: right; }
.pay-total .zh { font-size: 18px; color: var(--red-dk); }
.pay-hint { background: #fff3c9; border-radius: 8px; padding: 6px 10px; font-size: 13px; font-weight: 700; margin-bottom: 8px; }
.step-none { display: flex; justify-content: flex-end; }

/* results */
.enc-result { padding: 4px 0 6px; }
.res-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.res-head h2 { margin: 0; font: 900 34px/1.1 var(--hz); }
.res-head h2 small { display: block; font: 700 14px/1.4 var(--ui); color: var(--ink-soft); }
.stars { font-size: 40px; letter-spacing: 4px; color: #d9d1c0; text-shadow: 0 3px 0 var(--ink); }
.stars span { display: inline-block; }
.stars .on { color: var(--gold); animation: starIn 0.5s; }
.stars .on:nth-child(2) { animation-delay: 0.2s; }
.stars .on:nth-child(3) { animation-delay: 0.4s; }
@keyframes starIn { from { transform: scale(0.4) rotate(-90deg); } }
.res-stats { font-size: 13px; font-weight: 600; margin: 8px 0 10px; color: var(--ink-soft); }
.res-stats .clean { color: var(--green); font-weight: 800; }
.res-words { display: flex; flex-wrap: wrap; gap: 8px; }
.res-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #fff;
  border: 2px solid var(--ink);
  border-radius: 10px;
  padding: 5px 9px;
}
.res-chip .hz { font: 700 20px/1 var(--hz); }
.res-chip .py { font-size: 12px; font-weight: 700; color: var(--red-dk); }
.res-chip em { font-style: normal; font-weight: 900; font-size: 12px; color: var(--gold-dk); }
.res-chip.st-mastered { border-color: var(--green); background: #effaf0; }
.res-prog { font-size: 11px; font-weight: 800; color: var(--ink-soft); }
.res-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 14px; }

/* ------------------------------------------------------------- phone --- */

.phone-wrap {
  position: absolute;
  inset: 0;
  background: rgba(20, 12, 28, 0.45);
  display: grid;
  place-items: center;
  z-index: 20;
  animation: fadeIn 0.15s;
}
.phone {
  position: relative;
  width: min(390px, calc(100% - 24px));
  height: min(760px, calc(100% - 24px));
  background: #f7f3ea;
  border: 10px solid #1c1622;
  border-radius: 44px;
  box-shadow: 0 0 0 3px #4a3f55, 0 18px 40px rgba(0, 0, 0, 0.45);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: phoneIn 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.15);
}
@keyframes phoneIn { from { transform: translateY(40px) rotate(2deg); } }
.phone-status { display: flex; justify-content: space-between; align-items: center; padding: 8px 22px 4px; font-size: 12px; font-weight: 800; }
.ph-notch { width: 90px; height: 22px; background: #1c1622; border-radius: 0 0 14px 14px; margin-top: -8px; }
.phone-body { flex: 1; overflow-y: auto; padding: 6px 16px 14px; user-select: text; -webkit-user-select: text; }
.phone-tabs { display: grid; grid-template-columns: repeat(6, 1fr); border-top: 2px solid #e2d8c6; background: #fff; padding-bottom: 14px; }
.phone-tabs button { border: none; background: none; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 4px; font-size: 11px; font-weight: 700; color: #8a7d88; }
.phone-tabs button .zh { font-size: 19px; font-weight: 800; width: 34px; height: 30px; display: grid; place-items: center; border-radius: 9px; }
.phone-tabs button.on { color: var(--red-dk); }
.phone-tabs button.on .zh { background: var(--red); color: #fff; }
.phone-home { position: absolute; bottom: 5px; left: 50%; transform: translateX(-50%); width: 110px; height: 5px; background: #1c1622; border-radius: 9px; cursor: pointer; }
.app-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 6px 0 10px; }
.app-head h3 { margin: 0; font-size: 20px; }
.app-head h3 .zh { color: var(--red); margin-right: 4px; }
.chip {
  border: 2px solid #d8ccb8;
  background: #fff;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 800;
  color: var(--ink-soft);
}
.chip.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.chip.st-discovered.on { background: var(--st-discovered); border-color: var(--st-discovered); }
.chip.st-practiced.on { background: var(--st-practiced); border-color: var(--st-practiced); }
.chip.st-mastered.on { background: var(--st-mastered); border-color: var(--st-mastered); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.lex-sum { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 10px; }
.lex-sum div { background: #fff; border-radius: 12px; padding: 8px; text-align: center; font-size: 11px; font-weight: 700; border-bottom: 4px solid; }
.lex-sum b { display: block; font-size: 22px; }
.lex-sum .st-discovered { border-color: var(--st-discovered); }
.lex-sum .st-practiced { border-color: var(--st-practiced); }
.lex-sum .st-mastered { border-color: var(--st-mastered); }
.lv-list { display: grid; gap: 4px; margin-bottom: 10px; }
.lv { display: grid; grid-template-columns: 56px 1fr 52px; gap: 8px; align-items: center; font-size: 11px; font-weight: 800; }
.lv small { text-align: right; color: var(--ink-soft); }
.lv-bar { height: 8px; background: #e6dfd2; border-radius: 99px; overflow: hidden; }
.lv-bar i { display: block; height: 100%; background: var(--red); border-radius: 99px; }
.lex-search {
  width: 100%;
  border: 2px solid #d8ccb8;
  border-radius: 12px;
  padding: 9px 12px;
  font: 600 14px var(--ui);
  margin-bottom: 8px;
  background: #fff;
}
.lex-list { display: grid; gap: 6px; }
.lex-row {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr auto 28px;
  align-items: center;
  gap: 10px;
  text-align: left;
  background: #fff;
  border: 2px solid transparent;
  border-radius: 12px;
  padding: 8px 10px;
}
.lex-row:hover { border-color: #d8ccb8; }
.lr-hz { font: 700 24px/1 var(--hz); min-width: 44px; }
.lr-mid { display: flex; flex-direction: column; min-width: 0; }
.lr-py { font-size: 13px; font-weight: 800; color: var(--red-dk); }
.lr-en { font-size: 12px; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lr-side { display: flex; align-items: center; gap: 6px; }
.lr-say { font-size: 16px; text-align: center; }
.dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
.dot.st-discovered { background: var(--st-discovered); }
.dot.st-practiced { background: var(--st-practiced); }
.dot.st-mastered { background: var(--st-mastered); box-shadow: 0 0 0 2px #d7f0da; }
.lex-hidden, .empty { text-align: center; font-size: 12px; color: var(--ink-soft); padding: 14px 0; font-weight: 600; }
.wd { text-align: center; background: #fff; border-radius: 16px; padding: 18px 12px; }
.wd-hz { font: 700 64px/1.1 var(--hz); }
.wd-py { font-size: 20px; font-weight: 800; color: var(--red-dk); }
.wd-en { font-size: 15px; margin: 4px 0 12px; }
.wd-track { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 12px 0 6px; }
.wd-step { text-align: center; font-size: 11px; font-weight: 800; color: #b3a99c; }
.wd-step i { display: block; height: 8px; border-radius: 99px; background: #e6dfd2; margin-bottom: 4px; }
.wd-step.on.st-discovered { color: var(--st-discovered); }
.wd-step.on.st-discovered i { background: var(--st-discovered); }
.wd-step.on.st-practiced { color: var(--st-practiced); }
.wd-step.on.st-practiced i { background: var(--st-practiced); }
.wd-step.on.st-mastered { color: var(--st-mastered); }
.wd-step.on.st-mastered i { background: var(--st-mastered); }
.wd-stats { font-size: 12px; text-align: center; color: var(--ink-soft); }
.wd-how { font-size: 13px; text-align: center; }
.wd-ex { position: relative; background: #fff; border-radius: 12px; padding: 10px 12px; margin-top: 10px; }
.wd-ex-hz { font: 600 20px/1.3 var(--hz); }
.wd-ex .py { font-size: 12px; font-weight: 700; color: var(--red-dk); }
.wd-ex-en { font-size: 12px; color: var(--ink-soft); }
.wd-ex .chip { position: absolute; top: 8px; right: 8px; }
.chat { display: flex; flex-direction: column; gap: 10px; }
.bubble {
  position: relative;
  align-self: flex-start;
  max-width: 88%;
  background: #fff;
  border-radius: 16px 16px 16px 4px;
  padding: 10px 40px 10px 14px;
  box-shadow: 0 2px 0 #e2d8c6;
  animation: pop 0.2s;
}
.b-hz { font: 700 22px/1.3 var(--hz); }
.bubble .py { font-size: 12px; font-weight: 700; color: var(--red-dk); }
.b-en { font-size: 12px; color: var(--ink-soft); }
.b-say { position: absolute; top: 8px; right: 8px; border: none; background: none; font-size: 16px; }
.quest { background: #fff; border-radius: 14px; padding: 12px 14px; margin-bottom: 10px; }
.quest h4 { margin: 0 0 6px; font-size: 15px; }
.quest h4 small { color: var(--ink-soft); font-weight: 600; }
.quest ol { margin: 0; padding-left: 20px; font-size: 13px; line-height: 1.6; }
.quest li.ok { text-decoration: line-through; color: #9a8f86; }
.quest li.ok::marker { content: "✓ "; color: var(--green); }
.quest.done { opacity: 0.75; }
.quest-stats { font-size: 12px; color: var(--ink-soft); display: grid; gap: 4px; }
.quest-level { margin-bottom: 14px; }
.quest-level > h4 { margin: 4px 2px 8px; font-size: 13px; letter-spacing: 0.04em; color: var(--red-dk); }
.quest-level > h4 small { color: var(--ink-soft); font-weight: 700; margin-left: 4px; }
.quest-level.locked > h4 { color: #9a8f86; }
.quest.locked { opacity: 0.5; padding: 8px 14px; }
.quest.locked h4 { margin: 0; }
.contacts { margin-bottom: 10px; }
.contacts .chip { position: relative; }
.contacts .dot { position: absolute; top: -3px; right: -3px; width: 9px; height: 9px; border-radius: 50%; background: var(--red); border: 2px solid #fff; }
.chat-actions { display: grid; gap: 8px; margin-top: 12px; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: #fff; border-radius: 12px; padding: 10px 12px; margin-bottom: 6px; font-size: 14px; font-weight: 700; }
.set-row.col { flex-direction: column; align-items: stretch; }
.set-row small { color: var(--ink-soft); float: right; }
.set-row input[type="range"] { width: 100%; accent-color: var(--red); }
.set-row input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--red); }
.set-voice { font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 10px 2px; }
.set-note { font-size: 12px; color: var(--red-dk); background: #ffe8e2; border-radius: 10px; padding: 8px 10px; }
.set-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.set-actions .btn { font-size: 13px; padding: 7px 10px; }

/* ------------------------------------------------------------ touch --- */

#ui > .touch { position: absolute; inset: 0; pointer-events: none; z-index: 10; }
.touch > * { pointer-events: auto; }
/* Floating joystick: rests bottom-left, jumps to wherever the thumb lands. */
.joy-zone {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 46%;
  height: 58%;
  touch-action: none;
}
.joy {
  position: absolute;
  /* left/top = the centre (JS moves it under the thumb) */
  left: calc(86px + env(safe-area-inset-left));
  top: calc(100% - 88px - env(safe-area-inset-bottom));
  width: 112px;
  height: 112px;
  margin: -56px 0 0 -56px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(251, 241, 220, 0.16) 0 52%, rgba(251, 241, 220, 0.3) 53% 100%);
  border: 2.5px solid rgba(43, 29, 42, 0.55);
  opacity: 0.7;
  transition: opacity 0.15s;
  pointer-events: none;
}
.joy.active { opacity: 1; }
.joy-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 52px;
  height: 52px;
  margin: -26px 0 0 -26px;
  border-radius: 50%;
  background: rgba(251, 241, 220, 0.92);
  border: 3px solid var(--ink);
  box-shadow: 0 3px 0 var(--ink);
}
.joy.active .joy-knob { background: var(--gold); }
.abtns {
  position: absolute;
  right: calc(18px + env(safe-area-inset-right));
  bottom: calc(26px + env(safe-area-inset-bottom));
  display: flex;
  gap: 14px;
  align-items: flex-end;
}
.abtns button {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  border: 3px solid var(--ink);
  background: rgba(251, 241, 220, 0.88);
  box-shadow: 0 4px 0 var(--ink);
  font: 900 24px/1 var(--ui);
  color: var(--ink);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  touch-action: none;
  -webkit-touch-callout: none;
}
.abtns button small { font-size: 10px; font-weight: 800; margin-top: 2px; opacity: 0.75; }
.abtns button small i { font-style: normal; }
.abtns .a { background: rgba(226, 35, 26, 0.9); color: #fff; margin-bottom: 26px; }
.abtns .b { width: 56px; height: 56px; font-size: 19px; }
.abtns button.on { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); background: var(--gold); color: var(--ink); }
.lbl-ff, .hud.riding ~ .touch .lbl-run { display: none; }
.hud.riding ~ .touch .lbl-ff { display: inline; }

/* Sideways only on touch screens. */
.rotate-hint { display: none; }
@media (orientation: portrait) {
  body.touch-mode .rotate-hint {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: #17131d;
    color: var(--paper);
    text-align: center;
    padding: 24px;
  }
}
.rh-phone { font-size: 64px; animation: rh-turn 2.4s ease-in-out infinite; }
.rotate-hint .zh { font: 900 30px/1.2 var(--hz); }
.rotate-hint span { font-size: 15px; font-weight: 700; opacity: 0.8; }
@keyframes rh-turn { 0%, 25% { transform: rotate(0); } 55%, 100% { transform: rotate(-90deg); } }

/* Touch mode: key hints make no sense — show button names where they matter. */
body.touch-mode kbd { display: none; }
body.touch-mode kbd[data-touch] { display: inline-block; font-size: 0; }
body.touch-mode kbd[data-touch]::after { content: attr(data-touch); font-size: 12px; }
body.touch-mode .hud-help { display: none; }
/* thumb-sized tablet and pause buttons (44 real px, whatever the UI size) */
body.touch-mode .hud-pause { width: calc(44px / var(--uiz, 1)); height: calc(44px / var(--uiz, 1)); border-radius: calc(13px / var(--uiz, 1)); font-size: calc(19px / var(--uiz, 1)); }
body.touch-mode :is(.hud-phone, .hud-watch) { min-height: calc(44px / var(--uiz, 1)); font-size: calc(22px / var(--uiz, 1)); }
body.touch-mode .enc-cmds button { min-height: calc(30px / var(--uiz, 1)); min-width: calc(34px / var(--uiz, 1)); }
body.touch-mode .enc-cmds [data-cmd="pause"] { min-width: calc(40px / var(--uiz, 1)); }
/* toasts start below that row of buttons */
body.touch-mode .toasts { top: calc(22px + 44px / var(--uiz, 1) + env(safe-area-inset-top) / var(--uiz, 1)); }
body.touch-mode .enc-cmds [data-cmd="pause"] .pz { font-size: calc(15px / var(--uiz, 1)); }
body.touch-mode .hud-prompt { pointer-events: auto; bottom: calc(26px + env(safe-area-inset-bottom) / var(--uiz, 1)); }
body.touch-mode .hud-led .led-ff { display: inline; }
/* Notches and home indicators (env() is 0 on desktop). */
.hud-tl { top: calc(14px + env(safe-area-inset-top) / var(--uiz, 1)); left: calc(14px + env(safe-area-inset-left) / var(--uiz, 1)); }
.hud-tr { top: calc(14px + env(safe-area-inset-top) / var(--uiz, 1)); right: calc(14px + env(safe-area-inset-right) / var(--uiz, 1)); }

/* -------------------------------------------------------- responsive --- */

@media (max-width: 720px) {
  .hud-help { display: none; }
  .enc-plate { min-width: 0; padding: 6px 9px; }
  .enc-plate.npc { top: 10px; left: 10px; }
  .bar { min-width: 90px; }
  .plate-name .role { display: none; }
  .enc-panel { max-height: 70%; padding: 10px 12px 8px; }
  .tile kbd, .opt kbd, .money kbd, .l2-stn kbd { display: none; }
  .sc-stats { grid-template-columns: repeat(3, 1fr); }
  .hud-obj { font-size: 12px; }
  .l2-hz { font-size: 16px; }
  .l2-stn { min-width: 70px; }
  .enc-plate.me { margin: 0 10px 8px 0; }
}
@media (max-height: 560px) {
  .enc-panel { padding-top: 12px; }
  .enc-line { padding: 12px 12px 7px; }
  .enc-py { font-size: 13px; margin-top: 2px; }
  .enc-task { margin: 7px 2px 5px; font-size: 13px; }
  .step-select .l2-note { padding: 3px 10px; margin-bottom: 4px; }
  .l2-msg { font-size: 18px; }
  .l2-track { padding-top: 10px; }
  .enc-hz { font-size: 24px; }
  .t-hz, .o-hz { font-size: 20px; }
  .build-answer { min-height: 52px; }
}

/* ------------------------------------------------------- stage 2 steps --- */

.step-mappick { display: flex; justify-content: center; }
.mp-map {
  display: grid;
  gap: 3px;
  width: min(100%, 560px);
  grid-auto-rows: 48px;
  background: #cfe3b8;
  border: 2.5px solid var(--ink);
  border-radius: 12px;
  padding: 6px;
}
.mp-cell { border-radius: 6px; display: flex; flex-direction: column; align-items: center; justify-content: center; position: relative; font-weight: 800; }
.mp-green { background: #b9d89c; }
.mp-road { background: #8f8474; color: var(--gold); font-size: 22px; }
.mp-road.h { background: linear-gradient(#8f8474 45%, #e9e4d6 45%, #e9e4d6 55%, #8f8474 55%); }
.mp-road.v { background: linear-gradient(90deg, #8f8474 45%, #e9e4d6 45%, #e9e4d6 55%, #8f8474 55%); }
.mp-you { color: #fff; }
.mp-me { background: var(--blue); border: 2px solid var(--ink); border-radius: 50%; width: 26px; height: 26px; display: grid; place-items: center; font: 800 13px var(--hz); }
.mp-arrow { font-size: 14px; line-height: 1; color: var(--gold); text-shadow: 0 1px 0 var(--ink); }
.mp-landmark { background: #fff7de; border: 2px solid var(--ink); display: grid; grid-template-columns: auto auto; column-gap: 6px; align-content: center; justify-content: center; }
.mp-landmark .mp-ic { grid-row: span 2; align-self: center; font-size: 20px; }
.mp-landmark .mp-hz { font: 700 16px/1.1 var(--hz); }
.mp-landmark .mp-py { font-size: 10px; line-height: 1.2; color: var(--ink-soft); }
.mp-ic { font-size: 16px; line-height: 1.1; }
.mp-cand { background: #fff; border: 2.5px dashed var(--ink-soft); padding: 0; }
.mp-cand:hover { background: #fff3c9; border-style: solid; }
.mp-cand kbd { position: absolute; top: 2px; left: 3px; margin: 0; font-size: 8px; line-height: 1; padding: 1px 3px; }
.mp-q { font: 900 16px/1 var(--hz); color: var(--ink-soft); }
.mp-cand.right { background: #d7f0da; border: 2.5px solid var(--green); }
.mp-cand.right .mp-q { color: var(--green); font-size: 13px; }
.mp-cand.wrong { background: #ffe0dc; border-color: var(--red); animation: shake 0.4s; }
.mp-landmark.hinted { animation: glow 0.9s ease-in-out infinite; background: #fff3c9; }
.show-route .mp-road.x { color: var(--gold); text-shadow: 0 2px 0 var(--ink); }

.step-menu { display: grid; gap: 8px; }
.menu-card {
  background: #fffaf0;
  border: 2.5px solid var(--ink);
  border-radius: 10px;
  padding: 6px 10px 8px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 2px 14px;
  box-shadow: 0 3px 0 var(--ink);
}
.menu-head { grid-column: 1 / -1; display: flex; gap: 8px; align-items: baseline; border-bottom: 2px solid #b3261e; padding-bottom: 4px; margin-bottom: 2px; }
.menu-head .zh { font: 900 22px/1 var(--hz); color: #b3261e; }
.menu-head small { font-weight: 700; color: var(--ink-soft); }
.menu-row { display: grid; grid-template-columns: auto 1fr auto auto; grid-template-rows: auto auto; align-items: center; column-gap: 8px; padding: 4px 4px; border-radius: 8px; }
.menu-row kbd { grid-row: span 2; margin: 0; }
.m-hz { font: 700 22px/1.1 var(--hz); }
.m-py { grid-column: 2; grid-row: 2; font-size: 11px; font-weight: 700; color: var(--red-dk); }
.m-price { grid-column: 3; grid-row: span 2; font-weight: 900; }
.m-price small { font-weight: 600; opacity: 0.7; margin-left: 1px; }
.m-step { grid-column: 4; grid-row: span 2; display: flex; align-items: center; gap: 4px; }
.m-step button { width: 28px; height: 28px; border: 2px solid var(--ink); border-radius: 8px; background: #fff; font-weight: 900; }
.m-step b { min-width: 16px; text-align: center; }
.menu-row.on { background: #fff3c9; }
.menu-row.hinted { box-shadow: inset 0 0 0 2px var(--gold); }
.m-want { grid-column: 3; font-style: normal; font-size: 11px; font-weight: 900; color: var(--gold-dk); }
.menu-foot { display: flex; gap: 8px; justify-content: flex-end; align-items: center; }
.menu-total { margin-right: auto; font: 700 18px var(--hz); }

.step-shoot { display: grid; gap: 10px; }
.shoot-meter {
  position: relative;
  height: 40px;
  background: linear-gradient(90deg, #3f6f73, #467a7e);
  border: 2.5px solid var(--ink);
  border-radius: 999px;
  overflow: hidden;
}
.shoot-zone { position: absolute; top: 0; bottom: 0; background: rgba(140, 198, 62, 0.85); box-shadow: inset 0 0 0 2px #d6f2a8; }
.shoot-cursor { position: absolute; top: 50%; transform: translate(-50%, -50%); font-size: 26px; line-height: 1; filter: drop-shadow(0 2px 0 rgba(0, 0, 0, 0.35)); }
.shoot-row { display: flex; align-items: center; gap: 12px; }
.shoot-shots { display: flex; gap: 6px; align-items: center; font-weight: 900; }
.shoot-shots .made { color: var(--orange, #ec8b32); }
.shoot-shots .miss { color: var(--red); }
.shoot-shots small { margin-left: 4px; color: var(--ink-soft); }
.shoot-msg { flex: 1; font: 800 22px var(--hz); color: var(--red-dk); }
.shoot-msg.pop { animation: pulse 0.4s; }

/* ------------------------------------------------------------ day card --- */

.day-card {
  position: absolute;
  inset: 0;
  z-index: 60;
  background: #17131d;
  display: grid;
  place-items: center;
  text-align: center;
  color: #fff5e6;
  transition: opacity 0.5s;
}
.day-card.out { opacity: 0; }
.dc-inner { animation: pop 0.6s ease-out; }
.dc-title { font: 900 clamp(48px, 9vw, 96px)/1 var(--hz); color: #ffe2a8; text-shadow: 0 5px 0 #7a2a55; letter-spacing: 0.08em; }
.dc-sub { font-size: 18px; font-weight: 700; margin-top: 16px; opacity: 0.85; }
.dc-stage { font-size: 13px; margin-top: 10px; opacity: 0.6; letter-spacing: 0.04em; }
.sc-levels { font-size: 13px; color: var(--ink-soft); text-align: center; margin: 8px 0 0; }

@media (max-width: 720px) {
  .mp-map { grid-auto-rows: 40px; gap: 2px; }
  .mp-landmark .mp-hz { font-size: 13px; }
  .mp-landmark .mp-py { font-size: 9px; line-height: 1; }
  .mp-ic { font-size: 13px; }
  .menu-card { grid-template-columns: 1fr; }
  .menu-row { padding: 1px 2px; }
  .m-hz { font-size: 18px; }
  .m-step button { width: 26px; height: 26px; }
}
@media (max-height: 560px) {
  /* directions map on short screens: shorter rows, landmark icon beside its name */
  .mp-map { grid-auto-rows: 34px; gap: 2px; }
  .mp-landmark { column-gap: 5px; }
  .mp-landmark .mp-ic { font-size: 15px; }
  .mp-landmark .mp-hz { font-size: 13px; }
  .mp-landmark .mp-py { font-size: 9px; line-height: 1.1; }
  .mp-cand .mp-ic { font-size: 12px; line-height: 1; }
  .mp-q { font-size: 13px; }
}

/* ------------------------------------------------------- stage 3 steps --- */

.step-route { display: flex; justify-content: center; }
.rt-map {
  position: relative;
  width: min(100%, 640px);
  height: 250px;
  background: #f7f3ea;
  border: 2.5px solid var(--ink);
  border-radius: 12px;
  margin-bottom: 4px;
}
.rt-line { position: absolute; border: 2px solid var(--ink); border-radius: 99px; }
.rt-line.h { height: 10px; transform: translateY(-50%); }
.rt-line.v { width: 10px; transform: translateX(-50%); }
.rt-badge { position: absolute; transform: translateX(-50%); color: #fff; font: 900 11px/1 var(--hz); padding: 4px 7px; border-radius: 6px; border: 2px solid var(--ink); white-space: nowrap; }
.rt-stn { position: absolute; transform: translate(-50%, -50%); background: none; border: none; padding: 0; z-index: 1; }
.rt-dot { display: block; width: 18px; height: 18px; border-radius: 50%; background: #fff; border: 3px solid var(--ink); }
.rt-stn.cross .rt-dot { width: 24px; height: 24px; border-width: 4px; box-shadow: 0 0 0 3px #b8a0d0, 0 0 0 5px var(--ink); }
.rt-label { position: absolute; top: 20px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; white-space: nowrap; pointer-events: none; }
.rt-stn.branch .rt-label { top: 50%; left: 24px; transform: translateY(-50%); align-items: flex-start; }
.rt-stn.cross .rt-label { top: auto; bottom: 18px; left: auto; right: 22px; transform: none; align-items: flex-end; }
.rt-badge.left { transform: translate(calc(-100% - 16px), -50%); }
.rt-label kbd { margin: 0 0 2px; font-size: 8px; }
.rt-hz { font: 700 15px/1.1 var(--hz); }
.rt-py { font-size: 10px; font-weight: 700; color: var(--ink-soft); }
.rt-tag { font: 800 10px/1 var(--hz); background: var(--red); color: #fff; padding: 3px 5px; border-radius: 4px; margin-top: 2px; }
.rt-tag.goal { background: var(--gold); color: var(--ink); }
.rt-stn:hover .rt-dot { background: var(--gold); }
.rt-stn.here .rt-dot { background: var(--red); }
.rt-stn.goal .rt-dot { background: #fff3c9; }
.rt-stn.right .rt-dot { background: var(--green); }
.rt-stn.wrong { animation: shake 0.4s; }
.rt-stn.wrong .rt-dot { background: #ffe0dc; border-color: var(--red); }
.rt-stn.hinted .rt-dot { animation: glow 0.9s ease-in-out infinite; background: var(--gold); }

.money.note.twenty { background: linear-gradient(135deg, #b07a4a, #7a4f2a); }
.money.note.fifty { background: linear-gradient(135deg, #4fa06a, #2a6a44); }
.money.note.hundred { background: linear-gradient(135deg, #e0505a, #9a2030); }
.step-choice .l2-note { grid-column: 1 / -1; justify-self: start; }
.step-shoot.photo .shoot-meter { background: linear-gradient(90deg, #d8d1c1, #e2b34c 50%, #d8d1c1); }
.step-shoot.photo .shoot-zone { background: rgba(255, 255, 255, 0.55); box-shadow: inset 0 0 0 2px var(--ink); display: grid; place-items: center; font-size: 18px; }

/* ------------------------------------------------------------- trainer --- */

.tab-badge {
  position: absolute;
  top: 2px;
  margin-left: 22px;
  background: var(--red);
  color: #fff;
  font: 800 9px/1 var(--ui);
  font-style: normal;
  padding: 3px 5px;
  border-radius: 99px;
  border: 1.5px solid #fff;
}
.phone-tabs button { position: relative; }
.tr-streak { font-weight: 900; font-size: 13px; }
.tr-sum .tr-due { border-color: var(--red); }
.tr-sum .tr-due b { color: var(--red); }
.tr-modes { display: grid; gap: 8px; margin: 6px 0 10px; }
.tr-mode {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  align-items: center;
  gap: 10px;
  text-align: left;
  background: #fff;
  border: 2px solid #e2d8c6;
  border-radius: 14px;
  padding: 10px 12px;
  box-shadow: 0 3px 0 #e2d8c6;
}
.tr-mode:hover:not(:disabled) { border-color: var(--ink); box-shadow: 0 3px 0 var(--ink); }
.tr-mode:disabled { opacity: 0.45; }
.tr-mode kbd { margin: 0; }
.tr-ic { font-size: 24px; text-align: center; }
.tr-t b { display: block; font-size: 15px; }
.tr-t b .zh { color: var(--red); margin-right: 3px; }
.tr-t small { color: var(--ink-soft); font-weight: 600; font-size: 12px; }
.tr-note { font-size: 11px; color: var(--ink-soft); line-height: 1.5; }
.tr-head { gap: 10px; }
.tr-progress { flex: 1; height: 8px; background: #e6dfd2; border-radius: 99px; overflow: hidden; }
.tr-progress i { display: block; height: 100%; background: var(--green); border-radius: 99px; transition: width 0.3s; }
.tr-card {
  background: #fff;
  border-radius: 18px;
  padding: 22px 12px;
  text-align: center;
  box-shadow: 0 3px 0 #e2d8c6;
  margin-bottom: 12px;
  min-height: 130px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}
.tr-hz { font: 700 56px/1.1 var(--hz); }
.tr-py { font-size: 18px; font-weight: 800; color: var(--red-dk); }
.tr-en { font-size: 18px; font-weight: 700; }
.tr-sub { font-size: 12px; color: var(--ink-soft); margin-top: 6px; font-weight: 600; }
.tr-plain { font-size: 20px; font-weight: 800; color: var(--ink-soft); letter-spacing: 0.04em; }
.tr-listen { font-size: 44px; width: 90px; height: 90px; border-radius: 50%; border: 3px solid var(--ink); background: var(--gold); box-shadow: 0 4px 0 var(--ink); }
.tr-back { text-align: center; background: #fff7de; border-radius: 14px; padding: 12px; margin-bottom: 10px; }
.tr-ex { font: 600 16px/1.4 var(--hz); margin-top: 8px; }
.tr-ex small { display: block; font: 600 12px var(--ui); color: var(--ink-soft); }
.tr-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tr-opt {
  position: relative;
  min-height: 62px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: #fff;
  border: 2.5px solid var(--ink);
  border-radius: 12px;
  box-shadow: 0 3px 0 var(--ink);
  padding: 8px 6px;
  font-weight: 700;
  font-size: 14px;
}
.tr-opts.tones .tr-opt { font-size: 18px; font-weight: 800; }
.tr-opt kbd { position: absolute; top: 4px; left: 5px; margin: 0; font-size: 8px; }
.tr-o-hz { font: 700 26px/1.1 var(--hz); }
.tr-opt .py { font-size: 11px; color: var(--red-dk); }
.tr-opt.right { background: #d7f0da; border-color: var(--green); }
.tr-opt.wrong { background: #ffe0dc; border-color: var(--red); animation: shake 0.4s; }
.tr-feedback { min-height: 22px; margin: 10px 2px; font-size: 13px; font-weight: 700; }
.tr-feedback .zh { font-size: 17px; }
.tr-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 8px; }
.tr-result { text-align: center; background: #fff; border-radius: 18px; padding: 18px; margin-bottom: 12px; }
.tr-score { font-size: 20px; font-weight: 800; }
.tr-score b { font-size: 48px; }
.tr-missed { display: flex; flex-wrap: wrap; gap: 6px; }
.tr-missed h4 { width: 100%; margin: 0 0 2px; font-size: 13px; }
.tr-missed .res-chip { cursor: pointer; }
.tr-m-en { font-size: 11px; color: var(--ink-soft); max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wd-mem { display: flex; align-items: center; justify-content: center; gap: 4px; font-size: 12px; font-weight: 800; margin: 6px 0; }
.wd-mem i { width: 16px; height: 8px; border-radius: 99px; background: #e6dfd2; display: inline-block; }
.wd-mem i.on { background: var(--green); }
.wd-mem small { font-weight: 600; color: var(--ink-soft); margin-left: 4px; }

@media (max-width: 720px) {
  .rt-map { height: 240px; }
  .rt-hz { font-size: 12px; }
  .rt-py { display: none; }
  .rt-badge { font-size: 9px; }
}

/* ---- metro network map / route planner ---- */
.mm-wrap {
  position: absolute;
  inset: 0;
  background: rgba(16, 12, 24, 0.55);
  display: grid;
  place-items: center;
  z-index: 22;
  animation: fadeIn 0.15s;
}
.mm {
  width: min(1180px, 96%);
  height: min(720px, 94%);
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: 16px;
  box-shadow: 0 6px 0 var(--ink);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.mm-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: #2e4068;
  color: #fff;
}
.mm-title { font-weight: 900; font-size: 18px; }
.mm-title .zh { font-size: 22px; margin-right: 4px; }
.mm-title small { font-weight: 700; font-size: 12px; opacity: 0.75; margin-left: 6px; }
.mm-card { margin-left: auto; font-weight: 800; font-size: 14px; background: rgba(255, 255, 255, 0.12); border-radius: 999px; padding: 4px 12px; }
.mm-card:empty { display: none; }
.mm-x { background: none; border: 0; color: #fff; font-size: 20px; font-weight: 900; padding: 2px 8px; }
.mm-body { flex: 1; display: grid; grid-template-columns: 1fr 320px; min-height: 0; }
.mm-mapwrap { overflow: auto; background: #f4f1ea; border-right: 3px solid var(--ink); touch-action: pan-x pan-y; }
.mm-svg { display: block; width: max(100%, 980px); height: auto; }
.mm-river-t { font: 700 13px var(--hz); fill: #5a9cc0; letter-spacing: 0.2em; }
.mm-river-t.small { font-size: 10px; letter-spacing: 0.1em; }
.mm-area { font: 800 12px var(--hz); fill: #b4aca0; letter-spacing: 0.25em; text-anchor: middle; }
.mm-area-en { font: 800 8px var(--ui); letter-spacing: 0.3em; }
.mm-road-t { font: 700 8.5px var(--hz); fill: #c39a3a; letter-spacing: 0.05em; }
.mm-lm-t { font: 700 9.5px var(--hz); fill: #a8987f; letter-spacing: 0.04em; }
.mm-cs-t { font: 900 9px var(--ui); fill: #b3a385; }
.mm-lm { pointer-events: none; }
.mm-case { fill: none; stroke: #fffaf0; stroke-width: 12; stroke-linejoin: round; stroke-linecap: round; }
.mm-line { fill: none; stroke-width: 7; stroke-linejoin: round; stroke-linecap: round; }
.mm-train { stroke: #fffaf0; stroke-width: 1.5; pointer-events: none; }
.mm-line.mag { stroke-dasharray: 10 6; stroke-width: 5; }
.mm-hl { fill: none; stroke: #ffd24a; stroke-width: 17; stroke-linejoin: round; stroke-linecap: round; opacity: 0.85; }
.mm-tag { font: 900 13px var(--ui); fill: #fff; text-anchor: middle; }
.mm-stn { cursor: pointer; }
.mm-dot { fill: #fff; stroke-width: 2.5; }
.mm-stn.x .mm-dot { stroke-width: 3; }
.mm-halo { fill: rgba(242, 193, 78, 0.28); stroke: none; }
.mm-stn.sel .mm-halo { fill: rgba(214, 60, 58, 0.35); }
.mm-stn.trip .mm-dot { fill: var(--gold); }
.mm-lbl { font: 600 10px var(--hz); fill: #3a3040; }
.mm-lbl.big { font: 900 14px var(--hz); fill: var(--ink); paint-order: stroke; stroke: #f7f3ea; stroke-width: 4px; }
.mm-lbl.en { font: 700 10px var(--ui); fill: #5a4a58; paint-order: stroke; stroke: #f7f3ea; stroke-width: 3px; }
.mm-stn:hover .mm-dot { fill: var(--gold); }
.mm-here { fill: none; stroke: var(--red); stroke-width: 3; animation: mmPulse 1.2s ease-out infinite; transform-origin: center; }
.mm-here-t { font: 900 11px var(--hz); fill: var(--red); text-anchor: middle; paint-order: stroke; stroke: #fff; stroke-width: 3px; }
@keyframes mmPulse { 0% { opacity: 1; } 100% { opacity: 0.25; } }
.mm-side { overflow: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.mm-side h4 { margin: 4px 0 0; font-size: 13px; }
.mm-legend { display: flex; flex-wrap: wrap; gap: 6px; }
.mm-legend span { display: flex; align-items: center; gap: 4px; font: 700 12px var(--hz); }
.mm-legend b { background: var(--c); color: #fff; border-radius: 5px; padding: 1px 6px; font: 900 12px var(--ui); }
.mm-now { font-size: 13px; background: var(--paper-2); border-radius: 8px; padding: 6px 8px; }
.mm-now b { font-size: 16px; }
.mm-dests { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.mm-dest {
  text-align: left;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: #fff;
  padding: 5px 6px;
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto auto;
  column-gap: 4px;
  align-items: center;
  font-size: 11px;
  position: relative;
}
.mm-dest kbd { grid-row: span 2; margin: 0; }
.mm-d-hz { font: 800 15px/1.2 var(--hz); }
.mm-d-en { color: var(--ink-soft); font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mm-d-lines { grid-column: 1 / -1; display: flex; gap: 3px; margin-top: 2px; }
.mm-d-lines i { font-style: normal; background: var(--c); color: #fff; border-radius: 4px; padding: 0 4px; font-weight: 900; font-size: 10px; }
.mm-dest.on { background: var(--gold); box-shadow: 0 3px 0 var(--ink); }
.mm-dest.locked { opacity: 0.55; background: #eee7da; }
.mm-dest.is-here { border-style: dashed; }
.mm-lock { grid-column: 1 / -1; font-size: 10px; font-weight: 800; color: var(--red-dk); }
.mm-who { grid-column: 1 / -1; font-size: 10px; font-weight: 800; color: var(--teal-dk, #1d7068); }
.mm-stn.gen .mm-lbl { fill: #2f3a4a; font-weight: 700; }
.mm-stn.gen.sel .mm-lbl, .mm-stn.gen.here .mm-lbl { fill: var(--red-dk); font-weight: 900; }
.mm-route { background: #fff; border: 2px solid var(--ink); border-radius: 10px; padding: 8px; font-size: 12px; }
.mm-hint { margin: 0; color: var(--ink-soft); font-weight: 600; line-height: 1.4; }
.mm-r-head { font-size: 16px; margin-bottom: 6px; }
.mm-leg { display: flex; gap: 8px; align-items: center; border-left: 5px solid var(--c); padding: 3px 0 3px 8px; margin: 4px 0; }
.mm-leg b { background: var(--c); color: #fff; border-radius: 5px; padding: 1px 6px; font-weight: 900; }
.mm-leg > span { display: flex; flex-direction: column; }
.mm-leg .zh { font-size: 14px; font-weight: 800; }
.mm-leg small { color: var(--ink-soft); font-weight: 700; }
.mm-xfer { font-size: 11px; font-weight: 800; color: var(--red-dk); padding-left: 8px; }
.mm-r-meta { display: flex; flex-wrap: wrap; gap: 8px; font-weight: 800; margin-top: 6px; }
.mm-r-zh { margin: 6px 0 0; font-size: 12px; color: var(--ink-soft); }
.mm-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: auto; }
.mm-actions .btn { font-size: 13px; padding: 7px 10px; }
.mm-actions .btn:disabled { opacity: 0.45; }
@media (max-width: 720px) {
  .mm { height: 96%; }
  .mm-body { grid-template-columns: 1fr; grid-template-rows: 44% 1fr; }
  .mm-mapwrap { border-right: 0; border-bottom: 3px solid var(--ink); }
  .mm-svg { width: 900px; }
  .mm-title small { display: none; }
}

/* ---- Shanghai Tower lift & Maglev speedometer ---- */
.lift-card {
  position: absolute;
  inset: 0;
  z-index: 30;
  background: radial-gradient(circle at 50% 40%, #2a2730, #0f0d13 70%);
  display: grid;
  place-items: center;
  color: #ffb347;
  transition: opacity 0.5s;
  animation: fadeIn 0.3s;
}
.lift-card.out { opacity: 0; }
.lift-inner { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.lift-dir { font-size: 28px; animation: ledBlink 0.6s steps(2) infinite; }
.lift-floor { background: #0c0a10; border: 3px solid #3a3345; border-radius: 12px; padding: 10px 28px; display: flex; align-items: baseline; gap: 8px; box-shadow: 0 0 30px rgba(255,179,71,0.15) inset; }
.lift-floor b { font: 900 84px/1 ui-monospace, 'SF Mono', Menlo, monospace; text-shadow: 0 0 18px rgba(255,179,71,0.55); min-width: 3ch; }
.lift-floor small { font: 800 18px var(--hz); }
.lift-speed { font: 800 14px var(--ui); color: #c9d1e2; }
.lift-note { font: 700 15px var(--hz); color: #fff; min-height: 20px; }

.hud-speedo {
  position: absolute;
  top: 12px;
  left: 14px;
  width: min(300px, calc(100vw - 290px));
  background: #0c1420;
  color: #fff;
  border: 3px solid var(--ink);
  border-radius: 12px;
  padding: 8px 12px;
  box-shadow: 0 4px 0 var(--ink);
}
.sp-tag { font: 800 12px var(--hz); color: #9fcdf2; }
.sp-num { display: flex; align-items: baseline; gap: 6px; }
.sp-num b { font: 900 44px/1.05 ui-monospace, 'SF Mono', Menlo, monospace; color: #7ad0ff; text-shadow: 0 0 12px rgba(120,200,255,0.5); }
.sp-num small { font-weight: 800; opacity: 0.8; }
.sp-bar { height: 8px; background: #1f2c3f; border-radius: 99px; overflow: hidden; }
.sp-bar i { display: block; height: 100%; background: linear-gradient(90deg, #1f78c8, #7ad0ff); width: 0; }
.hud-speedo.top .sp-num b { color: #ffe27a; text-shadow: 0 0 14px rgba(255,220,120,0.6); }
.hud.riding .hud-speedo ~ .hud-led { display: none; }
@media (max-width: 720px) {
  .hud-speedo { top: 64px; left: 50%; transform: translateX(-50%); width: 80vw; }
}

/* ---- phone: 地铁 Metro app ---- */
.metro-app .mm-svg { width: 100%; min-width: 0; }
.ma-map { border: 2px solid #e2d8c6; border-radius: 10px; overflow: hidden; background: #f7f3ea; margin-bottom: 8px; }
.ma-card { display: flex; align-items: center; gap: 10px; background: linear-gradient(135deg, #2f6fb5, #1f4f8a); color: #fff; border-radius: 12px; padding: 10px 12px; margin-bottom: 8px; box-shadow: 0 3px 0 #1c3558; }
.ma-card.bike { background: #2b9a8d; box-shadow: 0 3px 0 #1f6f66; }
.ma-card.bike b { font-size: 17px; }
.ma-card b { font-size: 22px; }
.ma-card small { opacity: 0.8; font-weight: 700; display: block; }
.ma-card .ma-chip { margin-left: auto; font-size: 26px; }
.ma-trip { background: #fff; border: 2px solid #e2d8c6; border-radius: 10px; padding: 8px 10px; font-size: 13px; margin-bottom: 8px; }
.ma-trip .zh { font-size: 15px; font-weight: 800; }
.ma-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.ma-actions .btn { font-size: 13px; padding: 7px 10px; }
.ma-tip { font-size: 12px; color: var(--ink-soft); line-height: 1.45; }

/* ------------------------------------------------ Maglev route strip --- */
.mg-route {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%); z-index: 3;
  display: flex; align-items: center; gap: 14px; pointer-events: none;
  width: min(560px, calc(100% - 700px)); min-width: 380px; padding: 10px 16px;
  background: rgba(12, 20, 32, 0.86); color: #fff; border: 2.5px solid #1f78c8; border-radius: 14px;
  font: 800 15px/1.1 var(--hz);
}
.mg-route small { display: block; font: 700 10px/1.3 var(--ui); opacity: 0.7; }
.mg-b { text-align: right; }
.mg-track { position: relative; flex: 1; height: 6px; border-radius: 999px; background: rgba(255, 255, 255, 0.18); }
.mg-fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; border-radius: inherit; background: #7ad0ff; }
.mg-dot { position: absolute; top: 50%; left: 0; transform: translate(-50%, -55%); font-size: 18px; }
.mg-ff { font: 700 11px var(--ui); opacity: 0.6; white-space: nowrap; }
.mg-route.ff .mg-ff { opacity: 1; color: #ffd76a; }
@media (max-width: 700px) { .mg-route { width: calc(100% - 24px); top: 64px; font-size: 13px; } .mg-ff { display: none; } }

/* ================================================================
   Compact notifications, a tablet instead of a phone, and phone-sized
   layouts without overlaps. (Later rules override the ones above.)
   ================================================================ */

/* ---- toasts: small single-line pills */
.toasts { top: 62px; right: 12px; gap: 4px; }
.toast {
  max-width: min(300px, 46vw); padding: 4px 10px; gap: 6px;
  font-size: 11px; font-weight: 700; line-height: 1.3; border-width: 2px; border-radius: 12px;
  box-shadow: 0 2px 0 var(--ink); white-space: normal; overflow: hidden;
}
/* up to two lines, never cut mid-word with an ellipsis */
.toast > span:last-child { min-width: 0; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.toast b.zh { font-size: 12px; }
.toast-ic { font-size: 12px; }

/* ---- announcements: a slim strip */
.hud-announce { padding: 6px 14px; max-width: min(620px, 70vw); border-width: 2px; }
.ann-tag { font-size: 9px; }
.ann-hz { font-size: 20px; }
.ann-py, .ann-en { font-size: 11px; }

/* ---- the tablet: landscape, tabs down the side */
.phone {
  width: min(980px, calc(100% - 32px));
  height: min(640px, calc(100% - 32px));
  border: 12px solid #1c1622;
  border-radius: 30px;
  display: grid;
  grid-template-columns: 96px 1fr;
  grid-template-rows: auto 1fr;
  grid-template-areas: 'status status' 'tabs body';
}
@keyframes phoneIn { from { transform: translateY(30px) scale(0.98); } }
.phone-status { grid-area: status; padding: 6px 54px 6px 18px; border-bottom: 2px solid #e2d8c6; }
.ph-notch { width: 10px; height: 10px; border-radius: 50%; margin: 0; background: #3a3045; }
.phone-body { grid-area: body; padding: 10px 22px 16px; }
.phone-tabs {
  grid-area: tabs; grid-template-columns: 1fr; grid-auto-rows: 1fr;
  border-top: 0; border-right: 2px solid #e2d8c6; padding: 6px 0;
}
.phone-tabs button { justify-content: center; padding: 4px 0; }
.phone-home {
  bottom: auto; left: auto; top: 5px; right: 10px; transform: none;
  width: 30px; height: 30px; border-radius: 50%; background: #1c1622;
}
.phone-home::after { content: '✕'; color: #fff; font: 900 14px/30px var(--ui); display: block; text-align: center; }

/* ---- phones in landscape and other short screens */
@media (max-height: 560px) {
  .phone { width: calc(100% - 16px); height: calc(100% - 16px); border-width: 8px; border-radius: 20px; grid-template-columns: 72px 1fr; }
  .phone-status { padding: 3px 46px 3px 12px; font-size: 11px; }
  .phone-home { top: 2px; right: 6px; width: 26px; height: 26px; }
  .phone-home::after { line-height: 26px; font-size: 12px; }
  .phone-tabs button { font-size: 9px; gap: 0; }
  .phone-tabs button .zh { font-size: 15px; width: 28px; height: 24px; }
  .phone-body { padding: 6px 12px 10px; }

  .toasts { top: 48px; right: 8px; }
  .toast { font-size: 10px; padding: 2px 8px; max-width: 40vw; }

  /* announcements move to the bottom centre, between joystick and buttons */
  .hud-announce, .hud-led:not(.hidden) ~ .hud-announce {
    top: auto; bottom: max(8px, calc(env(safe-area-inset-bottom) / var(--uiz, 1))); max-width: 44vw; padding: 4px 10px;
  }
  .ann-tag { display: none; }
  .ann-hz { font-size: 15px; line-height: 1.25; }
  .ann-py, .ann-en { font-size: 10px; }

  /* the in-car LED board and the Maglev speedometer: compact, top-left */
  .hud-led { top: 6px; left: 8px; transform: none; width: min(46vw, 420px); padding: 4px 8px 6px; }
  .led-hz { font-size: 18px; }
  .led-strip, .led-meta, .led-toward small, .led-ff { display: none; }
  .hud-speedo { top: 6px; left: 8px; transform: none; width: 34vw; padding: 4px 10px; }
  .sp-num b { font-size: 26px; }
  .mg-route { top: 6px; left: auto; right: 8px; transform: none; width: 34vw; min-width: 0; padding: 5px 10px; font-size: 11px; }
  .mg-route small { display: none; }
}

/* the return trip: the route strip runs right → left */
.mg-route.rev .mg-track { transform: scaleX(-1); }
.mg-route.rev .mg-dot { transform: translate(-50%, -55%) scaleX(-1); }
.mg-route.rev .mg-a { order: 3; text-align: right; }
.mg-route.rev .mg-b { order: 1; text-align: left; }
.mg-route.rev .mg-track { order: 2; }
.mg-route.rev .mg-ff { order: 4; }

/* the Maglev ride from above: only fast-forward on touch screens, and the
   route strip replaces the money/tablet chips so nothing overlaps */
body.cinematic .touch .joy-zone, body.cinematic .touch .abtns .a { display: none; }
body.cinematic .hud-tl, body.cinematic .hud-tr > :not(.hud-pause) { display: none; }
body.cinematic .mg-route { right: 66px; left: auto; transform: none; }
body.touch-mode.cinematic .mg-route { right: calc(26px + 44px / var(--uiz, 1)); }

/* ---- UI size (settings.uiSize, src/ui/uiScale.js): every panel over the
   canvas is drawn at --uiz; the title, touch pad and word popover are not. */
#ui > :not(.touch):not(.title):not(.t-enter) { zoom: var(--uiz, 1); }

/* ---- tablet: 猫 Cats tab (story/cats.js) */
.cat-where { margin-left: auto; font-size: 13px; font-weight: 700; color: var(--ink-soft); }
.cat-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; margin-top: 8px; }
.cat-card { display: flex; gap: 12px; background: #fff; border: 2px solid #e2d8c6; border-radius: 16px; padding: 12px; }
.cat-card canvas { width: 96px; height: 88px; image-rendering: pixelated; flex: none; background: radial-gradient(circle at 50% 60%, #fdf3e3, #f3e3c3); border-radius: 12px; }
.cat-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.cat-name { font-size: 12px; color: var(--ink-soft); }
.cat-name b { font-size: 17px; color: var(--ink); margin-right: 6px; }
.cat-bar { display: grid; grid-template-columns: 92px 1fr 26px; align-items: center; gap: 6px; font-size: 11.5px; }
.cat-bar i { height: 8px; border-radius: 999px; background: #efe4cf; overflow: hidden; }
.cat-bar em { display: block; height: 100%; border-radius: inherit; background: var(--green); transition: width 0.3s; }
.cat-bar.low em { background: var(--red); }
.cat-bar small { text-align: right; font-weight: 700; color: var(--ink-soft); }
.cat-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }
.cat-hats { display: contents; }
.cat-row .chip[disabled], .cat-feed .btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.cat-feed { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 12px; font-size: 13px; }
/* naming the kittens */
.modal-wrap.cat-naming .modal { max-width: 520px; }
.modal-wrap.cat-naming .modal h2 small { display: block; font-size: 13px; color: var(--ink-soft); }
.cn-cat { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.cn-cat canvas { width: 72px; height: 66px; image-rendering: pixelated; background: #fdf3e3; border-radius: 12px; flex: none; }
.cn-field { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.cn-coat { font-size: 12px; color: var(--ink-soft); }
.cn-field input { font: 700 16px/1.2 var(--ui); padding: 9px 12px; border: 2px solid #e2d8c6; border-radius: 12px; outline: none; }
.cn-field input:focus { border-color: var(--ink); }
.cn-tip { margin: 4px 0 6px; font-size: 12px; color: var(--ink-soft); }
.cn-ideas { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---------------------------------------------------------- pause menu --- */
#ui:has(> .pause-wrap) > .toasts { visibility: hidden; }
.pause-wrap {
  position: absolute;
  inset: 0;
  z-index: 45;
  display: grid;
  place-items: center;
  background: rgba(20, 12, 28, 0.62);
  animation: fadeIn 0.18s;
  padding: 16px;
}
.pause {
  position: relative;
  width: min(440px, 100%);
  max-height: 100%;
  overflow: auto;
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: 18px;
  box-shadow: 0 6px 0 var(--ink);
  padding: 26px 24px 20px;
  text-align: center;
  animation: pauseIn 0.22s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
@keyframes pauseIn { from { transform: translateY(14px) scale(0.97); opacity: 0; } }
.pause-seal {
  position: absolute;
  top: -22px;
  left: 50%;
  transform: translateX(-50%) rotate(-5deg);
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  background: var(--red);
  color: var(--paper);
  border: 3px solid var(--ink);
  border-radius: 12px;
  font: 900 22px/1 var(--hz);
}
.pause h2 { margin: 6px 0 16px; font: 900 26px/1.1 var(--ui); color: var(--ink); }
.pause h2 span { color: var(--red); margin-right: 6px; font-family: var(--hz); }
.pause-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  background: var(--paper-2);
  color: var(--ink);
  border: 2.5px solid var(--ink);
  border-radius: 999px;
  padding: 11px 16px;
  font: 800 15px/1.2 var(--ui);
  box-shadow: 0 3px 0 var(--ink);
  cursor: pointer;
}
.pause-btn:hover { background: var(--gold); }
.pause-btn.primary { background: var(--red); color: #fff; font-size: 17px; }
.pause-btn.primary:hover { background: #e9544f; }
.pause-btn kbd { font-size: 10px; background: rgba(255, 255, 255, 0.2); color: inherit; border-color: rgba(255, 255, 255, 0.5); }
.pause-toggles { display: grid; gap: 8px; margin: 16px 0 8px; }
.pause-tog {
  display: grid;
  grid-template-columns: 38px 1fr auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  background: #fff;
  border: 2.5px solid var(--ink);
  border-radius: 12px;
  padding: 8px 12px;
  font: 700 15px/1.2 var(--ui);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}
.pause-tog b { display: grid; place-items: center; height: 30px; border-radius: 8px; background: var(--ink); color: var(--gold); font: 900 13px/1 var(--ui); }
.pause-tog b[lang] { font: 900 16px/1 var(--hz); }
.pause-tog i { font-style: normal; font-weight: 900; font-size: 13px; padding: 5px 10px; border-radius: 999px; background: var(--paper-3); color: var(--ink-soft); min-width: 44px; text-align: center; }
.pause-tog[aria-pressed="true"] i { background: var(--green); color: #fff; }
.pause-lang { display: flex; align-items: center; gap: 6px; margin: 4px 0 10px; }
.pause-lang > span { flex: 1; font-size: 13px; font-weight: 800; color: var(--ink-soft); text-align: left; }
.pause-lang button { font: 800 13px/1 var(--ui); padding: 8px 12px; border-radius: 999px; border: 2px solid var(--ink); background: var(--paper); color: var(--ink); cursor: pointer; }
.pause-lang button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.pause-note { margin: 4px 2px 16px; font-size: 13px; line-height: 1.45; color: var(--ink-soft); }
.pause-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pause-row .pause-btn { font-size: 13.5px; padding: 10px 10px; }
@media (max-height: 560px) {
  .pause { padding: 20px 18px 14px; }
  .pause h2 { margin: 2px 0 10px; font-size: 21px; }
  .pause-toggles { margin: 10px 0 4px; }
  .pause-note { margin-bottom: 10px; font-size: 12px; }
  .pause-btn.primary { padding: 9px 14px; }
}
body.touch-mode .pause-btn kbd { display: none; }

/* -------------------------------------------- tablet: one colour per app --- */
/* Each app (--tone, set per tab in phoneUI.js) colours its rail icon, the
   active rail slot and its own page header, so tabs are told apart at a
   glance. Pages are compact: one summary line, one row of filters. */
.phone { --tone: #d63c3a; }
.phone-tabs button { color: #8a7d88; transition: background 0.15s, color 0.15s; }
.phone-tabs button .zh {
  background: color-mix(in srgb, var(--tone) 12%, #fff);
  color: var(--tone);
  border: 2px solid transparent;
}
.phone-tabs button:hover .zh { border-color: color-mix(in srgb, var(--tone) 45%, #fff); }
.phone-tabs button.on { color: var(--tone); background: color-mix(in srgb, var(--tone) 7%, #fff); box-shadow: inset 4px 0 0 var(--tone); }
.phone-tabs button.on .zh { background: var(--tone); color: #fff; }
.tab-badge { top: 0; left: calc(50% + 9px); margin-left: 0; }
.app-head {
  margin: 2px 0 12px;
  padding-bottom: 8px;
  border-bottom: 3px solid var(--tone);
}
.app-head h3 { display: flex; align-items: center; gap: 8px; }
.app-head h3 .zh {
  display: inline-grid; place-items: center;
  min-width: 34px; height: 30px; padding: 0 6px;
  border-radius: 9px; background: var(--tone); color: #fff; margin: 0;
  font-size: 17px;
}
.phone .chip.on:not([class*="st-"]) { background: var(--tone); border-color: var(--tone); }

/* one summary line instead of big counters */
.app-sum { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 0 2px 10px; font-size: 13px; font-weight: 700; color: var(--ink-soft); }
.app-sum span { display: inline-flex; align-items: baseline; gap: 5px; }
.app-sum span::before { content: ''; width: 9px; height: 9px; border-radius: 50%; background: var(--tone); align-self: center; }
.app-sum b { font-size: 17px; color: var(--ink); }
.app-sum .st-discovered::before { background: var(--st-discovered); }
.app-sum .st-practiced::before { background: var(--st-practiced); }
.app-sum .st-mastered::before { background: var(--st-mastered); }
.app-sum .tr-due b { color: var(--tone); }
.lv-list { grid-template-columns: repeat(4, 1fr); gap: 4px 14px; margin-bottom: 12px; }
.lv { grid-template-columns: auto 1fr auto; gap: 6px; font-size: 10.5px; }
.lv-bar { height: 6px; }
.lv-bar i { background: var(--tone); }
.lex-filters { display: grid; gap: 8px; margin-bottom: 10px; }
.lex-filters .lex-search { margin: 0; }
.chips.one-row { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-bottom: 10px; align-items: center; }
.lex-filters .chips.one-row { margin-bottom: 0; }
.chips.one-row::-webkit-scrollbar { display: none; }
.chips.one-row .chip { flex: none; }
.chip-sep { flex: none; width: 2px; height: 18px; background: #e2d8c6; border-radius: 2px; margin: 0 2px; }

/* trainer: the five drills as a compact grid */
.tr-modes { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 2px 0 8px; }
.tr-mode { padding: 10px 12px; }
.tr-mode .zh { color: var(--tone); }
.tr-note { font-size: 12px; color: var(--ink-soft); margin: 4px 2px 0; }

/* quests: open ones in full, finished ones as a line, the rest folded */
.quest-level { margin-bottom: 10px; }
.quest-level > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 6px; }
.quest-level > summary::-webkit-details-marker { display: none; }
.quest-level > summary::before { content: '›'; color: var(--tone); font: 900 18px/1 var(--ui); width: 12px; display: inline-block; text-align: center; transition: transform 0.15s; }
.quest-level[open] > summary::before { transform: rotate(90deg); }
.quest-level > summary h4, .quest-level > h4 { margin: 4px 0 8px; font-size: 13px; letter-spacing: 0.04em; color: var(--tone); }
.quest-level.locked > h4 { color: #a59aa2; }
.quest-level > summary h4 small, .quest-level > h4 small { color: var(--ink-soft); font-weight: 700; margin-left: 4px; letter-spacing: 0; }
.quest { border-left: 4px solid var(--tone); }
.quest-done { list-style: none; margin: 0 0 8px; padding: 8px 12px; background: #fff; border-radius: 12px; display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12.5px; font-weight: 700; color: #8a7d88; }
.quest-done li::first-letter { color: var(--green); }
.quest-more { margin: 0 2px 6px; font-size: 12.5px; font-weight: 700; color: #a59aa2; }
/* the quest log groups each stage's quests by day of the trip */
.quest-day { margin: 12px 2px 6px; font: 800 12px/1 var(--ui); letter-spacing: 0.06em; text-transform: uppercase; color: var(--tone, #3866b8); display: flex; align-items: center; gap: 8px; }
.quest-day b { font: 900 14px/1 var(--hz); letter-spacing: 0; text-transform: none; color: var(--ink); }
.quest-day::after { content: ''; flex: 1; height: 2px; border-radius: 2px; background: currentColor; opacity: 0.2; }

/* settings: grouped */
.set-h { margin: 14px 2px 6px; font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-soft); display: flex; align-items: center; gap: 6px; }
.set-h:first-of-type { margin-top: 4px; }
.set-h .zh { color: var(--tone); font-size: 13px; letter-spacing: 0; text-transform: none; }
.set-group { background: #fff; border-radius: 14px; padding: 2px 0; margin-bottom: 4px; }
.set-group .set-row { background: none; border-radius: 0; margin: 0; border-bottom: 1.5px solid #f0e8da; }
.set-group .set-row:last-child { border-bottom: 0; }
.set-row:not(.col) > span { display: flex; flex-direction: column; gap: 2px; }
.set-row:not(.col) > span small { float: none; font-size: 12px; font-weight: 600; }
.set-row input[type="range"], .set-row input[type="checkbox"] { accent-color: var(--tone); }

@media (max-height: 560px) {
  .phone-tabs button .zh { width: 30px; height: 24px; }
  .tab-badge { left: calc(50% + 7px); top: -3px; padding: 2px 4px; font-size: 8px; }
  .app-head { margin-bottom: 8px; padding-bottom: 6px; }
  .app-head h3 .zh { height: 26px; min-width: 30px; font-size: 15px; }
  .lv-list { grid-template-columns: repeat(2, 1fr); }
  .tr-mode { padding: 7px 10px; }
}

/* ------------------------------------- pause menu: conversation history --- */
.pause.wide { width: min(760px, 100%); text-align: left; padding: 18px 20px 16px; }
.pause-btn.hist { margin-bottom: 10px; background: #fff; }
.pause-btn.hist span { color: var(--red); font-family: var(--hz); }
.pause-btn.hist small { font: 800 11px/1 var(--ui); background: var(--paper-3); color: var(--ink-soft); border-radius: 999px; padding: 3px 7px; }
.pause-btn.hist em { font-style: normal; font: 800 11px/1 var(--ui); background: var(--red); color: #fff; border-radius: 999px; padding: 4px 8px; }
.h-top { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.h-top h2 { margin: 0; font-size: 21px; }
.h-back { width: auto; padding: 7px 14px; font-size: 13px; }
.h-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.h-item { background: #fff; border: 2px solid #eadfcb; border-radius: 12px; overflow: hidden; }
.h-item.open { border-color: var(--ink); }
.h-head { width: 100%; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; background: none; border: 0; padding: 9px 12px; text-align: left; cursor: pointer; font: 700 14px/1.2 var(--ui); color: var(--ink); }
.h-head:hover { background: #fff8e8; }
.h-who { font: 900 16px/1 var(--hz); color: var(--red); }
.h-title { flex: 1; min-width: 120px; color: var(--ink-soft); font-weight: 700; }
.h-head small { color: #9a8f86; font-size: 11.5px; font-weight: 700; }
.h-ok, .h-bad, .h-fixed, .h-left { font: 800 11px/1 var(--ui); border-radius: 999px; padding: 4px 8px; }
.h-ok { background: #dff0e2; color: #2f7a43; }
.h-fixed { background: #e3ecf8; color: #2f5d9a; }
.h-bad { background: #fde3df; color: var(--red-dk); }
.h-left { background: var(--paper-3); color: var(--ink-soft); }
.h-body { padding: 4px 12px 12px; border-top: 2px solid #f0e8da; display: grid; gap: 8px; }
.h-turn { display: grid; gap: 3px; padding: 6px 0 4px 10px; border-left: 3px solid #e2d8c6; }
.h-turn.missed { border-left-color: var(--red); }
.h-turn.missed.fixed { border-left-color: var(--blue); }
.h-q { margin: 0; display: flex; flex-wrap: wrap; gap: 2px 10px; align-items: baseline; }
.h-q b { font: 600 17px/1.35 var(--hz); color: var(--ink); }
.h-q .py { font-size: 12px; font-weight: 700; color: var(--red-dk); }
.h-en { font-size: 12px; color: var(--ink-soft); }
.h-a { margin: 0; display: flex; gap: 8px; align-items: baseline; }
.h-a span { flex: none; width: 22px; height: 20px; display: grid; place-items: center; border-radius: 6px; font: 900 11px/1 var(--ui); }
.h-a b { font: 600 15px/1.35 var(--hz); }
.h-a.wrong span { background: #fde3df; color: var(--red-dk); }
.h-a.wrong b { color: #9a8f86; text-decoration: line-through; text-decoration-color: var(--red); }
.h-a.right span { background: #dff0e2; color: #2f7a43; }
.h-a.right b { color: #2f7a43; }
.h-a.said span { background: var(--blue); color: #fff; font-family: var(--hz); }
.h-practise { margin-top: 4px; }
.h-empty { text-align: center; margin: 24px 0; }

/* ---------------------------------------------------------------- smartwatch
   丽丽 and 小李's birthday present (ui/watchScene.js): conversations and the
   grammar in them, on a dark watch face with a rose strap. */
.watch-wrap {
  position: absolute;
  inset: 0;
  background: rgba(20, 12, 28, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  animation: fadeIn 0.15s;
}
.watch {
  position: relative;
  flex: none;
  height: min(640px, calc(100% - 20px));
  aspect-ratio: 0.74;
  max-width: calc(100% - 20px);
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: watchIn 0.32s cubic-bezier(0.2, 0.9, 0.3, 1.15);
}
@keyframes watchIn { from { transform: translateY(26px) scale(0.96); opacity: 0; } }
.w-strap {
  width: 58%;
  height: 9%;
  flex: none;
  background: repeating-linear-gradient(90deg, #8e3b57 0 2px, #a4486a 2px 9px);
  border: 2px solid #5a2236;
  box-shadow: inset 0 0 0 4px rgba(255, 255, 255, 0.08);
}
.w-strap.top { border-radius: 14px 14px 4px 4px; border-bottom: none; }
.w-strap.bottom { border-radius: 4px 4px 14px 14px; border-top: none; }
.w-case {
  position: relative;
  flex: 1;
  width: 100%;
  min-height: 0;
  padding: 12px;
  border-radius: 64px;
  background: linear-gradient(160deg, #57505f, #24202a 45%, #121016);
  box-shadow: 0 0 0 3px #0c0a0f, 0 22px 44px rgba(0, 0, 0, 0.5), inset 0 2px 0 rgba(255, 255, 255, 0.18);
}
.w-crown {
  position: absolute;
  right: -11px;
  top: 20%;
  width: 14px;
  height: 46px;
  border: 2px solid #0c0a0f;
  border-radius: 6px;
  background: repeating-linear-gradient(0deg, #f2c14e 0 3px, #c2912e 3px 5px);
  cursor: pointer;
}
.w-screen {
  height: 100%;
  border-radius: 52px;
  background: radial-gradient(120% 70% at 50% 0%, #241d2c, #0f0c13 60%);
  overflow: hidden;
  display: flex;
}
.w-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 20px 28px;
  color: #f6efe4;
  font-family: var(--ui);
  scrollbar-width: thin;
  scrollbar-color: #5a4a68 transparent;
}
.w-body [lang="zh"], .w-body p[lang="zh"] { font-family: var(--hz); }
.w-head { position: sticky; top: -20px; margin: -20px -20px 12px; padding: 16px 20px 10px; display: flex; align-items: center; gap: 10px; background: linear-gradient(#18131e 70%, rgba(24, 19, 30, 0)); z-index: 1; }
.w-head h3 { margin: 0; font: 800 17px/1.2 var(--ui); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-head h3 [lang="zh"] { font: 900 19px/1 var(--hz); color: var(--gold); }
.w-head small { font-size: 12px; color: #b9a9b8; }
.w-back { flex: none; width: 34px; height: 34px; border-radius: 50%; border: none; background: #2e2637; color: #fff; font: 800 22px/1 var(--ui); cursor: pointer; }
.w-back:hover { background: var(--red); }
/* home */
.w-home { display: flex; flex-direction: column; align-items: center; text-align: center; padding-top: 6%; }
.w-time { font: 800 64px/1 var(--ui); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.w-day { margin-top: 8px; font-size: 14px; color: #c9b9c8; }
.w-day b { font: 900 16px/1 var(--hz); color: var(--gold); margin-right: 4px; }
.w-apps { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; width: 100%; margin-top: 26px; }
.w-app { border: none; border-radius: 24px; padding: 16px 8px 14px; color: #fff; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 4px; box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.25); }
.w-app b { font: 900 30px/1 var(--hz); }
.w-app span { font-weight: 800; font-size: 14px; }
.w-app small { font-size: 11px; opacity: 0.85; }
.w-app.hist { background: linear-gradient(160deg, #e0564f, #a8302f); }
.w-app.gram { background: linear-gradient(160deg, #36b0a2, #1f7a70); }
.w-app:hover { filter: brightness(1.08); }
.w-tip { margin: 18px 4px 0; font-size: 12px; color: #9e8e9d; line-height: 1.4; }
.w-recent { width: 100%; margin-top: 18px; text-align: left; }
.w-recent h4 { margin: 0 2px 8px; }
.w-recent h4 [lang="zh"] { color: var(--gold); letter-spacing: 0; text-transform: none; font-size: 13px; }
.w-recent .w-chip { text-align: left; }
.w-recent .w-chip small { font: 700 11px/1 var(--ui); opacity: 0.8; }
/* lists */
.w-list { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.w-row { width: 100%; text-align: left; border: none; border-radius: 16px; background: #221c29; color: #f6efe4; padding: 10px 12px; cursor: pointer; display: grid; grid-template-columns: auto 1fr; column-gap: 8px; align-items: center; font: 700 14px/1.3 var(--ui); }
.w-row:hover { background: #2f2738; }
.w-row small { grid-column: 2; font-weight: 600; font-size: 11px; color: #a796a6; }
.w-row [lang="zh"] { font-family: var(--hz); }
.w-row mark { background: var(--gold); color: var(--ink); border-radius: 4px; padding: 0 2px; }
.w-who { font: 800 12px/1 var(--hz); background: #3a3044; color: #f2c14e; padding: 5px 7px; border-radius: 999px; white-space: nowrap; }
.w-row.g { grid-template-columns: 4.6em 1fr auto; }
.w-row.g b { font: 900 16px/1.2 var(--hz); color: #fff; }
.w-row.g small { grid-column: 3; color: var(--gold); }
.w-row.g.seen b::after { content: ' ●'; color: var(--gold); font-size: 10px; vertical-align: middle; }
.w-body h4 { margin: 14px 2px 8px; font: 800 12px/1 var(--ui); letter-spacing: 0.08em; text-transform: uppercase; color: #b9a9b8; }
.w-note { margin: 0 2px 4px; font-size: 11px; color: #9e8e9d; }
.w-empty { margin: 18px 4px; font-size: 13px; line-height: 1.5; color: #b9a9b8; text-align: center; }
/* a conversation, line by line */
.w-turn { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.w-line { background: #221c29; border-radius: 18px 18px 18px 6px; padding: 10px 12px; }
.w-line.you { background: #2a3550; border-radius: 18px 18px 6px 18px; margin-left: 12%; }
.w-spk { display: block; font: 800 11px/1 var(--hz); color: var(--gold); margin-bottom: 4px; }
.w-line.you .w-spk { color: #9cc3ff; font-family: var(--ui); }
.w-line p { margin: 0; font: 600 19px/1.35 var(--hz); }
.w-line .py, .w-ex .py { display: block; font-size: 12px; font-weight: 700; color: #f19c98; margin-top: 2px; }
.w-en { display: block; font-size: 12px; color: #b9a9b8; margin-top: 2px; }
.w-chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 7px; }
.w-chip { border: none; border-radius: 999px; padding: 4px 9px; font: 900 13px/1 var(--hz); cursor: pointer; color: var(--ink); }
.w-chip.lv1 { background: #9bd68a; }
.w-chip.lv2 { background: var(--gold); }
.w-chip.lv3 { background: #f39a86; }
.w-chip:hover { filter: brightness(1.1); transform: translateY(-1px); }
/* one grammar point */
.w-point h2 { margin: 2px 0 10px; font: 800 20px/1.25 var(--ui); }
.w-pattern { font: 800 15px/1.4 var(--hz); background: #1c1622; border: 2px dashed var(--gold); color: var(--gold); border-radius: 14px; padding: 10px 12px; margin-bottom: 10px; }
.w-point > p { font-size: 14px; line-height: 1.55; color: #e9dfd2; margin: 8px 0; }
.w-tipline { background: #2b2433; border-radius: 12px; padding: 8px 10px; font-size: 13px !important; }
.w-ex { background: #221c29; border-radius: 14px; padding: 9px 12px; margin-bottom: 8px; }
.w-ex p { margin: 0; font: 600 18px/1.35 var(--hz); }
.w-ex mark, .w-line mark { background: var(--gold); color: var(--ink); border-radius: 4px; padding: 0 2px; }
.w-src { margin-top: 16px !important; font-size: 11px !important; color: #9e8e9d !important; line-height: 1.45 !important; }
.w-src a { color: #9cc3ff; }

/* ---------------------------------------------------------------- dream trip
   The country card on Day 5 (story/birthday.js · pickCountry). */
.modal-wrap.trip-pick .modal { max-width: 540px; }
.tp-lead { color: var(--ink-soft); }
.tp-input { width: 100%; font: 800 20px/1.2 var(--ui); padding: 12px 14px; border: 2.5px solid var(--ink); border-radius: 14px; outline: none; background: #fff; }
.tp-input:focus { box-shadow: 0 0 0 4px rgba(242, 193, 78, 0.6); }
.tp-match { min-height: 52px; display: flex; align-items: center; gap: 10px; margin: 10px 2px 4px; font-weight: 700; }
.tp-match b { font: 900 28px/1 var(--hz); }
.tp-match .py { color: var(--red-dk); }
.tp-flag { font-size: 30px; }
.tp-none { color: var(--ink-soft); font-weight: 600; font-size: 14px; }
.tp-ideas { display: flex; flex-wrap: wrap; gap: 6px; }
.tp-ideas .chip b { font-family: var(--hz); }

/* A friend's Liaoliao post shared in a chat (phoneUI.js · postCard) */
.post-card { align-self: flex-start; width: min(300px, 88%); background: #fff; border-radius: 16px; overflow: hidden; box-shadow: 0 2px 0 #e2d8c6; animation: pop 0.2s; }
.pc-head { display: flex; align-items: center; gap: 8px; padding: 8px 12px; font-size: 13px; }
.pc-head small { color: var(--ink-soft); margin-left: auto; font-size: 11px; }
.pc-av { width: 26px; height: 26px; border-radius: 50%; background: #e06b98; color: #fff; display: grid; place-items: center; font: 800 13px/1 var(--hz); }
.pc-head b { font-family: var(--hz); }
.pc-pic { position: relative; height: 128px; background: linear-gradient(#ffd9e8, #fff3d6 62%, #e9d7bf 62%); overflow: hidden; }
.pc-sun { position: absolute; top: 14px; right: 26px; width: 30px; height: 30px; border-radius: 50%; background: #ffcf5a; box-shadow: 0 0 0 8px rgba(255, 207, 90, 0.3); }
.pc-cloud { position: absolute; top: 26px; left: 30px; width: 70px; height: 20px; border-radius: 20px; background: #fff; box-shadow: 18px -10px 0 -2px #fff, 38px -2px 0 2px #fff; }
.pc-sign { position: absolute; left: 50%; top: 52px; transform: translateX(-50%); background: #e06b98; color: #fff; font: 900 14px/1 var(--hz); padding: 6px 10px; border-radius: 8px; border: 2px solid #2b1d2a; }
.pc-cup { position: absolute; bottom: 10px; width: 26px; height: 38px; border-radius: 4px 4px 9px 9px; background: linear-gradient(#f6e6cf 0 18%, #d9a978 18% 72%, #3b2418 72%); border: 2px solid #2b1d2a; }
.pc-cup::before { content: ''; position: absolute; top: -14px; left: 12px; width: 4px; height: 16px; background: #e06b98; border: 1px solid #2b1d2a; }
.pc-cup.a { left: 38%; transform: rotate(-6deg); }
.pc-cup.b { left: 52%; transform: rotate(5deg); }
.pc-hz { padding: 10px 12px 0; font: 700 18px/1.35 var(--hz); }
.post-card .py { padding: 0 12px; font-size: 12px; font-weight: 700; color: var(--red-dk); }
.post-card .b-en { padding: 0 12px; }
.pc-tag { padding: 6px 12px 10px; font-size: 12px; color: var(--blue); font-weight: 700; }
