/* System fonts keep the mobile build independent of external asset hosts. */

:root {
  --bg: #101117;
  --panel: rgba(27, 29, 39, 0.9);
  --panel-strong: #1d1f2a;
  --panel-soft: #242633;
  --line: rgba(255, 255, 255, 0.09);
  --text: #f7f7fb;
  --muted: #a6a8b4;
  --yellow: #ffd84b;
  --yellow-2: #ffb82e;
  --green: #58e39a;
  --red: #ff6b73;
  --blue: #70a7ff;
  --purple: #aa83ff;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html { color-scheme: dark; }

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 12% 2%, rgba(255, 216, 75, 0.08), transparent 27rem),
    radial-gradient(circle at 92% 32%, rgba(112, 167, 255, 0.08), transparent 30rem),
    var(--bg);
  color: var(--text);
  font-family: "Noto Sans SC", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input, select { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 3px solid rgba(255, 216, 75, 0.55);
  outline-offset: 2px;
}

.ambient {
  position: fixed;
  width: 28rem;
  height: 28rem;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.09;
  pointer-events: none;
  z-index: -1;
}
.ambient-a { top: -14rem; left: -7rem; background: var(--yellow); }
.ambient-b { right: -10rem; bottom: -12rem; background: var(--blue); }

.app-shell {
  width: min(1540px, calc(100% - 32px));
  margin: 0 auto;
  padding: 26px 0 38px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 24px;
  margin-bottom: 18px;
}

.eyebrow, .section-kicker {
  color: var(--yellow);
  font-family: "DM Sans", sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.18em;
}

.brand-line {
  display: flex;
  align-items: baseline;
  gap: 11px;
  margin-top: 4px;
}
.brand-line h1 {
  margin: 0;
  font-size: clamp(30px, 3.2vw, 48px);
  line-height: 1;
  letter-spacing: -0.055em;
  font-weight: 800;
}
.brand-line p {
  margin: 0;
  font-size: clamp(17px, 1.5vw, 23px);
  font-weight: 600;
  color: #d7d8e0;
}
.title-divider { color: #4e5060; font-size: 22px; }

.top-actions { display: flex; align-items: center; gap: 9px; }
.icon-button, .secondary-button, .primary-button, .demo-button {
  border: 1px solid var(--line);
  border-radius: 12px;
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}
.icon-button:hover, .secondary-button:hover, .primary-button:hover, .demo-button:hover { transform: translateY(-1px); }
.icon-button {
  width: 42px;
  height: 42px;
  background: rgba(255,255,255,0.045);
  font-weight: 800;
}
.secondary-button {
  min-height: 42px;
  padding: 0 16px;
  background: rgba(255,255,255,0.05);
  font-weight: 700;
}
.primary-button {
  min-height: 44px;
  padding: 0 20px;
  color: #17180f;
  background: linear-gradient(135deg, var(--yellow), var(--yellow-2));
  border-color: transparent;
  font-weight: 800;
}

.score-strip {
  display: grid;
  grid-template-columns: 1.15fr 1fr 1fr 1fr 1.5fr;
  overflow: hidden;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: rgba(27, 29, 39, 0.72);
  backdrop-filter: blur(14px);
  box-shadow: 0 14px 44px rgba(0,0,0,0.16);
}
.score-item {
  min-height: 74px;
  padding: 13px 20px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  border-right: 1px solid var(--line);
}
.score-item:last-child { border-right: 0; }
.score-item strong {
  font-family: "DM Sans", "Noto Sans SC", sans-serif;
  font-size: 24px;
  line-height: 1.15;
}
.score-item small { color: var(--muted); font-size: 12px; }
.score-label { color: var(--muted); font-size: 11px; margin-bottom: 4px; }
.score-primary { background: linear-gradient(135deg, rgba(255,216,75,0.18), rgba(255,184,46,0.04)); }
.score-primary strong { color: var(--yellow); font-size: 31px; }

.game-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.75fr) minmax(340px, 0.75fr);
  gap: 14px;
  align-items: stretch;
}
.stage-card, .coach-card {
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(15px);
}
.stage-card { padding: 18px; min-width: 0; }
.stage-head, .stage-foot, .guide-head, .log-head, .name-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
.stage-head { margin-bottom: 13px; }
.stage-head h2 { margin: 4px 0 0; font-size: 22px; }
.difficulty-wrap { display: flex; align-items: center; gap: 8px; }
.difficulty-wrap label { color: var(--muted); font-size: 12px; }
.difficulty-wrap select {
  height: 36px;
  padding: 0 32px 0 12px;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #242633;
}

.canvas-wrap {
  position: relative;
  overflow: hidden;
  width: 100%;
  aspect-ratio: 11 / 7;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 15px;
  background: #30333c;
}
#gameCanvas { display: block; width: 100%; height: 100%; }
.objective-pill {
  position: absolute;
  top: 13px;
  left: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid rgba(255,255,255,0.13);
  border-radius: 999px;
  background: rgba(15,16,21,0.76);
  backdrop-filter: blur(10px);
  font-size: 12px;
  font-weight: 600;
}
.objective-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 5px rgba(88,227,154,0.12); }
.stage-toast {
  position: absolute;
  left: 50%;
  bottom: 18px;
  max-width: calc(100% - 40px);
  padding: 10px 15px;
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 12px;
  background: rgba(13,14,19,0.88);
  opacity: 0;
  transform: translate(-50%, 12px);
  transition: 0.22s ease;
  pointer-events: none;
  text-align: center;
  font-size: 13px;
  font-weight: 700;
}
.stage-toast.visible { opacity: 1; transform: translate(-50%, 0); }
.stage-toast.danger { border-color: rgba(255,107,115,0.55); color: #ffd0d3; }
.stage-toast.success { border-color: rgba(88,227,154,0.55); color: #c9ffe2; }

.stage-foot { padding-top: 13px; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; color: var(--muted); font-size: 11px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.legend-target { background: var(--green); }
.legend-car { background: var(--yellow); }
.legend-obstacle { background: #89909e; }
.demo-button {
  min-height: 36px;
  padding: 0 13px;
  color: #101117;
  background: #f3f4f7;
  border-color: transparent;
  font-size: 12px;
  font-weight: 800;
}
.demo-button.active { background: var(--red); color: #fff; }

.coach-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}
.student-panel {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 14px;
  padding: 20px;
  border-bottom: 1px solid var(--line);
  background:
    radial-gradient(circle at 20% 15%, rgba(170,131,255,0.16), transparent 12rem),
    linear-gradient(145deg, rgba(255,255,255,0.03), transparent);
}
.avatar {
  position: relative;
  width: 88px;
  height: 92px;
  transform-origin: 50% 80%;
}
.avatar.reacting { animation: avatarReact 0.42s ease; }
.avatar.crashed { animation: avatarCrash 0.45s ease; }
.face {
  position: absolute;
  left: 16px;
  top: 17px;
  z-index: 2;
  width: 59px;
  height: 65px;
  border-radius: 47% 47% 45% 45%;
  background: linear-gradient(155deg, #ffe0c6, #efb895);
  box-shadow: inset -5px -5px 0 rgba(151,79,61,0.08);
}
.hair-back {
  position: absolute;
  left: 7px;
  top: 4px;
  width: 76px;
  height: 83px;
  border-radius: 47% 47% 36% 36%;
  background: linear-gradient(135deg, #35233f, #17121f);
}
.hair-front {
  position: absolute;
  left: 17px;
  top: 10px;
  z-index: 3;
  width: 57px;
  height: 26px;
  border-radius: 100% 20% 80% 30%;
  border-top: 13px solid #24172d;
  transform: rotate(-4deg);
}
.hair-pin { position: absolute; top: 16px; right: 7px; z-index: 4; color: var(--yellow); font-size: 18px; transform: rotate(18deg); }
.eye, .brow, .mouth, .blush { position: absolute; }
.eye { top: 29px; width: 7px; height: 9px; border-radius: 50%; background: #251c24; }
.eye-left { left: 14px; }
.eye-right { right: 14px; }
.brow { top: 21px; width: 13px; height: 4px; border-top: 2px solid rgba(50,30,37,0.72); border-radius: 50%; }
.brow-left { left: 10px; transform: rotate(-5deg); }
.brow-right { right: 10px; transform: rotate(5deg); }
.mouth { left: 24px; top: 46px; width: 13px; height: 6px; border-bottom: 2px solid #9c4e51; border-radius: 50%; }
.blush { top: 41px; width: 10px; height: 5px; border-radius: 50%; background: rgba(232,101,112,0.22); filter: blur(1px); }
.blush-left { left: 6px; }
.blush-right { right: 6px; }
.avatar.annoyed .brow-left { transform: rotate(15deg); }
.avatar.annoyed .brow-right { transform: rotate(-15deg); }
.avatar.annoyed .mouth { border-bottom: 0; border-top: 2px solid #9c4e51; top: 51px; }
.avatar.panicked .eye { height: 13px; width: 10px; }
.avatar.panicked .mouth { width: 14px; height: 12px; border: 2px solid #9c4e51; border-radius: 50%; top: 45px; }
.avatar.happy .mouth { height: 10px; border-bottom-width: 3px; }
@keyframes avatarReact { 0%,100%{transform:rotate(0)} 35%{transform:rotate(-4deg) scale(1.04)} 70%{transform:rotate(3deg)} }
@keyframes avatarCrash { 0%,100%{transform:translateX(0)} 20%{transform:translateX(-5px) rotate(-4deg)} 40%{transform:translateX(6px) rotate(5deg)} 65%{transform:translateX(-3px)} }

.student-copy { min-width: 0; }
.name-line strong { font-size: 14px; }
.status-badge {
  padding: 4px 8px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 9px;
  white-space: nowrap;
}
.status-badge.listening { color: #17180f; background: var(--yellow); border-color: transparent; }
.status-badge.thinking { color: #dacbff; border-color: rgba(170,131,255,0.4); background: rgba(170,131,255,0.1); }
.speech-bubble {
  position: relative;
  min-height: 61px;
  margin-top: 9px;
  padding: 11px 13px;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 6px 14px 14px 14px;
  background: rgba(255,255,255,0.055);
  color: #ededf2;
  font-size: 13px;
  line-height: 1.55;
}

.command-guide, .input-panel, .log-panel { padding: 16px 18px; border-bottom: 1px solid var(--line); }
.guide-head h3, .log-head h3 { margin: 0; font-size: 13px; }
.guide-head span, .log-head button { color: var(--muted); font-size: 10px; }
.chips { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-top: 10px; }
.chips button {
  min-height: 34px;
  padding: 6px 9px;
  color: #cfd0d8;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(255,255,255,0.035);
  cursor: pointer;
  text-align: left;
  font-size: 10px;
  transition: 0.16s ease;
}
.chips button:hover { color: var(--text); border-color: rgba(255,216,75,0.35); background: rgba(255,216,75,0.06); }

.mic-button {
  position: relative;
  display: grid;
  grid-template-columns: 42px 1fr auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 64px;
  padding: 10px 13px;
  overflow: hidden;
  border: 1px solid rgba(255,216,75,0.3);
  border-radius: 13px;
  background: linear-gradient(135deg, rgba(255,216,75,0.13), rgba(255,184,46,0.04));
  cursor: pointer;
  text-align: left;
}
.mic-button::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 12% 50%, rgba(255,216,75,0.18), transparent 9rem);
  opacity: 0;
  transition: 0.2s ease;
}
.mic-button:hover::after, .mic-button.listening::after { opacity: 1; }
.mic-button.listening { border-color: var(--yellow); box-shadow: 0 0 0 4px rgba(255,216,75,0.08); }
.mic-icon {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  color: #17180f;
  border-radius: 50%;
  background: var(--yellow);
  font-size: 13px;
}
.mic-copy { position: relative; z-index: 1; display: flex; flex-direction: column; }
.mic-copy strong { font-size: 12px; }
.mic-copy small { margin-top: 2px; color: var(--muted); font-size: 9px; }
.voice-bars { position: relative; z-index: 1; display: flex; align-items: center; gap: 3px; height: 24px; }
.voice-bars i { width: 3px; height: 7px; border-radius: 4px; background: var(--yellow); opacity: 0.55; }
.mic-button.listening .voice-bars i { animation: bar 0.72s ease-in-out infinite alternate; }
.mic-button.listening .voice-bars i:nth-child(2) { animation-delay: -0.34s; }
.mic-button.listening .voice-bars i:nth-child(3) { animation-delay: -0.12s; }
.mic-button.listening .voice-bars i:nth-child(4) { animation-delay: -0.52s; }
@keyframes bar { to { height: 21px; opacity: 1; } }

.text-command-row { display: grid; grid-template-columns: 1fr auto; gap: 7px; margin-top: 9px; }
.text-command-row input {
  min-width: 0;
  height: 40px;
  padding: 0 11px;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255,255,255,0.045);
  font-size: 11px;
}
.text-command-row input::placeholder { color: #777a89; }
.text-command-row button {
  min-width: 58px;
  border: 0;
  border-radius: 10px;
  color: #15160e;
  background: var(--yellow);
  cursor: pointer;
  font-size: 11px;
  font-weight: 800;
}
.ai-mode-row { margin-top: 10px; }
.toggle-label { display: flex; align-items: center; gap: 9px; cursor: pointer; }
.toggle-label input { position: absolute; opacity: 0; pointer-events: none; }
.toggle-ui {
  position: relative;
  flex: 0 0 auto;
  width: 34px;
  height: 20px;
  border-radius: 999px;
  background: #393b48;
  transition: 0.2s ease;
}
.toggle-ui::after {
  content: "";
  position: absolute;
  left: 3px;
  top: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #b9bbc5;
  transition: 0.2s ease;
}
.toggle-label input:checked + .toggle-ui { background: var(--purple); }
.toggle-label input:checked + .toggle-ui::after { transform: translateX(14px); background: white; }
.toggle-label > span:last-child { display: flex; flex-direction: column; }
.toggle-label strong { font-size: 10px; }
.toggle-label small { margin-top: 1px; color: var(--muted); font-size: 8px; line-height: 1.35; }

.log-panel { border-bottom: 0; flex: 1; min-height: 170px; display: flex; flex-direction: column; }
.log-head button { border: 0; background: transparent; cursor: pointer; }
.command-log {
  flex: 1;
  min-height: 124px;
  max-height: 238px;
  margin-top: 10px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #454755 transparent;
}
.log-empty { padding: 18px 0; color: #777a88; font-size: 10px; text-align: center; }
.log-entry { display: grid; grid-template-columns: 26px 1fr; gap: 8px; margin-bottom: 9px; }
.log-avatar {
  display: grid;
  place-items: center;
  width: 25px;
  height: 25px;
  border-radius: 8px;
  font-size: 10px;
  font-weight: 800;
}
.log-entry.user .log-avatar { color: #17180f; background: var(--yellow); }
.log-entry.student .log-avatar { background: rgba(170,131,255,0.18); color: #dacbff; }
.log-entry.system .log-avatar { background: rgba(112,167,255,0.16); color: #bdd4ff; }
.log-content { min-width: 0; padding-top: 2px; }
.log-content strong { display: block; margin-bottom: 2px; font-size: 9px; }
.log-content p { margin: 0; color: #c6c8d1; font-size: 10px; line-height: 1.42; word-break: break-word; }
.log-meta { display: block; margin-top: 3px; color: #747786; font-size: 8px; }

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 18px;
  visibility: hidden;
  opacity: 0;
  transition: 0.22s ease;
}
.modal.open { visibility: visible; opacity: 1; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(5,6,9,0.76); backdrop-filter: blur(9px); }
.modal-card {
  position: relative;
  z-index: 1;
  width: min(520px, 100%);
  padding: 28px;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 22px;
  background: #20222c;
  box-shadow: 0 30px 100px rgba(0,0,0,0.6);
  transform: translateY(10px) scale(0.98);
  transition: 0.22s ease;
}
.modal.open .modal-card { transform: translateY(0) scale(1); }
.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255,255,255,0.04);
  cursor: pointer;
  font-size: 22px;
}
.help-card h2 { margin: 7px 40px 20px 0; font-size: 26px; letter-spacing: -0.04em; }
.help-steps { display: grid; gap: 12px; }
.help-steps > div { display: grid; grid-template-columns: 42px 1fr; align-items: start; gap: 12px; padding: 13px; border: 1px solid var(--line); border-radius: 13px; background: rgba(255,255,255,0.025); }
.help-steps b { color: var(--yellow); font-family: "DM Sans"; font-size: 17px; }
.help-steps p { margin: 0; display: flex; flex-direction: column; }
.help-steps strong { font-size: 12px; }
.help-steps span { margin-top: 3px; color: var(--muted); font-size: 10px; line-height: 1.5; }
.tip-box { display: flex; flex-direction: column; margin-top: 13px; padding: 13px; border-left: 3px solid var(--purple); background: rgba(170,131,255,0.07); }
.tip-box strong { font-size: 11px; }
.tip-box span { margin-top: 3px; color: #c8c0db; font-size: 10px; line-height: 1.5; }
.modal-primary { width: 100%; margin-top: 17px; }

.result-card { text-align: center; }
.result-emoji { font-size: 42px; margin-bottom: 5px; }
.result-card h2 { margin: 6px 0 2px; font-size: 26px; }
.result-score { display: flex; justify-content: center; align-items: baseline; gap: 4px; margin: 14px 0; }
.result-score strong { color: var(--yellow); font-family: "DM Sans"; font-size: 68px; line-height: 0.9; }
.result-score span { color: var(--muted); font-weight: 700; }
.result-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.result-grid div { padding: 11px 8px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,0.03); }
.result-grid span { display: block; color: var(--muted); font-size: 9px; }
.result-grid strong { display: block; margin-top: 4px; font-family: "DM Sans"; font-size: 17px; }
.result-comment { min-height: 22px; margin: 16px 0; color: #d8d9df; font-size: 11px; }
.result-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }

@media (max-width: 1100px) {
  .game-grid { grid-template-columns: 1fr; }
  .coach-card { display: grid; grid-template-columns: 1fr 1fr; }
  .student-panel { grid-column: 1 / -1; }
  .command-guide { border-right: 1px solid var(--line); }
  .log-panel { grid-column: 1 / -1; min-height: 150px; }
  .command-log { max-height: 170px; }
}

@media (max-width: 760px) {
  .app-shell { width: min(100% - 20px, 1540px); padding-top: 16px; }
  .topbar { align-items: flex-start; }
  .brand-line { flex-wrap: wrap; gap: 6px 9px; }
  .brand-line h1 { font-size: 31px; }
  .brand-line p { font-size: 15px; }
  .title-divider { display: none; }
  .top-actions .secondary-button { display: none; }
  .score-strip { grid-template-columns: repeat(4, 1fr); }
  .score-item { min-height: 62px; padding: 9px 10px; }
  .score-item strong { font-size: 18px; }
  .score-primary strong { font-size: 23px; }
  .score-wide { grid-column: 1 / -1; border-top: 1px solid var(--line); }
  .score-item:nth-child(4) { border-right: 0; }
  .stage-card { padding: 12px; }
  .stage-head { align-items: flex-start; }
  .stage-head h2 { font-size: 18px; }
  .difficulty-wrap { flex-direction: column; align-items: flex-end; gap: 2px; }
  .difficulty-wrap select { max-width: 128px; font-size: 10px; }
  .objective-pill { font-size: 9px; max-width: calc(100% - 26px); }
  .stage-foot { align-items: flex-end; }
  .legend { max-width: 58%; gap: 7px; }
  .coach-card { display: flex; }
  .command-guide { border-right: 0; }
  .student-panel { grid-template-columns: 75px 1fr; padding: 15px; }
  .avatar { transform: scale(0.82); transform-origin: top left; width: 72px; height: 78px; }
  .avatar.reacting { animation: none; }
  .result-grid { grid-template-columns: 1fr; }
  .result-actions { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
}

/* Screen navigation keeps the lobby separate from the active lesson. */
[hidden] { display: none !important; }
.home-screen { padding: 30px 0; }
.home-hero { padding: clamp(26px, 6vw, 76px); border: 1px solid var(--line); border-radius: 26px; background: radial-gradient(ellipse at 85% 30%,rgba(170,131,255,.22),transparent 65%),var(--panel); }
.home-hero h2 { font-size: clamp(32px,5vw,66px); line-height: 1.2; margin: 20px 0; letter-spacing: -.04em; }
.home-hero p, .level-card p, .home-note { color: var(--muted); line-height: 1.8; }
.home-hero .primary-button { margin-top: 16px; min-height: 52px; }
.level-card { display: flex; align-items: center; gap: 28px; padding: 30px; margin-top: 20px; background: var(--panel); border: 1px solid var(--line); border-radius: 20px; }
.level-number { color: var(--yellow); font-size: 64px; font-weight: 800; }
.level-card h3 { font-size: 25px; margin: 8px 0; }
.level-actions { display: flex; gap: 10px; margin-left: auto; }
.home-note { text-align: center; font-size: 12px; }
.level-nav { display: flex; align-items: center; gap: 18px; margin-bottom: 18px; flex-wrap: wrap; }
.level-nav label { margin-left: auto; color: var(--muted); font-size: 13px; }
.level-nav select { background: var(--panel); color: var(--text); padding: 9px; border: 1px solid var(--line); border-radius: 9px; }
body[data-screen="home"] #resetButton { display: none; }
body[data-screen="demo"] .command-guide, body[data-screen="demo"] .input-panel, body[data-screen="demo"] .difficulty-wrap { display: none; }
@media(max-width:760px) { .level-card { flex-wrap: wrap; gap: 16px; padding: 22px; } .level-actions { margin-left: 0; width: 100%; } .level-actions button { flex: 1; } .level-nav label { margin-left: 0; } }

/* A lightweight diorama style adds depth without a WebGL dependency. */
body { background: #111a21; }
.app-shell { padding-top: max(18px, env(safe-area-inset-top)); padding-bottom: max(24px, env(safe-area-inset-bottom)); }
.home-hero { position: relative; overflow: hidden; background: radial-gradient(ellipse at 80% 20%,#294d55,transparent 70%),#192831; }
.hero-copy { position: relative; z-index: 2; max-width: 620px; }
.hero-caption { display: block; margin-top: 12px; color: #a5bbc1; font-size: 12px; }
.hero-art { position: absolute; right: 5%; top: 18%; width: 300px; height: 270px; transform: rotate(-12deg); opacity: .85; }
.hero-bay { position: absolute; width: 180px; height: 240px; border: 5px dashed #74dfb4; border-radius: 20px; transform: skewY(14deg); color: #74dfb4; text-align: center; font-size: 110px; background: #203f3c; box-shadow: 18px 25px 0 #102d30; }
.hero-car { position: absolute; left: 120px; top: 110px; width: 92px; height: 150px; border-radius: 24px; background: linear-gradient(90deg,#b98412,#ffdc60 45%,#efbc34); box-shadow: 9px 13px 0 #8c581a,22px 30px 18px #0c1e25; transform: rotate(44deg); border: 3px solid #ffe692; }
.hero-car::before,.hero-car::after { content:''; position:absolute; left:12px; right:12px; height:34px; border-radius:12px; background:linear-gradient(130deg,#9ce7e7,#214657); }
.hero-car::before { top:20px; } .hero-car::after { bottom:20px; }
.hero-car span { position:absolute; top:63px; width:100%; text-align:center; color:#65400f; font-weight:900; }
.hero-boom { position:absolute; right:0; top:50px; color:#15242a; padding:12px; border-radius:50% 50% 50% 0; background:#fff2cb; font-weight:900; transform:rotate(12deg); }
.hero-cone { position:absolute; bottom:-20px; left:15px; color:#ff9850; font-size:68px; text-shadow:8px 8px #824319; }
.canvas-wrap { background: radial-gradient(ellipse at 50% 40%,#3b5b62,#14262f); }
.stage-card { background:#1b2b34; } .coach-card { background:#19262f; }
.browser-notice { padding: 12px 15px; border-radius:12px; border:1px solid #627b88; color:#d9e7ed; background:#263f4c; font-size:12px; line-height:1.6; margin-bottom:12px; }
.demo-controls { display:flex; align-items:center; gap:12px; padding-top:14px; }
.demo-controls button { min-height:44px; } .demo-controls span { font-size:12px; color:#bed5d9; } .demo-controls progress { margin-left:auto; width:30%; height:7px; accent-color:var(--yellow); }
.comic-caption { position:absolute; top:28%; left:50%; pointer-events:none; opacity:0; transform:translate(-50%,0) scale(.6) rotate(-8deg); font-size:clamp(28px,5vw,64px); color:#ffe39d; text-shadow:3px 3px #773b32,-2px -2px #773b32,4px 7px #11212a; font-weight:900; transition:opacity .2s,transform .2s; white-space:nowrap; }
.comic-caption.visible { opacity:1; transform:translate(-50%,-12px) scale(1) rotate(-8deg); }
.log-panel summary { cursor:pointer; font-size:13px; font-weight:700; min-height:30px; }
.log-panel .log-head { margin-top:8px; } .log-panel .log-head h3 { display:none; }
.mic-button { touch-action:none; user-select:none; -webkit-user-select:none; -webkit-touch-callout:none; }
body:not([data-screen="demo"]) .demo-speed-control { display:none; }
body[data-screen="demo"] .score-strip { display:none; }
@media(min-width:1000px) { .hero-copy { max-width:65%; } }
@media(max-width:760px) {
  .app-shell { width:calc(100% - 24px); }
  .topbar { gap:8px; margin-bottom:12px; align-items:center; }
  .brand-line p { font-size:12px; } .brand-line h1 { font-size:27px; }
  .eyebrow { font-size:8px; letter-spacing:.1em; } .top-actions { gap:5px; } .icon-button { width:40px; height:40px; }
  .home-screen { padding:6px 0; } .home-hero { padding:240px 22px 26px; }
  .hero-art { top:0; right:calc(50% - 160px); transform:rotate(-12deg) scale(.72); transform-origin:center top; opacity:1; }
  .home-hero h2 { font-size:34px; margin:14px 0; } .home-hero p { font-size:14px; }
  .home-hero .primary-button { width:100%; font-size:15px; }
  .home-hero .section-kicker { font-size:9px; } .hero-caption { text-align:center; }
  .level-card { padding:18px; margin-top:12px; } .level-number { font-size:42px; } .level-card h3 { font-size:20px; }
  .level-card p { font-size:12px; margin:8px 0; } .level-actions button { padding:0 10px; min-height:48px; font-size:13px; }
  .level-nav { gap:8px; justify-content:space-between; margin-bottom:10px; } .level-nav strong { font-size:12px; } .level-nav label { width:100%; display:flex; align-items:center; gap:10px; }
  .score-strip { grid-template-columns:repeat(4,1fr); margin-bottom:10px; } .score-item { min-height:52px; padding:7px 10px; } .score-wide { flex-direction:row; justify-content:space-between; min-height:36px; align-items:center; } .score-wide .score-label { margin:0; }
  .game-grid { gap:10px; } .stage-card { padding:10px; } .stage-head h2 { font-size:17px; }
  .canvas-wrap { aspect-ratio: 6 / 7; } .objective-pill { font-size:11px; top:8px; left:8px; padding:0 9px; }
  .stage-toast { font-size:12px; max-width:95%; width:max-content; bottom:12px; padding:8px 10px; }
  .legend { font-size:10px; } .stage-foot { align-items:center; padding-top:10px; }
  .student-panel { padding:12px; gap:7px; } .speech-bubble { font-size:14px; line-height:1.6; min-height:0; } .name-line strong { font-size:13px; }
  .command-guide { padding:12px; } .chips button { font-size:12px; min-height:44px; }
  .input-panel { padding:12px; } .mic-button { min-height:62px; } .mic-copy strong { font-size:14px; } .mic-copy small { font-size:11px; }
  .text-command-row input { font-size:16px; height:44px; } .text-command-row button { font-size:14px; min-width:60px; }
  .log-panel { min-height:0; padding:12px; } .log-panel:not([open]) { display:block; } .log-content p { font-size:12px; } .log-content strong { font-size:11px; }
  .modal-card { padding:22px; } .result-card h2 { font-size:24px; } .result-card p { line-height:1.7; }
  .home-note { font-size:11px; }
}
@media(prefers-reduced-motion:reduce) { .comic-caption { transition:none; } }

/* Candy-colored toy-town theme; shared across the lobby, lesson and dialogs. */
:root {
  --bg: #fff6e7; --panel: #fffdf8; --panel-strong: #fff9ef; --panel-soft: #fff0df;
  --line: #e9d9c3; --text: #414b43; --muted: #6e7b6b;
  --yellow: #f6b947; --yellow-2: #ffd985; --green: #59ae83;
  --red: #dc706c; --blue: #80bcd0; --purple: #b99ace;
  --shadow: 0 9px 0 #eadbc450, 0 18px 40px #94795b10;
}
html { color-scheme: light; }
body { background: radial-gradient(ellipse at 12% 5%,#ffe5c480,transparent 60%),#fff6e7; }
.ambient { opacity:.14; } .brand-line p { color:#76876e; } .brand-line h1 { color:#487754; }
.eyebrow,.section-kicker { color:#947024; }
.title-divider { color:#bfa78b; }
.top-actions .icon-button { background:#fffdf8; box-shadow:0 3px 0 #e6d5be; }
.secondary-button { background:#fffdf7; border-color:#e3cfb5; color:#6c6653; box-shadow:0 3px 0 #eadbc6; }
.primary-button { color:#5c481e; background:linear-gradient(135deg,#ffe299,#ffc968); box-shadow:0 4px 0 #dca94d; border:1px solid #e6bb68; }
.home-hero { border:2px solid #e3ceaa; background:radial-gradient(ellipse at 80% 12%,#f4fbdf,transparent 70%),#fffdf5; box-shadow:var(--shadow); }
.hero-caption { color:#847153; } .hero-bay { background:#c1e7c5; border-color:#fffdf4; color:#fffdf4; box-shadow:18px 25px 0 #82b893,25px 33px 0 #e3c98b; }
.hero-car { border-color:#fff2bc; box-shadow:9px 13px 0 #c58b39,22px 30px 18px #56765325; }
.hero-boom { color:#95604d; background:#ffe8db; box-shadow:4px 4px 0 #dca48d; }
.hero-cone { color:#ef9980; text-shadow:6px 7px #c87965; }
.hero-tree { position:absolute; color:#72b682; text-shadow:6px 10px #438f67; font-size:88px; z-index:0; line-height:1; }
.tree-left { left:-68px; top:44px; transform:rotate(10deg); } .tree-right { right:-45px; bottom:-8px; transform:rotate(12deg) scale(.8); }
.hero-flower { position:absolute; color:#ed9da3; text-shadow:3px 3px #c97d77; font-size:44px; }
.flower-left { left:-30px; bottom:3px; } .flower-right { right:-7px; top:18px; font-size:30px; }
.hero-cloud { position:absolute; top:-40px; right:50px; color:#e3f3f7; font-size:85px; text-shadow:3px 5px #badbe1; }
.level-card { position:relative; background:#f3f8e9; border:2px solid #d3dec0; box-shadow:0 6px 0 #e4e7cf; }
.level-sticker { position:absolute; right:15px; top:12px; font-size:32px; transform:rotate(12deg); opacity:.8; }
.level-number { color:#78aa76; } .level-card p { color:#6d7d61; }
.level-actions { position:relative; z-index:1; } .home-note { color:#897c64; }
.score-strip { background:#fffdf8; box-shadow:0 4px 0 #eadcc6; } .score-primary { background:#fff0c5; } .score-primary strong { color:#a67223; }
.stage-card,.coach-card { background:#fffdf7; border:2px solid #e5d3b9; border-radius:24px; }
.stage-head h2 { color:#567756; }
.difficulty-wrap select,.level-nav select { color:#58624f; background:#f5f5e8; border-color:#d8dcc5; }
.canvas-wrap { background:#dcf0dc; border:2px solid #c8dfc2; border-radius:20px; }
.objective-pill { background:#fffef1e8; color:#4d7656; border-color:#c7dcb5; box-shadow:0 3px 0 #89b89c28; }
.objective-dot { background:#68b888; }
.stage-toast { color:#716247; background:#fff9eaf2; border-color:#e7cc9f; box-shadow:0 4px 0 #b3915b25; }
.stage-toast.danger { color:#ac554f; border-color:#e6a39c; background:#fff0e7f5; } .stage-toast.success { color:#427657; border-color:#98c5a6; background:#effbecf5; }
.legend-obstacle { background:#bfa1d0; } .demo-button { background:#d8efdb; color:#4c7658; border:1px solid #aad1ad; box-shadow:0 3px 0 #a4c7a6; }
.demo-button.active { background:#f4b5a4; color:#784c41; border-color:#df9684; box-shadow:0 3px 0 #d7907c; }
.student-panel { background:radial-gradient(circle at 15% 20%,#ffe6ec,transparent 70%),#fff4e7; }
.speech-bubble { background:#ffffffbd; color:#675446; border-color:#ecd1bb; box-shadow:0 3px 0 #f2dcc9; }
.status-badge { background:#fffdf7; color:#86715c; border-color:#e4cdb7; }
.status-badge.thinking { color:#84629a; border-color:#cbb5db; background:#f1eaf8; }
.chips button { color:#657551; background:#f5f7e9; border-color:#d9dec7; }
.chips button:hover { color:#426e50; border-color:#93bfa0; background:#eaf5e4; }
.mic-button { background:linear-gradient(135deg,#ffedbc,#fff6df); border-color:#e8c980; box-shadow:0 4px 0 #eddaaa; }
.mic-icon { color:#765722; background:#ffdb87; } .mic-copy small { color:#9a7c47; }
.voice-bars i { background:#bb8b38; }
.text-command-row input { color:#665941; background:#fffdf6; border-color:#e3d6bd; } .text-command-row input::placeholder { color:#a09076; }
.text-command-row button { color:#725220; background:#ffdc91; }
.toggle-ui { background:#ddd7c8; } .toggle-ui::after { background:#fffdf8; }
.log-empty,.log-meta { color:#9a8a74; } .log-content p { color:#77634f; } .log-content strong { color:#7b725d; }
.log-entry.user .log-avatar { color:#8b6128; background:#ffebbd; } .log-entry.student .log-avatar { color:#99657c; background:#fbe2e9; } .log-entry.system .log-avatar { color:#538791; background:#dceef0; }
.command-log { scrollbar-color:#d8cbb6 transparent; }
.modal-backdrop { background:#8c7f6366; } .modal-card { background:#fffaf0; border:2px solid #e5cba7; box-shadow:0 12px 0 #b7976b30,0 24px 60px #826b4d30; }
.help-steps>div { background:#faf3e6; } .tip-box { background:#f5eafa; color:#7f638e; } .tip-box span { color:#806e89; }
.result-grid div { background:#f4f5e7; } .result-comment { color:#8a685a; } .result-score strong { color:#c49336; }
.modal-close { background:#fff3df; } .demo-controls span { color:#6c855a; } .demo-controls progress { accent-color:#81b27c; }
.comic-caption { color:#fff4c7; text-shadow:3px 3px #bd7d68,-2px -2px #bd7d68,4px 7px #ddb597; }
.browser-notice { background:#f1f7e8; color:#607554; border-color:#c8d6b7; }
.face { background:linear-gradient(150deg,#ffe6c8,#f3c7a3); } .hair-back { background:linear-gradient(135deg,#9b6d5d,#6a483e); } .hair-front { border-top-color:#7d5548; }
.hair-pin { color:#ecac67; } .blush { background:#ed9ca877; }
button:focus-visible,input:focus-visible,select:focus-visible { outline-color:#609570; }
@media(min-width:1000px) { .hero-art { right:9%; } }
@media(max-width:760px) { .home-hero { padding-top:250px; } .hero-art { top:27px; right:calc(50% - 155px); } .level-sticker { font-size:26px; } .level-card h3 { font-size:19px; } .comic-caption { font-size:30px; } }

/* The student is a fictional, gender-neutral robot with expressive display eyes. */
.avatar .hair,.avatar .hair-pin,.avatar .blush,.avatar .brow { display:none; }
.avatar .face { left:10px; top:23px; width:68px; height:57px; border-radius:18px; background:linear-gradient(135deg,#e3efd9,#a1cabb); border:2px solid #83afa0; box-shadow:0 5px 0 #78a99c; }
.avatar .face::before { content:''; position:absolute; left:7px; right:7px; top:11px; height:24px; border-radius:10px; background:#eaf8f5; }
.avatar::before { content:''; position:absolute; top:6px; left:41px; height:19px; width:5px; border-radius:5px; background:#83afa0; }
.avatar::after { content:''; position:absolute; top:2px; left:36px; width:15px; height:15px; border-radius:50%; background:#f7cf77; border:2px solid #cda556; }
.avatar .eye { top:17px; background:#4e8276; width:8px; height:12px; border-radius:5px; }
.avatar .mouth { top:39px; left:26px; width:13px; border-color:#4e8276; }
.avatar.panicked .mouth { top:36px; left:26px; border-color:#4e8276; height:12px; }
.avatar.annoyed .mouth { top:43px; border-color:#4e8276; }

/* Continuous voice status stays separate from editable text commands. */
.voice-transcript { margin-top:12px; padding:9px 11px; color:#6a785c; background:#f4f7eb; border-radius:10px; font-size:12px; line-height:1.6; overflow-wrap:anywhere; }
.mic-button { touch-action:manipulation; }

/* In-scene dialogue distinguishes the coach from the student without voiceover. */
.stage-dialogue {
  position:absolute;
  z-index:3;
  width:min(310px,38%);
  padding:11px 14px 13px;
  border:1px solid #c5dac0;
  border-radius:16px;
  background:#fffef5f2;
  color:#4c6250;
  box-shadow:0 4px 0 #aec6a045,0 8px 22px #5f795b12;
  pointer-events:none;
  overflow-wrap:anywhere;
}
.stage-dialogue::after {
  content:"";
  position:absolute;
  bottom:-8px;
  left:28px;
  width:14px;
  height:14px;
  background:#fffef5;
  border-right:1px solid #c5dac0;
  border-bottom:1px solid #c5dac0;
  transform:rotate(45deg);
}
.stage-dialogue-ai { left:16px; top:58px; }
.stage-dialogue-coach { left:16px; bottom:30px; background:#fff4e7f5; border-color:#e5c99f; color:#785d35; box-shadow:0 4px 0 #e5c99f45,0 8px 22px #94754912; }
.stage-dialogue-coach::after { background:#fff4e7; border-color:#e5c99f; }
.dialogue-speaker { display:flex; align-items:center; gap:6px; font-size:10px; line-height:1.5; letter-spacing:.02em; }
.dialogue-speaker span { display:grid; place-items:center; min-width:22px; height:18px; padding:0 3px; border-radius:6px; background:#e6efda; color:#658055; font-size:9px; }
.stage-dialogue-coach .dialogue-speaker span { background:#ffe4bb; color:#95703c; font-size:14px; }
.stage-dialogue .speech-bubble,.stage-dialogue p {
  min-height:0;
  margin:6px 0 0;
  padding:0;
  border:0;
  border-radius:0;
  background:none;
  box-shadow:none;
  color:inherit;
  font-size:14px;
  font-weight:600;
  line-height:1.55;
}
.stage-dialogue.speaking { animation:dialogueAppear .22s ease-out; }
@keyframes dialogueAppear { from { opacity:.35; transform:translateY(5px) scale(.98); } to { opacity:1; transform:translateY(0) scale(1); } }
.student-caption { margin:9px 0 0; font-size:12px; line-height:1.65; color:#8a775f; }
body:not([data-screen="demo"]) .stage-dialogue-coach { display:none; }

/* Two explicit session controls keep the microphone open between commands. */
.voice-session-panel { margin-top:15px; padding:13px; border:1px solid #d9e0c4; border-radius:16px; background:#f5f8ee; }
.voice-session-heading { display:flex; justify-content:space-between; align-items:center; gap:12px; margin-bottom:10px; }
.voice-session-heading strong { font-size:12px; color:#567655; }
.voice-session-heading span { font-size:11px; color:#80906f; }
.voice-engine-row { display:flex; align-items:center; gap:10px; font-size:12px; color:#657c58; }
.voice-engine-row select { flex:1; min-width:0; padding:8px 10px; border:1px solid #d2ddc4; border-radius:10px; color:#52694d; background:#fffef6; font:inherit; }
.voice-engine-note { margin:8px 0 12px; font-size:11px; line-height:1.6; color:#7f8c70; }
.parking-rule-note { color:#697b5e; font-size:12px; line-height:1.7; }
.voice-session-actions { display:grid; grid-template-columns:minmax(0,1fr) auto; gap:10px; align-items:stretch; }
.voice-session-panel .mic-button { min-height:58px; grid-template-columns:36px minmax(0,1fr) auto; gap:8px; padding:8px 11px; }
.voice-session-panel .mic-icon { width:34px; height:34px; }
.voice-session-panel .mic-copy strong { font-size:14px; }
.voice-session-panel .mic-copy small { font-size:11px; }
.end-voice-button { min-height:58px; padding:8px 16px; border:1px solid #dcbaa7; border-radius:13px; background:#fff0e7; color:#9a6550; box-shadow:0 3px 0 #e8cdbd; cursor:pointer; font-size:13px; font-weight:700; }
.end-voice-button span { margin-right:4px; font-size:9px; }
.end-voice-button:hover:not(:disabled) { background:#ffe7da; }
.end-voice-button:disabled { color:#a6a792; background:#f0f1e8; border-color:#d9dbcc; box-shadow:none; cursor:default; }
.voice-session-panel .mic-button:disabled { cursor:default; }
.voice-session-panel .mic-button:disabled:not(.listening) { opacity:.6; }
.voice-session-panel .voice-transcript { margin:11px 0 0; padding:0 2px; background:none; color:#738166; font-size:12px; }
body[data-screen="demo"] .voice-session-panel { display:none; }
.input-panel .text-command-row { margin-top:0; }

@media(max-width:760px) {
  .stage-dialogue { width:calc(100% - 30px); padding:9px 11px 11px; border-radius:13px; }
  .stage-dialogue-ai { left:14px; top:auto; bottom:18px; }
  .stage-dialogue-coach { left:14px; top:54px; bottom:auto; }
  .stage-dialogue-coach::after { left:auto; right:28px; }
  .stage-dialogue .speech-bubble,.stage-dialogue p { font-size:13px; line-height:1.5; margin-top:4px; }
  .dialogue-speaker { font-size:10px; }
  .stage-toast { z-index:4; bottom:112px; }
  .voice-session-panel { margin-top:12px; padding:11px; }
  .voice-session-actions { gap:8px; }
  .voice-session-panel .mic-button { grid-template-columns:30px minmax(0,1fr); gap:7px; padding:8px; }
  .voice-session-panel .mic-icon { width:29px; height:29px; font-size:10px; }
  .voice-session-panel .voice-bars { display:none; }
  .voice-session-panel .mic-copy strong { font-size:14px; }
  .voice-session-panel .mic-copy small { font-size:10px; }
  .end-voice-button { padding:8px 11px; font-size:13px; }
  .voice-session-panel .voice-transcript { font-size:11px; }
}

.stage-dialogue-ai.panicked { border-color:#e5b398; background:#fff3e6f5; }
.stage-dialogue-ai.annoyed { border-color:#ccbdd6; }
.stage-dialogue-ai.happy { border-color:#9fcba8; background:#f4fbedf5; }
.log-entry.coach .log-avatar { color:#8d6b30; background:#ffe8c4; }
