:root {
  color-scheme: light;
  --paper: #fdf7ec;
  --card: #ffffff;
  --ink: #262a45;
  --ink-soft: #545a78;
  --pencil: #7b7f95;
  --line: rgba(38, 42, 69, 0.1);
  --line-strong: rgba(38, 42, 69, 0.2);
  --rose: #d6336c;
  --teal: #17a398;
  --sun: #f2b705;
  --sky: #3a9bd5;
  --stage: #ff8fab;
  --stage-ink: color-mix(in srgb, var(--stage) 62%, #262a45);
  --good: #16a34a;
  --bad: #e03b4f;
  --shadow: 0 10px 30px rgba(38, 42, 69, 0.12);
  --display: "Fraunces", Georgia, serif;
  --body: "Nunito", ui-rounded, system-ui, -apple-system, "Segoe UI", sans-serif;
  --radius: 18px;
}

* { box-sizing: border-box; }

html, body { margin: 0; height: 100%; }

body {
  color: var(--ink);
  font-family: var(--body);
  font-size: 15px;
  line-height: 1.5;
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; opacity: 0.45; }

:focus-visible { outline: 3px dashed var(--rose); outline-offset: 3px; border-radius: 10px; }

[hidden] { display: none !important; }

/* ---------------------------------------------------------------- layout */
.app {
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr) 380px;
  grid-template-rows: 62px minmax(0, 1fr);
  grid-template-areas: "top top top" "route stage story";
  height: 100vh;
  height: 100dvh;
  background:
    radial-gradient(900px 600px at 50% 30%, rgba(255, 255, 255, 0.95), transparent 70%),
    radial-gradient(700px 500px at 85% 85%, rgba(255, 196, 214, 0.45), transparent 70%),
    radial-gradient(700px 500px at 10% 80%, rgba(170, 236, 214, 0.5), transparent 70%),
    linear-gradient(180deg, #dff2ff, #fff4e4);
}

.topbar {
  grid-area: top;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(10px);
  z-index: 5;
}

.home {
  flex: none;
  padding: 7px 13px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--card);
  color: var(--ink);
  font-weight: 800;
  font-size: 13px;
  text-decoration: none;
}
.home:hover { background: #fff3c4; }

.brand { min-width: 0; }
.brand h1 { margin: 0; font-family: var(--display); font-size: 23px; font-weight: 800; line-height: 1.1; }
.brand h1::after { content: ""; display: inline-block; width: 9px; height: 9px; margin-left: 6px; border-radius: 50%; background: var(--stage); vertical-align: 3px; }
.brand p { margin: 0; color: var(--ink-soft); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.top-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 13px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--card);
  font-weight: 800;
  font-size: 13px;
  box-shadow: 0 2px 6px rgba(38, 42, 69, 0.06);
}
.chip:hover { background: #fff3c4; }
.meal-emoji { font-size: 18px; line-height: 1; }
.icon-chip { width: 36px; padding: 0; justify-content: center; }
.icon-chip svg { width: 20px; height: 20px; }
.icon-chip .sound-waves { display: none; }
.icon-chip[aria-pressed="true"] { color: #fff; border-color: var(--teal); background: var(--teal); }
.icon-chip[aria-pressed="true"] .sound-waves { display: inline; }
.icon-chip[aria-pressed="true"] .sound-off { display: none; }

.language-switcher { display: inline-flex; padding: 3px; border: 1px solid var(--line-strong); border-radius: 999px; background: var(--card); }
.language-switcher button { padding: 4px 10px; border: 0; border-radius: 999px; background: none; color: var(--ink-soft); font-weight: 800; font-size: 12px; }
.language-switcher button[aria-pressed="true"] { background: var(--ink); color: #fff; }

/* ---------------------------------------------------------------- route */
.route {
  grid-area: route;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px 14px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.55);
  overflow-y: auto;
}

.panel-title { margin: 0 0 2px 6px; color: var(--pencil); font-size: 11px; font-weight: 900; letter-spacing: 1.4px; text-transform: uppercase; }

.stops { position: relative; margin: 0; padding: 0; list-style: none; }
.stops::before { content: ""; position: absolute; top: 18px; bottom: 18px; left: 20px; width: 0; border-left: 3px dotted var(--line-strong); }

.stop {
  position: relative;
  display: grid;
  grid-template-columns: 26px 1fr;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 7px 8px;
  border: 2px solid transparent;
  border-radius: 14px;
  background: none;
  text-align: left;
}
.stop:hover { background: rgba(255, 255, 255, 0.8); }
.stop .dot {
  position: relative;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border: 2.5px solid var(--c);
  border-radius: 50%;
  background: var(--card);
  color: color-mix(in srgb, var(--c) 60%, #262a45);
  font-size: 12px;
  font-weight: 900;
  transition: transform 0.25s, background 0.25s;
}
.stop .name { display: block; font-weight: 800; font-size: 14px; line-height: 1.2; }
.stop .time { display: block; color: var(--pencil); font-size: 11.5px; font-weight: 700; }
.stop.done .dot { background: var(--c); color: #fff; }
.stop.current { border-color: var(--c); background: var(--card); box-shadow: 0 6px 16px color-mix(in srgb, var(--c) 30%, transparent); }
.stop.current .dot { transform: scale(1.15); background: var(--c); color: #fff; }

.clock {
  margin-top: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
}
.clock-label { display: block; color: var(--ink-soft); font-size: 11.5px; font-weight: 800; letter-spacing: 0.4px; text-transform: uppercase; }
.clock-value { display: block; margin: 2px 0 4px; color: var(--rose); font-family: var(--display); font-size: 27px; font-variant-numeric: tabular-nums; line-height: 1.15; }
.clock-note { margin: 0; color: var(--pencil); font-size: 11.5px; line-height: 1.4; }

/* ---------------------------------------------------------------- stage */
.stage { grid-area: stage; position: relative; min-height: 0; overflow: hidden; }

#scene { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; }
#scene.pointing { cursor: pointer; }

.loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--ink-soft);
  font-weight: 800;
  background: linear-gradient(180deg, #e6f5ff, #fff6e8);
  z-index: 8;
  transition: opacity 0.5s;
}
.loading.gone { opacity: 0; pointer-events: none; }
.spinner { width: 22px; height: 22px; border: 3px solid var(--line-strong); border-top-color: var(--rose); border-radius: 50%; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.webgl-error { position: absolute; top: 40%; left: 10%; right: 10%; padding: 16px; border: 2px solid var(--bad); border-radius: var(--radius); background: var(--card); text-align: center; z-index: 9; }

.labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.label {
  position: absolute;
  top: 0;
  left: 0;
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 800;
  transition: opacity 0.3s;
  will-change: transform;
}
.label i { flex: none; width: 10px; height: 10px; border: 2px solid #fff; border-radius: 50%; background: var(--c); box-shadow: 0 1px 4px rgba(38, 42, 69, 0.3); }
.label b { padding: 2px 9px; border: 2px solid var(--c); border-radius: 999px; background: rgba(255, 255, 255, 0.92); color: var(--ink); font-weight: 800; box-shadow: 0 2px 8px rgba(38, 42, 69, 0.12); }
.label.left { flex-direction: row-reverse; }
.label.context b { color: var(--ink-soft); font-weight: 700; border-style: dashed; }
.label.active b { background: color-mix(in srgb, var(--c) 22%, #fff); }

.tooltip {
  position: absolute;
  z-index: 6;
  padding: 4px 11px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--card);
  font-size: 12.5px;
  font-weight: 800;
  pointer-events: none;
  transform: translate(12px, -130%);
}

.caption {
  position: absolute;
  left: 50%;
  bottom: 88px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  width: min(620px, calc(100% - 32px));
  transform: translateX(-50%);
  text-align: center;
  pointer-events: none;
  z-index: 3;
}
.caption-stop { padding: 2px 11px; border-radius: 999px; background: var(--stage); color: var(--ink); font-size: 11.5px; font-weight: 900; letter-spacing: 0.5px; text-transform: uppercase; }
.caption-text {
  padding: 9px 18px;
  border: 2px solid color-mix(in srgb, var(--stage) 60%, transparent);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.95);
  font-size: 17px;
  font-weight: 800;
  line-height: 1.35;
  box-shadow: var(--shadow);
}
.caption.fresh .caption-text { animation: pop 0.45s ease-out; }
@keyframes pop { from { transform: translateY(6px) scale(0.98); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------------------------------------------------------------- dock */
.dock {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.93);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  z-index: 4;
}

.transport { display: flex; flex: none; align-items: center; gap: 8px; }

.icon-btn {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: var(--card);
}
.icon-btn:hover { background: #fff3c4; }
.icon-btn svg { width: 20px; height: 20px; }

.play-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 46px;
  min-width: 132px;
  justify-content: center;
  padding: 0 20px;
  border: 0;
  border-radius: 999px;
  background: var(--stage);
  color: var(--ink);
  font-weight: 900;
  font-size: 16px;
  box-shadow: 0 4px 0 color-mix(in srgb, var(--stage) 55%, #262a45), 0 8px 18px color-mix(in srgb, var(--stage) 35%, transparent);
  transition: transform 0.15s, box-shadow 0.15s;
}
.play-btn:hover { transform: translateY(-1px); }
.play-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 color-mix(in srgb, var(--stage) 55%, #262a45); }
.play-btn svg { width: 20px; height: 20px; }
.play-btn .icon-pause { display: none; }
.play-btn.playing .icon-pause { display: block; }
.play-btn.playing .icon-play { display: none; }
.play-btn.hold { animation: nudge 1.4s ease-in-out infinite; }
@keyframes nudge { 50% { transform: scale(1.06); } }

.speed { display: inline-flex; flex: none; padding: 3px; border: 1px solid var(--line-strong); border-radius: 999px; background: var(--card); }
.speed button { min-width: 38px; padding: 5px 8px; border: 0; border-radius: 999px; background: none; color: var(--ink-soft); font-weight: 800; font-size: 13px; }
.speed button[aria-pressed="true"] { background: var(--ink); color: #fff; }

.timeline { position: relative; flex: 1; min-width: 120px; height: 24px; cursor: pointer; touch-action: none; }
.segments { position: absolute; left: 0; right: 0; top: 7px; display: flex; gap: 3px; height: 10px; }
.segment { position: relative; height: 100%; overflow: hidden; border-radius: 999px; background: color-mix(in srgb, var(--c) 25%, #fff); }
.segment span { position: absolute; inset: 0; width: 0; background: var(--c); border-radius: inherit; }
.thumb {
  position: absolute;
  top: 2px;
  left: 0;
  width: 20px;
  height: 20px;
  margin-left: -10px;
  border: 4px solid #fff;
  border-radius: 50%;
  background: var(--stage);
  box-shadow: 0 2px 6px rgba(38, 42, 69, 0.35);
  pointer-events: none;
}

.views {
  position: absolute;
  top: 12px;
  left: 12px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  z-index: 4;
}
.toggle {
  padding: 5px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.85);
  color: var(--ink-soft);
  font-size: 12.5px;
  font-weight: 800;
  box-shadow: 0 2px 6px rgba(38, 42, 69, 0.06);
  backdrop-filter: blur(6px);
}
.toggle::before { content: ""; display: inline-block; width: 9px; height: 9px; margin-right: 6px; border: 2px solid currentColor; border-radius: 50%; vertical-align: -1px; }
.toggle[aria-pressed="true"] { border-color: var(--teal); color: var(--ink); background: #e3f7f3; }
.toggle[aria-pressed="true"]::before { background: var(--teal); border-color: var(--teal); }
.toggle.plain::before { display: none; }
.toggle:hover { color: var(--ink); }
.quiz-btn { border: 2px solid var(--sun); background: #fff3c4; color: var(--ink); }
.quiz-btn::before { display: none; }
.quiz-btn:hover { background: #ffe99a; }

/* ---------------------------------------------------------------- organ card & quiz */
.organ-card, .quizbar {
  position: absolute;
  top: 14px;
  right: 14px;
  width: min(320px, calc(100% - 28px));
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
  z-index: 6;
}
.organ-card { border-top: 6px solid var(--c, var(--teal)); }
.organ-card h3 { margin: 0 0 4px; padding-right: 30px; font-family: var(--display); font-size: 22px; }
.organ-card p { margin: 0 0 8px; color: var(--ink-soft); }
.organ-card .organ-fact { color: var(--ink); font-size: 14px; }
.organ-tag { display: inline-block; margin-bottom: 6px; padding: 2px 8px; border-radius: 999px; background: #eef0f6; color: var(--ink-soft); font-size: 11px; font-weight: 800; }
.close { position: absolute; top: 8px; right: 10px; width: 30px; height: 30px; border: 0; border-radius: 50%; background: #f1f2f7; font-size: 20px; line-height: 1; }
.link-button { padding: 0; border: 0; background: none; color: var(--rose); font-weight: 800; text-decoration: underline; text-underline-offset: 3px; }

.quizbar { left: 50%; right: auto; width: min(560px, calc(100% - 28px)); transform: translateX(-50%); border-top: 6px solid var(--sun); text-align: center; }
.quiz-head { display: flex; justify-content: center; gap: 10px; color: #a87700; font-size: 13px; font-weight: 900; text-transform: uppercase; letter-spacing: 0.6px; }
.quiz-score { color: var(--ink); }
.quiz-question { margin: 6px 0; font-family: var(--display); font-size: 21px; line-height: 1.3; }
.quiz-feedback { min-height: 1.5em; margin: 0 0 8px; color: var(--ink-soft); font-weight: 800; }
.quiz-feedback.good { color: var(--good); }
.quiz-feedback.bad { color: var(--bad); }
.quiz-actions { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }

.btn {
  padding: 9px 18px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--card);
  font-weight: 800;
}
.btn:hover { background: #fff3c4; }
.btn.primary { border-color: transparent; background: var(--rose); color: #fff; box-shadow: 0 4px 0 #9e1f4d; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.primary:active { transform: translateY(3px); box-shadow: 0 1px 0 #9e1f4d; }
.btn.ghost { border-color: transparent; background: none; color: var(--ink-soft); }
.btn.big { padding: 13px 32px; font-size: 18px; }

/* ---------------------------------------------------------------- modals */
.modal {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: end center;
  padding: 16px;
  background: linear-gradient(180deg, rgba(255, 248, 236, 0) 30%, rgba(255, 248, 236, 0.85));
  z-index: 7;
}
.modal-card {
  width: min(620px, 100%);
  max-height: 100%;
  overflow-y: auto;
  padding: 22px 24px;
  border: 2px solid var(--ink);
  border-radius: 26px;
  background: var(--card);
  box-shadow: 0 8px 0 rgba(38, 42, 69, 0.12), 0 24px 60px rgba(38, 42, 69, 0.18);
  text-align: center;
}
.modal-card h2 { margin: 0 0 6px; font-family: var(--display); font-size: 30px; line-height: 1.15; }
.modal-card > p { margin: 0 0 14px; color: var(--ink-soft); }
.hint { margin: 14px 0 0 !important; color: var(--pencil) !important; font-size: 12.5px; }

.meals { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 18px; }
.meal {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 14px 10px;
  border: 2px solid var(--line-strong);
  border-radius: 20px;
  background: #fffaf2;
  transition: transform 0.15s, border-color 0.15s, background 0.15s;
}
.meal:hover { transform: translateY(-3px) rotate(-1deg); }
.meal[aria-pressed="true"] { border-color: var(--sun); background: #fff3c4; box-shadow: 0 4px 0 #e0a800; }
.meal .emoji { font-size: 44px; line-height: 1.1; }
.meal > span:last-child { display: flex; flex-direction: column; gap: 2px; }
.meal strong { font-size: 16px; }
.meal small { color: var(--ink-soft); font-size: 12.5px; line-height: 1.35; }

.done-sub { margin: 10px 0 6px !important; color: var(--ink) !important; font-weight: 800; }
.done-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; margin: 0 0 6px; padding: 0; list-style: none; }
.done-list li { padding: 8px; border: 2px solid color-mix(in srgb, var(--c) 50%, transparent); border-radius: 14px; background: color-mix(in srgb, var(--c) 12%, #fff); font-size: 13px; font-weight: 700; }
.done-list b { display: block; font-size: 19px; color: color-mix(in srgb, var(--c) 55%, #262a45); }
.done-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; margin-top: 16px; }

/* ---------------------------------------------------------------- story */
.story {
  grid-area: story;
  padding: 16px 18px 28px;
  border-left: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.7);
  overflow-y: auto;
}
.story h3 { margin: 18px 0 6px; color: var(--pencil); font-size: 12px; font-weight: 900; letter-spacing: 1.1px; text-transform: uppercase; }
.story p { margin: 0; }

.story-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.stop-no { color: var(--stage-ink); font-size: 12px; font-weight: 900; letter-spacing: 1px; text-transform: uppercase; }
.tags { display: flex; gap: 5px; flex-wrap: wrap; }
.tag { padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 800; cursor: help; }
.tag.mech { background: #dff3ff; color: #1b6a96; }
.tag.chem { background: #ecf8d2; color: #4d6b00; }
.tag.absorb { background: #fff3c4; color: #8a6200; }
.tag.bacteria { background: #efe5ff; color: #6234b8; }
.tag.move { background: #ffe8d1; color: #a0520a; }

.stage-name { margin: 6px 0 0; font-family: var(--display); font-size: 31px; line-height: 1.1; }
.headline { margin-top: 2px !important; color: var(--stage-ink); font-size: 16px; font-weight: 800; }

.food-card {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 10px 12px;
  align-items: center;
  margin-top: 14px;
  padding: 12px;
  border: 2px solid color-mix(in srgb, var(--stage) 40%, transparent);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
}
.food-swatch {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--food, #e4b79c);
  box-shadow: inset -6px -8px 14px rgba(0, 0, 0, 0.25), inset 5px 5px 10px rgba(255, 255, 255, 0.5), 0 3px 8px rgba(38, 42, 69, 0.15);
  transition: border-radius 0.8s, background 0.4s;
}
.food-swatch.solid { border-radius: 34% 66% 58% 42% / 45% 38% 62% 55%; animation: none; }
.food-swatch.mushy { border-radius: 48% 52% 50% 50% / 52% 48% 52% 48%; }
.food-swatch.thick, .food-swatch.liquid { animation: slosh 1.6s ease-in-out infinite; }
.food-swatch.paste { animation: slosh 3s ease-in-out infinite; }
.food-swatch.soft { border-radius: 40% 40% 45% 45% / 30% 30% 70% 70%; }
@keyframes slosh {
  0%, 100% { border-radius: 52% 48% 40% 60% / 56% 44% 56% 44%; }
  50% { border-radius: 40% 60% 58% 42% / 44% 58% 42% 56%; }
}
.food-info { display: flex; flex-direction: column; }
.food-info strong { font-size: 18px; line-height: 1.2; }
.food-state { color: var(--ink-soft); font-size: 13px; font-weight: 700; }
.mini-label { color: var(--pencil); font-size: 11px; font-weight: 800; letter-spacing: 0.5px; text-transform: uppercase; }
.mini-label output { color: var(--ink); font-size: 12px; }
.ph { grid-column: 1 / -1; }
.ph-bar { position: relative; height: 10px; margin: 4px 0 2px; border-radius: 999px; background: linear-gradient(90deg, #ff3b3b, #ff9f1a 22%, #ffe14d 38%, #5be36b 50%, #2ec4b6 64%, #3b82f6 80%, #7c3aed); }
.ph-marker { position: absolute; top: -5px; left: 50%; width: 8px; height: 20px; margin-left: -4px; border: 2px solid var(--ink); border-radius: 4px; background: #fff; transition: left 0.3s; }
.ph-scale { display: flex; justify-content: space-between; color: var(--pencil); font-size: 11px; font-weight: 700; }

.micro canvas { display: block; width: 100%; height: 170px; border: 2px solid var(--line); border-radius: var(--radius); }
.micro h3 span:last-child { color: var(--ink); letter-spacing: 0.3px; text-transform: none; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
.chips li { padding: 4px 11px; border-radius: 999px; background: color-mix(in srgb, var(--stage) 18%, #fff); border: 1px solid color-mix(in srgb, var(--stage) 50%, transparent); font-size: 13px; font-weight: 700; }

.fact, .think { margin-top: 16px; padding: 4px 14px 12px; border-radius: var(--radius); }
.fact { background: #fff6d6; border: 2px solid #ffe08a; }
.fact h3 { color: #a87700; }
.think { background: #e6f7f4; border: 2px solid #a9e4da; }
.think h3 { color: #0f7f75; }
.think .link-button { margin-top: 6px; color: #0f7f75; }
.think-answer { margin-top: 6px !important; padding-top: 6px; border-top: 2px dashed #a9e4da; }

.nutrient { margin-bottom: 9px; }
.nutrient-head { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; font-weight: 800; }
.nutrient-head small { color: var(--pencil); font-weight: 700; }
.nutrient-head output { color: var(--ink-soft); font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.nutrient-bar { position: relative; height: 10px; margin-top: 3px; border-radius: 999px; background: #eef0f6; overflow: hidden; }
.nutrient-bar span { position: absolute; top: 0; bottom: 0; left: 0; border-radius: inherit; transition: width 0.25s; }
.nutrient-bar .b { background: color-mix(in srgb, var(--c) 35%, #fff); }
.nutrient-bar .a { background: var(--c); }
.legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; color: var(--pencil); font-size: 11.5px; font-weight: 700; }
.legend .key { width: 18px; height: 8px; border-radius: 999px; }
.legend .key.broken { background: #ffeeb0; }
.legend .key.absorbed { margin-left: 8px; background: #f2b705; }

/* ---------------------------------------------------------------- smaller screens */
@media (max-width: 1180px) {
  .app { grid-template-columns: 200px minmax(0, 1fr) 330px; }
  .stage-name { font-size: 26px; }
}

@media (max-width: 920px) {
  html, body { height: auto; }
  .app {
    display: flex;
    flex-direction: column;
    height: auto;
    min-height: 100vh;
  }
  .topbar { position: sticky; top: 0; height: 56px; flex: none; gap: 10px; padding: 0 10px; }
  .brand p { display: none; }
  .brand h1 { font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .brand h1::after { display: none; }
  .home { padding: 6px 10px; font-size: 12px; }
  .meal-chip [data-i18n] { display: none; }
  .route { order: 1; flex-direction: row; align-items: stretch; padding: 8px 10px; border-right: 0; border-bottom: 1px solid var(--line); overflow-x: auto; overflow-y: hidden; }
  .panel-title { display: none; }
  .stops { display: flex; gap: 4px; }
  .stops::before { display: none; }
  .stop { grid-template-columns: 22px auto; gap: 6px; padding: 5px 8px; white-space: nowrap; }
  .stop .dot { width: 22px; height: 22px; font-size: 10px; }
  .stop .time { display: none; }
  .stop .name { font-size: 12.5px; }
  .clock { flex: none; margin: 0 0 0 4px; padding: 4px 10px; display: flex; flex-direction: column; justify-content: center; box-shadow: none; }
  .clock-value { margin: 0; font-size: 17px; }
  .clock-label { font-size: 9.5px; }
  .clock-note { display: none; }
  .stage { order: 2; flex: none; height: min(78vh, 720px); min-height: 520px; }
  .story { order: 3; border-left: 0; border-top: 1px solid var(--line); overflow: visible; }
  .caption { bottom: 128px; }
  .caption-text { font-size: 15px; }
  .dock { left: 8px; right: 8px; bottom: 8px; flex-wrap: wrap; justify-content: center; gap: 8px 10px; padding: 10px; border-radius: 24px; }
  .transport { flex-basis: 100%; justify-content: center; }
  .speed button { min-width: 30px; padding: 4px 6px; }
  .views { top: 8px; left: 8px; right: 8px; flex-direction: row; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
  .toggle { flex: none; }
  .meal { padding: 10px 6px; }
  .meal small, .hint { display: none; }
  .meal .emoji { font-size: 34px; }
  .modal-card h2 { font-size: 24px; }
  .modal-card > p { font-size: 14px; }
  .organ-card { top: auto; bottom: 140px; }
  .quizbar { top: 52px; }
}

@media (max-width: 480px) {
  .play-btn { min-width: 0; padding: 0 16px; }
  .icon-btn { width: 36px; height: 36px; }
  .speed button { min-width: 30px; padding: 4px 6px; }
  .modal-card { padding: 16px; }
  .home [data-i18n] { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .play-btn.hold, .food-swatch { animation: none !important; }
}
