:root {
  color-scheme: light;
  --ink: #243447;
  --muted: #65758a;
  --line: #dce8e0;
  --soft-line: #edf3ee;
  --bg: #f5faf5;
  --surface: #ffffff;
  --leaf: #6aaf67;
  --leaf-dark: #4a7a4a;
  --sun: #ffd84d;
  --sky: #3f8df3;
  --coral: #ff7d63;
  --violet: #7568e8;
  --mint: #dff7ea;
  --shadow: 0 18px 44px rgba(36, 52, 71, 0.13);
  --app-height: 100dvh;
  --app-width: 100vw;
  --bottom-safe: max(22px, env(safe-area-inset-bottom));
  --setup-control-height: 68px;
  --game-bubble-font-size: clamp(22px, 2.4vw, 30px);
  --game-bubble-mobile-font-size: clamp(21px, 5.4vw, 28px);
  --game-cta-font-size: clamp(26px, 3.4vw, 38px);
  --game-cta-mobile-font-size: clamp(24px, 6vw, 32px);
  --story-dialogue-font-size: clamp(36px, 4.8vw, 58px);
  --story-dialogue-mobile-font-size: clamp(30px, 7.6vw, 42px);
  --attention-pulse-duration: 0.9s;
}

/* Follow-up QA: stable trail practice bubble and unified numeric keypad panels. */
.trail-guide-page:has(.trail-guide-practice).story-scene-screen {
  --trail-practice-board-height: clamp(190px, 36dvh, 340px);
  display: grid;
  grid-template-columns: minmax(112px, 18vw) minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto;
  align-content: stretch;
  column-gap: clamp(14px, 2.4vw, 30px);
  row-gap: clamp(10px, 1.8dvh, 18px);
  padding: clamp(12px, 2dvh, 22px) clamp(18px, 3vw, 34px);
}

.trail-guide-page:has(.trail-guide-practice) .story-character-stage,
.trail-guide-page:has(.trail-guide-practice) .story-dialogue-box,
.trail-guide-page:has(.trail-guide-practice) .story-extra-content,
.trail-guide-page:has(.trail-guide-practice) .story-choice-row {
  position: static;
  inset: auto;
  transform: none;
}

.trail-guide-page:has(.trail-guide-practice) .story-character-stage {
  grid-column: 1;
  grid-row: 1;
  width: min(150px, 17vw);
  align-self: center;
  justify-self: end;
}

.trail-guide-page:has(.trail-guide-practice) .story-dialogue-box {
  grid-column: 2;
  grid-row: 1;
  width: min(820px, 100%);
  min-height: clamp(126px, 18dvh, 184px);
  max-height: clamp(126px, 18dvh, 184px);
  align-self: center;
  justify-self: start;
  overflow: visible;
  padding: clamp(16px, 2.4dvh, 26px) clamp(22px, 3vw, 36px);
}

.trail-guide-page:has(.trail-guide-practice) .story-dialogue-box::before,
.trail-guide-page:has(.trail-guide-practice) .story-dialogue-box::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 0;
  height: 0;
  pointer-events: none;
  transform: translateY(-50%);
}

.trail-guide-page:has(.trail-guide-practice) .story-dialogue-box::before {
  left: -18px;
  border-top: 14px solid transparent;
  border-bottom: 14px solid transparent;
  border-right: 18px solid #d4c0a0;
}

.trail-guide-page:has(.trail-guide-practice) .story-dialogue-box::after {
  left: -14px;
  border-top: 11px solid transparent;
  border-bottom: 11px solid transparent;
  border-right: 15px solid var(--story-dialog-fill);
}

.trail-guide-page:has(.trail-guide-practice) .story-dialogue-text {
  font-size: clamp(24px, 2.6vw, 36px);
  line-height: 1.16;
}

.trail-guide-page:has(.trail-guide-practice) .story-extra-content {
  grid-column: 1 / -1;
  grid-row: 2;
  width: min(860px, 100%);
  min-height: 0;
  align-self: stretch;
  justify-self: center;
}

.trail-guide-page:has(.trail-guide-practice) .trail-guide-practice {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  width: 100%;
  height: 100%;
  min-height: 0;
  gap: clamp(8px, 1.2dvh, 12px);
}

.trail-guide-page:has(.trail-guide-practice) .trail-guide-board {
  width: 100%;
  height: min(var(--trail-practice-board-height), 100%);
  min-height: clamp(170px, 28dvh, 250px);
  max-height: 100%;
  aspect-ratio: auto;
}

.trail-guide-page:has(.trail-guide-practice) .trail-guide-practice strong {
  min-height: 1.4em;
  text-align: center;
  font-size: clamp(18px, 2vw, 24px);
  line-height: 1.28;
}

.trail-guide-page:has(.trail-guide-practice) .story-choice-row {
  grid-column: 1 / -1;
  grid-row: 3;
  align-self: end;
  justify-self: center;
}

.trail-guide-page .story-character-wrap .story-character,
.trail-guide-page .story-character-wrap .character-container,
.trail-guide-page .story-next-triangle {
  animation: none !important;
}

.digit-page.ready.keypad-split-page,
.serial-page.keypad-split-page,
.orientation-number-page.keypad-split-page {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto auto;
  align-content: center;
  justify-items: center;
  width: min(720px, calc(100vw - 40px));
  max-height: calc(100dvh - 150px);
  margin: 0 auto;
  padding: clamp(20px, 3dvh, 34px);
  gap: clamp(18px, 2.8dvh, 28px);
  overflow: visible;
  border: 3px solid #d8e6dc;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 10px 0 #d4e0d7, 0 22px 46px rgba(31, 95, 61, 0.16);
}

.digit-page.ready.keypad-split-page .keypad-question-panel,
.serial-page.keypad-split-page .keypad-question-panel,
.orientation-number-page.keypad-split-page .keypad-question-panel,
.digit-page.ready.keypad-split-page .keypad-panel,
.serial-page.keypad-split-page .keypad-panel,
.orientation-number-page.keypad-split-page .keypad-panel {
  width: 100%;
  height: auto;
  min-height: 0;
  padding: 0;
  align-content: center;
  justify-items: center;
  background: transparent;
  box-shadow: none;
}

.digit-page.ready.keypad-split-page .keypad-panel .keypad,
.serial-page.keypad-split-page .keypad-panel .keypad,
.orientation-number-page.keypad-split-page .keypad-panel .keypad {
  width: min(520px, 100%);
  height: clamp(300px, 43dvh, 420px);
  max-width: 520px;
  max-height: 420px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(4, minmax(0, 1fr));
  grid-auto-rows: minmax(0, 1fr);
  gap: clamp(10px, 1.8vw, 16px);
}

.digit-page.ready.keypad-split-page .keypad-panel .keypad button,
.serial-page.keypad-split-page .keypad-panel .keypad button,
.orientation-number-page.keypad-split-page .keypad-panel .keypad button,
.digit-page.ready.keypad-split-page .keypad-panel .keypad-spacer,
.serial-page.keypad-split-page .keypad-panel .keypad-spacer,
.orientation-number-page.keypad-split-page .keypad-panel .keypad-spacer {
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
}

.digit-page.ready.keypad-split-page .keypad-delete,
.serial-page.keypad-split-page .keypad-delete,
.orientation-number-page.keypad-split-page .keypad-delete {
  font-size: clamp(22px, 3vw, 32px);
  font-weight: 1000;
  color: #7b332b;
  border-color: #efc7bd;
  background: #fff5f1;
  box-shadow: 0 5px 0 #e1b5aa;
}

.answer-square-row.digit-answer-squares,
.year-digit-row,
.date-input-pair {
  width: min(560px, 100%);
  max-width: 100%;
  justify-content: center;
  gap: clamp(14px, 2.4vw, 24px);
}

.answer-square-row .answer-square,
.digit-answer-squares .answer-square,
.year-digit-row .year-digit-box,
.orientation-answer-square {
  width: clamp(62px, 9vw, 86px);
  min-width: clamp(62px, 9vw, 86px);
  height: clamp(62px, 9vw, 86px);
  font-size: clamp(30px, 4.4vw, 44px);
}

.serial-page .serial-display,
.orientation-answer-box {
  width: min(460px, 100%);
  min-height: clamp(78px, 11dvh, 106px);
  font-size: clamp(30px, 4vw, 46px);
}

.date-input-box {
  width: clamp(110px, 18vw, 150px);
  min-height: clamp(76px, 11dvh, 100px);
}

@media (max-width: 640px) {
  .trail-guide-page:has(.trail-guide-practice).story-scene-screen {
    grid-template-columns: minmax(86px, 26vw) minmax(0, 1fr);
    column-gap: 12px;
    padding-inline: 12px;
  }

  .trail-guide-page:has(.trail-guide-practice) .story-character-stage {
    width: min(104px, 28vw);
  }

  .trail-guide-page:has(.trail-guide-practice) .story-dialogue-box {
    min-height: 112px;
    max-height: 148px;
    padding: 12px 16px;
  }

  .digit-page.ready.keypad-split-page,
  .serial-page.keypad-split-page,
  .orientation-number-page.keypad-split-page {
    width: min(540px, calc(100vw - 24px));
    max-height: calc(100dvh - 124px);
    padding: clamp(14px, 2.4dvh, 22px);
  }

  .digit-page.ready.keypad-split-page .keypad-panel .keypad,
  .serial-page.keypad-split-page .keypad-panel .keypad,
  .orientation-number-page.keypad-split-page .keypad-panel .keypad {
    height: clamp(284px, 42dvh, 360px);
  }
}

* {
  box-sizing: border-box;
}

html,
body,
#app {
  width: 100%;
  height: var(--app-height);
  min-height: 0;
  max-height: var(--app-height);
  overflow: hidden;
  overscroll-behavior-x: none;
}

body {
  margin: 0;
  overflow: hidden;
  background:
    linear-gradient(0deg, rgba(255, 255, 255, 0.44), rgba(255, 255, 255, 0.44)),
    repeating-linear-gradient(90deg, rgba(34, 169, 107, 0.07) 0 1px, transparent 1px 56px),
    repeating-linear-gradient(0deg, rgba(63, 141, 243, 0.06) 0 1px, transparent 1px 56px),
    var(--bg);
  color: var(--ink);
  font-family:
    Inter, "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 20px;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
  touch-action: manipulation;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.46;
}

h1,
h2,
h3,
h4,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 56px;
  line-height: 1.05;
}

h2 {
  margin-bottom: 0;
  font-size: 34px;
  line-height: 1.14;
}

h3 {
  margin-bottom: 12px;
  font-size: 34px;
  line-height: 1.12;
}

h4 {
  margin-bottom: 16px;
  font-size: 34px;
  line-height: 1.2;
}

.setup-screen {
  position: relative;
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
  overflow: hidden;
  overscroll-behavior-x: none;
  padding: 28px;
  background-color: #FDFBF7;
}

.setup-screen::before,
.setup-screen::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  filter: blur(100px);
  will-change: transform, opacity;
}

.setup-screen::before {
  width: 74vmin; height: 74vmin;
  top: -20%; left: -14%;
  background: radial-gradient(circle, rgba(170,220,195,0.78) 0%, rgba(170,220,195,0.30) 50%, transparent 72%);
  animation: ambientGlowA 8s ease-in-out infinite;
}

.setup-screen::after {
  width: 60vmin; height: 60vmin;
  bottom: -6%; right: -4%;
  background: radial-gradient(circle, rgba(255,238,188,0.70) 0%, rgba(255,238,188,0.24) 50%, transparent 72%);
  animation: ambientGlowB 10s ease-in-out infinite;
}

@keyframes ambientGlowA {
  0%,100% { transform: scale(0.92); opacity: 0.65; }
  50%     { transform: scale(1.12); opacity: 1; }
}
@keyframes ambientGlowB {
  0%,100% { transform: scale(0.88); opacity: 0.55; }
  50%     { transform: scale(1.15); opacity: 1; }
}

.floating-stars {
  position: absolute;
  inset: 0;
  display: none;
  pointer-events: none;
}

.floating-stars i {
  position: absolute;
  width: 32px;
  height: 32px;
  background: var(--sun);
  clip-path: polygon(50% 0, 61% 34%, 96% 35%, 68% 56%, 79% 91%, 50% 70%, 21% 91%, 32% 56%, 4% 35%, 39% 34%);
  opacity: 0.55;
  animation: twinkle 2.4s ease-in-out infinite;
}

.floating-stars i:nth-child(1) {
  left: 10%;
  top: 16%;
}

.floating-stars i:nth-child(2) {
  right: 12%;
  top: 20%;
  background: var(--coral);
  animation-delay: 0.45s;
}

.floating-stars i:nth-child(3) {
  right: 18%;
  bottom: 14%;
  background: var(--sky);
  animation-delay: 0.8s;
}

.setup-panel {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(250px, 0.75fr);
  gap: clamp(26px, 4vw, 54px);
  align-items: center;
  width: min(1100px, 94vw);
  padding: clamp(28px, 4dvh, 42px) clamp(34px, 5vw, 60px);
  border: 1.5px solid rgba(255,255,255,0.55);
  border-radius: 20px;
  background: rgba(255,255,255,0.62);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 8px 40px rgba(120,140,130,0.10), 0 2px 8px rgba(120,140,130,0.06);
}

.brand-row,
.page-header,
.task-badge-row,
.task-footer,
.control-row,
.admin-toolbar,
.drawer-brand,
.drawer-task,
.domain-row,
.admin-row,
.audio-visual,
.results-actions {
  display: flex;
  align-items: center;
}

.brand-row {
  gap: 18px;
  margin-bottom: clamp(22px, 3dvh, 30px);
}

.logo-image {
  width: 104px;
  height: 104px;
  object-fit: contain;
  flex: 0 0 auto;
}

.eyebrow {
  margin-bottom: 5px;
  color: var(--leaf-dark);
  font-size: 16px;
  font-weight: 850;
}

.setup-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-auto-rows: minmax(0, auto);
  gap: 15px;
}

.setup-left {
  min-width: 0;
}

.setup-play-zone {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 20px;
  min-height: 100%;
}

.play-orbit {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.play-orbit i {
  position: absolute;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  background: var(--sun);
  box-shadow: 0 8px 18px rgba(36, 52, 71, 0.08);
  animation: floaty 2.8s ease-in-out infinite;
}

.play-orbit i:nth-child(1) {
  left: 10%;
  top: 18%;
}

.play-orbit i:nth-child(2) {
  right: 8%;
  top: 28%;
  background: var(--sky);
  animation-delay: 0.35s;
}

.play-orbit i:nth-child(3) {
  right: 20%;
  bottom: 12%;
  background: var(--coral);
  animation-delay: 0.7s;
}

.field {
  display: grid;
  gap: 10px;
  color: var(--ink);
  font-size: 22px;
  font-weight: 900;
}

.field > span {
  color: var(--muted);
  font-size: 20px;
  font-weight: 900;
  padding-left: 4px;
}

.field input,
.field select,
.transcript-input {
  width: 100%;
  min-width: 0;
  border: 3px solid var(--line);
  border-left: 5px solid var(--leaf);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.field input,
.field select {
  height: var(--setup-control-height);
  min-height: var(--setup-control-height);
  padding: 0 18px;
  font-size: 24px;
  font-weight: 900;
}

.field.invalid input,
.field.invalid select,
.field.invalid .segment-option {
  border-color: #ef4c3f;
  border-left-color: #ef4c3f;
  background: #fff3f0;
  box-shadow: 0 0 0 4px rgba(239, 76, 63, 0.14);
}

.field input:focus,
.field select:focus,
.transcript-input:focus {
  border-color: var(--leaf);
  border-left-color: var(--leaf-dark);
  box-shadow: 0 0 0 5px rgba(34, 169, 107, 0.18);
}

.segmented-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-rows: var(--setup-control-height);
  gap: 12px;
}

.edu-segment-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.segment-option {
  height: var(--setup-control-height);
  min-height: 0;
  border: 2.5px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  font-size: 22px;
  font-weight: 950;
  box-shadow: 0 4px 0 #cddbd2;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}

.segment-option:hover:not(.picked) {
  border-color: var(--leaf);
  background: var(--mint);
}

.segment-option.picked {
  border-color: var(--leaf);
  background: var(--leaf);
  color: #fff;
  box-shadow: 0 4px 0 var(--leaf-dark);
}

.voice-setup-row {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 35px;
}

.setup-age-note {
  margin: 16px 0 0;
  color: var(--leaf-dark);
  font-size: 18px;
  font-weight: 850;
  text-align: center;
}

.setup-age-note.warning {
  color: #d7392f;
}

.setup-voice-button {
  z-index: 2;
  min-height: 66px;
  padding: 18px 42px;
  border: 3px solid var(--leaf);
  border-radius: 999px;
  background: #fff;
  color: var(--leaf);
  font-size: 26px;
  font-weight: 950;
  box-shadow: 0 6px 18px rgba(34, 169, 107, 0.12);
  transition: all 0.2s;
}

.setup-voice-button:hover {
  background: var(--leaf);
  color: #fff;
  transform: translateY(-2px);
}

.setup-voice-button.recording {
  border-color: #ff4757;
  background: #ff4757;
  color: #fff;
  animation: pulseGreen var(--attention-pulse-duration) ease-in-out infinite;
}

.setup-voice-button.transcribing {
  border-color: #cddbd2;
  background: #f4f7f5;
  color: #758393;
  box-shadow: none;
  cursor: not-allowed;
}

.encouragement-toast {
  position: fixed;
  bottom: 12%;
  left: 50%;
  z-index: 10000;
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: min(92vw, 520px);
  padding: clamp(12px, 2vh, 20px) clamp(22px, 4vw, 42px);
  border: 3px solid var(--leaf);
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 14px 36px rgba(34, 169, 107, 0.24);
  color: var(--leaf-dark);
  font-size: clamp(24px, 3vw, 32px);
  font-weight: 950;
  line-height: 1.1;
  pointer-events: none;
  transform: translateX(-50%);
  animation: toastInOut 2.6s cubic-bezier(0.18, 0.89, 0.32, 1.28) forwards;
}

.encouragement-toast .emoji {
  font-size: clamp(28px, 3.4vw, 38px);
}

.primary,
.secondary,
.confirm-button,
.utility-button,
.ghost,
.option,
.keypad button,
.drawer-item,
.drawer-hearing-link,
.drawer-section-toggle,
.drawer-task,
.admin-row,
.tap-button {
  border-radius: 12px;
  min-height: 46px;
  transition:
    transform 0.16s ease,
    box-shadow 0.16s ease,
    border-color 0.16s ease,
    background 0.16s ease;
}

.primary,
.secondary,
.confirm-button,
.tap-button {
  padding: 12px 20px;
  color: #fff;
  font-weight: 900;
}

.primary {
  background: var(--leaf);
  box-shadow: 0 5px 0 var(--leaf-dark);
}

.secondary {
  background: var(--sky);
  box-shadow: 0 5px 0 #2167bf;
}

.confirm-button {
  min-width: clamp(138px, 18vw, 190px);
  min-height: clamp(58px, 8dvh, 72px);
  border-radius: 999px;
  background: linear-gradient(135deg, #6aaf67, #5b8c5a);
  box-shadow: 0 5px 0 #4a7a4a;
  color: #fff;
  font-size: clamp(22px, 2.5vw, 28px);
}

.confirm-button.answer-ready {
  animation: pulseGreen var(--attention-pulse-duration) ease-in-out infinite;
}

.confirm-button.attention-nudge {
  animation: confirmNudge var(--attention-pulse-duration) ease-in-out infinite;
}

.utility-button {
  min-width: clamp(108px, 14vw, 150px);
  min-height: clamp(52px, 7dvh, 66px);
  padding: 10px 18px;
  border: 2px solid var(--line);
  border-radius: 999px;
  background: #ffffff;
  color: var(--ink);
  font-size: clamp(20px, 2.1vw, 24px);
  font-weight: 950;
  box-shadow: 0 4px 0 #cddbd2;
}

.replay-button {
  color: #1a6fba;
  border-color: #bad3eb;
  background: #f0f7ff;
  box-shadow: 0 4px 0 #bad3eb;
}

.ghost {
  padding: 11px 17px;
  border: 2px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-weight: 850;
}

.big-button {
  min-width: 178px;
  min-height: 76px;
  font-size: 28px;
}

.setup-start-button {
  position: relative;
  z-index: 1;
  display: grid;
  width: clamp(190px, 22vw, 280px);
  height: clamp(190px, 22vw, 280px);
  min-height: 0;
  place-items: center;
  align-content: center;
  border: 8px solid #e9fff1;
  border-radius: 999px;
  background: #5b8c5a;
  box-shadow:
    0 10px 0 #0f5f35,
    0 24px 42px rgba(18,122,73,0.24);
  color: #fff;
  text-align: center;
  text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.setup-start-button span {
  display: block;
  font-size: clamp(40px, 5vw, 62px);
  font-weight: 1000;
  line-height: 0.98;
  color: #fff;
}

.setup-start-button small {
  display: block;
  margin-top: 4px;
  font-size: clamp(40px, 5vw, 62px);
  font-weight: 1000;
  line-height: 0.98;
}

.primary:hover,
.secondary:hover,
.confirm-button:hover,
.utility-button:hover,
.ghost:hover,
.option:hover,
.keypad button:hover,
.drawer-item:hover,
.drawer-hearing-link:hover,
.drawer-section-toggle:hover,
.drawer-task:hover,
.admin-row:hover {
  transform: translateY(-1px);
}

.primary:active,
.secondary:active,
.confirm-button:active,
.tap-button:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.22);
}

.app-shell {
  position: relative;
  width: 100%;
  height: var(--app-height);
  max-height: var(--app-height);
  overflow: hidden;
  overscroll-behavior-x: none;
}

.app-shell::before,
.app-shell::after {
  content: "";
  position: absolute;
  z-index: 0;
  pointer-events: none;
}

.app-shell::before {
  left: 86px;
  bottom: 30px;
  width: 104px;
  height: 44px;
  border-radius: 999px;
  background: #e9f7ff;
  box-shadow: 34px 12px 0 #e9f7ff, -24px 14px 0 #e9f7ff;
  opacity: 0.68;
}

.app-shell::after {
  right: 110px;
  bottom: 84px;
  width: 42px;
  height: 42px;
  background: var(--sun);
  clip-path: polygon(50% 0, 61% 34%, 96% 35%, 68% 56%, 79% 91%, 50% 70%, 21% 91%, 32% 56%, 4% 35%, 39% 34%);
  opacity: 0.55;
  animation: twinkle 2.4s ease-in-out infinite;
}

.page-shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-rows: clamp(64px, 10dvh, 98px) minmax(0, 1fr);
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior-x: none;
}

.page-header {
  justify-content: space-between;
  gap: 18px;
  padding: clamp(8px, 1.8dvh, 14px) clamp(16px, 2.5vw, 24px);
  border-bottom: 1px solid rgba(36, 52, 71, 0.08);
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(10px);
}

.icon-button {
  width: 52px;
  height: 52px;
  flex: 0 0 auto;
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  font-size: 28px;
  font-weight: 900;
  box-shadow: 0 8px 18px rgba(36, 52, 71, 0.1);
}

.header-title {
  flex: 1 1 auto;
  min-width: 0;
}

.header-title h2 {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-prompt {
  display: -webkit-box;
  max-width: 920px;
  margin: 4px 0 0;
  overflow: hidden;
  color: #3e4d5e;
  font-size: clamp(16px, 2.1vw, 22px);
  font-weight: 820;
  line-height: 1.34;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.header-progress {
  width: 190px;
  flex: 0 0 auto;
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-weight: 900;
  text-align: right;
}

.progress-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #dfe9e3;
}

.progress-track span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--leaf), var(--sun));
}

.hidden-drawer {
  position: fixed;
  inset: 0;
  z-index: 20;
  pointer-events: none;
}

.drawer-mask {
  position: absolute;
  inset: 0;
  opacity: 0;
  background: rgba(20, 31, 43, 0.24);
  transition: opacity 0.18s ease;
}

.drawer-panel {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: min(360px, 86vw);
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 100dvh;
  padding: 22px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  border-right: 2px solid var(--soft-line);
  background: #fff;
  box-shadow: var(--shadow);
  transform: translateX(-104%);
  transition: transform 0.22s ease;
  -webkit-overflow-scrolling: touch;
}

.drawer-panel > * {
  flex-shrink: 0;
}

.hidden-drawer.open {
  pointer-events: auto;
}

.hidden-drawer.open .drawer-mask {
  opacity: 1;
}

.hidden-drawer.open .drawer-panel {
  transform: translateX(0);
}

.drawer-brand {
  gap: 12px;
  margin-bottom: 8px;
}

.drawer-logo {
  width: 58px;
  height: 58px;
  border: 2px solid #e3efe5;
  border-radius: 20px;
  object-fit: contain;
  background: #fff;
}

.drawer-brand div {
  display: grid;
  min-width: 0;
}

.drawer-brand strong {
  font-size: 22px;
}

.drawer-brand span {
  overflow: hidden;
  color: var(--muted);
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.drawer-item {
  width: 100%;
  padding: 0 16px;
  border: 2px solid var(--soft-line);
  background: #fff;
  color: var(--ink);
  font-weight: 900;
  text-align: left;
}

.drawer-hearing-link,
.drawer-section-toggle {
  width: 100%;
  min-height: 62px;
  padding: 0 16px;
  border: 2px solid var(--soft-line);
  border-radius: 12px;
  font-weight: 950;
  text-align: left;
}

.drawer-hearing-link {
  background: var(--mint);
  color: var(--leaf-dark);
}

.drawer-hearing-link.active {
  border-color: var(--leaf);
  background: #dff5e8;
}

.drawer-section-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: #fff;
  color: var(--ink);
}

.drawer-section-toggle em {
  color: var(--leaf-dark);
  font-size: 16px;
  font-style: normal;
}

.drawer-section-toggle::after {
  content: "⌄";
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  transition: transform 0.16s ease;
}

.drawer-section-toggle.open::after {
  transform: rotate(180deg);
}

.drawer-task-list {
  display: none;
  align-content: start;
  gap: 8px;
  overflow: visible;
  padding: 0 2px 18px 0;
}

.drawer-task-list.open {
  display: grid;
}

.drawer-spacer {
  flex: 1 1 auto;
  min-height: 18px;
}

.drawer-task {
  justify-content: flex-start;
  gap: 10px;
  width: 100%;
  padding: 9px 11px;
  border: 2px solid transparent;
  background: #f8fbf8;
  color: var(--ink);
  text-align: left;
}

.drawer-task span {
  display: grid;
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 999px;
  background: #e8efe9;
  color: var(--muted);
  font-size: 16px;
  font-weight: 900;
}

.drawer-task strong {
  overflow: hidden;
  font-size: 16px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.drawer-task.active {
  border-color: var(--leaf);
  background: #f0fbf4;
}

.drawer-task.done span {
  background: var(--leaf);
  color: #fff;
}

.admin-password-dialog {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 24px;
}

.admin-password-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 31, 43, 0.48);
}

.admin-password-panel {
  position: relative;
  z-index: 1;
  display: grid;
  width: min(560px, 94vw);
  gap: 18px;
  padding: clamp(22px, 5vw, 34px);
  border: 3px solid var(--line);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 18px 48px rgba(20, 31, 43, 0.24);
}

.admin-password-panel h3 {
  margin: 0;
  color: var(--ink);
  font-size: clamp(32px, 6vw, 46px);
  font-weight: 1000;
  line-height: 1.12;
  text-align: center;
}

.admin-password-input {
  width: 100%;
  min-height: 72px;
  padding: 0 18px;
  border: 3px solid var(--line);
  border-left: 7px solid var(--leaf);
  border-radius: 12px;
  color: var(--ink);
  font-size: clamp(30px, 6vw, 44px);
  font-weight: 950;
  text-align: center;
}

.admin-password-panel p {
  margin: 0;
  color: #c23b32;
  font-size: clamp(24px, 5vw, 34px);
  font-weight: 950;
  text-align: center;
}

.admin-password-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.admin-password-actions button {
  min-height: 68px;
  font-size: clamp(24px, 4.8vw, 34px);
}

.draft-resume-dialog {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  padding: 24px;
  overscroll-behavior: contain;
}

.draft-resume-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 31, 43, 0.54);
}

.draft-resume-panel {
  position: relative;
  z-index: 1;
  display: grid;
  width: min(640px, 94vw);
  gap: 18px;
  padding: clamp(24px, 5vw, 40px);
  border: 3px solid var(--line);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 18px 48px rgba(20, 31, 43, 0.24);
  text-align: center;
}

.draft-resume-panel h3 {
  margin: 0;
  color: var(--ink);
  font-size: clamp(32px, 6vw, 48px);
  font-weight: 1000;
  line-height: 1.12;
}

.draft-resume-panel p {
  margin: 0;
  color: var(--muted);
  font-size: clamp(20px, 3.8vw, 28px);
  font-weight: 850;
  line-height: 1.35;
}

.draft-resume-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.draft-resume-actions .big-button {
  min-height: 72px;
}

.single-page {
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  overscroll-behavior-x: none;
  -webkit-overflow-scrolling: touch;
}

.hearing-page {
  display: grid;
  place-items: stretch center;
  padding: clamp(8px, 1.5dvh, 16px) clamp(10px, 2.5vw, 28px) var(--bottom-safe);
}

.hearing-card {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: clamp(14px, 2dvh, 22px);
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: clamp(20px, 3dvh, 34px) clamp(22px, 4vw, 48px);
  overflow: auto;
  border: 2px solid var(--soft-line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 10px 28px rgba(36, 52, 71, 0.08);
  -webkit-overflow-scrolling: touch;
}

.hearing-step-card {
  align-content: center;
}

.hearing-intro-card {
  place-items: center;
  align-items: center;
  min-height: 0;
}

.hearing-intro-layout {
  display: grid;
  grid-template-columns: minmax(180px, 0.8fr) minmax(280px, 1fr);
  align-items: center;
  justify-content: center;
  gap: clamp(34px, 5vw, 86px);
  width: min(920px, 100%);
}

.hearing-intro-main {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: clamp(18px, 2.6dvh, 30px);
  min-width: 0;
  text-align: center;
}

.hearing-hero-icon {
  display: grid;
  place-items: center;
  width: clamp(210px, 20vw, 280px);
  aspect-ratio: 1;
  justify-self: center;
  border: 2px solid #d8e9ff;
  border-radius: 12px;
  background: linear-gradient(180deg, #f5fbff, #ffffff);
  box-shadow: inset 0 -8px 0 rgba(63, 141, 243, 0.08);
}

.hearing-copy {
  display: grid;
  gap: 12px;
  justify-items: center;
  min-width: 0;
}

.hearing-copy h3 {
  margin: 0;
  color: var(--ink);
  font-size: clamp(38px, 5vw, 58px);
  line-height: 1.05;
}

.hearing-instruction,
.hearing-summary-note {
  margin: 0;
  color: var(--muted);
  font-size: clamp(20px, 2.5vw, 28px);
  font-weight: 900;
  line-height: 1.45;
  text-align: center;
}

.hearing-check-row {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
  width: 100%;
}

.hearing-check-button {
  min-width: clamp(150px, 14vw, 190px);
}

.hearing-env-status {
  display: inline-grid;
  min-height: 46px;
  place-items: center;
  padding: 8px 16px;
  border-radius: 999px;
  background: #f7faf7;
  color: var(--muted);
  font-size: 18px;
  font-weight: 950;
}

.hearing-env-status.quiet {
  background: var(--mint);
  color: var(--leaf-dark);
}

.hearing-env-status.noisy {
  background: #fff1d2;
  color: #9a6400;
}

.hearing-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
  width: 100%;
}

.hearing-start-button {
  min-width: clamp(210px, 18vw, 260px);
}

.hearing-stage-label {
  display: inline-grid;
  min-height: 36px;
  place-items: center;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--mint);
  color: var(--leaf-dark);
  font-size: 18px;
  font-weight: 950;
}

.hearing-ear-target {
  position: relative;
  display: grid;
  place-items: center;
  gap: 8px;
  width: clamp(180px, 24vw, 240px);
  aspect-ratio: 1;
  padding: 14px;
  border: 3px solid #d8e9ff;
  border-radius: 12px;
  background: #f5fbff;
  overflow: hidden;
}

.hearing-focus-row .hearing-ear-target:not(.compact) {
  align-self: center;
  width: clamp(190px, 28vmin, 250px);
}

.hearing-focus-row {
  display: grid;
  grid-template-columns: auto auto;
  align-items: center;
  justify-content: center;
  gap: clamp(22px, 4vw, 52px);
  width: 100%;
}

.hearing-ear-target.left {
  border-color: #d8e9ff;
  background: linear-gradient(90deg, #e8f3ff 0 34%, #f8fcff 34% 100%);
}

.hearing-ear-target.right {
  border-color: #cdebd8;
  background: linear-gradient(90deg, #f8fff9 0 66%, #e9f9f0 66% 100%);
}

.hearing-ear-target::before {
  content: "";
  position: absolute;
  top: 14px;
  bottom: 14px;
  width: 18px;
  border-radius: 999px;
  opacity: 0.95;
}

.hearing-ear-target.left::before {
  left: 14px;
  background: var(--sky);
  box-shadow: 20px 22px 0 rgba(63, 141, 243, 0.18), 20px -22px 0 rgba(63, 141, 243, 0.18);
}

.hearing-ear-target.right::before {
  right: 14px;
  background: var(--leaf);
  box-shadow: -20px 22px 0 rgba(41, 171, 110, 0.18), -20px -22px 0 rgba(41, 171, 110, 0.18);
}

.hearing-ear-target.compact {
  width: clamp(130px, 16vw, 170px);
}

.hearing-ear-target strong {
  color: var(--ink);
  font-size: clamp(22px, 2.6vw, 30px);
  font-weight: 1000;
}

.ear-illustration {
  width: min(150px, 78%);
  max-height: 72%;
  overflow: visible;
  z-index: 1;
}

.hearing-ear-target.right .ear-illustration {
  justify-self: end;
  margin-right: 26px;
}

.hearing-ear-target.compact .ear-illustration {
  width: min(110px, 74%);
}

.hearing-ear-target.left .ear-illustration {
  justify-self: start;
  margin-left: 26px;
  transform: scaleX(-1);
}

.ear-fill {
  fill: #ffd9b0;
}

.ear-line,
.ear-inner,
.sound-wave {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ear-line {
  stroke: #7d563b;
  stroke-width: 8;
}

.ear-inner {
  stroke: #9c6c4b;
  stroke-width: 7;
}

.sound-wave {
  stroke: var(--leaf);
  stroke-width: 8;
}

.hearing-ear-target.left .sound-wave {
  stroke: var(--sky);
}

  .hearing-play-button {
  margin: 2px 0;
}

.hearing-response-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(150px, 1fr));
  gap: 14px;
  width: min(620px, 100%);
}

.hearing-response-slot {
  display: grid;
  place-items: center;
  width: min(620px, 100%);
  min-height: clamp(86px, 12dvh, 112px);
  visibility: hidden;
  pointer-events: none;
}

.hearing-response-slot.ready {
  visibility: visible;
  pointer-events: auto;
}

.hearing-response-slot .hearing-response-grid {
  width: 100%;
}

.hearing-response-grid .option {
  min-height: clamp(76px, 11dvh, 98px);
  font-size: clamp(24px, 3vw, 32px);
}

.hearing-heard,
.hearing-missed {
  border-color: var(--leaf);
  background: var(--mint);
  color: var(--leaf-dark);
  font-weight: 900;
}

.hearing-test-card {
  width: 100%;
  align-content: stretch;
  grid-template-rows: auto minmax(170px, 1fr) auto minmax(96px, auto) minmax(36px, auto);
}

.hearing-meter-row {
  align-self: center;
  display: grid;
  grid-template-columns: minmax(130px, 0.85fr) repeat(2, minmax(150px, 1fr));
  gap: 14px;
  width: 100%;
  align-items: stretch;
}

.hearing-stimulus-panel {
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 138px;
  padding: 14px;
  border: 2px solid #d9e6de;
  border-radius: 12px;
  background: #fff;
}

.hearing-stimulus-panel span,
.hearing-summary-item span {
  color: var(--muted);
  font-size: 18px;
  font-weight: 950;
}

.hearing-stimulus-panel strong {
  color: var(--ink);
  font-size: clamp(30px, 4vw, 44px);
  font-weight: 1000;
  line-height: 1.05;
}

.hearing-message-slot {
  display: grid;
  min-height: 36px;
  place-items: center;
  text-align: center;
  visibility: hidden;
}

.hearing-message-slot.visible {
  visibility: visible;
}

.hearing-summary-card {
  position: relative;
  align-content: center;
  padding-bottom: clamp(54px, 8dvh, 78px);
}

.hearing-complete-animation {
  position: relative;
  display: grid;
  width: clamp(82px, 10vw, 118px);
  height: clamp(82px, 10vw, 118px);
  place-items: center;
}

.hearing-complete-ring {
  position: absolute;
  inset: 0;
  border: 6px solid rgba(34, 169, 107, 0.24);
  border-top-color: var(--leaf);
  border-radius: 999px;
  animation: hearingCompleteSpin 1.1s ease-out 1, hearingCompleteSettle 1.5s ease-in-out 1.1s infinite;
}

.hearing-complete-check {
  display: grid;
  width: 68%;
  height: 68%;
  place-items: center;
  border-radius: 999px;
  background: var(--leaf);
  box-shadow: 0 6px 0 var(--leaf-dark);
  color: #fff;
  font-size: clamp(38px, 5vw, 58px);
  font-weight: 1000;
  line-height: 1;
  transform: scale(0.74);
  animation: hearingCheckPop 0.55s cubic-bezier(0.18, 0.89, 0.32, 1.28) 0.35s forwards;
}

.hearing-result-panel {
  width: 100%;
  min-height: 210px;
}

.hearing-result-panel strong {
  font-size: clamp(48px, 8vw, 82px);
}

.hearing-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  width: min(860px, 100%);
}

.hearing-summary-item {
  display: grid;
  place-items: center;
  gap: 4px;
  min-height: auto;
  padding: 18px;
  border: 2px solid #d9e6de;
  border-radius: 12px;
  background: #fff;
  text-align: center;
}

.hearing-summary-item strong {
  color: var(--leaf-dark);
  font-size: clamp(36px, 5vw, 48px);
  font-weight: 1000;
}
.hearing-summary-item em {
  font-style: normal;
  color: var(--leaf);
  font-size: 18px;
  font-weight: 900;
}

.hearing-summary-actions {
  display: grid;
  place-items: center;
  width: 100%;
}

.hearing-continue-button {
  min-width: min(360px, 82vw);
  min-height: 92px;
  font-size: clamp(32px, 4vw, 44px);
}

.hearing-retest-link {
  position: absolute;
  right: 22px;
  bottom: 18px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 16px;
  font-weight: 900;
  text-decoration: underline;
  cursor: pointer;
}

.task-page {
  position: relative;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: clamp(6px, 1.1dvh, 10px);
  padding: clamp(8px, 1.4dvh, 14px) clamp(112px, 12vw, 132px) var(--bottom-safe);
  max-height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  overscroll-behavior-x: none;
}

.task-copy {
  position: relative;
  min-height: 0;
  overflow: hidden;
  padding: 22px;
  border: 2px solid var(--soft-line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 10px 26px rgba(36, 52, 71, 0.08);
}

.task-badge-row {
  gap: 10px;
  margin-bottom: 14px;
}

.domain-badge,
.step-badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  max-width: 100%;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 16px;
  font-weight: 900;
}

.domain-badge {
  background: var(--mint);
  color: var(--leaf-dark);
}

.step-badge {
  background: #fff1d2;
  color: #9a6400;
}

.prompt {
  margin-bottom: 10px;
  color: #3e4d5e;
  font-size: 20px;
  font-weight: 800;
  line-height: 1.55;
}

.page-hint {
  color: var(--muted);
  font-size: 16px;
  font-weight: 750;
  line-height: 1.45;
}

.cute-helper {
  position: absolute;
  right: 16px;
  bottom: 14px;
  width: 92px;
  height: 92px;
  object-fit: contain;
}

.task-workspace {
  min-width: 0;
  min-height: 0;
  overflow: visible;
}

.task-footer {
  display: none;
}

.task-footer .primary,
.task-footer .ghost {
  min-width: 132px;
}

.edge-arrow {
  position: absolute;
  top: 50%;
  z-index: 4;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 0;
  height: auto;
  padding: 16px 24px;
  border: none;
  border-radius: 999px;
  box-shadow: 0 6px 20px rgba(36, 52, 71, 0.18), 0 2px 6px rgba(36, 52, 71, 0.10);
  transform: translateY(-50%);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  font-size: 22px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}

.edge-arrow-left {
  left: clamp(14px, 2vw, 24px);
  border: 2.5px solid #c8dcd1;
  background: #ffffff;
  color: var(--leaf-dark);
  box-shadow: 0 4px 14px rgba(36, 52, 71, 0.12), 0 2px 4px rgba(36, 52, 71, 0.08);
}

.edge-arrow-right {
  right: clamp(14px, 2vw, 24px);
  background: var(--coral);
  color: #fff;
  box-shadow: 0 6px 0 #4a7a4a, 0 8px 20px rgba(34,169,107,0.25);
}

.edge-arrow:not(:disabled):hover {
  transform: translateY(calc(-50% - 2px));
  box-shadow: 0 10px 28px rgba(36, 52, 71, 0.22);
}

.edge-arrow:not(:disabled):active {
  transform: translateY(calc(-50% + 3px));
  box-shadow: 0 2px 8px rgba(36, 52, 71, 0.14);
}

.edge-arrow-right:not(:disabled):active {
  box-shadow: 0 2px 0 #4a7a4a, 0 4px 10px rgba(34,169,107,0.2);
}

.edge-arrow:disabled {
  cursor: not-allowed;
  opacity: 0.3;
}

.edge-arrow svg {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
}

.arrow-label {
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0;
  line-height: 1;
  white-space: nowrap;
}

.task-actions {
  position: relative;
  z-index: 6;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  min-height: clamp(52px, 7.2dvh, 68px);
  padding: 0 clamp(4px, 1vw, 10px);
}

.task-actions.spacer {
  min-height: 0;
}

.task-actions-left {
  display: flex;
  gap: 10px;
  align-items: center;
  min-width: 0;
}

.task-actions-left:empty {
  display: block;
}

.trail-page,
.drawing-page,
.naming-page,
.memory-page,
.speech-page,
.abstraction-page,
.orientation-page,
.digit-page,
.vigilance-page,
.serial-page,
.fluency-page,
.wait-card {
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  border: 2px solid var(--soft-line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 10px 28px rgba(36, 52, 71, 0.08);
}

.trail-page {
  position: relative;
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  gap: 10px;
  padding: 14px;
}

.control-row {
  justify-content: center;
  gap: 12px;
}

.drawing-page {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(0, 2fr);
  grid-template-rows: minmax(0, 1fr);
  gap: 18px;
  padding: 14px;
  align-items: stretch;
}

.drawing-page.cube-page,
.drawing-page.clock-page {
  grid-template-columns: minmax(260px, 1fr) 44px minmax(0, 1.35fr);
}

.reference-panel {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  height: 100%;
  border: 2px solid #c3d5c9;
  border-left: 5px solid var(--leaf);
  border-radius: 12px;
  background: #f4fbf6;
}

.reference-label {
  position: absolute;
  top: 12px;
  left: 50%;
  z-index: 1;
  padding: 4px 14px;
  border-radius: 999px;
  background: var(--leaf);
  color: #fff;
  font-size: 16px;
  font-weight: 900;
  line-height: 1.2;
  transform: translateX(-50%);
  white-space: nowrap;
}

.reference-svg {
  width: min(520px, 100%);
  max-height: 98%;
}

.canvas-wrap {
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
  height: 100%;
  touch-action: none;
}

.cube-page .canvas-wrap,
.clock-page .canvas-wrap {
  grid-template-rows: minmax(0, 1fr);
}

.canvas-surface {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 0;
  height: 100%;
  touch-action: none;
}

.clock-reference-panel {
  border-color: #c8d4e4;
  border-left-color: var(--sky);
  background: #f5f9ff;
}

.clock-time-reference {
  display: grid;
  place-items: center;
  gap: 14px;
  padding: 28px 16px 10px;
  color: var(--ink);
  text-align: center;
}

.clock-time-reference strong {
  max-width: 100%;
  overflow: hidden;
  font-size: clamp(52px, 7vw, 112px);
  font-weight: 1000;
  line-height: 0.9;
  white-space: nowrap;
}

.clock-time-reference span {
  color: var(--muted);
  font-size: clamp(26px, 2.8vw, 42px);
  font-weight: 950;
  line-height: 1.1;
}

.task-canvas {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  border: 2px solid #cfe0d7;
  border-radius: 12px;
  background: #fff;
  touch-action: none;
}

.task-canvas.locked {
  cursor: not-allowed;
  opacity: 0.5;
  filter: grayscale(0.28);
}

.cube-canvas {
  border: 2.5px dashed var(--leaf);
  border-radius: 12px;
  box-shadow: inset 0 2px 12px rgba(34, 169, 107, 0.07);
}

.cube-arrow-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  color: var(--leaf);
  font-size: 36px;
  font-weight: 950;
  opacity: 0.72;
}

.trail-completion-modal {
  position: fixed;
  inset: 0;
  z-index: 8;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(36, 52, 71, 0.22);
}

.trail-completion-panel {
  display: grid;
  gap: 18px;
  justify-items: center;
  width: min(460px, 92%);
  padding: 28px;
  border: 3px solid var(--leaf);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 18px 48px rgba(36, 52, 71, 0.22);
  text-align: center;
}

.trail-completion-panel strong {
  color: var(--ink);
  font-size: clamp(28px, 4vw, 42px);
  font-weight: 1000;
  line-height: 1.1;
}

.trail-completion-panel p {
  margin: 0;
  color: var(--muted);
  font-size: clamp(20px, 2.4vw, 28px);
  font-weight: 900;
}

.trail-completion-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(120px, 1fr));
  gap: 12px;
  width: min(340px, 100%);
}

.redraw-button {
  position: absolute;
  right: 12px;
  bottom: 12px;
}

.naming-page {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-content: center;
  justify-items: center;
  gap: 20px;
  padding: 24px;
}

.animal-emoji {
  display: grid;
  justify-self: center;
  width: min(260px, 100%);
  aspect-ratio: 1;
  place-items: center;
  border: 2px solid #f6e8ba;
  border-radius: 12px;
  background: #fff7dc;
  font-size: 184px;
  line-height: 1;
  filter: drop-shadow(0 16px 16px rgba(36, 52, 71, 0.12));
}

.animal-photo {
  display: block;
  justify-self: center;
  width: min(560px, 100%);
  max-height: 100%;
  aspect-ratio: 5 / 4;
  border: 2px solid #d8e5dd;
  border-radius: 8px;
  background: #fff;
  object-fit: contain;
  box-shadow: 0 16px 30px rgba(36, 52, 71, 0.14);
}

.animal-side {
  width: min(640px, 100%);
  min-width: 0;
}

.option-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.option {
  position: relative;
  min-height: 86px;
  padding: 10px 14px;
  border: 2px solid #d9e6de;
  background: #fff;
  color: var(--ink);
  font-size: 26px;
  font-weight: 900;
}

.option.picked {
  border-color: var(--leaf);
  background: var(--leaf);
  color: #fff;
  box-shadow: 0 6px 20px rgba(34, 169, 107, 0.32);
}

.option.picked::before {
  content: none;
}

.memory-page {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) minmax(0, auto);
  align-content: stretch;
  gap: 16px;
  padding: clamp(16px, 2.6dvh, 26px) clamp(20px, 3vw, 34px);
}

.memory-page.ready {
  grid-template-rows: auto minmax(0, 1fr) auto;
  align-content: center;
}

.memory-page:not(.ready) {
  grid-template-rows: auto auto;
  place-content: center;
}

.memory-audio {
  display: grid;
  justify-items: center;
  gap: 8px;
}

.memory-choice-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  color: var(--ink);
  font-size: 28px;
  font-weight: 950;
  text-align: center;
}

.memory-choice-panel span {
  display: grid;
  min-width: 86px;
  min-height: 48px;
  place-items: center;
  border-radius: 999px;
  background: var(--mint);
  color: var(--leaf-dark);
}

.memory-options {
  width: min(860px, 100%);
  justify-self: center;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  align-content: center;
}

.memory-options .option {
  min-height: clamp(62px, 9dvh, 76px);
  font-size: clamp(22px, 2.5vw, 26px);
}

.memory-wait-copy {
  margin: 0;
  color: var(--muted);
  font-size: clamp(22px, 2.6vw, 30px);
  font-weight: 950;
  text-align: center;
}

.memory-review-modal {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(36, 52, 71, 0.26);
}

.memory-review-panel {
  display: grid;
  gap: 20px;
  justify-items: center;
  width: min(560px, 92vw);
  padding: clamp(26px, 5vw, 42px);
  border: 3px solid var(--leaf);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 20px 54px rgba(36, 52, 71, 0.24);
  text-align: center;
}

.memory-review-panel strong {
  color: var(--ink);
  font-size: clamp(30px, 5vw, 44px);
  font-weight: 1000;
  line-height: 1.1;
}

.memory-review-panel p {
  margin: 0;
  color: var(--ink);
  font-size: clamp(24px, 3.4vw, 34px);
  font-weight: 950;
  line-height: 1.28;
}

.memory-review-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(130px, 1fr));
  gap: 14px;
  width: min(390px, 100%);
}

.memory-review-button {
  min-height: 74px;
  font-size: clamp(26px, 3.5vw, 34px);
}

.task-warning,
.task-ok,
.vigilance-listening {
  justify-self: center;
  margin: 0;
  font-size: 22px;
  font-weight: 950;
}

.task-warning {
  color: #d7392f;
}

.task-ok {
  color: var(--leaf-dark);
}

.vigilance-listening {
  color: var(--muted);
}

.speech-page,
.abstraction-page,
.orientation-page,
.digit-page,
.vigilance-page,
.serial-page,
.fluency-page,
.wait-card {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 18px;
  padding: clamp(14px, 2.4dvh, 22px);
}

.audio-visual {
  justify-content: center;
  gap: 22px;
}

.speech-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  flex-wrap: wrap;
}

.audio-wave-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: 100%;
}

.audio-wave {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 180px;
  height: 96px;
  border: 2px solid #d8e9ff;
  border-radius: 12px;
  background: linear-gradient(180deg, #f5fbff, #ffffff);
  box-shadow: inset 0 -6px 0 rgba(63, 141, 243, 0.06);
}

.audio-wave span {
  width: 12px;
  height: 28px;
  border-radius: 999px;
  background: var(--sky);
  opacity: 0.75;
  transform-origin: center;
}

.audio-wave span:nth-child(2),
.audio-wave span:nth-child(4) {
  height: 46px;
  background: var(--leaf);
}

.audio-wave span:nth-child(3) {
  height: 66px;
  background: var(--coral);
}

.audio-wave.active span {
  animation: wave 0.72s ease-in-out infinite;
}

.audio-wave.active span:nth-child(2) {
  animation-delay: 0.1s;
}

.audio-wave.active span:nth-child(3) {
  animation-delay: 0.2s;
}

.audio-wave.active span:nth-child(4) {
  animation-delay: 0.3s;
}

.audio-wave.active span:nth-child(5) {
  animation-delay: 0.4s;
}

.audio-progress {
  width: min(400px, 68%);
  min-width: min(280px, 88vw);
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #e4eef7;
  box-shadow: inset 0 2px 4px rgba(36, 52, 71, 0.06);
}

.audio-progress-fill {
  width: 0%;
  height: 100%;
  border-radius: 999px;
  background: var(--sky);
  transition: width 0.1s linear;
}

.digit-page.ready {
  grid-template-rows: auto auto auto minmax(0, auto);
}

.digit-answer-prompt {
  color: var(--ink);
  font-size: clamp(28px, 4vw, 42px);
  font-weight: 1000;
  line-height: 1.12;
  text-align: center;
}

.digit-example {
  margin: 0;
  color: var(--muted);
  font-size: clamp(20px, 2.6vw, 28px);
  font-weight: 900;
  text-align: center;
}

.voice-status {
  color: var(--muted);
  font-size: 20px;
  font-weight: 950;
}

.headphone-icon,
.mic-icon {
  position: relative;
  display: inline-block;
  width: 82px;
  height: 82px;
}

.headphone-icon::before {
  content: "";
  position: absolute;
  inset: 8px 10px 20px;
  border: 8px solid var(--sky);
  border-bottom: 0;
  border-radius: 20px 20px 12px 12px;
}

.headphone-icon::after {
  content: "";
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 14px;
  height: 30px;
  border-radius: 12px;
  background:
    linear-gradient(90deg, var(--sky) 0 20px, transparent 20px calc(100% - 20px), var(--sky) calc(100% - 20px));
}

.mic-icon::before {
  content: "";
  position: absolute;
  left: 26px;
  top: 6px;
  width: 30px;
  height: 48px;
  border-radius: 20px;
  background: var(--coral);
  box-shadow: inset 0 -7px 0 rgba(0, 0, 0, 0.1);
}

.mic-icon::after {
  content: "";
  position: absolute;
  left: 16px;
  top: 38px;
  width: 50px;
  height: 32px;
  border: 7px solid var(--ink);
  border-top: 0;
  border-radius: 0 0 20px 20px;
}

.mic-icon.recording {
  animation: pulse var(--attention-pulse-duration) ease-in-out infinite;
}

.sound-button {
  min-width: 170px;
  min-height: 58px;
  font-size: 20px;
}

.transcript-input {
  width: min(560px, 96%);
  height: 112px;
  resize: none;
  padding: 14px;
  color: #3d4e5f;
  font-size: 28px;
  font-weight: 750;
  line-height: 1.25;
}

.live-transcript-box {
  width: min(680px, 96%);
  min-height: clamp(126px, 22dvh, 220px);
  max-height: 28dvh;
  padding: clamp(16px, 2.2dvh, 22px);
  overflow: auto;
  border: 3px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: #23384b;
  font-size: clamp(24px, 3vw, 34px);
  font-weight: 900;
  line-height: 1.55;
  text-align: left;
  box-shadow: inset 0 -6px 0 rgba(34, 169, 107, 0.06);
  -webkit-overflow-scrolling: touch;
}

.live-transcript-final {
  color: #23384b;
}

.live-transcript-interim {
  color: #9aa8b5;
}

.live-transcript-placeholder {
  color: #9aa8b5;
  font-weight: 850;
}

.wait-card strong {
  font-size: 30px;
}

.wait-card span {
  color: var(--leaf-dark);
  font-size: 46px;
  font-weight: 950;
}

.digit-answer {
  display: flex;
  min-height: 58px;
  gap: 10px;
}

.digit-answer span {
  display: grid;
  width: 48px;
  height: 58px;
  place-items: center;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--leaf-dark);
  font-size: 28px;
  font-weight: 950;
}

.keypad {
  display: grid;
  grid-template-columns: repeat(3, clamp(64px, 8.4vw, 86px));
  gap: 12px;
  justify-content: center;
}

.digit-keypad {
  grid-template-columns: repeat(3, clamp(64px, 8.4vw, 86px));
}

.serial-keypad {
  grid-template-columns: repeat(3, clamp(64px, 8.4vw, 86px));
}

.keypad button {
  min-width: 0;
  min-height: clamp(48px, 7dvh, 62px);
  border: 2px solid #d7e4dc;
  background: #fff;
  color: var(--ink);
  font-size: 24px;
  font-weight: 950;
  box-shadow: 0 4px 0 #cddbd2;
}

.keypad-spacer {
  min-height: clamp(48px, 7dvh, 62px);
}

.keypad .key-wide {
  grid-column: span 2;
  color: var(--muted);
  font-size: 18px;
}

.keypad .key-action {
  color: var(--muted);
  font-size: 18px;
}

.keypad .confirm {
  border-color: var(--leaf);
  background: #ecfbf2;
  color: var(--leaf-dark);
}

.vigilance-page {
  gap: 22px;
}

.tap-instruction {
  color: var(--ink);
  font-size: 48px;
  font-weight: 1000;
  line-height: 1.1;
}

.circle-button,
.timer-button {
  width: 160px;
  height: 160px;
  border-radius: 999px;
  font-size: 28px;
}

.sound-button {
  width: 160px;
  min-width: 160px;
  height: 160px;
  min-height: 160px;
  padding: 0;
  font-size: 28px;
}

.tap-button {
  width: min(420px, 90%);
  min-height: 160px;
  border-radius: 999px;
  background: linear-gradient(180deg, #6aaf67, #5b8c5a);
  box-shadow: 0 7px 0 #4a7a4a;
  font-size: 36px;
}

.tap-count,
.count-label {
  color: var(--muted);
  font-size: 18px;
  font-weight: 850;
}

.serial-page {
  grid-template-rows: auto auto auto;
}

.math-question {
  color: var(--ink);
  font-size: 46px;
  font-weight: 950;
}

.serial-display {
  display: grid;
  width: 220px;
  height: 72px;
  place-items: center;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: #fff;
  font-size: 34px;
  font-weight: 950;
}

.abstraction-page {
  gap: 26px;
  padding: clamp(18px, 3dvh, 42px) clamp(24px, 4vw, 54px);
}

.word-pair {
  display: flex;
  gap: clamp(18px, 3vw, 34px);
  justify-content: center;
  align-items: center;
}

.word-card {
  display: grid;
  min-width: clamp(150px, 22vw, 220px);
  min-height: clamp(118px, 20dvh, 170px);
  place-items: center;
  padding: 14px;
  border: 2px solid #f6e8ba;
  border-radius: 12px;
  background: #fff7dc;
}

.word-card span {
  font-size: clamp(42px, 7vw, 68px);
  line-height: 1;
}

.word-card strong {
  font-size: clamp(30px, 4.8vw, 48px);
  font-weight: 1000;
}

.abstraction-options {
  width: min(760px, 100%);
}

.guided-option {
  position: relative;
  overflow: visible;
}

.hand-cue {
  position: absolute;
  left: 12px;
  top: 50%;
  font-size: 42px;
  filter: drop-shadow(0 6px 8px rgba(36, 52, 71, 0.22));
  animation: handPoint var(--attention-pulse-duration) ease-in-out infinite;
  pointer-events: none;
}

.fluency-page .timer-button {
  border: 0;
  background: var(--leaf);
  color: #fff;
  font-weight: 950;
  box-shadow: 0 7px 0 var(--leaf-dark);
}

.timer-button.running {
  background: var(--violet);
  box-shadow: 0 7px 0 #5147aa;
}

.pair-title,
.orientation-question {
  max-width: 88%;
  color: var(--ink);
  text-align: center;
  font-size: 34px;
  font-weight: 950;
  line-height: 1.22;
}

.location-text {
  max-width: 88%;
  margin-bottom: 0;
  color: var(--muted);
  text-align: center;
  font-size: 16px;
  font-weight: 800;
}

.orientation-page {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 18px;
}

.orientation-options {
  width: min(680px, 94%);
}

.results-page {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 18px;
  padding: 24px;
  height: 100%;
}

.result-hero,
.domain-table,
.admin-table,
.json-preview,
.rubric-page-head,
.rubric-group {
  min-height: 0;
  overflow: hidden;
  border: none;
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(34,169,107,0.08), rgba(34,169,107,0.02));
  box-shadow: 0 10px 28px rgba(36, 52, 71, 0.08);
}

.result-hero {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(8px, 1.4dvh, 12px);
  padding: clamp(14px, 2.4dvh, 28px);
  min-height: 100%;
}

.result-hero.celebrate {
  background: linear-gradient(180deg, #fffdf2, #f0fff6);
}

.result-hero.soft-alert {
  background: linear-gradient(180deg, #fff8f5, #f7fbff);
}

.result-logo {
  position: relative;
  z-index: 1;
  width: clamp(96px, 14dvh, 150px);
  height: clamp(96px, 14dvh, 150px);
  object-fit: contain;
}

.confetti {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.confetti i {
  position: absolute;
  width: 16px;
  height: 28px;
  border-radius: 12px;
  background: var(--sun);
  animation: confettiDrop 1.8s ease-in-out infinite;
}

.confetti i:nth-child(1) {
  left: 18%;
  top: 18%;
  background: var(--coral);
}

.confetti i:nth-child(2) {
  left: 36%;
  top: 10%;
  animation-delay: 0.18s;
}

.confetti i:nth-child(3) {
  right: 30%;
  top: 16%;
  background: var(--sky);
  animation-delay: 0.35s;
}

.confetti i:nth-child(4) {
  right: 18%;
  top: 28%;
  background: var(--leaf);
  animation-delay: 0.5s;
}

.confetti i:nth-child(5) {
  left: 48%;
  bottom: 18%;
  background: var(--violet);
  animation-delay: 0.75s;
}

.confetti i:nth-child(6) {
  left: 12%;
  bottom: 24%;
  background: var(--sky);
  animation-delay: 0.9s;
}

.confetti i:nth-child(7) {
  right: 12%;
  bottom: 18%;
  background: var(--sun);
  animation-delay: 1.05s;
}

.confetti i:nth-child(8) {
  right: 44%;
  bottom: 12%;
  background: var(--coral);
  animation-delay: 1.2s;
}

.result-sparkles {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.result-sparkles i {
  position: absolute;
  width: 34px;
  height: 34px;
  background: var(--sun);
  clip-path: polygon(50% 0, 61% 34%, 96% 35%, 68% 56%, 79% 91%, 50% 70%, 21% 91%, 32% 56%, 4% 35%, 39% 34%);
  animation: twinkle 1.6s ease-in-out infinite;
}

.result-sparkles i:nth-child(1) {
  left: 26%;
  top: 24%;
}

.result-sparkles i:nth-child(2) {
  right: 25%;
  top: 22%;
  background: var(--sky);
  animation-delay: 0.3s;
}

.result-sparkles i:nth-child(3) {
  left: 30%;
  bottom: 24%;
  background: var(--coral);
  animation-delay: 0.6s;
}

.result-sparkles i:nth-child(4) {
  right: 31%;
  bottom: 26%;
  background: var(--leaf);
  animation-delay: 0.9s;
}

.result-hero span {
  position: relative;
  z-index: 1;
  color: var(--muted);
  font-weight: 900;
}

.result-hero strong {
  position: relative;
  z-index: 1;
  color: var(--leaf-dark);
  font-size: clamp(58px, 11dvh, 94px);
  line-height: 0.9;
}

.result-hero em {
  margin-left: 8px;
  font-size: 34px;
  color: var(--muted);
  font-style: normal;
  font-weight: 950;
}

.result-hero p {
  position: relative;
  z-index: 1;
  margin-bottom: 0;
  color: var(--ink);
  font-size: 24px;
  font-weight: 900;
}

.radar-card {
  position: relative;
  z-index: 1;
  display: grid;
  width: min(320px, 46dvh);
  aspect-ratio: 1;
  place-items: center;
}

.radar-pulse {
  position: absolute;
  inset: 18%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(34, 169, 107, 0.20), rgba(34, 169, 107, 0));
  animation: radarPulse 1.9s ease-out infinite;
}

.radar-chart {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.radar-ring {
  fill: none;
  stroke: rgba(36, 52, 71, 0.18);
  stroke-width: 1.5;
}

.radar-axis {
  stroke: rgba(36, 52, 71, 0.14);
  stroke-width: 1.5;
}

.radar-area {
  fill: rgba(34, 169, 107, 0.28);
  stroke: var(--leaf);
  stroke-width: 4;
  stroke-linejoin: round;
  animation: radarGrow 0.72s ease-out both;
  transform-origin: center;
}

.radar-dot {
  fill: var(--coral);
  stroke: #fff;
  stroke-width: 2;
}

.radar-label {
  fill: #3d4e5f;
  font-size: 11px;
  font-weight: 900;
}

.result-medals {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
}

.result-medals b {
  display: grid;
  min-width: 86px;
  min-height: 46px;
  place-items: center;
  border-radius: 999px;
  background: #fff1d2;
  color: #8a5a00;
  font-size: 18px;
  font-weight: 950;
}

.domain-table {
  display: grid;
  align-content: start;
  gap: 10px;
  padding: 18px;
}

.domain-row {
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  padding: 0 14px;
  border-radius: 12px;
  background: #f7faf7;
  font-weight: 850;
}

.results-actions {
  justify-content: flex-end;
  gap: 12px;
}

.admin-page {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto auto auto minmax(0, 1fr);
  gap: 16px;
  padding: 22px 24px 24px;
}

.admin-toolbar {
  grid-column: 1 / -1;
  justify-content: flex-end;
  gap: 12px;
}

.admin-filter-bar {
  display: flex;
  grid-column: 1 / -1;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.admin-filter-button,
.admin-page-button {
  min-height: 42px;
  padding: 8px 14px;
  border: 2px solid var(--soft-line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-size: 16px;
  font-weight: 950;
  box-shadow: 0 3px 0 rgba(36, 52, 71, 0.12);
}

.admin-filter-button.active {
  border-color: var(--leaf);
  background: #effbf4;
  color: var(--leaf-dark);
}

.admin-page-button:disabled,
.admin-filter-button:disabled {
  color: var(--muted);
  box-shadow: none;
  opacity: 0.55;
}

.admin-pagination {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 16px;
  font-weight: 900;
}

.admin-sync-status {
  grid-column: 1 / -1;
  margin: -4px 0 0;
  color: var(--leaf-dark);
  font-size: 16px;
  font-weight: 900;
}

.admin-sync-status.error {
  color: #b94736;
}

.admin-layout {
  display: grid;
  grid-template-columns: minmax(520px, 1.05fr) minmax(360px, 0.95fr);
  gap: 16px;
  min-height: 0;
  overflow: hidden;
}

.admin-table {
  display: block;
  padding: 12px;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  touch-action: pan-x pan-y;
}

.admin-head,
.admin-row {
  display: grid;
  grid-template-columns: minmax(128px, 1.08fr) minmax(72px, 0.72fr) minmax(70px, 0.52fr) minmax(86px, 0.64fr) minmax(138px, 1fr);
  gap: 10px;
  align-items: center;
  min-width: 0;
}

.admin-head {
  padding: 10px 12px;
  color: var(--muted);
  font-size: 16px;
  font-weight: 900;
}

.admin-group-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 12px 0 8px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #eef5ee;
  color: var(--ink);
}

.admin-group-title strong {
  font-size: 17px;
  font-weight: 900;
}

.admin-group-title span {
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.admin-group-empty {
  min-width: 0;
}

.admin-row {
  width: 100%;
  min-height: 50px;
  padding: 0 12px;
  border: 2px solid transparent;
  background: #f8fbf8;
  color: var(--ink);
  text-align: left;
}

.admin-row.active {
  border-color: var(--leaf);
  background: #eef9ef;
}

.admin-head span,
.admin-row span,
.admin-row strong,
.admin-row small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-case-cell {
  font-size: 17px;
  font-weight: 950;
}

.admin-name-cell {
  font-size: 16px;
  font-weight: 900;
}

.admin-total-cell {
  color: var(--leaf-dark);
  font-size: 17px;
  font-weight: 950;
}

.admin-bonus-cell {
  color: var(--ink);
  font-size: 16px;
  font-weight: 900;
}

.admin-time-cell {
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.admin-detail {
  min-height: 0;
  padding: 14px;
  overflow: auto;
  color: var(--ink);
  overscroll-behavior: contain;
  touch-action: pan-x pan-y;
}

.empty-detail {
  display: grid;
  align-content: start;
}

.detail-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 14px;
  padding: 4px 2px 12px;
}

.detail-header span {
  color: var(--muted);
  font-size: 16px;
  font-weight: 900;
}

.detail-header strong {
  font-size: 22px;
  font-weight: 950;
}

.detail-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.detail-summary div {
  min-height: 68px;
  padding: 10px 12px;
  border: 2px solid #e6f0e7;
  border-radius: 12px;
  background: #fbfefb;
}

.detail-summary span,
.detail-block h4 {
  display: block;
  color: var(--muted);
  font-size: 16px;
  font-weight: 900;
}

.detail-summary strong {
  display: block;
  margin-top: 6px;
  overflow: hidden;
  color: var(--ink);
  font-size: 16px;
  font-weight: 950;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-detail-list {
  display: grid;
  gap: 10px;
  overscroll-behavior: contain;
  touch-action: pan-x pan-y;
}

.item-detail {
  border: 2px solid #e5efe7;
  border-radius: 12px;
  background: #ffffff;
}

.item-detail summary,
.item-detail-row {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 52px;
  padding: 0 12px;
  cursor: pointer;
  list-style: none;
}

.item-detail summary::-webkit-details-marker {
  display: none;
}

.item-detail summary span,
.item-detail-row span {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 50%;
  background: var(--sun);
  color: var(--ink);
  font-size: 16px;
  font-weight: 950;
}

.item-detail summary strong {
  overflow: hidden;
  font-size: 16px;
  font-weight: 950;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-detail summary em {
  color: var(--leaf-dark);
  font-style: normal;
  font-weight: 950;
}

.item-detail-row strong {
  overflow: hidden;
  font-size: 16px;
  font-weight: 950;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-detail-row em {
  color: var(--leaf-dark);
  font-style: normal;
  font-weight: 950;
}

.item-detail-row {
  cursor: default;
}

.item-answer-summary {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 0 12px 12px 64px;
}

.item-answer-summary > span {
  color: var(--muted);
  font-size: 16px;
  font-weight: 900;
}

.answer-part-list {
  display: grid;
  gap: 6px;
}

.answer-part {
  display: grid;
  grid-template-columns: minmax(64px, auto) minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  min-height: 34px;
  padding: 8px 10px;
  border-radius: 12px;
  background: #f7faf7;
  color: #263a32;
  font-size: 16px;
  font-weight: 850;
  line-height: 1.45;
  word-break: break-word;
}

.answer-part span {
  color: var(--muted);
  font-size: 16px;
  font-weight: 900;
}

.answer-part strong {
  min-width: 0;
  color: #263a32;
  font-size: 16px;
  font-weight: 900;
}

.answer-part small {
  grid-column: 2;
  color: #8b2f23;
  font-size: 16px;
  font-weight: 850;
}

.answer-part.wrong-answer {
  border: 1.5px solid #f1b4aa;
  background: #fff4f2;
}

.answer-part.wrong-answer strong {
  color: #b3261e;
}

.answer-part.correct-answer {
  border: 1.5px solid #d9eadc;
}

.admin-drawing-preview {
  display: grid;
  min-height: 160px;
  margin: 0 12px 12px 64px;
  place-items: center;
  border-radius: 12px;
  background: #f7faf7;
  overscroll-behavior: contain;
  touch-action: pan-x pan-y;
}

.admin-drawing-preview img {
  display: block;
  max-width: min(100%, 520px);
  max-height: 260px;
  border-radius: 12px;
  background: #fff;
}

.empty-drawing-preview {
  color: var(--muted);
  font-size: 16px;
  font-weight: 900;
}

.admin-audio-preview {
  display: grid;
  gap: 8px;
  margin: 0 12px 12px 64px;
}

.admin-audio-preview label {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 10px;
  border-radius: 12px;
  background: #f7faf7;
}

.admin-audio-preview span {
  color: var(--muted);
  font-size: 16px;
  font-weight: 900;
}

.admin-audio-preview audio {
  width: 100%;
  min-width: 0;
}

.item-detail-body {
  display: grid;
  gap: 10px;
  padding: 0 12px 12px;
}

.detail-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.detail-chips span {
  padding: 7px 10px;
  border-radius: 999px;
  background: #f1f7f2;
  color: #566a5b;
  font-size: 16px;
  font-weight: 900;
}

.detail-block {
  display: grid;
  gap: 6px;
}

.detail-block h4 {
  margin: 0;
}

.detail-block pre,
.detail-empty {
  margin: 0;
  padding: 10px;
  overflow: auto;
  border-radius: 12px;
  background: #f7faf7;
  color: #374b5e;
  font-size: 16px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.drawing-preview {
  display: grid;
  min-height: 160px;
  place-items: center;
  padding: 10px;
  border-radius: 12px;
  background: #f7faf7;
  overscroll-behavior: contain;
  touch-action: pan-x pan-y;
}

.drawing-preview img {
  display: block;
  max-width: 100%;
  max-height: 320px;
  border: 2px solid #d9e6dc;
  border-radius: 12px;
  background: #ffffff;
  object-fit: contain;
}

.json-preview {
  margin: 0;
  padding: 16px;
  overflow: auto;
  color: #374b5e;
  font-size: 16px;
  line-height: 1.45;
  white-space: pre-wrap;
  overscroll-behavior: contain;
  touch-action: pan-x pan-y;
}

.empty {
  margin: 22px 12px;
  color: var(--muted);
  font-weight: 850;
}

.design-page {
  display: grid;
  gap: 12px;
  grid-template-rows: minmax(260px, 1fr);
  padding: 12px;
  overflow: auto;
  background: #f5f8f6;
}

.moca-pdf-frame {
  width: 100%;
  height: 100%;
  min-height: 0;
  border: 0;
  border-radius: 12px;
  background: #fff;
}

.moca-pdf-frame iframe {
  width: 100%;
  height: 100%;
  border: 0;
}

.rubric-page-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  padding: 18px 22px;
}

.rubric-page-head h3 {
  margin: 0;
}

.rubric-page-head p {
  margin: 0;
  color: var(--muted);
  font-size: 22px;
  font-weight: 900;
}

.rubric-layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  min-height: 0;
  overflow: visible;
}

.rubric-group {
  display: grid;
  grid-template-rows: auto auto;
  gap: 10px;
  min-width: 0;
  min-height: 230px;
  padding: 16px;
}

.rubric-group h4 {
  margin: 0;
  color: var(--leaf-dark);
  font-size: 26px;
}

.rubric-cards {
  display: grid;
  align-content: start;
  gap: 10px;
  min-height: 0;
  overflow: visible;
}

.rubric-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  width: 100%;
  min-height: 58px;
  padding: 14px;
  border: 2px solid #e3ece6;
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  text-align: left;
}

.rubric-card span {
  font-size: 22px;
  font-weight: 950;
}

.rubric-card em {
  flex: 0 0 auto;
  color: var(--leaf-dark);
  font-size: 16px;
  font-style: normal;
  font-weight: 950;
}

.rubric-card-body strong,
.rubric-modal-body strong {
  color: var(--leaf-dark);
  font-size: 17px;
  font-weight: 950;
}

.rubric-card-body p,
.rubric-modal-body p {
  margin: 0;
  color: #3d4e5f;
  font-size: 18px;
  font-weight: 800;
  line-height: 1.55;
}

.rubric-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  padding: clamp(12px, 2vw, 28px);
}

.rubric-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(24, 38, 51, 0.42);
}

.rubric-modal-panel {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: 100%;
  height: 100%;
  place-self: center;
  overflow: hidden;
  border: 3px solid #dfe9e3;
  border-radius: 12px;
  background: #fffdf7;
  box-shadow: 0 24px 70px rgba(24, 38, 51, 0.26);
}

.rubric-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 26px;
  border-bottom: 2px solid #e8f0ea;
}

.rubric-modal-head span {
  color: var(--leaf-dark);
  font-size: 18px;
  font-weight: 950;
}

.rubric-modal-head h3 {
  margin: 4px 0 0;
  font-size: clamp(34px, 4vw, 48px);
}

.rubric-modal-body {
  display: grid;
  align-content: start;
  gap: 22px;
  padding: 28px;
  overflow: auto;
}

.rubric-modal-body section {
  display: grid;
  gap: 10px;
}

.rubric-modal-body strong {
  font-size: 24px;
}

.rubric-modal-body p {
  font-size: clamp(26px, 3.1vw, 34px);
  line-height: 1.55;
}

.rubric-sheet-image {
  width: min(420px, 100%);
  max-height: 260px;
  justify-self: center;
  border: 2px solid #dfe9e3;
  border-radius: 12px;
  object-fit: contain;
}

.rubric-sheet-image.large {
  width: min(780px, 100%);
  max-height: 430px;
}

.bounce-in {
  animation: bounceIn 0.55s cubic-bezier(0.2, 0.9, 0.3, 1.2) both;
}

.pop-in {
  animation: popIn 0.34s cubic-bezier(0.2, 0.9, 0.3, 1.25) both;
}

.floaty {
  animation: floaty 2.4s ease-in-out infinite;
}

.pulse {
  animation: pulse var(--attention-pulse-duration) ease-in-out infinite;
}

@keyframes bounceIn {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.birth-date-selects {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 0.85fr) minmax(0, 0.85fr);
  gap: 12px;
}

.birth-date-unit-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.birth-date-unit-field select {
  padding-right: 34px;
  font-size: clamp(28px, 3.1vw, 36px);
  text-align: center;
  text-align-last: center;
}

.birth-date-unit-field > span {
  color: var(--ink);
  font-size: clamp(24px, 2.45vw, 32px);
  font-weight: 1000;
  line-height: 1;
  white-space: nowrap;
}

.task-page {
  position: relative;
}

.task-actions {
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  justify-items: center;
}

.task-actions-left {
  justify-self: start;
}

.task-actions-right {
  justify-self: end;
}

.confirm-button {
  justify-self: center;
}

.task-skip-link {
  position: absolute;
  right: clamp(18px, 3vw, 34px);
  bottom: max(10px, env(safe-area-inset-bottom));
  z-index: 7;
  padding: 4px 6px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 16px;
  font-weight: 850;
  line-height: 1;
}

.task-skip-link:hover {
  color: var(--leaf-dark);
}

.digit-keypad,
.serial-keypad,
.orientation-keypad {
  grid-template-columns: repeat(3, clamp(88px, 11vw, 122px));
  gap: 16px;
}

.digit-keypad button,
.serial-keypad button,
.orientation-keypad button {
  min-height: clamp(70px, 10dvh, 94px);
  font-size: clamp(30px, 4vw, 40px);
}

.digit-keypad .keypad-spacer,
.serial-keypad .keypad-spacer,
.orientation-keypad .keypad-spacer {
  min-height: clamp(70px, 10dvh, 94px);
}

.orientation-number-page {
  gap: 22px;
}

.orientation-number-display {
  display: grid;
  min-width: min(420px, 88%);
  min-height: clamp(72px, 12dvh, 104px);
  place-items: center;
  border: 3px solid var(--line);
  border-left: 7px solid var(--leaf);
  border-radius: 12px;
  background: #fff;
  color: var(--leaf-dark);
  font-size: clamp(42px, 8vw, 68px);
  font-weight: 1000;
}

.year-digit-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(72px, 1fr));
  gap: 14px;
  width: min(520px, 92%);
}

.year-digit-box {
  display: grid;
  min-height: clamp(84px, 13dvh, 118px);
  place-items: center;
  border: 3px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--leaf-dark);
  box-shadow: 0 4px 0 #cddbd2;
  font-size: clamp(38px, 7vw, 58px);
  font-weight: 1000;
  line-height: 1;
}

.year-digit-box.active {
  border-color: var(--leaf);
  background: var(--mint);
  box-shadow: 0 4px 0 var(--leaf-dark);
}

.date-input-pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(120px, 1fr));
  gap: 18px;
  width: min(520px, 92%);
}

.date-input-box {
  display: grid;
  gap: 8px;
  min-height: clamp(84px, 13dvh, 118px);
  place-items: center;
  border: 3px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  box-shadow: 0 4px 0 #cddbd2;
}

.date-input-box.active {
  border-color: var(--leaf);
  background: var(--mint);
  color: var(--leaf-dark);
  box-shadow: 0 4px 0 var(--leaf-dark);
}

.date-input-box span {
  color: var(--muted);
  font-size: 18px;
  font-weight: 900;
}

.date-input-box strong {
  min-height: 1em;
  font-size: clamp(38px, 7vw, 58px);
  font-weight: 1000;
  line-height: 1;
}

.clock-time-reference strong {
  font-size: clamp(118px, 15vw, 220px);
}

.result-hero {
  place-content: center;
  gap: 18px;
}

.results-page {
  grid-template-rows: minmax(0, 1fr);
}

.result-hero > p {
  color: var(--leaf-dark);
  font-size: clamp(30px, 5vw, 54px);
  font-weight: 1000;
}

@media (max-width: 760px), (max-height: 620px) {
  .birth-date-selects {
    grid-template-columns: minmax(0, 1fr) minmax(0, 0.82fr) minmax(0, 0.82fr);
    gap: 8px;
  }

  .task-actions {
    min-height: clamp(50px, 7svh, 62px);
    padding-inline: 48px;
  }

  .task-skip-link {
    right: 10px;
    bottom: max(8px, env(safe-area-inset-bottom));
    font-size: 16px;
  }

  .digit-keypad,
  .serial-keypad,
  .orientation-keypad {
    grid-template-columns: repeat(3, clamp(72px, 22vw, 96px));
    gap: 12px;
  }

  .digit-keypad button,
  .serial-keypad button,
  .orientation-keypad button,
  .digit-keypad .keypad-spacer,
  .serial-keypad .keypad-spacer,
  .orientation-keypad .keypad-spacer {
    min-height: clamp(62px, 11svh, 82px);
  }

  .clock-time-reference strong {
    font-size: clamp(74px, 18vw, 118px);
  }

  .year-digit-row {
    grid-template-columns: repeat(4, minmax(52px, 1fr));
    gap: 10px;
    width: min(390px, 94%);
  }

  .year-digit-box {
    min-height: clamp(62px, 11svh, 82px);
    font-size: clamp(30px, 8vw, 44px);
  }
}

@keyframes popIn {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.82);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes floaty {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-8px);
  }
}

@keyframes pulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.04);
  }
}

@keyframes pulseGreen {
  0% {
    transform: scale(1);
    box-shadow: 0 5px 0 #4a7a4a, 0 0 0 0 rgba(34, 169, 107, 0.36);
  }
  70% {
    transform: scale(1.035);
    box-shadow: 0 5px 0 #4a7a4a, 0 0 0 12px rgba(34, 169, 107, 0);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 5px 0 #4a7a4a, 0 0 0 0 rgba(34, 169, 107, 0);
  }
}

@keyframes hearingCompleteSpin {
  from {
    transform: rotate(-180deg) scale(0.78);
    opacity: 0.4;
  }
  to {
    transform: rotate(0deg) scale(1);
    opacity: 1;
  }
}

@keyframes hearingCompleteSettle {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.04);
  }
}

@keyframes hearingCheckPop {
  from {
    opacity: 0;
    transform: scale(0.74);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes toastInOut {
  0% {
    opacity: 0;
    transform: translate(-50%, 60px);
  }
  15%,
  85% {
    opacity: 1;
    transform: translate(-50%, 0);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -28px);
  }
}

@keyframes confirmNudge {
  0%,
  100% {
    transform: scale(1);
    box-shadow: 0 5px 0 #4a7a4a;
  }
  50% {
    transform: scale(1.08);
    box-shadow: 0 8px 0 #4a7a4a, 0 12px 22px rgba(34,169,107,0.34);
  }
}

@keyframes wave {
  0%,
  100% {
    transform: scaleY(0.58);
  }
  50% {
    transform: scaleY(1.12);
  }
}

@keyframes confettiDrop {
  0%,
  100% {
    transform: translateY(0) rotate(0deg);
    opacity: 0.75;
  }
  50% {
    transform: translateY(14px) rotate(14deg);
    opacity: 1;
  }
}

@keyframes twinkle {
  0%,
  100% {
    transform: rotate(0deg) scale(0.92);
  }
  50% {
    transform: rotate(10deg) scale(1.08);
  }
}

@keyframes radarPulse {
  from {
    transform: scale(0.3);
    opacity: 0.78;
  }
  to {
    transform: scale(1.25);
    opacity: 0;
  }
}

@keyframes radarGrow {
  from {
    transform: scale(0.08);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes handPoint {
  0%,
  100% {
    transform: translate(-74%, -50%) rotate(-6deg);
  }
  50% {
    transform: translate(-54%, -50%) rotate(-6deg);
  }
}

@media (max-width: 960px) {
  .task-page {
    padding: 14px 108px 18px;
  }

  .drawing-page {
    grid-template-columns: minmax(220px, 1fr) minmax(0, 2fr);
  }

  .rubric-layout {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (orientation: portrait) {
  .setup-panel {
    width: min(900px, 94vw);
    padding: 24px;
  }

  .page-shell {
    grid-template-rows: clamp(68px, 9dvh, 92px) minmax(0, 1fr);
  }

  .task-page {
    padding-inline: 100px;
    padding-bottom: var(--bottom-safe);
  }

  .drawing-page {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(180px, 0.42fr) minmax(0, 1fr);
  }

  .drawing-page.cube-page {
    grid-template-columns: minmax(220px, 0.95fr) 34px minmax(0, 1.05fr);
    grid-template-rows: minmax(0, 1fr);
  }

  .reference-svg {
    width: min(380px, 92%);
  }

  .rubric-layout,
  .admin-page {
    grid-template-columns: minmax(0, 1fr);
  }

  .result-logo {
    width: 104px;
    height: 104px;
  }

  .radar-card {
    width: min(300px, 36dvh);
  }
}

@media (max-width: 760px) {
  .setup-panel {
    grid-template-columns: minmax(0, 1fr);
    width: min(620px, 94vw);
  }

  .setup-play-zone {
    min-height: auto;
  }

  .setup-start-button {
    width: min(210px, 48vw);
    height: min(210px, 48vw);
  }

  .task-page {
    padding-inline: 64px;
  }

  .edge-arrow {
    min-width: 50px;
    padding: 8px;
  }

  .edge-arrow svg {
    width: 22px;
    height: 22px;
  }

  .edge-arrow .arrow-label {
    display: none;
  }

  .drawing-page.cube-page,
  .drawing-page.clock-page {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(170px, 0.42fr) 28px minmax(0, 1fr);
  }

  .cube-arrow-hint {
    width: 100%;
    transform: rotate(90deg);
  }
}

@media (max-height: 820px) {
  :root {
    --setup-control-height: 56px;
  }

  .setup-screen {
    padding: 14px;
  }

  .setup-panel {
    width: min(1020px, 94vw);
    padding: 22px;
  }

  .brand-row {
    gap: 14px;
    margin-bottom: 16px;
  }

  .logo-image {
    width: 78px;
    height: 78px;
  }

  h1 {
    font-size: 42px;
  }

  .setup-grid {
    gap: 10px;
  }

  .field {
    gap: 6px;
    font-size: 18px;
  }

  .field input,
  .field select,
  .segment-option {
    font-size: 21px;
  }

  .big-button {
    min-height: 62px;
    font-size: 25px;
  }

  .setup-start-button {
    width: clamp(160px, 19vw, 220px);
    height: clamp(160px, 19vw, 220px);
  }

  .setup-start-button span {
    font-size: clamp(34px, 4.2vw, 48px);
  }

  .setup-start-button small {
    font-size: clamp(34px, 4.2vw, 48px);
  }

  .page-shell {
    grid-template-rows: 76px minmax(0, 1fr);
  }

  .page-header {
    padding-top: 8px;
    padding-bottom: 7px;
  }

  .header-prompt {
    -webkit-line-clamp: 1;
  }

  .task-page {
    padding-top: 7px;
    padding-bottom: var(--bottom-safe);
  }

  .task-copy {
    padding: 14px;
  }
}

@media (max-height: 720px) {
  .page-shell {
    grid-template-rows: 64px minmax(0, 1fr);
  }

  .page-header {
    padding-top: 10px;
    padding-bottom: 8px;
  }

  .icon-button {
    width: 48px;
    height: 48px;
  }

  h2 {
    font-size: 23px;
  }

  h3 {
    font-size: 28px;
  }

  .prompt {
    font-size: 18px;
  }

  .header-prompt {
    font-size: 16px;
  }

  .cute-helper {
    width: 72px;
    height: 72px;
  }

  .task-page {
    padding-top: 8px;
    padding-bottom: 8px;
    gap: 8px;
  }

  .task-copy {
    padding: 18px;
  }

  .option {
    min-height: 52px;
    font-size: 22px;
  }

  .math-question {
    font-size: 38px;
  }

  .circle-button,
  .timer-button,
  .sound-button {
    width: 116px;
    height: 116px;
    min-width: 116px;
    min-height: 116px;
  }

  .task-actions {
    min-height: 50px;
  }

  .confirm-button,
  .utility-button {
    min-height: 46px;
    font-size: 20px;
  }

  .tap-button {
    min-height: 128px;
  }

  .transcript-input {
    height: 92px;
  }
}

@media (max-width: 640px), (max-height: 560px) {
  :root {
    --bottom-safe: max(10px, env(safe-area-inset-bottom));
    --setup-control-height: 52px;
  }

  body {
    font-size: 18px;
  }

  h1 {
    font-size: clamp(36px, 10vw, 44px);
  }

  h2 {
    font-size: clamp(20px, 5.8vw, 26px);
  }

  h3,
  h4 {
    font-size: clamp(22px, 6vw, 28px);
  }

  .setup-screen {
    place-items: stretch;
    padding: 10px;
    overflow: auto;
  }

  .floating-stars i {
    width: 22px;
    height: 22px;
  }

  .setup-panel {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(104px, 0.72fr);
    gap: 10px;
    align-self: stretch;
    width: 100%;
    min-height: 0;
    padding: 14px;
    overflow: hidden;
  }

  .setup-panel::after,
  .play-orbit {
    display: none;
  }

  .setup-left {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    min-height: 0;
  }

  .brand-row {
    gap: 10px;
    margin-bottom: 10px;
  }

  .logo-image {
    width: 58px;
    height: 58px;
  }

  .setup-grid {
    gap: 7px;
    min-height: 0;
  }

  .field {
    gap: 4px;
    font-size: 17px;
  }

  .field input,
  .field select,
  .segment-option {
    font-size: 19px;
  }

  .segmented-options {
    gap: 8px;
  }

  .setup-play-zone {
    min-height: 104px;
  }

  .setup-start-button {
    width: clamp(112px, 34vw, 150px);
    height: clamp(112px, 34vw, 150px);
    border-width: 5px;
    box-shadow:
      0 7px 0 var(--leaf-dark),
      0 14px 26px rgba(18, 122, 73, 0.2);
  }

  .setup-start-button span {
    font-size: clamp(28px, 8vw, 38px);
  }

  .setup-start-button small {
    margin-top: 2px;
    font-size: clamp(28px, 8vw, 38px);
  }

  .page-shell {
    grid-template-rows: 56px minmax(0, 1fr);
  }

  .page-header {
    gap: 8px;
    padding: 6px 8px;
  }

  .icon-button {
    width: 42px;
    height: 42px;
    font-size: 24px;
  }

  .header-title h2 {
    font-size: clamp(20px, 5.6vw, 25px);
  }

  .header-prompt {
    margin-top: 1px;
    font-size: clamp(13px, 3.8vw, 16px);
    line-height: 1.2;
    -webkit-line-clamp: 1;
  }

  .header-progress {
    width: 66px;
    gap: 4px;
    font-size: 16px;
  }

  .progress-track {
    height: 7px;
  }

  .drawer-panel {
    width: min(320px, 88vw);
    gap: 7px;
    padding: 14px;
  }

  .drawer-logo {
    width: 46px;
    height: 46px;
  }

  .drawer-item {
    min-height: 42px;
    font-size: 18px;
  }

  .drawer-score {
    min-height: 58px;
    font-size: 26px;
  }

  .drawer-task {
    min-height: 42px;
    padding: 6px 9px;
  }

  .task-page {
    gap: 6px;
    padding: 6px 64px var(--bottom-safe);
  }

  .edge-arrow {
    min-width: 48px;
    height: auto;
    padding: 8px;
    font-size: 30px;
    border-width: 1px;
  }

  .edge-arrow svg {
    width: 22px;
    height: 22px;
  }

  .edge-arrow .arrow-label {
    font-size: 10px;
  }

  .edge-arrow-left {
    left: 6px;
  }

  .edge-arrow-right {
    right: 6px;
  }

  .task-actions {
    min-height: 46px;
    gap: 8px;
    padding: 0;
  }

  .task-actions-left {
    gap: 6px;
  }

  .confirm-button {
    min-width: 96px;
    min-height: 44px;
    padding: 8px 15px;
    font-size: 20px;
    box-shadow: 0 4px 0 #4a7a4a;
  }

  .utility-button {
    min-width: 78px;
    min-height: 42px;
    padding: 7px 12px;
    font-size: 18px;
    box-shadow: 0 3px 0 #cddbd2;
  }

  .trail-page,
  .drawing-page,
  .naming-page,
  .memory-page,
  .speech-page,
  .abstraction-page,
  .orientation-page,
  .digit-page,
  .vigilance-page,
  .serial-page,
  .fluency-page,
  .wait-card {
    border-width: 1px;
  }

  .trail-page {
    padding: 8px;
  }

  .drawing-page {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(118px, 0.32fr) minmax(0, 1fr);
    gap: 8px;
    padding: 8px;
  }

  .drawing-page.cube-page,
  .drawing-page.clock-page {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(118px, 0.32fr) 22px minmax(0, 1fr);
  }

  .reference-svg {
    width: min(230px, 86%);
    max-height: 96%;
  }

  .clock-time-reference {
    gap: 6px;
    padding: 24px 10px 6px;
  }

  .clock-time-reference strong {
    font-size: clamp(48px, 12vw, 74px);
  }

  .clock-time-reference span {
    font-size: clamp(20px, 4vw, 28px);
  }

  .redraw-button {
    right: 8px;
    bottom: 8px;
  }

  .naming-page {
    gap: 10px;
    padding: 12px;
  }

  .animal-emoji {
    width: min(136px, 42vw);
    font-size: clamp(88px, 27vw, 120px);
  }

  .animal-side {
    width: 100%;
  }

  .animal-side h4 {
    margin-bottom: 8px;
    text-align: center;
  }

  .option-grid {
    gap: 8px;
  }

  .option {
    min-height: 52px;
    padding: 8px 10px;
    font-size: clamp(18px, 5vw, 22px);
  }

  .memory-page {
    gap: 8px;
    padding: 10px;
  }

  .memory-choice-panel {
    gap: 10px;
    font-size: clamp(20px, 5.6vw, 24px);
  }

  .memory-choice-panel span {
    min-width: 64px;
    min-height: 38px;
  }

  .memory-wait-copy {
    font-size: clamp(18px, 5vw, 23px);
  }

  .speech-page,
  .abstraction-page,
  .orientation-page,
  .digit-page,
  .vigilance-page,
  .serial-page,
  .fluency-page,
  .wait-card {
    gap: 10px;
    padding: 10px;
  }

  .audio-wave {
    width: 138px;
    height: 62px;
    gap: 7px;
  }

  .audio-wave span {
    width: 9px;
  }

  .voice-status {
    font-size: 17px;
  }

  .circle-button,
  .timer-button,
  .sound-button {
    width: 112px;
    height: 112px;
    min-width: 112px;
    min-height: 112px;
    font-size: 22px;
  }

  .digit-answer {
    min-height: 46px;
    gap: 6px;
  }

  .digit-answer span {
    width: 38px;
    height: 46px;
    font-size: 24px;
  }

  .keypad,
  .digit-keypad,
  .serial-keypad {
    grid-template-columns: repeat(3, clamp(54px, 15vw, 70px));
    gap: 8px;
  }

  .keypad button,
  .keypad-spacer {
    min-height: 44px;
  }

  .keypad button {
    font-size: 21px;
  }

  .tap-instruction {
    font-size: clamp(28px, 8vw, 38px);
    text-align: center;
  }

  .tap-button {
    width: min(260px, 90%);
    min-height: 112px;
    font-size: 28px;
  }

  .math-question {
    font-size: clamp(30px, 8vw, 38px);
  }

  .serial-display {
    width: 168px;
    height: 56px;
    font-size: 30px;
  }

  .word-pair {
    gap: 10px;
  }

  .word-card {
    min-width: min(132px, 40vw);
    min-height: 94px;
    padding: 8px;
  }

  .word-card span {
    font-size: clamp(32px, 10vw, 42px);
  }

  .word-card strong {
    font-size: clamp(23px, 7vw, 30px);
  }

  .hand-cue {
    left: 10px;
    top: 50%;
    font-size: 34px;
  }

  .pair-title,
  .orientation-question {
    max-width: 96%;
    font-size: clamp(24px, 7vw, 30px);
  }

  .transcript-input {
    width: 96%;
    height: 82px;
    font-size: 22px;
  }

  .results-page,
  .design-page,
  .admin-page {
    gap: 10px;
    padding: 10px;
    overflow: auto;
  }

  .results-page {
    grid-template-rows: minmax(0, 1fr) auto;
  }

  .design-page {
    overflow: auto;
  }

  .result-hero {
    gap: 6px;
    padding: 10px;
  }

  .result-logo {
    width: 76px;
    height: 76px;
  }

  .result-hero strong {
    font-size: clamp(46px, 13vw, 64px);
  }

  .result-hero p {
    font-size: 18px;
    text-align: center;
  }

  .radar-card {
    width: min(230px, 46dvh);
  }

  .result-medals {
    gap: 7px;
  }

  .result-medals b {
    min-width: 66px;
    min-height: 36px;
    font-size: 15px;
  }

  .results-actions {
    justify-content: center;
  }

  .results-actions .primary,
  .results-actions .ghost,
  .admin-toolbar .primary,
  .admin-toolbar .secondary {
    min-height: 42px;
    padding: 8px 12px;
    font-size: 16px;
  }

  .admin-page {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
  }

  .admin-layout {
    grid-template-columns: minmax(0, 1fr);
    overflow: auto;
  }

  .admin-toolbar {
    justify-content: start;
    overflow-x: auto;
  }

  .admin-filter-bar {
    align-items: flex-start;
    flex-direction: column;
  }

  .admin-pagination {
    width: 100%;
    justify-content: space-between;
  }

  .admin-head,
  .admin-row {
    grid-template-columns: minmax(104px, 1.05fr) minmax(58px, 0.68fr) minmax(58px, 0.48fr) minmax(70px, 0.58fr) minmax(112px, 1fr);
    gap: 6px;
    min-width: 0;
    padding-inline: 8px;
    font-size: 16px;
  }

  .detail-header {
    align-items: start;
    flex-direction: column;
  }

  .detail-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .rubric-page-head {
    display: grid;
    gap: 4px;
    padding: 12px;
  }

  .rubric-page-head p {
    font-size: 16px;
  }

  .rubric-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
  }

  .rubric-group {
    min-height: 0;
    padding: 12px;
  }

  .rubric-group h4 {
    font-size: 22px;
  }

  .rubric-card {
    min-height: 48px;
    padding: 10px;
  }

  .rubric-card span {
    font-size: 19px;
  }

  .rubric-card em {
    font-size: 16px;
  }

  .rubric-modal {
    padding: 8px;
  }

  .rubric-modal-head {
    padding: 14px;
  }

  .rubric-modal-head h3 {
    font-size: clamp(28px, 8vw, 36px);
  }

  .rubric-modal-body {
    gap: 14px;
    padding: 16px;
  }

  .rubric-modal-body p {
    font-size: clamp(22px, 6vw, 28px);
  }
}

@media (max-width: 430px) {
  :root {
    --setup-control-height: 48px;
  }

  .setup-screen {
    padding: 8px;
  }

  .setup-panel {
    padding: 12px;
  }

  .logo-image {
    width: 52px;
    height: 52px;
  }

  .setup-grid {
    gap: 6px;
  }

  .field {
    font-size: 16px;
  }

  .field input,
  .field select,
  .segment-option {
    font-size: 18px;
  }

  .task-page {
    padding-inline: 58px;
  }

  .edge-arrow {
    min-width: 46px;
    height: auto;
    padding: 7px;
    font-size: 28px;
  }

  .edge-arrow svg {
    width: 20px;
    height: 20px;
  }

  .edge-arrow .arrow-label {
    display: none;
  }

  .confirm-button {
    min-width: 84px;
    min-height: 42px;
    padding: 7px 12px;
    font-size: 18px;
  }

  .utility-button {
    min-width: 68px;
    min-height: 40px;
    padding: 6px 10px;
    font-size: 17px;
  }

  .task-actions {
    gap: 6px;
  }

  .drawing-page,
  .drawing-page.cube-page,
  .drawing-page.clock-page {
    grid-template-rows: minmax(104px, 0.3fr) minmax(0, 1fr);
  }

  .option {
    min-height: 48px;
  }

  .memory-page .option {
    min-height: 44px;
    font-size: 17px;
  }

  .circle-button,
  .timer-button,
  .sound-button {
    width: 100px;
    height: 100px;
    min-width: 100px;
    min-height: 100px;
  }
}

@media (max-height: 500px) and (orientation: landscape) {
  :root {
    --setup-control-height: 44px;
  }

  .setup-panel {
    grid-template-columns: minmax(0, 1fr) minmax(112px, 0.32fr);
    grid-template-rows: minmax(0, 1fr);
    gap: 12px;
  }

  .brand-row {
    margin-bottom: 6px;
  }

  .logo-image {
    width: 44px;
    height: 44px;
  }

  h1 {
    font-size: 32px;
  }

  .setup-grid {
    gap: 5px;
  }

  .field {
    font-size: 15px;
  }

  .field input,
  .field select,
  .segment-option {
    font-size: 17px;
  }

  .setup-start-button {
    width: 104px;
    height: 104px;
  }

  .setup-start-button span {
    font-size: 27px;
  }

  .setup-start-button small {
    font-size: 27px;
  }

  .page-shell {
    grid-template-rows: 50px minmax(0, 1fr);
  }

  .page-header {
    padding-block: 4px;
  }

  .icon-button {
    width: 38px;
    height: 38px;
  }

  .header-prompt {
    display: none;
  }

  .task-page {
    padding-top: 4px;
    padding-bottom: 6px;
  }

  .drawing-page {
    grid-template-columns: minmax(150px, 0.8fr) minmax(0, 1.4fr);
    grid-template-rows: minmax(0, 1fr);
  }

  .drawing-page.cube-page {
    grid-template-columns: minmax(150px, 0.8fr) 26px minmax(0, 1.4fr);
    grid-template-rows: minmax(0, 1fr);
  }

  .naming-page {
    grid-template-columns: minmax(120px, 0.5fr) minmax(0, 1fr);
  }

  .animal-emoji {
    width: min(128px, 30dvh);
    font-size: min(106px, 24dvh);
  }

  .option {
    min-height: 42px;
  }

  .circle-button,
  .timer-button,
  .sound-button {
    width: 92px;
    height: 92px;
    min-width: 92px;
    min-height: 92px;
  }
}

@supports (height: 100svh) {
  :root {
    --app-height: 100svh;
  }
}

html,
body,
#app,
.app-shell,
.page-shell {
  min-width: 0;
}

.setup-panel,
.setup-left,
.setup-grid,
.field,
.segmented-options,
.edu-segment-options {
  min-width: 0;
}

.segment-option {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.setup-voice-button {
  max-width: 100%;
  white-space: normal;
}

#app {
  width: min(100vw, var(--app-width));
}

.single-page,
.task-page,
.task-workspace {
  min-width: 0;
}

.task-page {
  height: 100%;
  min-height: 0;
}

.task-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  overflow: hidden;
}

.task-workspace > * {
  min-width: 0;
  min-height: 0;
}

.edge-arrow {
  max-width: min(104px, calc(var(--app-width) * 0.18));
}

@media (max-width: 1024px), (max-height: 760px) {
  .page-shell {
    grid-template-rows: clamp(54px, 9svh, 82px) minmax(0, 1fr);
  }

  .task-page {
    padding-inline: clamp(58px, 9vw, 104px);
  }

  .task-actions {
    min-height: clamp(44px, 7svh, 58px);
  }

  .trail-page,
  .drawing-page,
  .naming-page,
  .memory-page,
  .speech-page,
  .abstraction-page,
  .orientation-page,
  .digit-page,
  .vigilance-page,
  .serial-page,
  .fluency-page,
  .wait-card {
    max-height: 100%;
  }

  .option {
    min-height: clamp(48px, 8svh, 72px);
  }

  .transcript-input {
    max-width: min(620px, 96%);
    height: clamp(78px, 18svh, 132px);
  }
}

@media (max-width: 1180px) and (orientation: portrait) {
  :root {
    --bottom-safe: max(28px, env(safe-area-inset-bottom));
  }

  .setup-screen {
    place-items: stretch;
    overflow-y: auto;
    padding: clamp(12px, 2.4vw, 24px);
  }

  .setup-panel {
    align-self: center;
    max-height: calc(var(--app-height) - 24px);
    overflow-y: auto;
  }

  .task-page {
    overflow-y: auto;
    padding-bottom: calc(var(--bottom-safe) + 8px);
  }

  .task-workspace {
    overflow: hidden;
  }
}

@media (max-width: 820px) and (orientation: portrait) {
  .setup-screen {
    place-items: stretch;
    padding: clamp(10px, 2.4vw, 20px);
    overflow-y: auto;
  }

  .setup-panel {
    align-self: center;
    max-height: calc(var(--app-height) - 20px);
    overflow-y: auto;
  }

  .task-page {
    padding-inline: clamp(52px, 8.5vw, 78px);
  }

  .edge-arrow {
    padding-inline: 8px;
  }

  .memory-options {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-content: start;
  }
}

@media (max-width: 620px) and (orientation: portrait) {
  .setup-panel {
    justify-self: center;
    width: min(360px, calc(100vw - 16px));
    max-width: calc(100vw - 16px);
    overflow-x: hidden;
  }

  .page-shell {
    grid-template-rows: clamp(50px, 7svh, 58px) minmax(0, 1fr);
  }

  .task-page {
    padding: 6px 52px max(8px, env(safe-area-inset-bottom));
  }

  .edu-segment-options {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .voice-setup-row {
    margin-top: 18px;
  }

  .setup-voice-button {
    min-height: 58px;
    padding: 12px 20px;
    font-size: clamp(20px, 5.2vw, 24px);
  }

  .edge-arrow {
    max-width: 44px;
    min-width: 44px;
    padding: 7px;
  }

  .edge-arrow-left {
    left: 4px;
  }

  .edge-arrow-right {
    right: 4px;
  }

  .task-actions {
    grid-template-columns: minmax(0, 1fr) auto;
    min-height: 42px;
  }

  .confirm-button,
  .utility-button {
    min-height: 40px;
  }
}

@media (orientation: landscape) and (max-height: 620px) {
  :root {
    --bottom-safe: max(6px, env(safe-area-inset-bottom));
  }

  .setup-screen {
    place-items: stretch;
    padding: 8px;
    overflow: hidden;
  }

  .setup-panel {
    align-self: stretch;
    align-items: start;
    width: 100%;
    max-height: calc(var(--app-height) - 16px);
    overflow-y: auto;
    padding: clamp(8px, 2.4svh, 14px) clamp(12px, 2.8vw, 18px);
  }

  .brand-row {
    margin-bottom: 6px;
  }

  .field {
    gap: 3px;
  }

  .field > span {
    font-size: 16px;
  }

  .field input,
  .field select,
  .segment-option {
    font-size: 17px;
  }

  .setup-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 5px;
  }

  .setup-grid .field:nth-child(4) {
    grid-column: 1 / -1;
  }

  .segmented-options,
  .edu-segment-options {
    gap: 7px;
  }

  .edu-segment-options {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .voice-setup-row {
    margin-top: 8px;
  }

  .setup-voice-button {
    min-height: 42px;
    padding: 7px 16px;
    font-size: 18px;
  }

  .page-shell {
    grid-template-rows: clamp(44px, 13svh, 58px) minmax(0, 1fr);
  }

  .page-header {
    min-width: 0;
    padding-block: 4px;
  }

  .header-title h2 {
    font-size: clamp(18px, 3svh, 24px);
  }

  .header-prompt {
    display: none;
  }

  .header-progress {
    width: 74px;
  }

  .task-page {
    gap: 4px;
    padding: 4px 56px max(5px, env(safe-area-inset-bottom));
    overflow-y: auto;
  }

  .task-actions {
    min-height: 38px;
  }

  .edge-arrow {
    top: calc(50% - 3px);
    min-width: 42px;
    max-width: 42px;
    padding: 7px;
  }

  .edge-arrow .arrow-label {
    display: none;
  }

  .edge-arrow svg {
    width: 20px;
    height: 20px;
  }

  .trail-page,
  .drawing-page,
  .naming-page,
  .memory-page,
  .speech-page,
  .abstraction-page,
  .orientation-page,
  .digit-page,
  .vigilance-page,
  .serial-page,
  .fluency-page,
  .wait-card {
    border-width: 1px;
  }

  .speech-page,
  .abstraction-page,
  .orientation-page,
  .digit-page,
  .vigilance-page,
  .serial-page,
  .fluency-page,
  .wait-card {
    gap: clamp(5px, 1.8svh, 10px);
    padding: clamp(6px, 1.7svh, 10px);
  }

  .drawing-page,
  .drawing-page.cube-page {
    gap: 8px;
    padding: 8px;
  }

  .circle-button,
  .timer-button,
  .sound-button {
    width: clamp(82px, 24svh, 106px);
    height: clamp(82px, 24svh, 106px);
    min-width: clamp(82px, 24svh, 106px);
    min-height: clamp(82px, 24svh, 106px);
  }

  .audio-wave {
    width: clamp(120px, 34svh, 154px);
    height: clamp(50px, 15svh, 72px);
  }

  .animal-emoji {
    width: min(132px, 34svh);
    font-size: min(108px, 28svh);
  }

  .option {
    min-height: clamp(38px, 11svh, 52px);
    padding-block: 6px;
    font-size: clamp(17px, 5svh, 22px);
  }

  .memory-page {
    gap: 6px;
    padding: 8px;
  }

  .memory-options {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 8px;
  }

  .memory-options .option {
    min-height: clamp(38px, 11svh, 50px);
  }

  .keypad,
  .digit-keypad,
  .serial-keypad {
    grid-template-columns: repeat(3, clamp(50px, 15svh, 64px));
    gap: 6px;
  }

  .keypad button,
  .keypad-spacer {
    min-height: clamp(36px, 11svh, 48px);
  }

  .tap-button {
    min-height: clamp(90px, 28svh, 126px);
  }

  .transcript-input {
    height: clamp(58px, 18svh, 86px);
  }
}

@media (orientation: landscape) and (max-width: 1280px) and (max-height: 900px) {
  :root {
    --setup-control-height: 56px;
  }

  .setup-screen {
    place-items: stretch;
    padding: 12px;
    overflow-y: auto;
  }

  .setup-panel {
    align-self: center;
    width: min(1100px, calc(100vw - 24px));
    max-height: calc(var(--app-height) - 24px);
    padding: clamp(18px, 3svh, 28px) clamp(24px, 3.2vw, 38px);
    overflow-y: auto;
  }

  .brand-row {
    margin-bottom: 14px;
  }

  .logo-image {
    width: clamp(70px, 10svh, 90px);
    height: clamp(70px, 10svh, 90px);
  }

  h1 {
    font-size: clamp(42px, 7svh, 54px);
  }

  .setup-grid {
    gap: 10px;
  }

  .field {
    gap: 6px;
  }

  .field > span {
    font-size: 17px;
  }

  .field input,
  .field select,
  .segment-option {
    font-size: 21px;
  }

  .voice-setup-row {
    margin-top: 18px;
  }

  .setup-voice-button {
    min-height: 54px;
    padding: 11px 28px;
    font-size: 22px;
  }

  .setup-start-button {
    width: clamp(170px, 25svh, 220px);
    height: clamp(170px, 25svh, 220px);
  }
}

@media (orientation: landscape) and (max-height: 430px) {
  .page-shell {
    grid-template-rows: 42px minmax(0, 1fr);
  }

  .task-page {
    padding-inline: 48px;
  }

  .edge-arrow {
    min-width: 38px;
    max-width: 38px;
    padding: 6px;
  }

  .icon-button {
    width: 34px;
    height: 34px;
  }

  .task-actions {
    min-height: 34px;
  }

  .confirm-button,
  .utility-button {
    min-height: 34px;
    padding-block: 5px;
    font-size: 16px;
  }

  .drawing-page {
    grid-template-columns: minmax(128px, 0.8fr) minmax(0, 1.45fr);
  }

  .drawing-page.cube-page,
  .drawing-page.clock-page {
    grid-template-columns: minmax(128px, 0.8fr) 20px minmax(0, 1.45fr);
  }

  .reference-label {
    top: 6px;
    font-size: 16px;
  }

  .clock-time-reference {
    gap: 4px;
    padding: 20px 8px 4px;
  }

  .clock-time-reference strong {
    font-size: clamp(44px, 13svh, 68px);
  }

  .clock-time-reference span {
    font-size: clamp(16px, 5svh, 24px);
  }

  .transcript-input {
    height: clamp(48px, 17svh, 72px);
  }
}

.setup-screen {
  place-items: stretch;
  padding: 0;
  overflow: hidden;
}

.setup-panel {
  align-self: stretch;
  justify-self: stretch;
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: none;
  grid-template-columns: minmax(0, 1.18fr) minmax(220px, 0.62fr);
  gap: clamp(28px, 4.8vw, 76px);
  padding: clamp(28px, 5.2dvh, 76px) clamp(44px, 7.2vw, 118px);
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  overflow: hidden;
}

.setup-panel::after {
  display: none;
}

.setup-left {
  align-self: center;
}

.setup-play-zone {
  align-self: center;
  transform: translateX(clamp(-108px, -7vw, -44px));
}

.play-orbit {
  display: none;
}

@media (orientation: portrait), (max-width: 760px) {
  .setup-screen {
    overflow-y: auto;
  }

  .setup-panel {
    width: 100%;
    max-width: none;
    min-height: 100%;
    height: auto;
    max-height: none;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(150px, auto);
    align-content: center;
    padding: clamp(22px, 4.6svh, 54px) clamp(20px, 6vw, 62px);
    overflow-y: auto;
  }

  .setup-play-zone {
    min-height: auto;
    transform: none;
  }
}

@media (orientation: landscape) and (max-height: 620px) {
  .setup-panel {
    height: 100%;
    min-height: 0;
    grid-template-columns: minmax(0, 1fr) minmax(116px, 0.34fr);
    grid-template-rows: minmax(0, 1fr);
    align-items: center;
    padding: clamp(10px, 3svh, 18px) clamp(18px, 5vw, 50px);
    overflow-y: auto;
  }
}

.task-actions {
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  justify-items: center;
}

.task-actions-left {
  justify-self: start;
}

.task-actions-right {
  justify-self: end;
}

.task-skip-link {
  position: absolute;
  right: clamp(18px, 3vw, 34px);
  bottom: max(10px, env(safe-area-inset-bottom));
  z-index: 7;
  padding: 4px 6px;
  background: transparent;
  color: var(--muted);
  font-size: 16px;
  font-weight: 850;
}

.digit-keypad,
.serial-keypad,
.orientation-keypad {
  grid-template-columns: repeat(3, clamp(88px, 11vw, 122px));
  gap: 16px;
}

.digit-keypad button,
.serial-keypad button,
.orientation-keypad button,
.digit-keypad .keypad-spacer,
.serial-keypad .keypad-spacer,
.orientation-keypad .keypad-spacer {
  min-height: clamp(70px, 10dvh, 94px);
}

.digit-keypad button,
.serial-keypad button,
.orientation-keypad button {
  font-size: clamp(30px, 4vw, 40px);
}

.clock-time-reference strong {
  font-size: clamp(118px, 15vw, 220px);
}

@media (max-width: 760px), (max-height: 620px) {
  .task-actions {
    padding-inline: 48px;
  }

  .task-skip-link {
    right: 10px;
    bottom: max(8px, env(safe-area-inset-bottom));
    font-size: 16px;
  }

  .digit-keypad,
  .serial-keypad,
  .orientation-keypad {
    grid-template-columns: repeat(3, clamp(72px, 22vw, 96px));
    gap: 12px;
  }

  .digit-keypad button,
  .serial-keypad button,
  .orientation-keypad button,
  .digit-keypad .keypad-spacer,
  .serial-keypad .keypad-spacer,
  .orientation-keypad .keypad-spacer {
    min-height: clamp(62px, 11svh, 82px);
  }

  .clock-time-reference strong {
    font-size: clamp(74px, 18vw, 118px);
  }
}

/* Login page polish */
.setup-panel {
  grid-template-columns: minmax(420px, 660px) minmax(0, 1fr);
  align-items: center;
  padding: clamp(28px, 5.2dvh, 70px) clamp(42px, 6.8vw, 112px);
}

.setup-left {
  display: grid;
  align-self: center;
  gap: clamp(18px, 2.2dvh, 26px);
  width: min(660px, 100%);
  padding: clamp(22px, 3.2dvh, 34px);
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.76), rgba(255, 255, 255, 0.58));
  box-shadow: 0 22px 54px rgba(36, 52, 71, 0.14);
  backdrop-filter: blur(12px);
}

.brand-row {
  margin-bottom: 0;
}

.brand-row h1 {
  color: #263640;
  font-size: clamp(58px, 6.4vw, 78px);
  line-height: 1;
}

.setup-grid {
  gap: clamp(14px, 1.9dvh, 20px);
}

.field {
  gap: 10px;
}

.field > span {
  color: #4d6572;
  font-size: clamp(24px, 2.35vw, 30px);
  font-weight: 1000;
  line-height: 1.05;
}

.field input,
.field select {
  height: clamp(68px, 8dvh, 80px);
  min-height: clamp(68px, 8dvh, 80px);
  padding: 0 clamp(18px, 2vw, 24px);
  border: 2px solid rgba(189, 210, 204, 0.86);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.93);
  box-shadow:
    0 4px 0 rgba(174, 193, 184, 0.54),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
  color: #243447;
  font-size: clamp(26px, 2.8vw, 32px);
  font-weight: 950;
}

.field input:focus,
.field select:focus {
  border-color: var(--leaf);
  box-shadow:
    0 4px 0 rgba(18, 122, 73, 0.22),
    0 0 0 5px rgba(34, 169, 107, 0.18);
}

.birth-date-selects {
  gap: 14px;
}

.segmented-options {
  grid-auto-rows: clamp(68px, 8dvh, 80px);
  gap: 14px;
}

.edu-segment-options {
  gap: 12px;
}

.segment-option {
  height: clamp(68px, 8dvh, 80px);
  border: 2px solid rgba(189, 210, 204, 0.86);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.93);
  box-shadow:
    0 4px 0 rgba(174, 193, 184, 0.54),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
  color: #263640;
  font-size: clamp(24px, 2.45vw, 30px);
}

.segment-option:hover:not(.picked) {
  border-color: rgba(34, 169, 107, 0.72);
  background: rgba(235, 250, 242, 0.96);
}

.segment-option.picked {
  border-color: var(--leaf-dark);
  background: linear-gradient(180deg, #34c982, var(--leaf));
  box-shadow: 0 4px 0 var(--leaf-dark);
}

.voice-setup-row {
  justify-content: stretch;
  margin-top: 0;
}

.setup-voice-button {
  width: 100%;
  min-height: clamp(64px, 7.4dvh, 74px);
  padding: 12px 22px;
  border: 2px solid rgba(34, 169, 107, 0.76);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 5px 0 rgba(18, 122, 73, 0.18);
  color: var(--leaf-dark);
  font-size: clamp(24px, 2.5vw, 30px);
}

.setup-start-button {
  display: flex;
  width: 100%;
  height: clamp(76px, 9dvh, 92px);
  min-height: clamp(76px, 9dvh, 92px);
  align-items: center;
  justify-content: center;
  margin-top: 0;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(180deg, #6aaf67, #5b8c5a);
  box-shadow:
    0 7px 0 #4a7a4a,
    0 20px 34px rgba(18,122,73,0.18);
  color: #263640;
  text-align: center;
}

.setup-start-button span {
  font-size: clamp(30px, 3vw, 38px);
  line-height: 1;
}

.setup-start-button small {
  display: none;
}

.setup-start-button::after {
  content: "→";
  display: grid;
  width: clamp(42px, 4vw, 54px);
  height: clamp(42px, 4vw, 54px);
  place-items: center;
  margin-left: 18px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
  color: #263640;
  font-size: clamp(28px, 2.7vw, 34px);
  font-weight: 1000;
  line-height: 1;
}

@media (orientation: landscape) and (max-width: 1280px) and (max-height: 900px) {
  .setup-panel {
    grid-template-columns: minmax(380px, 610px) minmax(0, 1fr);
    padding: clamp(20px, 3.2svh, 34px) clamp(30px, 4.4vw, 56px);
  }

  .setup-left {
    gap: 14px;
    padding: clamp(18px, 2.4svh, 24px);
  }

  .brand-row h1 {
    font-size: clamp(48px, 7svh, 64px);
  }

  .setup-grid {
    gap: 11px;
  }

  .field > span {
    font-size: clamp(24px, 3svh, 28px);
  }

  .field input,
  .field select,
  .segment-option {
    height: clamp(58px, 8svh, 68px);
    min-height: clamp(58px, 8svh, 68px);
    font-size: clamp(26px, 3.4svh, 30px);
  }

  .setup-voice-button {
    min-height: clamp(54px, 7svh, 64px);
    font-size: clamp(21px, 3svh, 25px);
  }

  .setup-start-button {
    height: clamp(64px, 8svh, 76px);
    min-height: clamp(64px, 8svh, 76px);
  }

  .setup-start-button span {
    font-size: clamp(26px, 3.6svh, 32px);
  }
}

@media (orientation: portrait), (max-width: 760px) {
  .setup-screen {
    background-position: center, 48% center;
  }

  .setup-panel {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto;
    align-content: start;
    align-items: start;
    padding: clamp(10px, 2svh, 18px) clamp(12px, 4vw, 24px) 48px;
    overflow-y: auto;
  }

  .setup-left {
    align-self: start;
    width: 100%;
    gap: clamp(9px, 1.4svh, 13px);
    padding: clamp(12px, 3vw, 18px);
  }

  .brand-row h1 {
    font-size: clamp(42px, 11vw, 56px);
  }

  .field > span {
    font-size: clamp(20px, 5.4vw, 26px);
  }

  .field input,
  .field select,
  .segment-option {
    height: clamp(52px, 6.9svh, 62px);
    min-height: clamp(52px, 6.9svh, 62px);
    font-size: clamp(20px, 5.4vw, 26px);
  }

  .birth-date-selects {
    gap: 10px;
  }

  .birth-date-unit-field {
    gap: 6px;
  }

  .birth-date-unit-field select {
    padding-inline: 10px 28px;
    font-size: clamp(24px, 6vw, 30px);
  }

  .birth-date-unit-field > span {
    font-size: clamp(20px, 5.2vw, 26px);
  }

  .edu-segment-options {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .setup-voice-button,
  .setup-start-button {
    min-height: clamp(54px, 6.8svh, 64px);
    font-size: clamp(20px, 5.2vw, 25px);
  }

  .setup-start-button {
    height: clamp(56px, 7.2svh, 66px);
  }

  .setup-start-button span {
    font-size: clamp(22px, 5.8vw, 28px);
  }

  .setup-start-button::after {
    width: clamp(34px, 8.8vw, 42px);
    height: clamp(34px, 8.8vw, 42px);
    margin-left: 12px;
    font-size: clamp(22px, 5.8vw, 28px);
  }
}

/* Full-screen tuning */
.setup-screen {
  padding: 0;
  background-image: none;
  isolation: isolate;
}

.setup-screen::before {
  content: "";
  position: absolute;
  inset: -1px;
  z-index: 0;
  background: none;
}

.setup-screen::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  background: linear-gradient(90deg, rgba(196, 236, 241, 0.48) 0 30%, rgba(196, 236, 241, 0.08) 56%, transparent 78%);
  pointer-events: none;
}

.setup-panel {
  z-index: 1;
  padding: clamp(20px, 4dvh, 56px) clamp(24px, 5vw, 72px);
}

.setup-left {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.70), rgba(255, 255, 255, 0.46));
}

.page-shell {
  grid-template-rows: clamp(56px, 8.5dvh, 84px) minmax(0, 1fr);
}

.task-page {
  padding: clamp(6px, 1dvh, 10px) clamp(8px, 1.4vw, 18px) calc(var(--bottom-safe) + 4px);
  gap: clamp(4px, 0.8dvh, 8px);
}

.task-workspace {
  height: 100%;
}

.trail-page,
.drawing-page,
.naming-page,
.memory-page,
.speech-page,
.abstraction-page,
.orientation-page,
.digit-page,
.vigilance-page,
.serial-page,
.fluency-page,
.wait-card {
  border-radius: 12px;
}

.trail-page,
.drawing-page {
  padding: clamp(8px, 1.2dvh, 12px);
}

.drawing-page {
  gap: clamp(8px, 1.2vw, 14px);
}

.task-actions {
  min-height: clamp(46px, 6.8dvh, 60px);
}

@media (orientation: portrait), (max-width: 760px) {
  .setup-screen::before {
    background-position: 54% center;
  }

  .setup-screen::after {
    background: linear-gradient(180deg, rgba(196, 236, 241, 0.28), rgba(255, 250, 235, 0.10) 58%, rgba(255, 219, 150, 0.12));
  }

  .setup-panel {
    width: 100%;
    max-width: none;
    padding: clamp(10px, 2svh, 18px) clamp(10px, 3vw, 16px) 42px;
  }

  .setup-left {
    width: min(720px, 100%);
    margin: 0 auto;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(255, 255, 255, 0.48));
  }

  .task-page {
    padding: clamp(4px, 0.8svh, 8px) clamp(6px, 1.8vw, 10px) calc(var(--bottom-safe) + 4px);
  }

  .task-actions {
    padding-inline: clamp(28px, 8vw, 48px);
  }
}

/* Latest clinician review adjustments */
:root {
  --login-edge-gap: clamp(16px, 2.3dvh, 28px);
}

.setup-panel {
  padding-top: max(var(--login-edge-gap), env(safe-area-inset-top));
  padding-bottom: max(var(--login-edge-gap), env(safe-area-inset-bottom));
}

.setup-left {
  max-height: calc(var(--app-height) - (var(--login-edge-gap) * 2));
}

.clock-time-reference {
  padding: clamp(16px, 2.6dvh, 26px) clamp(10px, 1.6vw, 18px);
}

.clock-time-reference strong {
  max-width: 100%;
  font-size: clamp(52px, 7vw, 112px);
  white-space: nowrap;
}

.date-input-with-units {
  grid-template-columns: minmax(110px, 1fr) auto minmax(110px, 1fr) auto;
  align-items: center;
  width: min(620px, 96%);
}

.date-input-with-units .date-input-box {
  width: 100%;
}

.date-unit {
  color: var(--ink);
  font-size: clamp(32px, 4vw, 48px);
  font-weight: 1000;
  line-height: 1;
}

.final-celebration {
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 42%, rgba(255, 232, 150, 0.42), transparent 34%),
    linear-gradient(180deg, #fffdf2, #f0fff6);
}

.results-page {
  grid-template-rows: minmax(0, 1fr) auto;
}

.final-celebration strong {
  font-size: clamp(76px, 14dvh, 128px);
}

.final-celebration p {
  color: var(--leaf-dark);
  font-size: clamp(28px, 4vw, 46px);
}

.result-fireworks {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.result-fireworks i {
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: var(--coral);
  box-shadow:
    0 -42px 0 var(--sun),
    32px -30px 0 var(--sky),
    42px 0 0 var(--leaf),
    30px 32px 0 var(--violet),
    0 42px 0 var(--coral),
    -32px 30px 0 var(--sky),
    -42px 0 0 var(--sun),
    -30px -32px 0 var(--leaf);
  opacity: 0;
  animation: fireworkBurst 1.8s ease-out infinite;
}

.result-fireworks i:nth-child(1) {
  left: 24%;
  top: 28%;
}

.result-fireworks i:nth-child(2) {
  right: 22%;
  top: 24%;
  animation-delay: 0.45s;
}

.result-fireworks i:nth-child(3) {
  left: 50%;
  bottom: 30%;
  animation-delay: 0.9s;
}

.final-results-actions {
  justify-content: center;
}

.final-results-actions .primary {
  min-width: min(360px, 70vw);
  min-height: clamp(62px, 8dvh, 78px);
  border-radius: 999px;
  font-size: clamp(24px, 3vw, 32px);
}

.final-results-actions {
  gap: clamp(12px, 2vw, 22px);
  flex-wrap: wrap;
}

.final-results-actions .big-button {
  min-width: min(300px, 42vw);
  min-height: clamp(58px, 7.2dvh, 76px);
  border-radius: 999px;
  font-size: clamp(22px, 2.6vw, 30px);
}

.save-status {
  margin: 0;
  color: var(--leaf-dark);
  font-size: clamp(16px, 2vw, 20px);
  font-weight: 900;
  text-align: center;
}

.save-status.error {
  color: #c23b3b;
}

.continue-survey-button,
.final-results-actions .continue-survey-button {
  min-width: min(420px, 86vw);
  min-height: 88px;
  border-radius: 12px;
  background: linear-gradient(180deg, #ff7f66, #ec5a45);
  color: #fff;
  font-size: 2.25rem;
  box-shadow: 0 10px 0 #b94736, 0 18px 32px rgba(185, 71, 54, 0.22);
}

.continue-survey-button:disabled,
.final-results-actions .continue-survey-button:disabled {
  box-shadow: none;
}

.post-survey-intro-page,
.post-survey-page,
.post-survey-done-page {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 24px;
  padding: 32px;
  text-align: center;
  background:
    linear-gradient(180deg, rgba(255, 253, 242, 0.96), rgba(239, 249, 255, 0.96));
}

.post-survey-intro-copy,
.post-survey-done-panel {
  display: grid;
  gap: 16px;
  width: min(960px, 94%);
}

.post-survey-intro-copy span,
.post-survey-done-panel span,
.post-survey-question-head span {
  color: var(--leaf-dark);
  font-size: 1.25rem;
  font-weight: 950;
}

.post-survey-intro-copy h2,
.post-survey-question,
.post-survey-done-panel h2 {
  max-width: 980px;
  margin: 0;
  color: var(--ink);
  font-size: 2.6rem;
  font-weight: 1000;
  line-height: 1.22;
}

.post-survey-start-button {
  min-width: min(360px, 78vw);
  min-height: 96px;
  border-radius: 12px;
  background: linear-gradient(180deg, #37b77f, #209a65);
  color: #fff;
  font-size: 2.35rem;
  box-shadow: 0 10px 0 #13764b, 0 18px 32px rgba(32, 154, 101, 0.22);
}

.post-survey-question-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: min(1000px, 94%);
  color: var(--muted);
}

.post-survey-question-head strong {
  color: var(--ink);
  font-size: 1.6rem;
  font-weight: 1000;
}

.post-survey-answer-row {
  display: grid;
  grid-template-columns: clamp(44px, 5vw, 64px) minmax(0, 1fr) clamp(44px, 5vw, 64px);
  align-items: center;
  gap: clamp(30px, 5vw, 72px);
  width: min(1440px, 100%);
}

.post-survey-answer-body {
  display: grid;
  place-items: center;
  min-width: 0;
  width: 100%;
}

.post-survey-arrow {
  display: grid;
  place-items: center;
  width: clamp(44px, 5vw, 64px);
  min-height: clamp(96px, 16dvh, 152px);
  padding: 0 0 8px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #8b4b0f;
  font-size: clamp(3.5rem, 5vw, 4.75rem);
  font-weight: 1000;
  line-height: 0.75;
  box-shadow: none;
}

.post-survey-arrow:disabled {
  background: transparent;
  color: #b8c0c8;
  cursor: not-allowed;
  opacity: 0.45;
}

.sus-likert-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 16px;
  width: 100%;
}

.sus-likert-option {
  display: grid;
  place-items: center;
  min-height: 176px;
  padding: 22px 14px;
  border: 3px solid var(--soft-line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  font-size: 2.35rem;
  font-weight: 950;
  line-height: 1.16;
  text-align: center;
  box-shadow: 0 6px 0 rgba(36, 52, 71, 0.12);
}

.sus-likert-option.picked {
  border-color: var(--leaf);
  background: #effbf4;
  box-shadow: 0 6px 0 #97cdae;
}

.nasa-slider-panel {
  display: grid;
  gap: 22px;
  box-sizing: border-box;
  width: 100%;
  padding: 26px;
  border: 3px solid var(--soft-line);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 10px 28px rgba(36, 52, 71, 0.08);
}

.nasa-value-readout {
  color: var(--leaf-dark);
  font-size: 4rem;
  font-weight: 1000;
  line-height: 1;
}

.nasa-slider {
  width: 100%;
  min-height: 52px;
  accent-color: var(--leaf);
}

.nasa-slider::-webkit-slider-thumb {
  width: 52px;
  height: 52px;
}

.nasa-slider::-moz-range-thumb {
  width: 52px;
  height: 52px;
}

.nasa-slider-labels {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  color: var(--ink);
  font-size: 1.7rem;
  font-weight: 950;
  line-height: 1.2;
}

.nasa-slider-labels span:first-child {
  text-align: left;
}

.nasa-slider-labels span:last-child {
  text-align: right;
}

.post-survey-actions {
  display: flex;
  justify-content: center;
  width: min(900px, 94%);
}

.post-survey-actions .big-button {
  min-width: min(460px, 86vw);
  min-height: 82px;
  border-radius: 12px;
  font-size: 2rem;
}

.post-survey-score-strip {
  display: flex;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
}

.post-survey-score-strip b {
  padding: 12px 18px;
  border: 2px solid var(--soft-line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  font-size: 1.3rem;
}

@media (max-width: 760px) {
  .post-survey-intro-page,
  .post-survey-page,
  .post-survey-done-page {
    gap: 12px;
    padding: 18px;
  }

  .post-survey-intro-copy h2,
  .post-survey-question,
  .post-survey-done-panel h2 {
    font-size: 2rem;
  }

  .post-survey-question-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .post-survey-answer-row {
    grid-template-columns: 40px minmax(0, 1fr) 40px;
    gap: 14px;
    width: 100%;
  }

  .post-survey-arrow {
    width: 40px;
    min-height: 86px;
    padding-bottom: 4px;
    font-size: 3rem;
  }

  .sus-likert-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .sus-likert-option {
    min-height: 74px;
    padding: 10px 12px;
    font-size: 1.75rem;
    text-align: center;
  }

  .nasa-value-readout {
    font-size: 3.1rem;
  }

  .nasa-slider-labels {
    font-size: 1.35rem;
  }

  .continue-survey-button,
  .post-survey-start-button,
  .post-survey-actions .big-button {
    min-height: 68px;
    font-size: 1.8rem;
  }
}

@keyframes fireworkBurst {
  0% {
    transform: scale(0.15) rotate(0deg);
    opacity: 0;
  }
  18% {
    opacity: 1;
  }
  68% {
    transform: scale(1) rotate(24deg);
    opacity: 0.9;
  }
  100% {
    transform: scale(1.18) rotate(32deg);
    opacity: 0;
  }
}

@media (orientation: portrait), (max-width: 760px) {
  :root {
    --login-edge-gap: clamp(14px, 1.9svh, 20px);
  }

  .setup-panel {
    padding-top: max(var(--login-edge-gap), env(safe-area-inset-top));
    padding-bottom: max(var(--login-edge-gap), env(safe-area-inset-bottom));
  }

  .setup-left {
    max-height: calc(var(--app-height) - (var(--login-edge-gap) * 2));
  }

  .clock-time-reference strong {
    font-size: clamp(42px, 12vw, 78px);
  }

  .date-input-with-units {
    grid-template-columns: minmax(82px, 1fr) auto minmax(82px, 1fr) auto;
    gap: 10px;
  }

  .date-unit {
    font-size: clamp(26px, 7vw, 34px);
  }
}

/* Viewport safety pass: keep login and task screens inside the visible device area. */
:root {
  --screen-edge-y: max(14px, env(safe-area-inset-top), env(safe-area-inset-bottom));
  --screen-edge-x: clamp(8px, 1.4vw, 18px);
  --login-control: clamp(48px, 7.2svh, 72px);
  --login-button: clamp(54px, 8svh, 82px);
  --login-gap: clamp(7px, 1.25svh, 16px);
  --login-card-pad: clamp(12px, 2.2svh, 26px);
  --login-title: clamp(38px, 7.5svh, 72px);
}

.setup-screen {
  width: 100%;
  height: var(--app-height);
  min-height: var(--app-height);
  padding: var(--screen-edge-y) var(--screen-edge-x);
  place-items: stretch;
  overflow: hidden;
}

.setup-panel {
  width: 100%;
  height: 100%;
  min-height: 0;
  max-height: none;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  gap: clamp(12px, 1.8vw, 28px);
  align-items: center;
  padding: 0;
  overflow: hidden;
}

.setup-left {
  align-self: center;
  display: grid;
  grid-template-rows: auto auto auto auto;
  gap: var(--login-gap);
  justify-self: stretch;
  width: 100%;
  max-height: 100%;
  min-height: 0;
  padding: var(--login-card-pad);
  overflow: hidden;
}

.brand-row h1 {
  font-size: var(--login-title);
  line-height: 0.98;
}

.setup-grid {
  gap: var(--login-gap);
  min-height: 0;
}

.field {
  gap: clamp(3px, 0.55svh, 7px);
}

.field > span {
  font-size: clamp(18px, 3svh, 28px);
  line-height: 1;
}

.field input,
.field select,
.segment-option {
  height: var(--login-control);
  min-height: var(--login-control);
  font-size: clamp(20px, 3.3svh, 30px);
}

.birth-date-selects,
.segmented-options,
.edu-segment-options {
  gap: clamp(6px, 1svh, 12px);
}

.segmented-options {
  grid-auto-rows: var(--login-control);
}

.setup-voice-button,
.setup-start-button {
  min-height: var(--login-button);
}

.setup-voice-button {
  font-size: clamp(20px, 3.2svh, 28px);
}

.setup-start-button {
  height: var(--login-button);
}

.setup-start-button span {
  font-size: clamp(24px, 4svh, 36px);
}

.setup-start-button::after {
  width: clamp(34px, 5.4svh, 50px);
  height: clamp(34px, 5.4svh, 50px);
  font-size: clamp(24px, 3.6svh, 32px);
}

.volume-setup-screen {
  display: grid;
  width: 100%;
  height: var(--app-height);
  min-height: var(--app-height);
  place-items: center;
  padding: var(--screen-edge-y) var(--screen-edge-x);
  overflow: hidden;
  background:
    linear-gradient(120deg, rgba(232, 249, 255, 0.86), rgba(255, 250, 235, 0.92)),
    url("./assets/village/login-hero-v3.webp") center / cover no-repeat;
}

.volume-setup-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.84fr);
  align-items: center;
  gap: clamp(22px, 4vw, 54px);
  width: min(1080px, 96vw);
  padding: clamp(24px, 5dvh, 58px);
  border: 1px solid rgba(255, 255, 255, 0.76);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 22px 54px rgba(36, 52, 71, 0.14);
  backdrop-filter: blur(10px);
}

.volume-setup-copy {
  display: grid;
  gap: clamp(12px, 2dvh, 20px);
  min-width: 0;
}

.volume-setup-copy span {
  color: var(--leaf-dark);
  font-size: clamp(18px, 2vw, 24px);
  font-weight: 1000;
}

.volume-setup-copy h2 {
  margin: 0;
  color: var(--ink);
  font-size: clamp(38px, 6vw, 72px);
  line-height: 1.08;
}

.volume-setup-copy p {
  max-width: 680px;
  margin: 0;
  color: #4d6572;
  font-size: clamp(20px, 2.4vw, 30px);
  font-weight: 850;
  line-height: 1.45;
}

.volume-slider-card {
  display: grid;
  gap: clamp(18px, 3dvh, 30px);
  min-width: 0;
  padding: clamp(22px, 3.2dvh, 34px);
  border: 2px solid rgba(189, 210, 204, 0.72);
  border-radius: 12px;
  background: #fffdf7;
}

.volume-level-value {
  color: var(--coral-dark);
  font-size: clamp(42px, 6vw, 76px);
  font-weight: 1000;
  line-height: 1;
  text-align: center;
}

.volume-slider {
  width: 100%;
  accent-color: var(--coral);
}

.volume-slider-scale,
.volume-setup-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.volume-slider-scale span {
  color: var(--muted);
  font-size: clamp(16px, 1.8vw, 22px);
  font-weight: 900;
}

.volume-setup-actions .big-button {
  flex: 1;
  min-width: 0;
}

.task-guide-page {
  display: grid;
  place-items: center;
  padding: clamp(10px, 2dvh, 22px);
}

.task-guide-card {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: clamp(14px, 2.2dvh, 24px);
  width: min(940px, 100%);
  height: min(100%, 680px);
  min-height: 0;
  padding: clamp(18px, 3dvh, 34px);
  overflow: hidden;
  border: 2px solid rgba(189, 210, 204, 0.82);
  border-radius: 12px;
  background: linear-gradient(180deg, #fffdf7, #eefbf4);
  box-shadow: inset 0 -8px 0 rgba(34, 169, 107, 0.06);
}

.task-guide-copy {
  display: grid;
  justify-items: center;
  gap: clamp(8px, 1.4dvh, 14px);
  max-width: 820px;
  text-align: center;
}

.task-guide-copy span {
  color: var(--leaf-dark);
  font-size: clamp(16px, 1.8vw, 22px);
  font-weight: 1000;
}

.task-guide-copy h2 {
  margin: 0;
  color: var(--ink);
  font-size: clamp(38px, 5.4vw, 68px);
  line-height: 1.08;
}

.task-guide-copy p {
  margin: 0;
  color: #3f5460;
  font-size: clamp(22px, 2.8vw, 34px);
  font-weight: 900;
  line-height: 1.42;
}

.task-guide-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  gap: clamp(12px, 2vw, 22px);
  width: min(620px, 100%);
  justify-self: center;
}

.task-guide-actions .secondary.big-button:not(:disabled) {
  border: 3px solid var(--sky);
  background: #ffffff;
  color: var(--sky);
  box-shadow: 0 5px 0 rgba(63, 141, 243, 0.24), 0 12px 24px rgba(63, 141, 243, 0.12);
}

.task-guide-actions .big-button:disabled {
  background: #eef2ef;
  color: #89958e;
  box-shadow: 0 5px 0 #c9d2cd;
}

.trail-guide-practice {
  display: grid;
  justify-items: center;
  gap: clamp(8px, 1.5dvh, 12px);
  width: min(580px, 100%);
}

.trail-guide-practice p,
.trail-guide-practice strong {
  margin: 0;
  color: var(--leaf-dark);
  font-size: clamp(18px, 2.2vw, 26px);
  font-weight: 1000;
}

.trail-guide-board {
  position: relative;
  width: min(100%, 540px);
  aspect-ratio: 2.35 / 1;
  border: 3px solid rgba(36, 52, 71, 0.16);
  border-radius: 12px;
  background: #fff;
  overflow: hidden;
}

.trail-guide-lines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.trail-guide-lines path {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.trail-guide-lines .guide-arrow {
  stroke: rgba(32, 166, 107, 0.2);
  stroke-width: 8;
  stroke-dasharray: 12 12;
}

.trail-guide-lines .drawn {
  stroke: var(--leaf);
  stroke-width: 7;
}

.trail-guide-node {
  position: absolute;
  display: grid;
  width: clamp(72px, 10vmin, 104px);
  aspect-ratio: 1;
  place-items: center;
  border: 3px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font-size: clamp(30px, 4vw, 48px);
  font-weight: 1000;
  box-shadow: 0 5px 0 #cddbd2;
}

.trail-guide-node.picked {
  border-color: var(--leaf);
  background: #dff7ea;
  color: var(--leaf-dark);
}

.trail-guide-node:disabled {
  background: #f0f3f1;
  color: #9aa6a0;
}

.trail-guide-node.node-1 {
  left: 14%;
  top: 50%;
  transform: translate(-50%, -50%);
}

.trail-guide-node.node-jia {
  left: 50%;
  top: 24%;
  transform: translate(-50%, -50%);
}

.trail-guide-node.node-2 {
  right: 14%;
  top: 50%;
  transform: translate(50%, -50%);
}

.trail-guide-finger {
  position: absolute;
  left: 32%;
  top: 34%;
  font-size: clamp(36px, 6vw, 58px);
  transform: rotate(-28deg);
  animation: trailGuideFinger var(--attention-pulse-duration) ease-in-out infinite;
  pointer-events: none;
}

@keyframes trailGuideFinger {
  0%,
  100% {
    transform: translate(0, 0) rotate(-28deg);
  }
  50% {
    transform: translate(42px, -22px) rotate(-22deg);
  }
}

@media (orientation: portrait), (max-width: 760px) {
  .volume-setup-panel {
    grid-template-columns: minmax(0, 1fr);
    width: min(680px, 100%);
    padding: clamp(18px, 4svh, 34px);
  }

  .volume-setup-copy h2,
  .task-guide-copy h2 {
    font-size: clamp(34px, 9vw, 52px);
  }

  .volume-setup-actions,
  .task-guide-actions {
    grid-template-columns: minmax(0, 1fr);
    flex-direction: column;
  }

  .task-guide-card {
    height: 100%;
    padding: clamp(14px, 3svh, 24px);
  }

  .trail-guide-board {
    aspect-ratio: 1.65 / 1;
  }
}

.app-shell {
  display: grid;
  width: 100%;
  height: var(--app-height);
  padding: var(--screen-edge-y) var(--screen-edge-x);
  overflow: hidden;
}

.page-shell {
  height: 100%;
  min-height: 0;
  grid-template-rows: clamp(56px, 8.2svh, 84px) minmax(0, 1fr);
  overflow: hidden;
}

.page-header {
  min-height: 0;
  padding: clamp(6px, 1svh, 10px) clamp(10px, 1.8vw, 18px);
}

.task-page {
  height: 100%;
  padding: clamp(5px, 0.9svh, 10px) clamp(8px, 1.4vw, 18px) clamp(5px, 0.9svh, 10px);
  overflow: hidden;
}

.task-workspace {
  overflow: hidden;
}

.task-actions {
  min-height: clamp(44px, 6.5svh, 58px);
}

.task-skip-link {
  right: calc(var(--screen-edge-x) + 2px);
  bottom: calc(var(--screen-edge-y) + 2px);
}

@media (orientation: landscape) and (max-height: 720px) {
  :root {
    --screen-edge-y: max(10px, env(safe-area-inset-top), env(safe-area-inset-bottom));
    --login-control: clamp(42px, 8.1svh, 58px);
    --login-button: clamp(44px, 8.2svh, 60px);
    --login-gap: clamp(4px, 0.9svh, 9px);
    --login-card-pad: clamp(9px, 1.8svh, 16px);
    --login-title: clamp(32px, 7.6svh, 50px);
  }

  .setup-panel {
    grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  }

  .setup-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .setup-grid .field:nth-child(4) {
    grid-column: 1 / -1;
  }

  .edu-segment-options {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .field > span {
    font-size: clamp(16px, 3.1svh, 22px);
  }

  .field input,
  .field select,
  .segment-option {
    font-size: clamp(18px, 3.6svh, 24px);
  }

  .setup-start-button::after {
    display: none;
  }
}

@media (orientation: portrait), (max-width: 760px) {
  :root {
    --screen-edge-y: max(12px, env(safe-area-inset-top), env(safe-area-inset-bottom));
    --screen-edge-x: clamp(8px, 2.4vw, 14px);
    --login-control: clamp(46px, 6.4svh, 62px);
    --login-button: clamp(50px, 6.8svh, 64px);
    --login-gap: clamp(6px, 0.95svh, 10px);
    --login-card-pad: clamp(10px, 2.4vw, 16px);
    --login-title: clamp(36px, 6.8svh, 54px);
  }

  .setup-panel {
    grid-template-columns: minmax(0, 1fr);
    align-items: start;
  }

  .setup-left {
    align-self: start;
    width: min(720px, 100%);
    margin: 0 auto;
  }

  .field > span {
    font-size: clamp(18px, 4.6vw, 24px);
  }

  .field input,
  .field select,
  .segment-option {
    font-size: clamp(19px, 5vw, 25px);
  }

  .task-page {
    padding: clamp(4px, 0.7svh, 8px) clamp(6px, 1.8vw, 10px) clamp(4px, 0.7svh, 8px);
  }
}

/* Final device-safe task header pass. Keep titles clear of tablet/browser edges. */
:root {
  --screen-edge-top: max(22px, env(safe-area-inset-top));
  --screen-edge-bottom: max(14px, env(safe-area-inset-bottom));
  --task-header-height: clamp(78px, 10.5svh, 108px);
}

.app-shell {
  padding: var(--screen-edge-top) var(--screen-edge-x) var(--screen-edge-bottom);
}

.page-shell {
  grid-template-rows: var(--task-header-height) minmax(0, 1fr);
}

.page-header {
  min-height: var(--task-header-height);
  padding-block: clamp(10px, 1.4svh, 16px);
}

.header-title h2 {
  font-size: clamp(26px, 3.3svh, 38px);
}

.task-page {
  padding-top: clamp(8px, 1.1svh, 14px);
}

@media (orientation: landscape) and (max-height: 620px) {
  :root {
    --screen-edge-top: max(14px, env(safe-area-inset-top));
    --screen-edge-bottom: max(8px, env(safe-area-inset-bottom));
    --task-header-height: clamp(60px, 15svh, 76px);
  }

  .page-header {
    padding-block: clamp(6px, 1.4svh, 10px);
  }

  .header-title h2 {
    font-size: clamp(20px, 4svh, 28px);
  }
}

@media (orientation: portrait), (max-width: 760px) {
  :root {
    --screen-edge-top: max(20px, env(safe-area-inset-top));
    --screen-edge-bottom: max(12px, env(safe-area-inset-bottom));
    --task-header-height: clamp(72px, 8.8svh, 96px);
  }

  .final-results-actions .big-button {
    min-width: min(320px, 78vw);
  }
}

@media (orientation: portrait), (max-width: 760px) {
  .hearing-page {
    place-items: stretch;
    padding: 12px 14px var(--bottom-safe);
  }

  .hearing-card {
    width: 100%;
    min-height: 0;
    align-content: start;
    padding: clamp(16px, 2.4svh, 24px);
  }

  .hearing-step-card {
    align-content: center;
  }

  .hearing-intro-card,
  .hearing-meter-row,
  .hearing-summary-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .hearing-intro-card {
    align-content: center;
  }

  .hearing-intro-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: clamp(16px, 2.5svh, 24px);
    width: min(560px, 100%);
  }

  .hearing-hero-icon {
    width: min(180px, 58vw);
  }

  .hearing-ear-target,
  .hearing-ear-target.compact {
    width: min(190px, 60vw);
    justify-self: center;
  }

  .hearing-focus-row {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }

  .hearing-response-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .hearing-response-slot {
    min-height: clamp(146px, 22svh, 176px);
  }

  .hearing-response-grid .option {
    min-height: 70px;
  }

  .hearing-play-button {
    width: clamp(132px, 36vw, 160px);
    min-width: clamp(132px, 36vw, 160px);
    height: clamp(132px, 36vw, 160px);
    min-height: clamp(132px, 36vw, 160px);
  }

  .hearing-continue-button {
    min-height: 78px;
  }
}

@media (orientation: landscape) and (max-height: 620px) {
  .hearing-page {
    padding: 8px 64px var(--bottom-safe);
  }

  .hearing-card {
    min-height: 0;
    gap: 10px;
    padding: 14px 18px;
  }

  .hearing-step-card {
    align-content: center;
  }

  .hearing-test-card {
    align-content: stretch;
    grid-template-rows: auto minmax(0, 1fr) auto minmax(66px, auto) minmax(24px, auto);
  }

  .hearing-intro-layout {
    grid-template-columns: 140px minmax(0, 1fr);
    gap: 24px;
    width: min(620px, 100%);
  }

  .hearing-hero-icon {
    width: 132px;
  }

  .hearing-copy h3 {
    margin-bottom: 6px;
    font-size: clamp(28px, 7svh, 42px);
  }

  .hearing-instruction,
  .hearing-summary-note {
    font-size: clamp(16px, 4svh, 20px);
  }

  .hearing-ear-target {
    width: clamp(122px, 22svh, 150px);
  }

  .hearing-ear-target.compact {
    width: clamp(102px, 20svh, 130px);
  }

  .ear-illustration {
    width: min(96px, 72%);
  }

  .hearing-ear-target.compact .ear-illustration {
    width: min(82px, 70%);
  }

  .hearing-ear-target.right .ear-illustration {
    margin-right: 16px;
  }

  .hearing-ear-target.left .ear-illustration {
    margin-left: 16px;
  }

  .hearing-stimulus-panel {
    min-height: 104px;
  }

  .hearing-response-grid .option {
    min-height: 58px;
  }

  .hearing-response-slot {
    min-height: 66px;
  }

.hearing-play-button {
    width: clamp(112px, 22svh, 136px);
    min-width: clamp(112px, 22svh, 136px);
    height: clamp(112px, 22svh, 136px);
    min-height: clamp(112px, 22svh, 136px);
    font-size: 24px;
  }
}

.animal-count-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  width: min(620px, 92%);
  max-height: 92px;
  overflow-y: auto;
}

.animal-count-list span {
  padding: 4px 9px;
  border: 1.5px solid #d8e9ff;
  border-radius: 999px;
  background: #f6fbff;
  color: var(--ink);
  font-size: 16px;
  font-weight: 850;
  line-height: 1.15;
}

.fluency-upload-status {
  margin: -6px 0 0;
  color: var(--muted);
  font-size: clamp(16px, 2vw, 20px);
  font-weight: 900;
  line-height: 1.2;
  text-align: center;
}

.setup-title-row {
  width: 100%;
  justify-content: center;
  gap: clamp(10px, 1.8vw, 18px);
  flex-wrap: nowrap;
}

.setup-title-row > div {
  min-width: 0;
}

.setup-title-row h1 {
  white-space: nowrap;
}

.setup-title-row .setup-voice-button {
  flex: 0 0 auto;
  width: auto;
  min-height: clamp(42px, 5.2dvh, 52px);
  padding: 8px 16px;
  border-radius: 999px;
  font-size: clamp(16px, 1.7vw, 20px);
  line-height: 1.1;
  white-space: nowrap;
}

@media (max-width: 520px) {
  .setup-title-row {
    gap: 8px;
  }

  .setup-title-row h1 {
    font-size: clamp(34px, 10vw, 44px);
  }

  .setup-title-row .setup-voice-button {
    min-height: 38px;
    padding: 7px 10px;
    font-size: 16px;
  }
}

.setup-grid {
  grid-template-columns: minmax(0, 1fr);
}

.participant-name-field,
.birth-date-field,
.sex-field,
.education-field {
  grid-column: 1 / -1;
}

.sex-field .segmented-options {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (orientation: landscape) and (max-height: 620px) and (min-width: 720px) {
  .setup-grid {
    grid-template-columns: minmax(0, 1.35fr) minmax(150px, 0.65fr);
  }

  .participant-name-field,
  .education-field {
    grid-column: 1 / -1;
  }

  .birth-date-field {
    grid-column: 1;
  }

  .sex-field {
    grid-column: 2;
  }
}

.hearing-copy h3 {
  display: grid;
  gap: 0.08em;
  justify-items: center;
}

.hearing-check-button {
  min-width: clamp(210px, 24vw, 280px);
  min-height: clamp(68px, 8dvh, 84px);
  border-radius: 12px;
  font-size: clamp(24px, 3vw, 34px);
}

.hearing-continue-button {
  min-width: min(460px, 88vw);
  min-height: clamp(96px, 13dvh, 124px);
  box-shadow:
    0 8px 0 var(--leaf-dark),
    0 18px 34px rgba(34, 169, 107, 0.22);
}

.final-results-actions .big-button:disabled,
.confirm-button:disabled {
  background: #d9dfdc;
  color: #7a8780;
  box-shadow: 0 4px 0 #b7c1bc;
  opacity: 0.86;
}

.naming-page {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  align-items: center;
  justify-items: stretch;
  gap: clamp(18px, 3vw, 36px);
  padding: clamp(18px, 3dvh, 34px) clamp(20px, 4vw, 48px);
}

.animal-visual-panel {
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  height: 100%;
}

.naming-page .animal-photo {
  width: min(100%, 620px, 76vmin);
  max-height: min(100%, 62dvh);
  object-fit: contain;
  padding: clamp(8px, 1.4vw, 14px);
}

.naming-page .animal-emoji {
  width: min(100%, 440px, 66vmin);
  max-height: 100%;
  font-size: clamp(160px, 28vw, 330px);
}

.naming-page .animal-side {
  display: grid;
  align-content: center;
  gap: clamp(16px, 2.4dvh, 26px);
  width: 100%;
  height: 100%;
}

.naming-page .animal-side h4 {
  margin: 0;
  font-size: clamp(30px, 4.2vw, 52px);
  line-height: 1.1;
  text-align: center;
}

.naming-page .option-grid {
  grid-template-columns: minmax(0, 1fr);
  width: min(520px, 100%);
  justify-self: center;
}

.naming-page .option {
  min-height: clamp(68px, 10dvh, 92px);
  font-size: clamp(24px, 3vw, 34px);
}

.keypad-split-page {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  align-items: stretch;
  justify-items: stretch;
  align-content: stretch;
  gap: clamp(16px, 3vw, 34px);
  overflow: hidden;
}

.keypad-question-panel,
.keypad-panel {
  display: grid;
  min-width: 0;
  min-height: 0;
  height: 100%;
  align-content: center;
  justify-items: center;
  gap: clamp(14px, 2.4dvh, 24px);
}

.keypad-question-panel {
  padding: clamp(8px, 1.6vw, 18px);
}

.keypad-panel {
  padding: clamp(8px, 1.6vw, 18px);
}

.keypad-panel .keypad {
  width: min(520px, 100%);
  height: min(100%, 460px);
  grid-template-columns: repeat(3, minmax(68px, 1fr));
  grid-auto-rows: minmax(58px, 1fr);
  gap: clamp(10px, 1.6vw, 16px);
}

.keypad-panel .keypad button,
.keypad-panel .keypad-spacer {
  height: 100%;
  min-height: 0;
}

.keypad-split-page .digit-answer-prompt,
.keypad-split-page .math-question,
.keypad-split-page .orientation-question {
  max-width: min(520px, 94%);
  text-align: center;
}

.keypad-split-page .digit-answer,
.keypad-split-page .serial-display,
.keypad-split-page .year-digit-row,
.keypad-split-page .date-input-pair {
  max-width: min(520px, 96%);
}

@media (max-width: 560px) {
  .setup-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .participant-name-field,
  .birth-date-field,
  .sex-field,
  .education-field {
    grid-column: 1 / -1;
  }
}

@media (orientation: portrait), (max-width: 760px) {
  .naming-page {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(120px, 0.45fr) minmax(0, 1fr);
  }

  .naming-page .animal-emoji {
    width: min(240px, 58vw);
    font-size: clamp(96px, 28vw, 170px);
  }

  .naming-page .animal-photo {
    width: min(340px, 86vw);
    max-height: 32dvh;
  }

  .naming-page .option {
    min-height: 56px;
  }

  .keypad-split-page {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 0.42fr) minmax(0, 0.58fr);
    gap: 8px;
  }

  .keypad-question-panel,
  .keypad-panel {
    gap: 8px;
    padding: 6px;
  }

  .keypad-panel .keypad {
    width: min(430px, 100%);
    height: min(100%, 350px);
    grid-template-columns: repeat(3, minmax(54px, 1fr));
  }
}

@media (orientation: landscape) and (max-height: 620px) {
  .keypad-split-page {
    gap: 10px;
  }

  .keypad-question-panel,
  .keypad-panel {
    gap: 8px;
    padding: 4px;
  }

  .keypad-panel .keypad {
    height: min(100%, 300px);
    grid-template-columns: repeat(3, minmax(48px, 1fr));
    gap: 8px;
  }

  .naming-page .animal-emoji {
    width: min(100%, 280px, 58vmin);
    font-size: clamp(112px, 24vw, 220px);
  }

  .naming-page .animal-photo {
    width: min(100%, 420px, 66vmin);
    max-height: 46dvh;
  }
}

.birth-date-field .birth-date-unit-field select {
  font-size: clamp(30px, 3.4vw, 38px);
  font-weight: 1000;
}

.birth-date-field .birth-date-unit-field > span {
  font-size: clamp(24px, 2.6vw, 32px);
}

@media (orientation: portrait), (max-width: 760px) {
  .birth-date-field .birth-date-unit-field select {
    padding-inline: 8px 26px;
    font-size: clamp(26px, 7vw, 32px);
  }

  .birth-date-field .birth-date-unit-field > span {
    font-size: clamp(21px, 5.6vw, 27px);
  }
}

.education-field .edu-segment-options {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.hearing-start-button {
  min-width: clamp(260px, 28vw, 360px);
  min-height: clamp(86px, 11dvh, 112px);
  box-shadow:
    0 8px 0 var(--leaf-dark),
    0 18px 34px rgba(34, 169, 107, 0.22);
}

.hearing-recheck-button {
  min-width: clamp(128px, 14vw, 170px);
  min-height: clamp(46px, 6dvh, 58px);
  padding-inline: 18px;
  border: 2px solid #d9e6de;
  background: #f6faf8;
  color: var(--muted);
  box-shadow: 0 3px 0 #cddbd2;
  font-size: clamp(17px, 2vw, 22px);
}

.keypad-split-page {
  gap: clamp(10px, 2vw, 24px);
  padding: clamp(12px, 2dvh, 22px);
}

.keypad-question-panel,
.keypad-panel {
  align-content: stretch;
  place-items: center;
}

.keypad-panel .keypad {
  width: min(100%, 520px);
  height: 100%;
  max-height: 520px;
  grid-auto-rows: minmax(0, 1fr);
  align-self: stretch;
}

.keypad-panel .keypad button,
.keypad-panel .keypad-spacer {
  min-height: 0;
}

.digit-question-panel {
  align-content: center;
}

.digit-mode-label {
  color: var(--ink);
  font-size: clamp(42px, 6vw, 72px);
  font-weight: 1000;
  line-height: 1;
}

.answer-square-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(10px, 1.6vw, 16px);
  width: 100%;
}

.answer-square {
  display: grid;
  width: clamp(76px, 9.5vmin, 112px);
  aspect-ratio: 1;
  place-items: center;
  border: 3px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--leaf-dark);
  box-shadow: 0 4px 0 #cddbd2;
  font-size: clamp(38px, 6vw, 58px);
  font-weight: 1000;
  line-height: 1;
}

.answer-square.empty {
  color: transparent;
}

.digit-answer-squares .answer-square {
  width: clamp(70px, 8.4vmin, 104px);
  height: auto;
}

.serial-page .math-question {
  max-width: min(560px, 96%);
  font-size: clamp(38px, 5.2vw, 66px);
  line-height: 1.12;
  text-align: center;
}

.serial-page .serial-display {
  width: clamp(190px, 22vmin, 270px);
  height: clamp(112px, 16vmin, 170px);
  font-size: clamp(48px, 7vw, 78px);
}

.date-input-with-units {
  width: auto;
  grid-template-columns: auto auto auto auto;
  align-items: center;
  justify-content: center;
  gap: clamp(8px, 1.4vw, 16px);
}

.date-input-with-units .date-input-box {
  width: clamp(86px, 11vmin, 118px);
  min-height: 0;
  aspect-ratio: 1;
}

.date-input-with-units .date-input-box strong {
  font-size: clamp(38px, 6vw, 58px);
}

.abstraction-split-page {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  align-items: stretch;
  justify-items: stretch;
  gap: clamp(18px, 3vw, 36px);
  overflow: hidden;
}

.abstraction-visual-panel,
.abstraction-choice-panel {
  display: grid;
  min-width: 0;
  min-height: 0;
  height: 100%;
  align-content: center;
  justify-items: center;
}

.abstraction-split-page .word-pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(14px, 2vw, 24px);
  width: min(100%, 560px);
}

.abstraction-split-page .word-card {
  min-width: 0;
  min-height: clamp(180px, 34dvh, 280px);
}

.abstraction-split-page .word-card span {
  font-size: clamp(62px, 11vw, 112px);
}

.abstraction-split-page .word-card strong {
  font-size: clamp(34px, 5vw, 58px);
}

.abstraction-choice-panel .abstraction-options {
  width: min(520px, 100%);
  height: min(100%, 460px);
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: repeat(4, minmax(0, 1fr));
}

.abstraction-choice-panel .option {
  min-height: 0;
  font-size: clamp(24px, 3vw, 34px);
}

.orientation-choice-page {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  align-items: stretch;
  justify-items: stretch;
  gap: clamp(16px, 3vw, 34px);
  overflow: hidden;
}

.orientation-choice-question-panel,
.orientation-choice-option-panel {
  display: grid;
  min-width: 0;
  min-height: 0;
  height: 100%;
  align-content: center;
  justify-items: center;
  gap: clamp(14px, 2.4dvh, 24px);
}

.weekday-answer-line {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(12px, 2vw, 20px);
  color: var(--ink);
  font-size: clamp(38px, 5vw, 62px);
  font-weight: 1000;
}

.orientation-answer-square {
  width: clamp(82px, 11vmin, 118px);
}

.orientation-answer-box {
  display: grid;
  width: min(520px, 92%);
  min-height: clamp(94px, 14dvh, 138px);
  place-items: center;
  padding: 14px 18px;
  border: 3px solid var(--line);
  border-left: 7px solid var(--leaf);
  border-radius: 12px;
  background: #fff;
  color: var(--leaf-dark);
  box-shadow: 0 4px 0 #cddbd2;
  font-size: clamp(30px, 4.2vw, 52px);
  font-weight: 1000;
  line-height: 1.15;
  text-align: center;
}

.orientation-answer-box.empty {
  color: transparent;
}

.orientation-choice-option-panel .orientation-options {
  width: min(520px, 100%);
}

.orientation-weekday-options {
  grid-template-columns: repeat(3, minmax(0, clamp(82px, 11vmin, 118px)));
  justify-content: center;
  gap: clamp(10px, 1.8vw, 16px);
}

.orientation-weekday-options .option {
  width: clamp(82px, 11vmin, 118px);
  min-height: 0;
  aspect-ratio: 1;
  padding: 0;
  font-size: clamp(34px, 5vw, 54px);
}

.orientation-weekday-options .option:nth-child(7) {
  grid-column: 2;
}

.orientation-text-options {
  height: min(100%, 430px);
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: repeat(4, minmax(0, 1fr));
}

.orientation-text-options .option {
  min-height: 0;
  font-size: clamp(22px, 2.6vw, 30px);
}

@media (orientation: portrait), (max-width: 760px) {
  .keypad-split-page,
  .abstraction-split-page,
  .orientation-choice-page {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 0.42fr) minmax(0, 0.58fr);
    gap: 8px;
    padding: 8px;
  }

  .answer-square,
  .digit-answer-squares .answer-square,
  .orientation-answer-square,
  .orientation-weekday-options .option {
    width: clamp(54px, 14vw, 78px);
    font-size: clamp(28px, 7vw, 42px);
  }

  .answer-square-row {
    gap: 7px;
  }

  .serial-page .serial-display {
    width: clamp(150px, 38vw, 210px);
    height: clamp(88px, 22vw, 124px);
  }

  .date-input-with-units .date-input-box {
    width: clamp(68px, 18vw, 88px);
  }

  .abstraction-split-page .word-card {
    min-height: clamp(104px, 20dvh, 150px);
  }

  .orientation-weekday-options {
    grid-template-columns: repeat(3, minmax(0, clamp(54px, 14vw, 78px)));
  }
}

/* Keep every numeric keypad on the same footprint as serial subtraction. */
.digit-page.ready.keypad-split-page,
.serial-page.keypad-split-page,
.orientation-number-page.keypad-split-page {
  grid-template-rows: minmax(0, 1fr);
  align-content: stretch;
}

.keypad-panel {
  overflow: hidden;
}

.keypad-panel .digit-keypad,
.keypad-panel .serial-keypad,
.keypad-panel .orientation-keypad {
  width: min(100%, 520px);
  height: min(100%, 520px);
  max-width: 520px;
  max-height: 520px;
  align-self: stretch;
  justify-self: center;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(4, minmax(0, 1fr));
  grid-auto-rows: minmax(0, 1fr);
  gap: clamp(10px, 1.6vw, 16px);
}

.keypad-panel .digit-keypad button,
.keypad-panel .serial-keypad button,
.keypad-panel .orientation-keypad button,
.keypad-panel .digit-keypad .keypad-spacer,
.keypad-panel .serial-keypad .keypad-spacer,
.keypad-panel .orientation-keypad .keypad-spacer {
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  aspect-ratio: auto;
}

.keypad-panel .digit-keypad button,
.keypad-panel .serial-keypad button,
.keypad-panel .orientation-keypad button {
  font-size: clamp(30px, 4vw, 44px);
  line-height: 1;
}

@media (orientation: portrait), (max-width: 760px) {
  .digit-page.ready.keypad-split-page,
  .serial-page.keypad-split-page,
  .orientation-number-page.keypad-split-page {
    grid-template-rows: minmax(0, 0.42fr) minmax(0, 0.58fr);
  }

  .keypad-panel .digit-keypad,
  .keypad-panel .serial-keypad,
  .keypad-panel .orientation-keypad {
    width: min(100%, 430px);
    height: min(100%, 360px);
    max-height: 360px;
    gap: clamp(8px, 2vw, 12px);
  }
}

@media (orientation: landscape) and (max-height: 620px) {
  .keypad-panel .digit-keypad,
  .keypad-panel .serial-keypad,
  .keypad-panel .orientation-keypad {
    width: min(100%, 430px);
    height: min(100%, 300px);
    max-height: 300px;
    gap: 8px;
  }
}

.drawer-panel {
  align-items: stretch;
}

.drawer-task-list {
  width: 100%;
  padding-right: 0;
}

.drawer-item,
.drawer-hearing-link,
.drawer-section-toggle,
.drawer-task {
  box-sizing: border-box;
  width: 100%;
}

.setup-skip-login {
  position: fixed;
  right: max(14px, env(safe-area-inset-right));
  bottom: max(12px, env(safe-area-inset-bottom));
  z-index: 4;
  min-height: 32px;
  padding: 4px 6px;
  border: 0;
  background: transparent;
  color: rgba(87, 98, 110, 0.72);
  font-size: clamp(13px, 1.8vw, 16px);
  font-weight: 750;
  line-height: 1;
  box-shadow: none;
}

.setup-skip-login:hover {
  color: rgba(49, 60, 72, 0.9);
  text-decoration: underline;
}

.digit-question-panel {
  grid-template-rows: minmax(72px, auto) minmax(112px, auto);
}

.digit-answer-squares {
  min-height: clamp(86px, 10vmin, 122px);
}

.answer-square.active {
  border-color: var(--leaf);
  background: #effbf4;
  box-shadow:
    0 4px 0 #97cdae,
    0 0 0 6px rgba(34, 169, 107, 0.16);
}

.secondary.circle-button.sentence-retry-button {
  border: 4px solid var(--leaf);
  background: #fff;
  color: var(--leaf-dark);
  box-shadow: 0 6px 0 #9bcdae;
  animation: none;
}

.post-survey-actions .confirm-button {
  min-width: min(520px, 88vw);
  min-height: clamp(78px, 10dvh, 96px);
  padding-inline: clamp(26px, 5vw, 54px);
  font-size: clamp(28px, 4vw, 40px);
}

.nasa-slider-labels {
  font-size: clamp(30px, 3.2vw, 42px);
}

@media (orientation: portrait), (max-width: 760px) {
  .post-survey-actions .confirm-button {
    min-height: 72px;
    font-size: clamp(26px, 6vw, 34px);
  }

  .nasa-slider-labels {
    font-size: clamp(24px, 6vw, 34px);
  }
}

.guide-character {
  display: block;
  width: min(230px, 28vw);
  max-height: min(360px, 50vh);
  object-fit: contain;
  pointer-events: none;
  user-select: none;
  filter: drop-shadow(0 12px 22px rgba(36, 52, 71, 0.14));
}

.onboarding-screen {
  position: relative;
  display: flex;
  width: 100%;
  height: 100%;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 34px;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(255, 253, 247, 0.96), rgba(238, 251, 244, 0.94)),
    url("./assets/village/login-hero-v3.webp") center / cover no-repeat;
  cursor: pointer;
}

.onboarding-content {
  display: flex;
  width: min(980px, 100%);
  flex: 1;
  align-items: center;
  justify-content: center;
  gap: 34px;
}

.onboarding-character {
  flex: 0 0 auto;
}

.onboarding-bubble {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex: 1 1 auto;
  min-width: 0;
  max-width: 640px;
  padding: 30px 36px;
  border: 2px solid rgba(189, 210, 204, 0.82);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 8px 0 rgba(197, 213, 201, 0.9), 0 18px 34px rgba(36, 52, 71, 0.12);
}

.onboarding-bubble::before {
  content: "";
  position: absolute;
  left: -16px;
  top: 50%;
  width: 0;
  height: 0;
  border-top: 12px solid transparent;
  border-bottom: 12px solid transparent;
  border-right: 16px solid rgba(189, 210, 204, 0.82);
  transform: translateY(-50%);
}

.onboarding-bubble p {
  margin: 0;
  color: var(--ink);
  font-size: 28px;
  font-weight: 850;
  line-height: 1.65;
  text-align: left;
}

.onboarding-hint {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 18px;
  color: rgba(36, 52, 71, 0.68);
  font-size: 18px;
  font-weight: 800;
  animation: hintPulse 2.2s ease-in-out infinite;
}

@keyframes hintPulse {
  0%, 100% { opacity: 0.48; }
  50% { opacity: 0.86; }
}

.onboarding-dots {
  display: flex;
  gap: 10px;
}

.onboarding-dots i {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #cfd9d4;
}

.onboarding-dots i.active {
  background: var(--leaf);
  transform: scale(1.28);
}

.onboarding-dots i.done {
  background: #93c7ab;
}

.setup-welcome {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.setup-welcome-inner {
  display: grid;
  justify-items: center;
  gap: 12px;
}

.setup-welcome .guide-character {
  width: min(250px, 26vw);
  max-height: 360px;
}

.setup-welcome-bubble {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 16px 22px;
  border: 2px solid rgba(189, 210, 204, 0.82);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--ink);
  font-size: 23px;
  font-weight: 850;
  line-height: 1.45;
  text-align: left;
  box-shadow: 0 6px 0 rgba(197, 213, 201, 0.9);
}

.setup-welcome-bubble::after {
  content: "";
  position: absolute;
  bottom: -12px;
  left: 50%;
  width: 0;
  height: 0;
  border-left: 10px solid transparent;
  border-right: 10px solid transparent;
  border-top: 12px solid rgba(189, 210, 204, 0.82);
  transform: translateX(-50%);
}

.hearing-intro-wrapper,
.hearing-summary-wrapper {
  display: flex;
  width: 100%;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  overflow-y: auto;
  padding: 12px;
}

.hearing-guide-character {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 18px;
}

.hearing-guide-character .guide-character {
  width: min(168px, 22vw);
  max-height: 230px;
}

.hearing-guide-bubble {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  max-width: 520px;
  padding: 16px 22px;
  border: 2px solid rgba(189, 210, 204, 0.82);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.96);
  color: var(--ink);
  font-size: 22px;
  font-weight: 800;
  line-height: 1.55;
  text-align: left;
  box-shadow: 0 6px 0 rgba(197, 213, 201, 0.9), 0 12px 26px rgba(36, 52, 71, 0.10);
}

.hearing-guide-bubble::before {
  content: "";
  position: absolute;
  left: -14px;
  bottom: 30px;
  width: 0;
  height: 0;
  border-top: 10px solid transparent;
  border-bottom: 10px solid transparent;
  border-right: 14px solid rgba(189, 210, 204, 0.82);
}

.hearing-guide-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(22, 32, 42, 0.28);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.hearing-guide-popup {
  display: grid;
  width: min(560px, 94vw);
  justify-items: center;
  gap: 18px;
  padding: 28px;
  border: 2px solid rgba(189, 210, 204, 0.82);
  border-radius: 12px;
  background: #fffdf7;
  box-shadow: 0 14px 44px rgba(36, 52, 71, 0.20);
}

.hearing-guide-popup-char .guide-character {
  width: min(170px, 30vw);
  max-height: 240px;
}

.hearing-guide-popup-bubble {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 16px 20px;
  border: 2px solid rgba(189, 210, 204, 0.82);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  font-size: 22px;
  font-weight: 800;
  line-height: 1.55;
  text-align: left;
}

.hearing-guide-popup-bubble p {
  margin: 0;
}

.character-dialog-screen {
  display: flex;
  width: min(1160px, 100%);
  height: min(100%, 720px);
  min-height: 0;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin: 0 auto;
  padding: clamp(12px, 2dvh, 24px);
}

.character-side {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  width: min(190px, 20vw);
}

.character-side .guide-character {
  width: min(190px, 20vw);
  max-height: 310px;
}

.character-dialog-bubble {
  position: relative;
  display: grid;
  flex: 1 1 auto;
  min-width: 0;
  justify-items: center;
  gap: 16px;
  padding: clamp(18px, 3dvh, 32px);
  border: 2px solid rgba(189, 210, 204, 0.82);
  border-radius: 12px;
  background: linear-gradient(180deg, #fffdf7, #eefbf4);
  box-shadow: 0 8px 0 rgba(197, 213, 201, 0.9), 0 18px 34px rgba(36, 52, 71, 0.12);
}

.character-dialog-bubble::before {
  content: "";
  position: absolute;
  left: -16px;
  top: 90px;
  width: 0;
  height: 0;
  border-top: 12px solid transparent;
  border-bottom: 12px solid transparent;
  border-right: 16px solid rgba(189, 210, 204, 0.82);
}

.character-dialog-btn {
  min-width: 190px;
}

.task-guide-panel {
  flex: 1 1 auto;
  min-width: 0;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: clamp(18px, 2.8dvh, 30px);
}

.task-guide-actions--center {
  justify-content: center;
}

.completion-cheer {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  width: min(720px, 100%);
  margin: 10px auto 0;
}

.completion-cheer .guide-character {
  width: min(120px, 22vw);
  max-height: 170px;
}

.completion-bubble {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 14px 20px;
  border: 2px solid rgba(189, 210, 204, 0.82);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.96);
  color: var(--ink);
  font-size: 22px;
  font-weight: 850;
  line-height: 1.45;
  text-align: left;
  box-shadow: 0 6px 0 rgba(197, 213, 201, 0.9);
}

.survey-cta-button {
  border-color: #f0b429;
  background: linear-gradient(180deg, #ffd85a, #f5b820);
  color: #473400;
  box-shadow: 0 7px 0 #c99010, 0 12px 28px rgba(245, 184, 32, 0.28);
}

@media (max-width: 760px) {
  .onboarding-content,
  .character-dialog-screen,
  .hearing-guide-character,
  .completion-cheer {
    flex-direction: column;
  }

  .onboarding-bubble::before,
  .character-dialog-bubble::before,
  .hearing-guide-bubble::before {
    display: none;
  }

  .guide-character,
  .setup-welcome .guide-character,
  .character-side .guide-character {
    width: min(180px, 46vw);
    max-height: 230px;
  }

  .onboarding-bubble p,
  .hearing-guide-bubble,
  .hearing-guide-popup-bubble,
  .completion-bubble {
    font-size: 22px;
  }

  .setup-welcome {
    display: none;
  }
}

.task-page-village {
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: clamp(10px, 1.8dvh, 16px);
  padding-top: clamp(10px, 1.8dvh, 18px);
  background:
    linear-gradient(180deg, rgba(255, 253, 247, 0.94), rgba(238, 251, 244, 0.92)),
    radial-gradient(circle at 12% 18%, rgba(255, 216, 90, 0.24), transparent 30%),
    radial-gradient(circle at 88% 12%, rgba(128, 197, 168, 0.28), transparent 32%);
}

.task-question-dialog {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: end;
  gap: 12px;
  width: min(900px, 100%);
  margin: 0 auto;
  pointer-events: none;
}

.task-question-character {
  display: grid;
  place-items: end center;
}

.task-question-character .guide-character {
  width: min(76px, 10vw);
  max-height: 96px;
}

.task-question-bubble {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  min-height: 48px;
  padding: 10px 16px;
  border: 2px solid rgba(107, 157, 128, 0.42);
  border-radius: 12px;
  background: rgba(255, 253, 247, 0.96);
  color: var(--ink);
  font-size: clamp(20px, 2.2vw, 28px);
  font-weight: 900;
  line-height: 1.35;
  text-align: left;
  white-space: pre-line;
  box-shadow: 0 6px 0 rgba(198, 222, 205, 0.95), 0 16px 30px rgba(36, 52, 71, 0.10);
}

.task-question-bubble::before {
  content: "";
  position: absolute;
  left: -14px;
  bottom: 20px;
  width: 0;
  height: 0;
  border-top: 10px solid transparent;
  border-bottom: 10px solid transparent;
  border-right: 14px solid rgba(107, 157, 128, 0.42);
}

.task-page-village .task-workspace {
  min-height: 0;
}

.task-page-village .trail-page,
.task-page-village .drawing-page,
.task-page-village .naming-page,
.task-page-village .memory-page,
.task-page-village .speech-page,
.task-page-village .abstraction-page,
.task-page-village .orientation-page,
.task-page-village .digit-page,
.task-page-village .vigilance-page,
.task-page-village .serial-page,
.task-page-village .fluency-page {
  border-color: rgba(122, 168, 139, 0.38);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 8px 0 rgba(205, 224, 211, 0.9), 0 18px 34px rgba(36, 52, 71, 0.10);
}

.task-guide-page {
  background:
    linear-gradient(180deg, rgba(255, 253, 247, 0.94), rgba(238, 251, 244, 0.92)),
    radial-gradient(circle at 20% 20%, rgba(255, 216, 90, 0.24), transparent 30%),
    radial-gradient(circle at 84% 16%, rgba(117, 187, 166, 0.24), transparent 30%);
}

.task-guide-page .character-dialog-screen {
  align-items: center;
  justify-content: center;
  height: 100%;
}

.task-guide-page .character-dialog-bubble {
  min-height: 0;
  align-content: center;
  justify-content: center;
  justify-items: stretch;
  border-color: rgba(107, 157, 128, 0.42);
  background: rgba(255, 253, 247, 0.96);
  box-shadow: 0 8px 0 rgba(198, 222, 205, 0.95), 0 18px 34px rgba(36, 52, 71, 0.12);
}

.typewriter-text {
  display: grid;
  white-space: pre-line;
}

.typewriter-measure,
.typewriter-live {
  grid-area: 1 / 1;
}

.typewriter-measure {
  visibility: hidden;
}

.typewriter-text:not(.typewriter-done) .typewriter-live::after {
  content: "";
  display: inline-block;
  width: 0.08em;
  height: 1em;
  margin-left: 3px;
  background: currentColor;
  vertical-align: -0.12em;
  animation: typewriterCaret 0.7s steps(1) infinite;
}

@keyframes typewriterCaret {
  0%, 45% { opacity: 1; }
  46%, 100% { opacity: 0; }
}

.trail-guide-practice {
  width: min(640px, 100%);
}

.trail-guide-board {
  background:
    linear-gradient(180deg, rgba(255, 253, 247, 0.98), rgba(244, 251, 246, 0.98));
}

.trail-guide-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

@media (max-width: 760px) {
  .task-question-dialog {
    grid-template-columns: 1fr;
    justify-items: center;
  }

  .task-question-character .guide-character {
    width: min(110px, 32vw);
  }

  .task-question-bubble::before {
    display: none;
  }
}

.page-shell:has(.task-page-village) .page-header {
  min-height: clamp(62px, 9dvh, 94px);
  padding: clamp(5px, 0.9dvh, 8px) clamp(14px, 2.2vw, 22px);
  align-items: center;
}

.page-shell:has(.task-page-village) .header-title {
  min-width: 0;
}

.page-shell:has(.task-page-village) {
  grid-template-rows: auto minmax(0, 1fr);
}

.page-header.task-answer-header {
  gap: clamp(10px, 1.5vw, 18px);
}

.page-header.task-answer-header .header-title {
  display: flex;
  align-items: center;
  justify-content: center;
}

.page-header.task-answer-header .task-question-dialog {
  width: min(900px, 100%);
  margin: 0;
  align-items: center;
}

.page-header.task-answer-header .task-question-character .guide-character {
  width: min(64px, 7vw);
  max-height: 76px;
}

.page-header.task-answer-header .task-question-bubble {
  min-height: 44px;
  padding: 8px 14px;
  font-size: clamp(20px, 2.2vw, 28px);
}

.task-page-village {
  grid-template-rows: minmax(0, 1fr) auto;
  padding-top: clamp(2px, 0.5dvh, 6px);
  gap: clamp(4px, 0.8dvh, 8px);
}

.task-page-village .task-question-dialog {
  width: min(840px, calc(100% - 32px));
  align-self: start;
}

.task-page-village .task-question-character .guide-character {
  width: min(64px, 8vw);
  max-height: 82px;
}

.task-page-village .task-question-bubble {
  min-height: 46px;
  padding: 9px 15px;
  font-size: clamp(20px, 2.3vw, 28px);
}

.task-page-village .task-workspace {
  grid-row: 1;
  min-height: 0;
}

.task-page-village .task-actions {
  grid-row: 2;
}

.task-guide-page .character-dialog-screen {
  width: min(1180px, 100%);
  height: 100%;
  padding: clamp(10px, 2dvh, 20px);
}

.task-guide-page .character-side .guide-character {
  width: min(210px, 18vw);
  max-height: 330px;
}

.task-guide-page .character-dialog-bubble {
  width: min(720px, 100%);
  min-height: 0;
  padding: clamp(18px, 3dvh, 32px);
  align-content: center;
  justify-items: stretch;
  border-color: rgba(107, 157, 128, 0.42);
  background: rgba(255, 253, 247, 0.96);
}

.task-guide-page .task-guide-copy {
  width: min(660px, 100%);
  justify-items: stretch;
  text-align: left;
}

.task-guide-page .task-guide-copy p {
  color: #000000;
  font-size: 40px;
  font-weight: 900;
  line-height: 1.14;
  text-align: left;
}

.task-guide-page .task-guide-copy .guide-typewriter,
.task-guide-page .task-guide-copy .guide-typewriter span {
  color: #000000;
  font-size: inherit;
  font-weight: inherit;
  line-height: inherit;
}

.trail-guide-page .character-dialog-screen {
  align-items: center;
}

.trail-guide-page .character-side .guide-character {
  width: min(160px, 14vw);
}

.trail-guide-page .character-dialog-bubble {
  width: min(760px, 100%);
  min-height: 0;
  max-height: calc(100dvh - 190px);
  overflow: auto;
  padding: clamp(18px, 2.6dvh, 28px);
}

.trail-guide-page .task-guide-copy p {
  font-size: 40px;
  line-height: 1.16;
}

.trail-guide-page .trail-guide-practice {
  width: min(760px, 100%);
}

.trail-guide-page .trail-guide-board {
  width: min(720px, 100%);
  height: clamp(190px, 30dvh, 280px);
  aspect-ratio: auto;
}

.audio-wave-container,
.audio-wave {
  display: none !important;
}

.audio-text-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 8px 18px;
  border: 2px solid rgba(107, 157, 128, 0.32);
  border-radius: 12px;
  background: rgba(255, 253, 247, 0.92);
  color: var(--ink);
  font-size: clamp(20px, 2.4vw, 28px);
  font-weight: 900;
  box-shadow: 0 4px 0 rgba(198, 222, 205, 0.9);
}

@media (max-width: 760px) {
  .page-header.task-answer-header {
    padding-inline: 10px;
  }

  .page-header.task-answer-header .header-progress {
    display: none;
  }

  .page-header.task-answer-header .task-question-dialog {
    grid-template-columns: auto minmax(0, 1fr);
    justify-items: stretch;
    width: 100%;
  }

  .page-header.task-answer-header .task-question-character {
    display: grid;
  }

  .page-header.task-answer-header .task-question-character .guide-character {
    width: min(52px, 13vw);
    max-height: 62px;
  }

  .page-header.task-answer-header .task-question-bubble {
    font-size: clamp(18px, 4.6vw, 24px);
  }

  .task-page-village .task-question-dialog {
    width: calc(100% - 20px);
  }

  .task-page-village .task-question-character {
    display: none;
  }

  .task-guide-page .character-dialog-screen {
    gap: 8px;
  }

  .task-guide-page .character-side .guide-character {
    width: min(128px, 34vw);
  }

  .task-guide-page .task-guide-copy p {
    font-size: 40px;
  }
}

.page-shell.story-shell {
  grid-template-rows: minmax(0, 1fr);
}

.page-shell.story-shell .page-header {
  display: none;
}

.story-scene-screen {
  --story-dialog-left: clamp(200px, 26vw, 340px);
  --story-dialog-right: clamp(12px, 3vw, 40px);
  --story-character-left: clamp(12px, 3vw, 50px);
  --story-character-width: clamp(210px, 23vw, 320px);
  --story-dialog-fill: #FFFBF2;
  position: relative;
  display: grid;
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  overscroll-behavior-x: none;
  padding: clamp(14px, 2dvh, 28px);
  background: #FFFBF5;
  cursor: default;
}

.story-scene-screen::before {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 34%;
  border-top: 2px solid rgba(34,169,107,0.12);
  background: linear-gradient(180deg, rgba(34,169,107,0.06), rgba(34,169,107,0.02));
  pointer-events: none;
}

.story-scene-screen[data-action] {
  cursor: pointer;
}

.story-dialogue-box {
  position: absolute;
  top: 50%;
  left: var(--story-dialog-left);
  right: var(--story-dialog-right);
  z-index: 3;
  display: grid;
  align-content: center;
  width: auto;
  height: min(50dvh, 420px);
  min-height: clamp(245px, 42dvh, 380px);
  padding: clamp(26px, 4dvh, 44px) clamp(30px, 5vw, 62px);
  border: 3px solid #d4c0a0;
  border-radius: 20px;
  outline: none;
  background: var(--story-dialog-fill);
  box-shadow:
    0 8px 0 #c0a880,
    0 24px 52px rgba(18,122,73,0.18);
  transform: translateY(-50%);
}

.story-dialogue-box::before,
.story-dialogue-box::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 0;
  height: 0;
  pointer-events: none;
  transform: translateY(-50%);
}

.story-dialogue-box::before {
  left: -18px;
  border-top: 14px solid transparent;
  border-bottom: 14px solid transparent;
  border-right: 18px solid #d4c0a0;
}

.story-dialogue-box::after {
  left: -14px;
  border-top: 11px solid transparent;
  border-bottom: 11px solid transparent;
  border-right: 15px solid var(--story-dialog-fill);
}

.story-dialogue-text {
  position: relative;
  z-index: 1;
  margin: 0;
  color: #000;
  font-size: var(--story-dialogue-font-size);
  font-weight: 1000;
  line-height: 1.2;
  text-align: left;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.story-dialogue-text .typewriter-text,
.story-dialogue-text .typewriter-text span {
  color: #000;
  font: inherit;
  line-height: inherit;
}

.story-next-triangle {
  position: absolute;
  left: 50%;
  bottom: clamp(13px, 2.2dvh, 22px);
  z-index: 2;
  width: 0;
  height: 0;
  border-right: 14px solid transparent;
  border-left: 14px solid transparent;
  border-top: 18px solid #d4c0a0;
  transform: translateX(-50%);
  animation: storyTriangleBounce 1.05s ease-in-out infinite;
}

.story-character-stage {
  position: absolute;
  top: 50%;
  left: var(--story-character-left);
  bottom: auto;
  z-index: 2;
  display: grid;
  justify-items: center;
  align-items: end;
  width: var(--story-character-width);
  pointer-events: none;
  transform: translateY(-50%);
}

.story-character-wrap {
  display: grid;
  justify-items: center;
  gap: clamp(8px, 1.3dvh, 14px);
  transform-origin: 50% 90%;
}

.story-character-wrap.nod .story-character,
.story-character-wrap.nod .character-container {
  animation: doctorNod 0.9s ease-in-out 0.25s 2;
}

.story-character-wrap.encourage .story-character,
.story-character-wrap.encourage .character-container {
  animation: doctorEncourage 1.45s ease-in-out infinite;
}

.story-character-stage .character-container {
  width: var(--story-character-width);
  max-height: min(46dvh, 390px);
  filter: drop-shadow(0 18px 24px rgba(41, 52, 43, 0.22));
}

.story-character-stage .character-container .character-base {
  width: 100%;
  height: auto;
  object-fit: contain;
}

.story-character-stage .guide-character {
  width: var(--story-character-width);
  max-height: min(46dvh, 390px);
  object-fit: contain;
  filter: drop-shadow(0 18px 24px rgba(41, 52, 43, 0.22));
}

.character-nameplate {
  display: inline-grid;
  min-height: clamp(44px, 6dvh, 58px);
  place-items: center;
  padding: 6px clamp(20px, 3vw, 34px);
  border: 2px solid #d4c0a0;
  border-radius: 999px;
  background: #FFFBF2;
  color: #3d2b1f;
  font-size: clamp(22px, 3vw, 34px);
  font-weight: 1000;
  line-height: 1;
  text-shadow: 0 2px 0 rgba(46, 38, 30, 0.28);
  box-shadow: 0 6px 0 rgba(63, 51, 37, 0.24);
}

.story-choice-row {
  position: absolute;
  left: var(--story-dialog-left);
  right: var(--story-dialog-right);
  bottom: clamp(24px, 6dvh, 60px);
  z-index: 4;
  display: flex;
  width: auto;
  justify-content: center;
  transform: none;
  pointer-events: none;
}

.story-action-bubble,
.story-status-bubble {
  min-width: min(360px, 82vw);
  min-height: clamp(72px, 10dvh, 92px);
  padding: 14px clamp(28px, 5vw, 52px);
  border-radius: 999px;
  font-size: var(--game-cta-font-size);
  font-weight: 1000;
  line-height: 1.05;
  text-align: center;
}

.story-action-bubble {
  border: 3px solid #5b8c5a;
  background: linear-gradient(180deg, #6aaf67, #5b8c5a);
  color: #fff;
  box-shadow: 0 7px 0 #4a7a4a, 0 14px 28px rgba(90,140,90,0.2);
  pointer-events: auto;
}

.story-status-bubble {
  border: 3px solid #c5d5c9;
  background: #e8f0ea;
  color: #5f6b63;
  box-shadow: 0 6px 0 #c5d5c9;
}

.story-action-bubble:disabled {
  border-color: #c5d5c9;
  background: #e8f0ea;
  color: #7e8a82;
  box-shadow: 0 6px 0 #c5d5c9;
}

.story-status-bubble {
  display: inline-grid;
  place-items: center;
  pointer-events: none;
}

.story-screen--task-guide .story-dialogue-box,
.story-screen--feedback .story-dialogue-box {
  width: auto;
}

.story-screen--feedback .story-dialogue-box {
  --story-dialog-fill: #FFFBF2;
}

.story-screen--task-guide .story-dialogue-text {
  font-size: clamp(32px, 4.2vw, 52px);
  line-height: 1.18;
}

@keyframes storyTriangleBounce {
  0%, 100% {
    transform: translate(-50%, 0);
  }
  50% {
    transform: translate(-50%, 7px);
  }
}

@keyframes doctorNod {
  0%, 100% {
    transform: rotate(0deg) translateY(0);
  }
  45% {
    transform: rotate(1.8deg) translateY(7px);
  }
}

@keyframes doctorEncourage {
  0%, 100% {
    transform: translateY(0) rotate(0deg);
  }
  50% {
    transform: translateY(-8px) rotate(-1deg);
  }
}

@media (max-width: 760px) {
  .story-scene-screen {
    --story-dialog-left: 12px;
    --story-dialog-right: 12px;
    --story-character-left: 12px;
    --story-character-width: min(42vw, 190px);
  }

  .story-dialogue-box {
    top: 12px;
    left: var(--story-dialog-left);
    right: var(--story-dialog-right);
    width: auto;
    height: 50dvh;
    min-height: 238px;
    padding: 24px 24px 40px;
    border-width: 3px;
    border-radius: 20px;
    transform: none;
  }

  .story-dialogue-box::before,
  .story-dialogue-box::after {
    top: auto;
    transform: none;
  }

  .story-dialogue-box::before {
    left: clamp(70px, 22vw, 112px);
    bottom: -28px;
    border-top: 28px solid #6aaf67;
    border-right: 20px solid transparent;
    border-left: 20px solid transparent;
    border-bottom: 0;
  }

  .story-dialogue-box::after {
    left: calc(clamp(70px, 22vw, 112px) + 5px);
    bottom: -20px;
    border-top: 21px solid var(--story-dialog-fill);
    border-right: 15px solid transparent;
    border-left: 15px solid transparent;
    border-bottom: 0;
  }

  .story-dialogue-text {
    font-size: var(--story-dialogue-mobile-font-size);
    line-height: 1.2;
  }

  .story-character-stage {
    top: auto;
    left: var(--story-character-left);
    bottom: clamp(82px, 13dvh, 108px);
    width: var(--story-character-width);
    transform: none;
  }

  .story-character-stage .guide-character {
    width: var(--story-character-width);
    max-height: 34dvh;
  }

  .character-nameplate {
    min-height: 40px;
    padding-inline: 16px;
    font-size: clamp(20px, 5.6vw, 27px);
  }

  .story-choice-row {
    left: var(--story-dialog-left);
    right: var(--story-dialog-right);
    bottom: max(18px, env(safe-area-inset-bottom));
    width: auto;
  }

  .story-action-bubble,
  .story-status-bubble {
    min-width: min(330px, 92vw);
    min-height: 68px;
    padding: 12px 22px;
    font-size: var(--game-cta-mobile-font-size);
  }
}

.drawer-item,
.drawer-hearing-link,
.drawer-section-toggle,
.drawer-task {
  min-height: 62px;
}

.drawer-item,
.drawer-hearing-link,
.drawer-section-toggle {
  padding: 0 16px;
}

.drawer-task {
  padding: 0 16px;
}

.drawer-task span {
  width: 32px;
  height: 32px;
  font-size: 16px;
}

.drawer-task strong {
  font-size: 16px;
}

.hearing-intro-guide-page .story-extra-content {
  width: min(760px, calc(100vw - 32px));
}

.hearing-intro-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(12px, 2vw, 20px);
  flex-wrap: wrap;
  width: 100%;
}

.hearing-intro-action {
  min-width: min(300px, 82vw);
}

.hearing-page {
  background:
    linear-gradient(180deg, rgba(255, 253, 247, 0.94), rgba(238, 251, 244, 0.92)),
    radial-gradient(circle at 12% 18%, rgba(255, 216, 90, 0.18), transparent 30%),
    radial-gradient(circle at 88% 24%, rgba(63, 141, 243, 0.12), transparent 28%);
}

.hearing-card {
  border-color: rgba(189, 210, 204, 0.82);
  background: linear-gradient(180deg, #fffdf7, #eefbf4);
  box-shadow: 0 8px 0 rgba(197, 213, 201, 0.9), 0 18px 34px rgba(36, 52, 71, 0.12);
}

.hearing-test-card {
  grid-template-rows: auto minmax(170px, 1fr) auto minmax(96px, auto) minmax(36px, auto);
}

.hearing-auto-status {
  display: inline-grid;
  min-width: min(420px, 86vw);
  min-height: clamp(76px, 10dvh, 96px);
  grid-template-columns: auto auto;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 12px clamp(22px, 4vw, 42px);
  border: none;
  border-radius: 999px;
  background: linear-gradient(180deg, #6aaf67, #5b8c5a);
  color: #fff;
  font-size: clamp(28px, 3.8vw, 42px);
  font-weight: 1000;
  line-height: 1.05;
  text-align: center;
  box-shadow: 0 7px 0 #4a7a4a, 0 14px 28px rgba(18,122,73,0.2);
}

.hearing-auto-status strong {
  display: inline-grid;
  min-width: 1.4em;
  place-items: center;
  color: #fff;
  font-size: 1.25em;
}

.hearing-auto-status.playing,
.hearing-auto-status.ready {
  grid-template-columns: minmax(0, 1fr);
}

.hearing-auto-status.playing {
  background: #e7f5ff;
  color: #1a2e3f;
  box-shadow: 0 8px 0 #9fc8e8, 0 18px 34px rgba(63, 141, 243, 0.16);
}

.hearing-auto-status.ready {
  background: #e7f8ef;
  color: #1a2e3f;
  box-shadow: 0 8px 0 #9bcdae, 0 18px 34px rgba(34, 169, 107, 0.16);
}

.hearing-response-grid .option {
  border: 2px solid #d9e6de;
  background: #fff;
  color: var(--ink);
  box-shadow: 0 4px 0 #cddbd2;
}

.hearing-response-grid .option:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.18);
}

@media (max-width: 760px) {
  .hearing-intro-controls {
    flex-direction: column;
  }

  .hearing-auto-status {
    grid-template-columns: minmax(0, 1fr);
    min-width: min(330px, 92vw);
    font-size: var(--game-cta-mobile-font-size);
  }
}

@media (max-height: 650px) and (orientation: landscape) {
  .story-dialogue-box {
    min-height: 220px;
    padding-block: 22px 34px;
  }

  .story-dialogue-text {
    font-size: clamp(30px, 4.2vw, 46px);
  }

  .story-character-stage {
    top: 50%;
    bottom: auto;
    transform: translateY(-50%);
  }

  .story-character-stage .guide-character {
    max-height: 39dvh;
  }
}

.onboarding-bubble p,
.setup-welcome-bubble,
.hearing-guide-bubble,
.hearing-guide-popup-bubble,
.completion-bubble,
.task-question-bubble {
  font-size: var(--game-bubble-font-size);
  font-weight: 900;
  line-height: 1.4;
}

.story-action-bubble,
.story-status-bubble,
.confirm-button,
.post-survey-actions .confirm-button,
.continue-survey-button,
.final-results-actions .continue-survey-button,
.hearing-continue-button {
  font-size: var(--game-cta-font-size);
  font-weight: 1000;
}

@media (max-width: 760px) {
  .onboarding-bubble p,
  .setup-welcome-bubble,
  .hearing-guide-bubble,
  .hearing-guide-popup-bubble,
  .completion-bubble,
  .task-question-bubble {
    font-size: var(--game-bubble-mobile-font-size);
  }

  .story-action-bubble,
  .story-status-bubble,
  .confirm-button,
  .post-survey-actions .confirm-button,
  .continue-survey-button,
  .final-results-actions .continue-survey-button,
  .hearing-continue-button {
    font-size: var(--game-cta-mobile-font-size);
  }
}

.setup-panel {
  grid-template-columns: minmax(0, 1fr);
  justify-items: start;
}

.setup-left {
  width: min(620px, 100%);
  justify-self: start;
}

@media (orientation: portrait), (max-width: 760px) {
  .setup-panel {
    justify-items: center;
  }

  .setup-left {
    justify-self: center;
  }
}

.story-scene-screen {
  --story-character-width: clamp(180px, 20vw, 260px);
  display: grid;
  grid-template-columns: auto minmax(0, max-content);
  grid-template-rows: auto auto auto;
  align-content: center;
  justify-content: center;
  align-items: center;
  gap: clamp(18px, 3dvh, 30px) clamp(18px, 3vw, 36px);
  padding: clamp(22px, 4dvh, 44px) clamp(18px, 4vw, 54px);
  background: #ffffff;
  background-image: none;
}

.story-scene-screen::before {
  display: none;
}

.story-dialogue-box {
  position: relative;
  top: auto;
  left: auto;
  right: auto;
  grid-column: 2;
  grid-row: 1;
  width: fit-content;
  max-width: min(720px, calc(100vw - 360px));
  height: auto;
  min-height: 0;
  padding: clamp(22px, 3.2dvh, 34px) clamp(28px, 4vw, 48px);
  align-self: center;
  justify-self: start;
  transform: none;
}

.story-dialogue-text {
  width: fit-content;
  max-width: 100%;
  font-size: clamp(30px, 3.6vw, 48px);
  line-height: 1.18;
}

.story-screen--task-guide .story-dialogue-text {
  font-size: clamp(28px, 3.2vw, 42px);
  line-height: 1.2;
}

.story-character-stage {
  position: relative;
  top: auto;
  left: auto;
  bottom: auto;
  grid-column: 1;
  grid-row: 1;
  width: var(--story-character-width);
  align-self: center;
  justify-self: end;
  transform: none;
}

.story-character-stage .guide-character {
  width: var(--story-character-width);
  max-height: min(40dvh, 300px);
}

.story-extra-content {
  grid-column: 1 / -1;
  grid-row: 2;
  justify-self: center;
  width: min(620px, calc(100vw - 32px));
}

.story-choice-row {
  position: relative;
  left: auto;
  right: auto;
  bottom: auto;
  grid-column: 1 / -1;
  grid-row: 3;
  width: auto;
  min-width: min(360px, 90vw);
  justify-self: center;
  transform: none;
}

.story-action-bubble,
.story-status-bubble {
  min-width: min(340px, 86vw);
}

.trail-guide-page .story-dialogue-box {
  max-width: min(720px, calc(100vw - 240px));
  height: auto;
  min-height: auto;
}
.trail-guide-page .story-character-stage {
  left: clamp(8px, 2vw, 30px);
}
.trail-guide-page .story-extra-content {
  margin-top: -10px;
}

.trail-guide-page .trail-guide-practice {
  width: min(600px, 100%);
}

.answer-confirm-modal {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: clamp(18px, 4vw, 40px);
  background: rgba(255, 255, 255, 0.78);
}

.answer-confirm-panel {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: clamp(14px, 3vw, 28px);
  width: min(760px, 94vw);
}

.answer-confirm-character {
  display: grid;
  justify-items: center;
  gap: 8px;
}

.answer-confirm-character .guide-character {
  width: clamp(116px, 18vw, 180px);
  max-height: 230px;
}

.answer-confirm-bubble {
  position: relative;
  display: grid;
  justify-items: center;
  gap: clamp(10px, 2dvh, 16px);
  padding: clamp(22px, 4vw, 36px);
  border: 3px solid #d4c0a0;
  border-radius: 20px;
  outline: none;
  background: #ffffff;
  box-shadow: 0 8px 0 #c0a880, 0 22px 54px rgba(18,122,73,0.18);
  text-align: center;
}

.answer-confirm-bubble::before,
.answer-confirm-bubble::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 0;
  height: 0;
  transform: translateY(-50%);
}

.answer-confirm-bubble::before {
  left: -34px;
  border-top: 23px solid transparent;
  border-bottom: 23px solid transparent;
  border-right: 34px solid #d4c0a0;
}

.answer-confirm-bubble::after {
  left: -25px;
  border-top: 17px solid transparent;
  border-bottom: 17px solid transparent;
  border-right: 26px solid #ffffff;
}

.answer-confirm-bubble p {
  margin: 0;
  color: #1a2e3f;
  font-size: clamp(24px, 3.2vw, 36px);
  font-weight: 950;
  line-height: 1.15;
}

.answer-confirm-bubble strong {
  max-width: 100%;
  overflow-wrap: anywhere;
  color: #f07a1f;
  font-size: clamp(38px, 6vw, 68px);
  font-weight: 1000;
  line-height: 1.05;
}

.answer-confirm-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(120px, 1fr));
  gap: clamp(12px, 2vw, 18px);
  width: min(360px, 100%);
  margin-top: 4px;
}

.answer-confirm-button {
  min-height: clamp(58px, 8dvh, 76px);
  border-radius: 999px;
  font-size: clamp(26px, 3.4vw, 38px);
  font-weight: 1000;
}

.answer-confirm-button.secondary {
  background: #e8eaed;
  color: #5f6368;
  border: 2px solid #d0d3d6;
  box-shadow: 0 4px 0 #c4c7ca;
}

@media (max-width: 760px) {
  .story-scene-screen {
    --story-character-width: min(38vw, 160px);
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto auto auto;
    align-content: center;
    justify-items: center;
    gap: clamp(12px, 2dvh, 18px);
    padding: 18px 12px;
  }

  .story-dialogue-box {
    grid-column: 1;
    grid-row: 1;
    width: fit-content;
    max-width: calc(100vw - 28px);
    padding: 22px 24px 38px;
  }

  .story-dialogue-text,
  .story-screen--task-guide .story-dialogue-text {
    font-size: clamp(26px, 6.6vw, 36px);
    line-height: 1.2;
  }

  .story-character-stage {
    grid-column: 1;
    grid-row: 2;
    justify-self: center;
    width: var(--story-character-width);
  }

  .story-character-stage .guide-character {
    width: var(--story-character-width);
    max-height: 24dvh;
  }

  .story-extra-content {
    grid-column: 1;
    grid-row: 3;
  }

  .story-choice-row {
    grid-column: 1;
    grid-row: 4;
    min-width: min(330px, 92vw);
  }

  .answer-confirm-panel {
    grid-template-columns: minmax(0, 1fr);
    justify-items: center;
    width: min(420px, 94vw);
  }

  .answer-confirm-bubble::before {
    top: -28px;
    left: 50%;
    border-right: 20px solid transparent;
    border-bottom: 28px solid #6aaf67;
    border-left: 20px solid transparent;
    border-top: 0;
    transform: translateX(-50%);
  }

  .answer-confirm-bubble::after {
    top: -20px;
    left: 50%;
    border-right: 15px solid transparent;
    border-bottom: 21px solid #ffffff;
    border-left: 15px solid transparent;
    border-top: 0;
    transform: translateX(-50%);
  }
}

/* ═══════════════════════════════════════════
   2.5D Layered Character (eyes + mouth overlay)
   ═══════════════════════════════════════════ */
.character-container {
  position: relative;
  width: min(280px, 38vw);
  aspect-ratio: 304 / 375;
  margin: 0 auto;
  user-select: none;
  -webkit-user-select: none;
}
.character-base {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}
.character-eyes {
  position: absolute;
  top: 23.5%;
  left: 50%;
  transform: translateX(-50%);
  width: 32%;
  pointer-events: none;
}
.character-eyes img {
  display: block;
  width: 100%;
  height: auto;
}
.character-mouth {
  position: absolute;
  top: 40%;
  left: 50%;
  transform: translateX(-50%);
  width: 15%;
  pointer-events: none;
}
.character-mouth img {
  display: block;
  width: 100%;
  height: auto;
}

/* ── Ambient + Geo + Welcome ── */
.setup-ambient-extra {
  position: absolute; inset: 0; pointer-events: none; overflow: hidden;
}
.setup-ambient-extra::before {
  content: "";
  position: absolute; width: 46vmin; height: 46vmin;
  top: 35%; left: 52%; border-radius: 50%; filter: blur(90px);
  background: radial-gradient(circle, rgba(175,215,230,0.58) 0%, rgba(175,215,230,0.18) 45%, transparent 70%);
  animation: ambientGlowC 9s ease-in-out infinite;
}
@keyframes ambientGlowC {
  0%,100% { transform: scale(0.9); opacity: 0.55; }
  50%     { transform: scale(1.10); opacity: 0.9; }
}
.setup-geo {
  position: absolute; display: block; pointer-events: none;
  border-radius: 50%; animation: geoFloat 8s ease-in-out infinite; z-index: 0;
}
.setup-geo--ring {
  background: transparent; border: 3.5px solid #a8d5c2;
  box-shadow: inset 0 4px 10px rgba(120,180,160,0.22), 0 8px 24px rgba(120,170,150,0.22);
}
.setup-geo--sphere {
  background: #c8e8d8;
  box-shadow: inset 0 -10px 22px rgba(120,185,158,0.40), inset 0 6px 14px rgba(255,255,255,0.72), 0 12px 32px rgba(120,165,145,0.22);
}
.setup-geo--pill {
  border-radius: 999px; background: #f0e8cc;
  box-shadow: inset 0 -6px 14px rgba(185,168,130,0.34), inset 0 5px 12px rgba(255,255,255,0.68), 0 10px 26px rgba(160,140,105,0.20);
}
.setup-geo-1 { width:110px; height:110px; top:7%; right:12%; animation-delay:0s; }
.setup-geo-2 { width:170px; height:64px; bottom:10%; left:5%; animation-delay:1.5s; }
.setup-geo-3 { width:78px; height:78px; top:52%; left:8%; animation-delay:2.8s; }
.setup-geo-4 { width:56px; height:56px; top:12%; right:26%; animation-delay:3.6s; opacity:0.70; }
@keyframes geoFloat {
  0%,100% { transform: translateY(0) rotate(0deg); }
  30%     { transform: translateY(-14px) rotate(5deg); }
  55%     { transform: translateY(8px) rotate(-3deg); }
  80%     { transform: translateY(-4px) rotate(2deg); }
}
.setup-welcome {
  grid-column: 2; grid-row: 1;
  display: flex; align-items: center; justify-content: center;
  z-index: 1; pointer-events: none; padding-bottom: 40px;
}
.setup-welcome-inner {
  display: flex; flex-direction: column; align-items: center; gap: 14px;
}
.setup-welcome .character-container {
  width: min(260px, 34vw); animation: none;
}
.setup-welcome-bubble {
  position: relative;
  background: rgba(250,248,243,0.82);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: 20px; padding: 20px 30px;
  font-size: clamp(20px, 2.6vw, 26px); font-weight: 800;
  color: var(--ink); text-align: center; line-height: 1.5;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.55), 0 0 0 1px rgba(160,150,130,0.10), 0 6px 28px rgba(100,80,50,0.07);
}
.setup-welcome-bubble::after {
  content: ""; position: absolute; bottom: -10px; left: 50%; transform: translateX(-50%);
  width: 0; height: 0;
  border-left: 10px solid transparent; border-right: 10px solid transparent;
  border-top: 12px solid rgba(250,248,243,0.82);
}

/* ── Sentence page — larger for elderly readability ── */
.sentence-page .circle-button {
  width: 180px; height: 180px;
  font-size: 28px; font-weight: 900;
}
.sentence-page .sentence-wait-copy {
  font-size: 28px; font-weight: 800;
  text-align: center; padding: 16px;
}
.sentence-page .transcript-input {
  font-size: 26px; min-height: 120px; padding: 16px;
}
.sentence-page .task-warning {
  font-size: 24px; font-weight: 800;
}

/* ── Fluency page — clean layout ── */
.fluency-instruction {
  font-size: 28px; font-weight: 900;
  text-align: center; margin: 0 0 16px;
}
.fluency-status-row {
  display: flex; align-items: center; justify-content: center;
  gap: 20px; margin: 16px 0;
}
.fluency-countdown {
  font-size: 64px; font-weight: 1000; color: var(--leaf);
}
.voice-recording-countdown {
  display: grid;
  place-items: center;
  gap: 8px;
  min-width: min(320px, 80vw);
  padding: 18px 26px;
  border: 3px solid rgba(34, 169, 107, 0.34);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  box-shadow: 0 14px 34px rgba(36, 52, 71, 0.12);
  text-align: center;
}
.voice-recording-countdown strong {
  color: var(--leaf);
  font-size: clamp(56px, 8vw, 88px);
  font-weight: 1000;
  line-height: 0.95;
}
.voice-recording-countdown span {
  color: var(--ink);
  font-size: clamp(24px, 3vw, 34px);
  font-weight: 950;
  line-height: 1.12;
}
.fluency-timer {
  font-size: 32px; font-weight: 900; color: var(--ink);
}
.fluency-count {
  font-size: 26px; font-weight: 900; text-align: center; margin: 12px 0;
}
.fluency-words {
  display: flex; flex-wrap: wrap; gap: 10px; justify-content: center;
  padding: 16px; max-width: 700px; margin: 0 auto;
}
.fluency-word-tag {
  background: var(--mint); color: var(--leaf-dark);
  padding: 8px 16px; border-radius: 999px;
  font-size: 22px; font-weight: 800;
}
.fluency-recording-indicator {
  display: flex; align-items: center; gap: 12px;
  font-size: 32px; font-weight: 900; color: var(--coral);
}
.fluency-recording-dot {
  width: 20px; height: 20px; background: var(--coral);
  border-radius: 50%;
  animation: recPulse 1s ease-in-out infinite;
}
.story-extra-content:has(.abstraction-example) {
  grid-column: 2; grid-row: 2;
  justify-self: center; align-self: start;
}
.abstraction-example {
  text-align: center;
  background: #f8faf7;
  border: 2px solid #d8e5dc;
  border-radius: 20px;
  padding: 20px 32px;
  width: 100%;
  max-width: 620px;
}
.abstraction-example-label {
  font-size: 18px; font-weight: 900; color: var(--leaf-dark); margin: 0 0 10px;
}
.abstraction-example-row {
  display: flex; align-items: center; justify-content: center;
  gap: 12px; font-size: 24px; font-weight: 800;
  flex-wrap: wrap;
}
.abstraction-example-word {
  background: #fff; padding: 6px 14px; border-radius: 12px;
  border: 2px solid #e0e5e0;
}
.abstraction-example-arrow {
  font-size: 28px; color: var(--leaf);
}
.abstraction-example-answer {
  background: var(--leaf); color: #fff;
  padding: 6px 18px; border-radius: 12px;
  font-weight: 900;
}
.abstraction-example-hint {
  font-size: 20px; font-weight: 800; color: var(--muted); margin: 10px 0 0;
}
/* Center character vertically in story screen */
.story-character-stage {
  align-self: center;
}
.serial-label {
  font-size: 36px; font-weight: 900; color: var(--ink);
  text-align: center; margin: 0 0 8px;
}
.hearing-summary-dialog {
  display: flex; align-items: center; justify-content: center;
  gap: clamp(24px, 4vw, 48px); width: 100%; max-width: 960px;
  margin: 0 auto; padding: 24px;
}
.hearing-summary-left {
  flex: 0 0 auto;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.hearing-summary-right {
  flex: 1 1 auto; min-width: 0;
  display: flex; flex-direction: column; align-items: center; gap: 16px;
}
.hearing-summary-bubble {
  background: #fff; border: 2px solid #6aaf67; border-radius: 20px;
  padding: 16px 24px; font-size: 24px; font-weight: 800;
  text-align: center; line-height: 1.5;
}
@keyframes recPulse {
  0%,100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* Trail guide — push left and widen */
.trail-guide-page .story-scene-screen {
  --story-character-left: clamp(8px, 2vw, 30px);
  --story-dialog-left: clamp(200px, 24vw, 320px);
  --story-dialog-right: clamp(8px, 2vw, 30px);
}

/* Layout fixes from 排版.pdf */
@media (min-width: 900px) and (orientation: landscape) {
  .setup-panel {
    grid-template-columns: minmax(560px, 720px) minmax(300px, 360px);
    justify-content: start;
    column-gap: clamp(42px, 7vw, 96px);
    padding-inline: clamp(20px, 4.2vw, 72px);
  }

  .setup-left {
    width: 100%;
    max-width: 720px;
  }

  .setup-welcome {
    width: 100%;
    justify-self: center;
  }

  .hearing-intro-guide-page.story-scene-screen {
    grid-template-columns: var(--story-character-width) minmax(500px, 560px);
    column-gap: clamp(24px, 3vw, 42px);
    justify-content: center;
    padding-inline: clamp(18px, 3vw, 44px);
  }

  .hearing-intro-guide-page .story-dialogue-box {
    width: min(560px, calc(100vw - 440px));
    max-width: 560px;
    justify-self: start;
  }

  .hearing-intro-guide-page .story-dialogue-text {
    font-size: clamp(30px, 3.6vw, 48px);
    line-height: 1.18;
  }
}

/* Current task refinements */
.standalone-shell,
.standalone-page-shell {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  overscroll-behavior-x: none;
}

.global-menu-button {
  position: fixed;
  top: max(14px, env(safe-area-inset-top));
  left: max(14px, env(safe-area-inset-left));
  z-index: 18;
}

.page-header {
  padding-left: calc(clamp(16px, 2.5vw, 24px) + 64px);
}

.setup-screen {
  place-items: center;
  padding: max(18px, env(safe-area-inset-top), env(safe-area-inset-bottom)) clamp(18px, 3vw, 34px);
}

.setup-panel {
  width: min(1120px, calc(100vw - clamp(36px, 6vw, 68px)));
  height: auto;
  max-height: calc(var(--app-height) - 36px);
  grid-template-columns: minmax(420px, 1.45fr) minmax(280px, 0.85fr);
  align-self: center;
  justify-self: center;
  align-items: center;
}

.setup-left {
  justify-self: stretch;
}

.setup-welcome {
  justify-self: center;
}

.hearing-intro-guide-page .story-extra-content,
.hearing-guide-page .story-extra-content {
  width: min(760px, calc(100vw - 32px));
}

.hearing-stimulus-panel {
  border: 0;
  background: transparent;
  box-shadow: none;
}

.hearing-auto-status.ready {
  min-height: auto;
  padding: 6px 8px;
  background: transparent;
  color: var(--ink);
  box-shadow: none;
}

.hearing-response-grid .option {
  border: 0;
}

.hearing-response-grid .option.picked,
.hearing-response-grid .option.picked:disabled {
  opacity: 1;
  color: #fff;
  transform: translateY(3px);
}

.hearing-response-grid .hearing-heard.picked,
.hearing-response-grid .hearing-heard.picked:disabled {
  background: #4a7a4a;
  box-shadow: inset 0 3px 0 rgba(255, 255, 255, 0.24), 0 2px 0 #315d35;
}

.hearing-response-grid .hearing-missed.picked,
.hearing-response-grid .hearing-missed.picked:disabled {
  background: #c65f4c;
  box-shadow: inset 0 3px 0 rgba(255, 255, 255, 0.24), 0 2px 0 #8f3f32;
}

@media (orientation: portrait), (max-width: 760px) {
  .setup-panel {
    width: min(720px, calc(100vw - 24px));
    max-height: calc(var(--app-height) - 24px);
    grid-template-columns: minmax(0, 1fr);
    align-items: center;
  }

}

/* Clinician review: fuller login, calmer guides, clearer hearing choices */
.setup-screen {
  padding: max(8px, env(safe-area-inset-top), env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left), env(safe-area-inset-right));
}

.setup-panel {
  width: min(1380px, calc(100vw - 16px));
  height: calc(var(--app-height) - 16px);
  max-height: calc(var(--app-height) - 16px);
  grid-template-columns: minmax(560px, 1.55fr) minmax(360px, 0.95fr);
  gap: clamp(20px, 3vw, 46px);
  padding: clamp(12px, 2dvh, 22px) clamp(16px, 2.5vw, 34px);
}

.setup-left {
  width: 100%;
  max-width: none;
  padding: clamp(18px, 3dvh, 36px);
}

.setup-grid {
  gap: clamp(12px, 1.8dvh, 20px);
}

.setup-welcome {
  width: 100%;
  padding-bottom: 0;
}

.setup-welcome-inner {
  gap: clamp(12px, 2dvh, 22px);
}

.setup-welcome .character-container {
  width: min(430px, 34vw);
  max-height: min(60dvh, 520px);
}

.setup-welcome-bubble {
  padding: clamp(18px, 2.8dvh, 28px) clamp(24px, 3.4vw, 42px);
  font-size: clamp(24px, 2.6vw, 34px);
}

.story-dialogue-box,
.story-screen--task-guide .story-dialogue-box,
.story-screen--feedback .story-dialogue-box {
  height: clamp(310px, 44dvh, 390px);
  min-height: clamp(310px, 44dvh, 390px);
  max-height: clamp(310px, 44dvh, 390px);
  align-content: center;
}

.story-dialogue-text {
  max-height: 100%;
}

.hearing-guide-page .story-extra-content {
  display: none;
}

.hearing-test-card {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: clamp(14px, 2dvh, 24px);
  align-content: stretch;
  justify-items: stretch;
  overflow: hidden;
}

.hearing-test-layout {
  display: grid;
  grid-template-columns: minmax(170px, 240px) minmax(0, 1fr);
  gap: clamp(18px, 3vw, 44px);
  width: 100%;
  height: 100%;
  min-height: 0;
  align-items: stretch;
}

.hearing-test-info-column {
  display: grid;
  grid-template-rows: minmax(120px, 1fr) repeat(2, minmax(92px, auto));
  gap: clamp(10px, 1.8dvh, 16px);
  min-width: 0;
  align-content: center;
}

.hearing-test-choice-column {
  display: grid;
  grid-template-rows: minmax(86px, auto) minmax(190px, 1fr) minmax(44px, auto);
  gap: clamp(18px, 3dvh, 34px);
  min-width: 0;
  min-height: 0;
  place-items: center stretch;
}

.hearing-test-card .hearing-stage-label {
  justify-self: center;
}

.hearing-test-card .hearing-ear-target.compact {
  width: 100%;
  min-height: 0;
  align-self: stretch;
}

.hearing-test-card .hearing-ear-target.compact .ear-illustration {
  width: min(138px, 100%);
}

.hearing-test-card .hearing-stimulus-panel {
  min-height: 92px;
  padding: 10px 8px;
}

.hearing-test-card .hearing-stimulus-panel span {
  font-size: clamp(17px, 1.7vw, 22px);
}

.hearing-test-card .hearing-stimulus-panel strong {
  font-size: clamp(25px, 2.7vw, 36px);
}

.hearing-test-choice-column .hearing-auto-status {
  justify-self: center;
}

.hearing-test-choice-column .hearing-response-slot {
  width: min(820px, 100%);
  min-height: clamp(190px, 32dvh, 280px);
}

.hearing-test-choice-column .hearing-response-grid {
  width: 100%;
  grid-template-columns: repeat(2, minmax(210px, 1fr));
  gap: clamp(20px, 3vw, 36px);
}

.hearing-test-choice-column .hearing-response-grid .option {
  min-height: clamp(150px, 24dvh, 230px);
  font-size: clamp(34px, 5vw, 58px);
  border: 0;
  border-radius: 18px;
  box-shadow: 0 8px 0 #cddbd2, 0 18px 34px rgba(36, 52, 71, 0.12);
  transform: none;
}

.hearing-response-grid .option:active,
.hearing-response-grid .option.picked,
.hearing-response-grid .option.picked:disabled {
  transform: none;
}

.hearing-response-grid .hearing-heard.picked,
.hearing-response-grid .hearing-heard.picked:disabled {
  box-shadow: 0 8px 0 #315d35, 0 18px 34px rgba(36, 52, 71, 0.12);
}

.hearing-response-grid .hearing-missed.picked,
.hearing-response-grid .hearing-missed.picked:disabled {
  box-shadow: 0 8px 0 #8f3f32, 0 18px 34px rgba(36, 52, 71, 0.12);
}

.hearing-message-slot {
  min-height: 44px;
}

@media (orientation: portrait), (max-width: 760px) {
  .setup-panel {
    width: calc(100vw - 16px);
    height: calc(var(--app-height) - 16px);
    max-height: calc(var(--app-height) - 16px);
    padding: 10px;
  }

  .setup-welcome .character-container {
    width: min(300px, 62vw);
  }

  .story-dialogue-box,
  .story-screen--task-guide .story-dialogue-box,
  .story-screen--feedback .story-dialogue-box {
    height: clamp(250px, 42dvh, 330px);
    min-height: clamp(250px, 42dvh, 330px);
    max-height: clamp(250px, 42dvh, 330px);
  }

  .hearing-test-layout {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
  }

  .hearing-test-info-column {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-template-rows: auto;
  }

  .hearing-test-choice-column .hearing-response-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .hearing-test-choice-column .hearing-response-grid .option {
    min-height: clamp(104px, 17dvh, 142px);
    font-size: clamp(30px, 9vw, 44px);
  }
}

/* Trail practice guide: keep the example fully visible on short and narrow screens */
.trail-guide-page:has(.trail-guide-practice).story-scene-screen {
  --trail-practice-board-height: clamp(150px, 31dvh, 300px);
  grid-template-columns: minmax(104px, 18vw) minmax(0, 1fr);
  grid-template-rows: minmax(0, auto) minmax(0, 1fr) auto;
  column-gap: clamp(10px, 2vw, 28px);
  row-gap: clamp(8px, 1.2dvh, 14px);
  align-content: stretch;
  padding: clamp(8px, 1.4dvh, 16px) clamp(12px, 2.2vw, 26px);
}

.trail-guide-page:has(.trail-guide-practice) .story-character-stage {
  grid-column: 1;
  grid-row: 1 / 3;
  width: min(150px, 16vw, 28dvh);
  align-self: center;
  justify-self: end;
}

.trail-guide-page:has(.trail-guide-practice) .story-character-stage .guide-character {
  width: 100%;
  max-height: min(260px, 42dvh);
}

.trail-guide-page:has(.trail-guide-practice) .story-dialogue-box {
  grid-column: 2;
  grid-row: 1;
  width: min(820px, 100%);
  max-width: 100%;
  height: auto;
  min-height: clamp(118px, 18dvh, 180px);
  max-height: none;
  overflow: visible;
  align-self: end;
  justify-self: start;
  padding: clamp(14px, 2.1dvh, 24px) clamp(18px, 3vw, 34px);
}

.trail-guide-page:has(.trail-guide-practice) .story-dialogue-text {
  font-size: clamp(24px, 2.7vw, 36px);
  line-height: 1.18;
}

.trail-guide-page:has(.trail-guide-practice) .story-extra-content {
  grid-column: 1 / -1;
  grid-row: 2;
  align-self: stretch;
  width: min(820px, 100%);
  min-height: 0;
  margin-top: 0;
}

.trail-guide-page:has(.trail-guide-practice) .trail-guide-practice {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  align-items: stretch;
  gap: clamp(6px, 1dvh, 10px);
  width: min(820px, 100%);
  height: 100%;
  min-height: 0;
}

.trail-guide-page:has(.trail-guide-practice) .trail-guide-board {
  width: 100%;
  height: min(var(--trail-practice-board-height), 100%);
  min-height: clamp(138px, 24dvh, 210px);
  max-height: 100%;
  aspect-ratio: auto;
}

.trail-guide-page:has(.trail-guide-practice) .trail-guide-practice strong {
  min-height: 1.35em;
  font-size: clamp(16px, 1.8vw, 22px);
  line-height: 1.28;
  text-align: center;
}

.trail-guide-page:has(.trail-guide-practice) .story-choice-row {
  grid-column: 1 / -1;
  grid-row: 3;
  align-self: end;
}

@media (max-height: 700px) and (orientation: landscape) {
  .trail-guide-page:has(.trail-guide-practice).story-scene-screen {
    --trail-practice-board-height: clamp(128px, 30dvh, 210px);
    grid-template-columns: minmax(80px, 13vw) minmax(0, 1fr);
    row-gap: 6px;
    padding-block: 6px;
  }

  .trail-guide-page:has(.trail-guide-practice) .story-character-stage {
    width: min(112px, 13vw, 24dvh);
  }

  .trail-guide-page:has(.trail-guide-practice) .story-dialogue-box {
    min-height: 96px;
    padding: 12px 18px;
  }

  .trail-guide-page:has(.trail-guide-practice) .story-dialogue-text {
    font-size: clamp(21px, 2.3vw, 30px);
    line-height: 1.12;
  }

  .trail-guide-page:has(.trail-guide-practice) .trail-guide-board {
    min-height: 126px;
  }

  .trail-guide-page:has(.trail-guide-practice) .trail-guide-practice strong {
    font-size: clamp(15px, 1.7vw, 19px);
  }
}

@media (orientation: portrait), (max-width: 760px) {
  .trail-guide-page:has(.trail-guide-practice).story-scene-screen {
    --trail-practice-board-height: clamp(180px, 34dvh, 330px);
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto minmax(0, 1fr) auto;
  }

  .trail-guide-page:has(.trail-guide-practice) .story-character-stage {
    grid-column: 1;
    grid-row: 1;
    width: min(118px, 28vw);
    align-self: center;
    justify-self: center;
  }

  .trail-guide-page:has(.trail-guide-practice) .story-dialogue-box {
    grid-column: 1;
    grid-row: 2;
    justify-self: center;
    min-height: clamp(112px, 18dvh, 170px);
  }

  .trail-guide-page:has(.trail-guide-practice) .story-extra-content {
    grid-column: 1;
    grid-row: 3;
  }

  .trail-guide-page:has(.trail-guide-practice) .story-choice-row {
    grid-column: 1;
    grid-row: 4;
  }
}

/* Final stability pass for the clinician QA list. */
.setup-panel {
  overflow: visible;
}

.setup-left {
  grid-template-rows: auto minmax(0, auto) auto;
  align-content: center;
  overflow: visible;
}

.setup-grid {
  align-content: center;
  overflow: visible;
}

.field input,
.field select,
.segment-option,
.transcript-input,
.serial-display,
.orientation-answer-box,
.date-input-box,
.answer-square {
  border-radius: 12px;
}

.setup-start-button {
  flex-shrink: 0;
  position: relative;
  z-index: 5;
}

.hearing-card {
  overflow: hidden;
}

.hearing-test-card {
  width: min(1040px, 100%);
  justify-self: center;
  align-content: stretch;
}

.hearing-test-layout {
  grid-template-columns: minmax(150px, 220px) minmax(0, 1fr);
  align-items: stretch;
}

.hearing-test-info-column {
  grid-template-rows: minmax(110px, 1fr) repeat(2, minmax(84px, auto));
}

.hearing-test-choice-column {
  grid-template-rows: minmax(82px, auto) minmax(190px, 1fr) minmax(44px, auto);
}

.hearing-test-choice-column .hearing-response-slot {
  visibility: visible;
  pointer-events: auto;
}

.hearing-test-choice-column .hearing-response-slot:not(.ready) {
  opacity: 0;
  pointer-events: none;
}

.hearing-test-choice-column .hearing-response-grid .option:disabled {
  pointer-events: none;
}

.digit-page.ready.keypad-split-page,
.serial-page.keypad-split-page {
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr);
}

.digit-question-panel {
  grid-template-rows: minmax(76px, auto) minmax(120px, auto);
  min-height: 100%;
}

.digit-mode-label {
  min-height: 1.1em;
}

.digit-answer-squares {
  min-height: clamp(96px, 12vmin, 132px);
}

.serial-page.keypad-split-page {
  place-items: center;
}

.serial-page .keypad-question-panel {
  width: min(520px, 100%);
  justify-self: end;
}

.serial-page .keypad-panel {
  width: min(520px, 100%);
  justify-self: start;
}

.serial-page .serial-display {
  width: min(100%, 520px);
  height: clamp(76px, 11dvh, 102px);
  max-width: none;
  padding: 0 clamp(18px, 3vw, 28px);
  border: 3px solid var(--line);
  border-left: 7px solid var(--leaf);
  box-shadow: 0 4px 0 #cddbd2;
  color: var(--leaf-dark);
  font-size: clamp(36px, 5vw, 58px);
  line-height: 1;
  text-align: center;
}

.serial-page .serial-display.empty {
  color: #8fa09a;
  font-size: clamp(24px, 3vw, 34px);
}

.orientation-choice-page,
.orientation-number-page.keypad-split-page {
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(118px, 0.36fr) minmax(0, 0.64fr);
  gap: clamp(12px, 2dvh, 22px);
}

.orientation-choice-question-panel,
.orientation-choice-option-panel,
.orientation-number-page .keypad-question-panel,
.orientation-number-page .keypad-panel {
  width: 100%;
  height: 100%;
}

.orientation-choice-question-panel,
.orientation-number-page .keypad-question-panel {
  align-content: end;
  padding-bottom: clamp(6px, 1.2dvh, 14px);
}

.orientation-choice-option-panel,
.orientation-number-page .keypad-panel {
  align-content: start;
  padding-top: clamp(6px, 1.2dvh, 14px);
}

.orientation-choice-option-panel .orientation-options,
.orientation-number-page .orientation-keypad {
  width: min(620px, 100%);
}

.orientation-text-options {
  height: min(100%, 360px);
}

.orientation-answer-box {
  width: min(620px, 92%);
}

.voice-finish-button {
  width: min(420px, 90%);
  min-height: 160px;
  border-radius: 999px;
  background: linear-gradient(180deg, #6aaf67, #5b8c5a);
  box-shadow: 0 7px 0 #4a7a4a;
  color: #fff;
  font-size: 36px;
  font-weight: 900;
}

.fluency-page,
.sentence-page,
.vigilance-page {
  gap: clamp(16px, 3dvh, 28px);
}

.fluency-instruction,
.sentence-wait-copy {
  max-width: min(760px, 94%);
  margin: 0;
  color: var(--ink);
  font-size: clamp(26px, 3.4vw, 42px);
  font-weight: 950;
  line-height: 1.24;
  text-align: center;
}

@media (orientation: landscape) and (max-height: 720px) {
  .setup-panel {
    grid-template-columns: minmax(430px, 1.45fr) minmax(260px, 0.9fr);
    gap: clamp(12px, 2vw, 26px);
    padding: clamp(8px, 1.4dvh, 14px) clamp(12px, 2vw, 22px);
  }

  .setup-left {
    padding: clamp(10px, 1.8dvh, 18px);
    gap: clamp(7px, 1.05dvh, 12px);
  }

  .brand-row h1 {
    font-size: clamp(36px, 7.2dvh, 50px);
  }

  .field > span {
    font-size: clamp(16px, 3dvh, 22px);
  }

  .field input,
  .field select,
  .segment-option {
    height: clamp(44px, 8.1dvh, 58px);
    min-height: clamp(44px, 8.1dvh, 58px);
    font-size: clamp(18px, 3.5dvh, 24px);
  }

  .segmented-options,
  .edu-segment-options {
    gap: clamp(6px, 1dvh, 10px);
  }

  .setup-start-button {
    height: clamp(48px, 8.8dvh, 64px);
    min-height: clamp(48px, 8.8dvh, 64px);
  }

  .setup-start-button span {
    font-size: clamp(24px, 4.7dvh, 34px);
  }

  .setup-welcome .character-container {
    width: min(280px, 28vw);
    max-height: min(50dvh, 340px);
  }
}

@media (orientation: portrait), (max-width: 760px) {
  .setup-panel {
    overflow: hidden;
  }

  .setup-left {
    align-self: center;
    gap: clamp(8px, 1dvh, 12px);
  }

  .setup-welcome {
    display: none;
  }

  .digit-page.ready.keypad-split-page,
  .serial-page.keypad-split-page,
  .orientation-number-page.keypad-split-page {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 0.36fr) minmax(0, 0.64fr);
  }

  .serial-page .keypad-question-panel,
  .serial-page .keypad-panel {
    justify-self: center;
  }

  .serial-page .serial-display {
    width: min(100%, 430px);
    height: clamp(64px, 16vw, 88px);
  }

  .orientation-choice-page {
    grid-template-rows: minmax(90px, 0.34fr) minmax(0, 0.66fr);
  }

  .orientation-text-options {
    height: min(100%, 330px);
  }

  .voice-finish-button {
    min-height: 132px;
    font-size: clamp(30px, 8vw, 40px);
  }
}

/* Tight final overrides for small screens and serial subtraction. */
.setup-panel,
.setup-left,
.setup-grid,
.field,
.field input,
.field select,
.setup-start-button,
.segment-option,
.setup-voice-button {
  box-sizing: border-box;
  max-width: 100%;
}

@media (orientation: portrait), (max-width: 760px) {
  .setup-screen {
    overflow-x: hidden;
  }

  .setup-panel {
    width: 100%;
    height: auto;
    min-height: 0;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto;
    justify-items: center;
    padding-inline: clamp(12px, 4vw, 22px);
  }

  .setup-left {
    width: 100%;
    min-width: 0;
    padding: clamp(12px, 3.2vw, 18px);
  }

  .setup-grid,
  .field,
  .voice-setup-row {
    width: 100%;
    min-width: 0;
  }

  .field input,
  .field select {
    min-width: 0;
    width: 100%;
  }

  .edu-segment-options {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.serial-page.keypad-split-page {
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  align-content: center;
  justify-items: center;
  gap: clamp(12px, 2.2dvh, 20px);
}

.serial-page .keypad-question-panel,
.serial-page .keypad-panel {
  width: min(520px, 100%);
  height: auto;
  justify-self: center;
  padding: 0;
}

.serial-page .keypad-question-panel {
  align-content: end;
}

.serial-page .keypad-panel {
  align-content: start;
}

.serial-page .keypad-panel .serial-keypad {
  width: min(520px, 100%);
  height: min(46dvh, 430px);
}

/* Follow-up QA pass: interruptible speech, steadier layouts, calmer login. */
.setup-screen::before,
.setup-screen::after,
.setup-ambient-extra,
.setup-geo {
  display: none;
}

.floating-stars.setup-stars {
  display: block;
}

.setup-stars i {
  width: clamp(22px, 3vw, 36px);
  height: clamp(22px, 3vw, 36px);
  opacity: 0.68;
  animation: none;
}

.setup-stars i:nth-child(1) {
  top: 9%;
  left: 11%;
  background: #ffd84d;
}

.setup-stars i:nth-child(2) {
  top: 15%;
  right: 14%;
  background: #ffb35c;
}

.setup-stars i:nth-child(3) {
  right: 12%;
  bottom: 18%;
  background: #7fcaa1;
}

.setup-stars i:nth-child(4) {
  left: 8%;
  bottom: 16%;
  background: #8eb8ff;
}

.setup-panel {
  align-items: stretch;
}

.setup-welcome {
  height: 100%;
  align-self: stretch;
  padding-bottom: 0;
}

.setup-welcome-inner {
  height: 100%;
  justify-content: center;
  gap: clamp(14px, 2dvh, 22px);
}

.setup-welcome-bubble {
  border: 3px solid #d4c0a0;
  border-radius: 20px;
  background: #fff8e8;
  box-shadow: 0 8px 0 #c0a880, 0 18px 36px rgba(18, 122, 73, 0.12);
  color: #000;
  text-align: left;
}

.setup-welcome-bubble::after {
  border-top-color: #d4c0a0;
}

.setup-skip-login {
  bottom: max(72px, calc(env(safe-area-inset-bottom) + 64px));
  z-index: 8;
}

.hearing-page {
  padding: 0;
}

.hearing-test-fullscreen {
  display: grid;
  width: 100%;
  height: 100%;
  min-height: 0;
  grid-template-rows: auto minmax(0, 1fr);
  gap: clamp(18px, 3dvh, 32px);
  padding: clamp(18px, 3dvh, 34px) clamp(24px, 4vw, 56px);
  overflow: hidden;
}

.hearing-test-topbar {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(8px, 1.4vw, 16px);
  width: min(720px, 100%);
  justify-self: center;
  padding: 6px 0;
}

.hearing-test-stat {
  display: grid;
  min-height: auto;
  place-items: center;
  gap: 2px;
  padding: 6px 10px;
  border: 1px solid rgba(100, 116, 139, 0.22);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.56);
  box-shadow: none;
  text-align: center;
}

.hearing-test-stat span {
  color: var(--muted);
  font-size: clamp(12px, 1.25vw, 16px);
  font-weight: 500;
  line-height: 1.2;
}

.hearing-test-stat strong,
.hearing-test-stat-value {
  color: var(--ink);
  font-size: clamp(14px, 1.6vw, 20px);
  font-weight: 500;
  line-height: 1.2;
}

.hearing-test-fullscreen .hearing-test-choice-column {
  grid-template-rows: minmax(82px, auto) minmax(0, 1fr) minmax(34px, auto);
  gap: clamp(18px, 3dvh, 32px);
  align-content: stretch;
}

.hearing-test-fullscreen .hearing-response-slot {
  display: grid;
  width: min(880px, 100%);
  min-height: 0;
  justify-self: center;
  align-self: stretch;
  place-items: center;
}

.hearing-test-fullscreen .hearing-response-grid {
  width: 100%;
  height: min(100%, 360px);
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.hearing-test-fullscreen .hearing-response-grid .option {
  min-height: clamp(170px, 34dvh, 280px);
  font-size: clamp(36px, 5.6vw, 64px);
}

.hearing-summary-wrapper {
  display: grid;
  height: 100%;
  place-items: center;
}

.hearing-summary-dialog {
  display: grid;
  width: min(760px, 92vw);
  justify-items: center;
  gap: clamp(24px, 4dvh, 40px);
  padding: 0;
}

.hearing-summary-bubble {
  border: 3px solid #d4c0a0;
  border-radius: 20px;
  background: #fff8e8;
  box-shadow: 0 8px 0 #c0a880, 0 18px 36px rgba(18, 122, 73, 0.12);
  color: #000;
  font-size: clamp(42px, 6vw, 72px);
  font-weight: 1000;
}

.digit-page.ready.keypad-split-page,
.serial-page.keypad-split-page,
.orientation-number-page.keypad-split-page {
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(118px, 0.34fr) minmax(0, 0.66fr);
  align-content: stretch;
  justify-items: center;
}

.digit-question-panel,
.serial-page .keypad-question-panel,
.orientation-number-page .keypad-question-panel {
  width: min(620px, 100%);
  height: 100%;
  align-content: end;
  padding: 0 0 clamp(8px, 1.4dvh, 14px);
}

.keypad-panel,
.serial-page .keypad-panel,
.orientation-number-page .keypad-panel {
  width: min(620px, 100%);
  height: 100%;
  align-content: start;
  padding: clamp(8px, 1.4dvh, 14px) 0 0;
}

.answer-square-row.digit-answer-squares {
  display: grid;
  width: min(620px, 100%);
  min-height: clamp(92px, 13dvh, 126px);
  grid-auto-flow: column;
  grid-auto-columns: clamp(72px, 9vmin, 104px);
  justify-content: center;
  gap: clamp(10px, 1.6vw, 18px);
}

.answer-square-row .answer-square,
.digit-answer-squares .answer-square {
  box-sizing: border-box;
  width: auto;
  height: clamp(76px, 11dvh, 104px);
}

.serial-page .serial-display,
.orientation-answer-box,
.date-input-with-units .date-input-box,
.year-digit-row .answer-square {
  box-sizing: border-box;
  height: clamp(76px, 11dvh, 102px);
}

.serial-page .serial-display,
.serial-page .serial-display.empty {
  width: min(520px, 100%);
  font-size: clamp(36px, 5vw, 58px);
}

.keypad-panel .serial-keypad,
.serial-page .keypad-panel .serial-keypad,
.keypad-panel .orientation-keypad,
.orientation-number-page .keypad-panel .orientation-keypad {
  width: min(520px, 100%);
  height: min(46dvh, 430px);
  grid-template-columns: repeat(3, minmax(68px, 1fr));
  grid-auto-rows: minmax(58px, 1fr);
  gap: clamp(10px, 1.6vw, 16px);
}

.keypad-panel .serial-keypad button,
.keypad-panel .orientation-keypad button,
.keypad-panel .serial-keypad .keypad-spacer,
.keypad-panel .orientation-keypad .keypad-spacer {
  height: 100%;
  min-height: 0;
}

.orientation-choice-page {
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(112px, 0.34fr) minmax(0, 0.66fr);
}

.orientation-answer-box {
  width: min(520px, 100%);
  min-height: 0;
}

.orientation-text-options .option,
.orientation-weekday-options .option {
  min-height: clamp(76px, 11dvh, 102px);
}

.voice-finish-button.pulse {
  animation-delay: 3s;
}

@media (orientation: portrait), (max-width: 760px) {
  .setup-panel {
    align-items: center;
  }

  .setup-welcome {
    display: none;
  }

  .hearing-test-fullscreen {
    padding: clamp(14px, 3dvh, 26px) clamp(14px, 4vw, 22px);
  }

  .hearing-test-topbar {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  .hearing-test-stat {
    min-height: auto;
    padding: 5px 6px;
  }

  .hearing-test-fullscreen .hearing-response-grid {
    grid-template-columns: minmax(0, 1fr);
    height: min(100%, 420px);
  }

  .hearing-test-fullscreen .hearing-response-grid .option {
    min-height: 132px;
  }
}

/* Final interaction and layout overrides for the clinician QA pass. */
.setup-screen {
  background:
    linear-gradient(90deg, rgba(198, 236, 241, 0.54) 0 32%, rgba(255, 250, 235, 0.18) 60%, rgba(255, 255, 255, 0.02) 100%),
    #fdfbf7;
}

.setup-screen::before,
.setup-screen::after,
.setup-ambient-extra,
.setup-geo {
  content: none;
  display: none !important;
}

.floating-stars.setup-stars {
  z-index: 0;
  display: block;
}

.setup-stars i {
  animation: none !important;
  transform: none !important;
}

.setup-panel {
  align-items: stretch;
}

.setup-left,
.setup-welcome {
  min-height: 0;
}

.setup-welcome {
  display: grid;
  height: min(100%, clamp(460px, 69dvh, 620px));
  align-self: center;
  place-items: center;
  padding-bottom: 0;
}

.setup-welcome-inner {
  display: flex;
  height: 100%;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(14px, 2dvh, 22px);
}

.setup-welcome .character-container {
  width: min(260px, 24vw);
  max-width: 100%;
  max-height: calc(100% - clamp(158px, 23dvh, 208px));
  align-self: center;
}

.setup-welcome-bubble {
  flex: 0 0 auto;
  align-self: center;
}

.setup-skip-login {
  bottom: max(90px, calc(env(safe-area-inset-bottom) + 84px));
}

.year-digit-box,
.serial-page .serial-display,
.orientation-answer-box,
.date-input-with-units .date-input-box {
  box-sizing: border-box;
  height: clamp(76px, 11dvh, 102px);
}

.orientation-choice-question-panel .weekday-answer-line {
  min-height: clamp(76px, 11dvh, 102px);
}

.task-page-village,
.task-page-village .task-workspace,
.task-page-village .digit-page,
.task-page-village .serial-page,
.task-page-village .orientation-page,
.task-page-village .orientation-number-page {
  overflow: hidden;
}

.task-page-village .digit-page.ready.keypad-split-page,
.task-page-village .serial-page.keypad-split-page,
.task-page-village .orientation-number-page.keypad-split-page {
  height: 100%;
  grid-template-rows: minmax(118px, 0.34fr) minmax(0, 0.66fr);
  align-content: stretch;
}

.task-page-village .serial-page.keypad-split-page {
  position: relative;
  display: block;
}

.task-page-village .serial-page .keypad-question-panel,
.task-page-village .serial-page .keypad-panel {
  position: fixed;
  left: 50%;
  width: min(620px, 100%);
  padding: 0;
  transform: translateX(-50%);
}

.task-page-village .serial-page .keypad-question-panel {
  top: clamp(170px, 28dvh, 205px);
  display: block;
  height: clamp(76px, 11dvh, 102px);
  align-content: start;
}

.task-page-village .serial-page .serial-display,
.task-page-village .serial-page .serial-display.empty {
  position: absolute;
  top: 0;
  left: 50%;
  margin: 0;
  transform: translateX(-50%);
}

.task-page-village .serial-page .keypad-panel {
  top: clamp(300px, 44dvh, 326px);
}

@media (orientation: portrait), (max-width: 760px) {
  .setup-screen {
    background:
      linear-gradient(180deg, rgba(198, 236, 241, 0.28), rgba(255, 250, 235, 0.18) 58%, rgba(255, 219, 150, 0.14)),
      #fdfbf7;
  }

  .setup-welcome {
    display: none;
  }

  .setup-skip-login {
    bottom: max(78px, calc(env(safe-area-inset-bottom) + 68px));
  }
}

/* Follow-up clinician QA: remove pastoral login, align controls, and stabilize guide/keypad layouts. */
.character-nameplate {
  display: none !important;
}

.setup-screen {
  background:
    radial-gradient(circle at 18% 20%, rgba(131, 197, 255, 0.18), transparent 28%),
    radial-gradient(circle at 82% 18%, rgba(255, 214, 117, 0.18), transparent 24%),
    linear-gradient(135deg, #f7fbff 0%, #fffaf0 54%, #f5fff9 100%) !important;
}

.setup-screen::before,
.setup-screen::after,
.setup-ambient-extra,
.setup-geo {
  content: none !important;
  display: none !important;
}

.floating-stars.setup-stars {
  display: block;
}

.setup-stars i {
  opacity: 0.52;
  animation: none !important;
  transform: none !important;
}

.global-menu-button {
  top: calc(max(0px, env(safe-area-inset-top)) + clamp(54px, 7dvh, 68px));
  transform: translateY(-50%);
}

.hearing-intro-guide-page .story-dialogue-box {
  height: auto;
  min-height: clamp(132px, 24dvh, 210px);
  max-height: clamp(150px, 28dvh, 240px);
  padding-block: clamp(18px, 2.8dvh, 28px);
}

.hearing-intro-guide-page .story-dialogue-text {
  font-size: clamp(30px, 3.8vw, 48px);
  line-height: 1.16;
}

@media (orientation: portrait), (max-width: 900px) {
  .hearing-intro-guide-page.story-scene-screen {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr) auto;
    justify-items: center;
    align-content: center;
    gap: clamp(14px, 2dvh, 24px);
  }

  .hearing-intro-guide-page .story-dialogue-box {
    position: relative;
    grid-column: 1;
    grid-row: 1;
    width: min(620px, calc(100vw - 36px));
    max-width: min(620px, calc(100vw - 36px));
    justify-self: center;
  }

  .hearing-intro-guide-page .story-character-stage {
    position: relative;
    grid-column: 1;
    grid-row: 2;
    top: auto;
    left: auto;
    bottom: auto;
    width: min(220px, 42vw);
    justify-self: center;
    transform: none;
  }

  .hearing-intro-guide-page .story-choice-row,
  .hearing-intro-guide-page .story-extra-content {
    position: relative;
    grid-column: 1;
    inset: auto;
    transform: none;
  }

  .hearing-intro-guide-page .story-extra-content {
    grid-row: 3;
  }

  .hearing-intro-guide-page .story-choice-row {
    grid-row: 4;
  }
}

.hearing-test-fullscreen .hearing-response-slot {
  align-self: start;
}

.hearing-test-fullscreen .hearing-response-grid {
  width: min(760px, 100%);
  height: auto;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(14px, 2.4vw, 24px);
}

.hearing-test-fullscreen .hearing-response-grid .option {
  min-height: clamp(82px, 13dvh, 112px);
  border: 3px solid var(--line);
  border-left: 7px solid var(--leaf);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 4px 0 #cddbd2;
  color: var(--ink);
  font-size: clamp(28px, 3.4vw, 40px);
}

.hearing-test-fullscreen .hearing-response-grid .option:disabled {
  background: #f1f5f3;
  color: #9aa7a1;
  opacity: 0.76;
}

.hearing-summary-dialog {
  display: grid;
  width: min(980px, 94vw);
  grid-template-columns: minmax(160px, 0.72fr) minmax(0, 1fr);
  align-items: center;
  justify-items: center;
  gap: clamp(24px, 4vw, 54px);
}

.hearing-summary-character .character-container {
  width: clamp(180px, 22vw, 300px);
  filter: drop-shadow(0 18px 24px rgba(41, 52, 43, 0.2));
}

.hearing-summary-copy {
  display: grid;
  justify-items: center;
  gap: clamp(22px, 4dvh, 40px);
}

.hearing-summary-bubble {
  position: relative;
  padding: clamp(22px, 3.4dvh, 34px) clamp(30px, 5vw, 58px);
  font-size: clamp(34px, 5vw, 66px);
  line-height: 1.12;
  white-space: nowrap;
}

.hearing-summary-bubble::before,
.hearing-summary-bubble::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 0;
  height: 0;
  transform: translateY(-50%);
}

.hearing-summary-bubble::before {
  left: -18px;
  border-top: 14px solid transparent;
  border-bottom: 14px solid transparent;
  border-right: 18px solid #d4c0a0;
}

.hearing-summary-bubble::after {
  left: -14px;
  border-top: 11px solid transparent;
  border-bottom: 11px solid transparent;
  border-right: 15px solid #fff8e8;
}

.trail-guide-page.story-scene-screen {
  --trail-practice-board-height: clamp(150px, 31dvh, 300px);
  display: grid;
  grid-template-columns: minmax(112px, 18vw) minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto;
  column-gap: clamp(12px, 2.4vw, 30px);
  row-gap: clamp(8px, 1.4dvh, 16px);
  align-content: stretch;
  padding: clamp(8px, 1.5dvh, 16px) clamp(14px, 2.4vw, 28px);
}

.trail-guide-page.story-scene-screen .story-character-stage,
.trail-guide-page.story-scene-screen .story-dialogue-box,
.trail-guide-page.story-scene-screen .story-extra-content,
.trail-guide-page.story-scene-screen .story-choice-row {
  position: static;
  inset: auto;
  transform: none;
}

.trail-guide-page.story-scene-screen .story-character-stage {
  grid-column: 1;
  grid-row: 1 / 3;
  width: min(150px, 16vw, 28dvh);
  align-self: center;
  justify-self: end;
}

.trail-guide-page.story-scene-screen .story-dialogue-box {
  grid-column: 2;
  grid-row: 1;
  width: min(820px, 100%);
  height: clamp(118px, 19dvh, 180px);
  min-height: clamp(118px, 19dvh, 180px);
  max-height: clamp(118px, 19dvh, 180px);
  align-self: end;
  justify-self: start;
  padding: clamp(14px, 2.1dvh, 24px) clamp(18px, 3vw, 34px);
}

.trail-guide-page.story-scene-screen .story-dialogue-text {
  font-size: clamp(24px, 2.7vw, 36px);
  line-height: 1.18;
}

.trail-guide-page.story-scene-screen .story-extra-content {
  grid-column: 1 / -1;
  grid-row: 2;
  width: min(820px, 100%);
  min-height: 0;
  justify-self: center;
  align-self: stretch;
}

.trail-guide-page.story-scene-screen .story-choice-row {
  grid-column: 1 / -1;
  grid-row: 3;
  align-self: end;
  justify-self: center;
}

.task-page-village .digit-page.ready.keypad-split-page {
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(118px, 0.34fr) minmax(0, 0.66fr);
  align-content: stretch;
  justify-items: center;
}

.task-page-village .digit-page .keypad-question-panel,
.task-page-village .digit-page .keypad-panel {
  width: min(620px, 100%);
  height: 100%;
  justify-self: center;
}

.task-page-village .digit-page .keypad-question-panel {
  align-content: end;
  padding: 0 0 clamp(8px, 1.4dvh, 14px);
}

.task-page-village .digit-page .keypad-panel {
  align-content: start;
  padding: clamp(8px, 1.4dvh, 14px) 0 0;
}

.task-page-village .digit-page .digit-keypad,
.task-page-village .orientation-number-page .orientation-keypad {
  width: min(520px, 100%);
  height: min(46dvh, 430px);
  grid-template-columns: repeat(3, minmax(68px, 1fr));
  grid-auto-rows: minmax(58px, 1fr);
  gap: clamp(10px, 1.6vw, 16px);
}

.task-page-village .orientation-number-page.keypad-split-page {
  transform: translateY(-3dvh);
}

.orientation-city-page,
.orientation-place-page {
  grid-template-rows: minmax(96px, 0.28fr) minmax(0, 0.72fr);
}

.orientation-city-page .orientation-text-options,
.orientation-place-page .orientation-text-options {
  width: min(700px, 100%);
  height: min(100%, 300px);
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
  gap: clamp(12px, 2vw, 22px);
}

.orientation-city-page .orientation-text-options .option,
.orientation-place-page .orientation-text-options .option {
  min-height: clamp(78px, 12dvh, 112px);
  padding-inline: clamp(12px, 2vw, 22px);
  font-size: clamp(22px, 2.8vw, 34px);
}

@media (orientation: portrait), (max-width: 760px) {
  .setup-screen {
    background:
      radial-gradient(circle at 18% 18%, rgba(131, 197, 255, 0.18), transparent 30%),
      linear-gradient(180deg, #f7fbff 0%, #fffaf0 58%, #f5fff9 100%) !important;
  }

  .hearing-intro-guide-page .story-dialogue-box {
    min-height: clamp(118px, 18dvh, 170px);
    max-height: clamp(132px, 22dvh, 190px);
  }

  .hearing-test-fullscreen .hearing-response-grid {
    grid-template-columns: minmax(0, 1fr);
    width: min(520px, 100%);
  }

  .hearing-test-fullscreen .hearing-response-grid .option {
    min-height: clamp(72px, 12dvh, 98px);
  }

  .hearing-summary-dialog {
    grid-template-columns: minmax(0, 1fr);
    gap: clamp(12px, 2.4dvh, 22px);
  }

  .hearing-summary-character .character-container {
    width: min(160px, 34vw);
  }

  .trail-guide-page.story-scene-screen {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto minmax(0, 1fr) auto;
  }

  .trail-guide-page.story-scene-screen .story-character-stage {
    grid-column: 1;
    grid-row: 1;
    width: min(118px, 28vw);
    justify-self: center;
  }

  .trail-guide-page.story-scene-screen .story-dialogue-box {
    grid-column: 1;
    grid-row: 2;
    justify-self: center;
    min-height: clamp(112px, 18dvh, 170px);
    max-height: clamp(112px, 18dvh, 170px);
  }

  .trail-guide-page.story-scene-screen .story-extra-content {
    grid-column: 1;
    grid-row: 3;
  }

  .trail-guide-page.story-scene-screen .story-choice-row {
    grid-column: 1;
    grid-row: 4;
  }

  .task-page-village .orientation-number-page.keypad-split-page {
    transform: translateY(-2dvh);
  }

  .orientation-city-page .orientation-text-options,
  .orientation-place-page .orientation-text-options {
    height: min(100%, 340px);
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: repeat(4, minmax(0, 1fr));
  }
}

/* Final follow-up override: keep trail practice and numeric keypads fixed. */
.trail-guide-page:has(.trail-guide-practice).story-scene-screen {
  --trail-practice-board-height: clamp(190px, 36dvh, 340px);
  display: grid !important;
  grid-template-columns: minmax(112px, 18vw) minmax(0, 1fr) !important;
  grid-template-rows: auto minmax(0, 1fr) auto !important;
  align-content: stretch !important;
  column-gap: clamp(14px, 2.4vw, 30px) !important;
  row-gap: clamp(10px, 1.8dvh, 18px) !important;
  padding: clamp(12px, 2dvh, 22px) clamp(18px, 3vw, 34px) !important;
}

.trail-guide-page:has(.trail-guide-practice) .story-character-stage,
.trail-guide-page:has(.trail-guide-practice) .story-dialogue-box,
.trail-guide-page:has(.trail-guide-practice) .story-extra-content,
.trail-guide-page:has(.trail-guide-practice) .story-choice-row {
  position: static !important;
  inset: auto !important;
  transform: none !important;
}

.trail-guide-page:has(.trail-guide-practice) .story-character-stage {
  grid-column: 1 !important;
  grid-row: 1 !important;
  width: min(150px, 17vw) !important;
  align-self: center !important;
  justify-self: end !important;
}

.trail-guide-page:has(.trail-guide-practice) .story-dialogue-box {
  grid-column: 2 !important;
  grid-row: 1 !important;
  width: min(820px, 100%) !important;
  min-height: clamp(126px, 18dvh, 184px) !important;
  max-height: clamp(126px, 18dvh, 184px) !important;
  align-self: center !important;
  justify-self: start !important;
  overflow: visible !important;
  padding: clamp(16px, 2.4dvh, 26px) clamp(22px, 3vw, 36px) !important;
}

.trail-guide-page:has(.trail-guide-practice) .story-dialogue-box::before,
.trail-guide-page:has(.trail-guide-practice) .story-dialogue-box::after {
  content: "" !important;
  position: absolute !important;
  top: 50% !important;
  width: 0 !important;
  height: 0 !important;
  pointer-events: none !important;
  transform: translateY(-50%) !important;
}

.trail-guide-page:has(.trail-guide-practice) .story-dialogue-box::before {
  left: -18px !important;
  border-top: 14px solid transparent !important;
  border-bottom: 14px solid transparent !important;
  border-right: 18px solid #d4c0a0 !important;
}

.trail-guide-page:has(.trail-guide-practice) .story-dialogue-box::after {
  left: -14px !important;
  border-top: 11px solid transparent !important;
  border-bottom: 11px solid transparent !important;
  border-right: 15px solid var(--story-dialog-fill) !important;
}

.trail-guide-page:has(.trail-guide-practice) .story-dialogue-text {
  font-size: clamp(24px, 2.6vw, 36px) !important;
  line-height: 1.16 !important;
}

.trail-guide-page:has(.trail-guide-practice) .story-extra-content {
  grid-column: 1 / -1 !important;
  grid-row: 2 !important;
  width: min(860px, 100%) !important;
  min-height: 0 !important;
  align-self: stretch !important;
  justify-self: center !important;
}

.trail-guide-page:has(.trail-guide-practice) .trail-guide-practice {
  display: grid !important;
  grid-template-rows: minmax(0, 1fr) auto !important;
  width: 100% !important;
  height: 100% !important;
  min-height: 0 !important;
  gap: clamp(8px, 1.2dvh, 12px) !important;
}

.trail-guide-page:has(.trail-guide-practice) .trail-guide-board {
  width: 100% !important;
  height: min(var(--trail-practice-board-height), 100%) !important;
  min-height: clamp(170px, 28dvh, 250px) !important;
  max-height: 100% !important;
  aspect-ratio: auto !important;
}

.trail-guide-page:has(.trail-guide-practice) .story-choice-row {
  grid-column: 1 / -1 !important;
  grid-row: 3 !important;
  align-self: end !important;
  justify-self: center !important;
}

.digit-page.ready.keypad-split-page,
.serial-page.keypad-split-page,
.orientation-number-page.keypad-split-page {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) !important;
  grid-template-rows: auto auto !important;
  align-content: center !important;
  justify-items: center !important;
  width: min(720px, calc(100vw - 40px)) !important;
  max-height: calc(100dvh - 150px) !important;
  margin: 0 auto !important;
  padding: clamp(20px, 3dvh, 34px) !important;
  gap: clamp(18px, 2.8dvh, 28px) !important;
  overflow: visible !important;
  transform: none !important;
  border: 3px solid #d8e6dc !important;
  border-radius: 18px !important;
  background: rgba(255, 255, 255, 0.96) !important;
  box-shadow: 0 10px 0 #d4e0d7, 0 22px 46px rgba(31, 95, 61, 0.16) !important;
}

.digit-page.ready.keypad-split-page .keypad-question-panel,
.serial-page.keypad-split-page .keypad-question-panel,
.orientation-number-page.keypad-split-page .keypad-question-panel,
.digit-page.ready.keypad-split-page .keypad-panel,
.serial-page.keypad-split-page .keypad-panel,
.orientation-number-page.keypad-split-page .keypad-panel {
  width: 100% !important;
  height: auto !important;
  min-height: 0 !important;
  padding: 0 !important;
  align-content: center !important;
  justify-items: center !important;
  background: transparent !important;
  box-shadow: none !important;
}

.digit-page.ready.keypad-split-page .keypad-panel .keypad,
.serial-page.keypad-split-page .keypad-panel .keypad,
.orientation-number-page.keypad-split-page .keypad-panel .keypad {
  width: min(520px, 100%) !important;
  height: clamp(300px, 43dvh, 420px) !important;
  max-width: 520px !important;
  max-height: 420px !important;
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  grid-template-rows: repeat(4, minmax(0, 1fr)) !important;
  grid-auto-rows: minmax(0, 1fr) !important;
  gap: clamp(10px, 1.8vw, 16px) !important;
}

.digit-page.ready.keypad-split-page .keypad-panel .keypad button,
.serial-page.keypad-split-page .keypad-panel .keypad button,
.orientation-number-page.keypad-split-page .keypad-panel .keypad button,
.digit-page.ready.keypad-split-page .keypad-panel .keypad-spacer,
.serial-page.keypad-split-page .keypad-panel .keypad-spacer,
.orientation-number-page.keypad-split-page .keypad-panel .keypad-spacer {
  width: 100% !important;
  height: 100% !important;
  min-width: 0 !important;
  min-height: 0 !important;
}

.digit-page.ready.keypad-split-page .keypad-delete,
.serial-page.keypad-split-page .keypad-delete,
.orientation-number-page.keypad-split-page .keypad-delete {
  font-size: clamp(22px, 3vw, 32px) !important;
  font-weight: 1000 !important;
  color: #7b332b !important;
  border-color: #efc7bd !important;
  background: #fff5f1 !important;
  box-shadow: 0 5px 0 #e1b5aa !important;
}

.answer-square-row.digit-answer-squares,
.year-digit-row,
.date-input-pair {
  width: min(560px, 100%) !important;
  max-width: 100% !important;
  justify-content: center !important;
  gap: clamp(14px, 2.4vw, 24px) !important;
}

.answer-square-row .answer-square,
.digit-answer-squares .answer-square,
.year-digit-row .year-digit-box,
.orientation-answer-square {
  width: clamp(62px, 9vw, 86px) !important;
  min-width: clamp(62px, 9vw, 86px) !important;
  height: clamp(62px, 9vw, 86px) !important;
  font-size: clamp(30px, 4.4vw, 44px) !important;
}

.serial-page .serial-display,
.orientation-answer-box {
  width: min(460px, 100%) !important;
  min-height: clamp(78px, 11dvh, 106px) !important;
  font-size: clamp(30px, 4vw, 46px) !important;
}

.date-input-box {
  width: clamp(110px, 18vw, 150px) !important;
  min-height: clamp(76px, 11dvh, 100px) !important;
}

/* Current QA pass: wider guide bubbles, stable hearing/test layouts, and unified keypads. */
.story-scene-screen .story-dialogue-box,
.story-screen--task-guide .story-dialogue-box,
.hearing-intro-guide-page .story-dialogue-box,
.hearing-guide-page .story-dialogue-box,
.digit-backward-guide-page .story-dialogue-box {
  right: auto !important;
  width: min(960px, calc(100vw - var(--story-dialog-left) - 40px)) !important;
  max-width: min(960px, calc(100vw - var(--story-dialog-left) - 40px)) !important;
}

.trail-guide-page.story-scene-screen,
.trail-guide-page:has(.trail-guide-practice).story-scene-screen {
  grid-template-columns: minmax(126px, 180px) minmax(0, 984px) !important;
  justify-content: center !important;
}

.trail-guide-page.story-scene-screen .story-dialogue-box,
.trail-guide-page:has(.trail-guide-practice) .story-dialogue-box {
  width: min(984px, 100%) !important;
  max-width: min(984px, 100%) !important;
  justify-self: start !important;
}

.trail-guide-page.story-scene-screen .story-character-stage,
.trail-guide-page:has(.trail-guide-practice) .story-character-stage {
  justify-self: end !important;
}

.hearing-intro-guide-page .story-dialogue-text {
  text-align: center !important;
  white-space: nowrap !important;
}

.typewriter-text.typewriter-done .typewriter-measure {
  visibility: visible;
}

.typewriter-text.typewriter-done .typewriter-live {
  visibility: hidden;
}

.story-dialogue-text .typewriter-text .guide-emphasis {
  color: #f08a24 !important;
}

.hearing-test-fullscreen {
  grid-template-rows: auto minmax(0, 1fr) !important;
  gap: clamp(26px, 5dvh, 62px) !important;
  padding-block: clamp(28px, 5dvh, 58px) !important;
}

.hearing-test-fullscreen .hearing-test-choice-column {
  display: grid !important;
  grid-template-rows: auto auto auto !important;
  align-content: center !important;
  justify-items: center !important;
  gap: clamp(24px, 5dvh, 56px) !important;
}

.hearing-test-fullscreen .hearing-response-slot {
  align-self: center !important;
}

.hearing-test-fullscreen .hearing-response-grid {
  width: min(820px, 100%) !important;
}

.hearing-test-fullscreen .hearing-response-grid .option {
  min-height: clamp(112px, 18dvh, 170px) !important;
}

.keypad .confirm,
.digit-page.ready.keypad-split-page .keypad .confirm,
.serial-page.keypad-split-page .keypad .confirm,
.orientation-number-page.keypad-split-page .keypad .confirm {
  color: #fff !important;
  border-color: #3f8f52 !important;
  background: linear-gradient(180deg, #66b86a, #4b9657) !important;
  box-shadow: 0 5px 0 #367844 !important;
}

.orientation-number-page.keypad-split-page {
  transform: none !important;
}

.date-input-with-units {
  align-items: center !important;
}

.date-input-with-units .date-input-box,
.date-input-box {
  width: clamp(76px, 11dvh, 104px) !important;
  min-width: clamp(76px, 11dvh, 104px) !important;
  height: clamp(76px, 11dvh, 104px) !important;
  min-height: clamp(76px, 11dvh, 104px) !important;
  aspect-ratio: 1 !important;
}

.orientation-city-page,
.orientation-place-page {
  justify-items: center !important;
}

.orientation-city-page .orientation-text-options,
.orientation-place-page .orientation-text-options {
  width: min(520px, 100%) !important;
  height: auto !important;
  max-height: none !important;
  grid-template-columns: minmax(0, 1fr) !important;
  grid-template-rows: repeat(4, minmax(72px, auto)) !important;
  justify-self: center !important;
  align-self: center !important;
  gap: clamp(10px, 1.8dvh, 16px) !important;
}

.orientation-city-page .orientation-text-options .option,
.orientation-place-page .orientation-text-options .option {
  min-height: clamp(72px, 10dvh, 96px) !important;
}

@media (orientation: portrait), (max-width: 760px) {
  .story-scene-screen .story-dialogue-box,
  .story-screen--task-guide .story-dialogue-box,
  .hearing-intro-guide-page .story-dialogue-box,
  .hearing-guide-page .story-dialogue-box,
  .digit-backward-guide-page .story-dialogue-box {
    right: auto !important;
    width: min(720px, calc(100vw - 28px)) !important;
    max-width: min(720px, calc(100vw - 28px)) !important;
  }

  .hearing-intro-guide-page .story-dialogue-text {
    font-size: clamp(28px, 7vw, 44px) !important;
  }

  .trail-guide-page.story-scene-screen,
  .trail-guide-page:has(.trail-guide-practice).story-scene-screen {
    grid-template-columns: minmax(0, 1fr) !important;
    justify-content: center !important;
  }

  .trail-guide-page.story-scene-screen .story-dialogue-box,
  .trail-guide-page:has(.trail-guide-practice) .story-dialogue-box {
    justify-self: center !important;
  }

  .hearing-test-fullscreen {
    gap: clamp(18px, 3dvh, 34px) !important;
    padding-block: clamp(18px, 3dvh, 32px) !important;
  }

  .hearing-test-fullscreen .hearing-test-choice-column {
    gap: clamp(16px, 3dvh, 30px) !important;
  }
}

/* QA completion pass: guide width, centered trail practice, and steadier answer surfaces. */
.story-scene-screen .story-dialogue-box,
.story-screen--task-guide .story-dialogue-box,
.story-screen--feedback .story-dialogue-box,
.hearing-intro-guide-page .story-dialogue-box,
.hearing-guide-page .story-dialogue-box,
.digit-backward-guide-page .story-dialogue-box {
  width: min(1152px, calc(100vw - var(--story-dialog-left) - 32px)) !important;
  max-width: min(1152px, calc(100vw - var(--story-dialog-left) - 32px)) !important;
}

.hearing-intro-guide-page .story-dialogue-text,
.hearing-intro-guide-page .typewriter-text {
  white-space: nowrap !important;
}

.hearing-intro-guide-page .story-dialogue-text {
  font-size: clamp(28px, 3.25vw, 44px) !important;
}

.trail-guide-page:has(.trail-guide-practice).story-scene-screen {
  grid-template-columns: minmax(0, 1fr) !important;
  grid-template-rows: auto auto minmax(0, 1fr) auto !important;
  align-content: center !important;
  justify-items: center !important;
  row-gap: clamp(8px, 1.45dvh, 16px) !important;
}

.trail-guide-page:has(.trail-guide-practice) .story-character-stage,
.trail-guide-page:has(.trail-guide-practice) .story-dialogue-box,
.trail-guide-page:has(.trail-guide-practice) .story-extra-content,
.trail-guide-page:has(.trail-guide-practice) .story-choice-row {
  grid-column: 1 !important;
  position: static !important;
  inset: auto !important;
  transform: none !important;
}

.trail-guide-page:has(.trail-guide-practice) .story-character-stage {
  grid-row: 1 !important;
  width: min(148px, 18vw, 24dvh) !important;
  justify-self: center !important;
  align-self: end !important;
}

.trail-guide-page:has(.trail-guide-practice) .story-dialogue-box {
  grid-row: 2 !important;
  width: min(1180px, calc(100vw - 44px)) !important;
  max-width: min(1180px, calc(100vw - 44px)) !important;
  justify-self: center !important;
  align-self: center !important;
}

.trail-guide-page:has(.trail-guide-practice) .story-extra-content {
  grid-row: 3 !important;
  width: min(900px, calc(100vw - 44px)) !important;
  justify-self: center !important;
  align-self: stretch !important;
}

.trail-guide-page:has(.trail-guide-practice) .story-choice-row {
  grid-row: 4 !important;
  justify-self: center !important;
}

.trail-guide-node {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  line-height: 1 !important;
  text-align: center !important;
}

.hearing-test-fullscreen {
  min-height: 100% !important;
  grid-template-rows: minmax(74px, auto) minmax(0, 1fr) !important;
  align-content: center !important;
  gap: clamp(34px, 6dvh, 74px) !important;
  padding-block: clamp(36px, 7dvh, 88px) !important;
}

.hearing-test-fullscreen .hearing-test-topbar {
  align-self: end !important;
}

.hearing-test-fullscreen .hearing-test-choice-column {
  align-content: center !important;
  gap: clamp(28px, 5dvh, 58px) !important;
}

.sentence-recording-indicator {
  margin-bottom: clamp(8px, 1.5dvh, 16px);
}

.date-input-box strong,
.year-digit-row .year-digit-box,
.orientation-answer-square {
  display: grid !important;
  place-items: center !important;
  line-height: 1 !important;
}

.year-digit-row {
  grid-template-columns: repeat(4, max-content) !important;
}

.year-digit-row .year-digit-box {
  width: clamp(76px, 11dvh, 104px) !important;
  min-width: clamp(76px, 11dvh, 104px) !important;
  height: clamp(76px, 11dvh, 104px) !important;
  min-height: clamp(76px, 11dvh, 104px) !important;
  aspect-ratio: 1 !important;
  box-sizing: border-box !important;
}

.orientation-city-page .orientation-text-options,
.orientation-place-page .orientation-text-options {
  width: min(560px, calc(100vw - 48px)) !important;
}

@media (orientation: portrait), (max-width: 760px) {
  .story-scene-screen .story-dialogue-box,
  .story-screen--task-guide .story-dialogue-box,
  .story-screen--feedback .story-dialogue-box,
  .hearing-intro-guide-page .story-dialogue-box,
  .hearing-guide-page .story-dialogue-box,
  .digit-backward-guide-page .story-dialogue-box {
    width: min(760px, calc(100vw - 24px)) !important;
    max-width: min(760px, calc(100vw - 24px)) !important;
  }

  .hearing-intro-guide-page .story-dialogue-text {
    font-size: clamp(25px, 6.1vw, 38px) !important;
  }

  .trail-guide-page:has(.trail-guide-practice) .story-character-stage {
    width: min(128px, 30vw) !important;
  }

  .hearing-test-fullscreen {
    gap: clamp(22px, 4dvh, 42px) !important;
    padding-block: clamp(24px, 5dvh, 46px) !important;
  }
}

/* QA pass: adaptive dialogue bubbles, menu-reset-friendly answer surfaces, and unclipped keypads. */
.story-scene-screen:not(:has(.trail-guide-practice)) {
  --story-character-left: max(18px, calc(50% - 520px)) !important;
  --story-dialog-left: max(218px, calc(50% - 258px)) !important;
  --story-dialog-right: max(18px, calc(50% - 520px)) !important;
}

.story-scene-screen:not(:has(.trail-guide-practice)) .story-dialogue-box,
.story-screen--task-guide:not(:has(.trail-guide-practice)) .story-dialogue-box,
.story-screen--feedback .story-dialogue-box,
.hearing-intro-guide-page .story-dialogue-box,
.hearing-guide-page .story-dialogue-box,
.digit-backward-guide-page .story-dialogue-box {
  width: fit-content !important;
  min-width: min(340px, calc(100vw - var(--story-dialog-left) - var(--story-dialog-right))) !important;
  max-width: min(820px, calc(100vw - var(--story-dialog-left) - var(--story-dialog-right))) !important;
  height: auto !important;
  min-height: clamp(128px, 20dvh, 210px) !important;
  max-height: min(58dvh, 420px) !important;
  padding: clamp(22px, 3.4dvh, 38px) clamp(28px, 4vw, 50px) !important;
}

.story-scene-screen:not(:has(.trail-guide-practice)) .story-dialogue-text {
  max-width: min(18em, calc(100vw - var(--story-dialog-left) - var(--story-dialog-right) - 80px)) !important;
}

.story-scene-screen:not(:has(.trail-guide-practice)) .story-choice-row {
  left: var(--story-dialog-left) !important;
  right: var(--story-dialog-right) !important;
}

.trail-guide-page:has(.trail-guide-practice).story-scene-screen {
  --trail-example-width: min(760px, calc(100vw - 230px));
  display: grid !important;
  grid-template-columns: minmax(116px, 180px) minmax(0, var(--trail-example-width)) !important;
  grid-template-rows: auto minmax(0, auto) auto !important;
  align-content: center !important;
  justify-content: center !important;
  justify-items: stretch !important;
  column-gap: clamp(16px, 3vw, 34px) !important;
  row-gap: clamp(10px, 1.8dvh, 18px) !important;
  padding: clamp(14px, 2.2dvh, 24px) clamp(16px, 3vw, 34px) !important;
}

.trail-guide-page:has(.trail-guide-practice) .story-character-stage,
.trail-guide-page:has(.trail-guide-practice) .story-dialogue-box,
.trail-guide-page:has(.trail-guide-practice) .story-extra-content,
.trail-guide-page:has(.trail-guide-practice) .story-choice-row {
  position: static !important;
  inset: auto !important;
  transform: none !important;
}

.trail-guide-page:has(.trail-guide-practice) .story-character-stage {
  grid-column: 1 !important;
  grid-row: 1 / 3 !important;
  width: min(168px, 17vw, 30dvh) !important;
  align-self: center !important;
  justify-self: end !important;
}

.trail-guide-page:has(.trail-guide-practice) .story-dialogue-box {
  grid-column: 2 !important;
  grid-row: 1 !important;
  width: fit-content !important;
  min-width: min(520px, 100%) !important;
  max-width: 100% !important;
  height: auto !important;
  min-height: clamp(104px, 17dvh, 168px) !important;
  max-height: none !important;
  justify-self: start !important;
  align-self: end !important;
  overflow: visible !important;
  padding: clamp(15px, 2.1dvh, 24px) clamp(22px, 3vw, 34px) !important;
}

.trail-guide-page:has(.trail-guide-practice) .story-dialogue-box::before,
.trail-guide-page:has(.trail-guide-practice) .story-dialogue-box::after {
  display: block !important;
  content: "" !important;
  position: absolute !important;
  top: 50% !important;
  width: 0 !important;
  height: 0 !important;
  transform: translateY(-50%) !important;
}

.trail-guide-page:has(.trail-guide-practice) .story-dialogue-box::before {
  left: -18px !important;
  border-top: 14px solid transparent !important;
  border-bottom: 14px solid transparent !important;
  border-right: 18px solid #d4c0a0 !important;
}

.trail-guide-page:has(.trail-guide-practice) .story-dialogue-box::after {
  left: -14px !important;
  border-top: 11px solid transparent !important;
  border-bottom: 11px solid transparent !important;
  border-right: 15px solid var(--story-dialog-fill) !important;
}

.trail-guide-page:has(.trail-guide-practice) .story-dialogue-text {
  max-width: min(18em, 100%) !important;
  font-size: clamp(23px, 2.35vw, 34px) !important;
  line-height: 1.16 !important;
}

.trail-guide-page:has(.trail-guide-practice) .story-extra-content {
  grid-column: 2 !important;
  grid-row: 2 !important;
  width: 100% !important;
  max-width: 100% !important;
  justify-self: stretch !important;
  align-self: start !important;
}

.trail-guide-page:has(.trail-guide-practice) .trail-guide-practice {
  width: 100% !important;
}

.trail-guide-page:has(.trail-guide-practice) .trail-guide-board {
  height: clamp(160px, 30dvh, 270px) !important;
  min-height: 0 !important;
}

.trail-guide-page:has(.trail-guide-practice) .story-choice-row {
  grid-column: 2 !important;
  grid-row: 3 !important;
  justify-self: center !important;
  align-self: end !important;
}

.trail-guide-page.story-scene-screen:not(:has(.trail-guide-practice)) {
  display: grid !important;
  grid-template-columns: minmax(116px, 180px) minmax(0, auto) !important;
  grid-template-rows: auto auto !important;
  align-content: center !important;
  justify-content: center !important;
  justify-items: stretch !important;
  column-gap: clamp(16px, 3vw, 34px) !important;
  row-gap: clamp(20px, 4dvh, 42px) !important;
  padding: clamp(18px, 3dvh, 34px) clamp(16px, 3vw, 34px) !important;
}

.trail-guide-page.story-scene-screen:not(:has(.trail-guide-practice)) .story-character-stage,
.trail-guide-page.story-scene-screen:not(:has(.trail-guide-practice)) .story-dialogue-box,
.trail-guide-page.story-scene-screen:not(:has(.trail-guide-practice)) .story-choice-row {
  position: static !important;
  inset: auto !important;
  transform: none !important;
}

.trail-guide-page.story-scene-screen:not(:has(.trail-guide-practice)) .story-character-stage {
  grid-column: 1 !important;
  grid-row: 1 !important;
  width: min(168px, 17vw, 30dvh) !important;
  align-self: center !important;
  justify-self: end !important;
}

.trail-guide-page.story-scene-screen:not(:has(.trail-guide-practice)) .story-dialogue-box {
  grid-column: 2 !important;
  grid-row: 1 !important;
  width: fit-content !important;
  min-width: min(420px, calc(100vw - 240px)) !important;
  max-width: min(820px, calc(100vw - 240px)) !important;
  height: auto !important;
  min-height: clamp(118px, 20dvh, 190px) !important;
  max-height: min(58dvh, 420px) !important;
  justify-self: start !important;
  align-self: center !important;
  overflow: visible !important;
}

.trail-guide-page.story-scene-screen:not(:has(.trail-guide-practice)) .story-dialogue-text {
  max-width: min(18em, calc(100vw - 320px)) !important;
}

.trail-guide-page.story-scene-screen:not(:has(.trail-guide-practice)) .story-choice-row {
  grid-column: 1 / -1 !important;
  grid-row: 2 !important;
  justify-self: center !important;
  align-self: center !important;
}

.hearing-summary-character {
  opacity: 0;
  transform: translateY(8px) scale(0.96);
  animation: hearingSummaryCharacterAppear 0.54s steps(2, end) 0.34s forwards;
}

@keyframes hearingSummaryCharacterAppear {
  0%, 56% {
    opacity: 0;
    transform: translateY(8px) scale(0.96);
  }
  57%, 100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.hearing-summary-copy {
  display: grid;
  justify-items: center;
  gap: clamp(18px, 3dvh, 30px);
}

.hearing-summary-wrapper .hearing-continue-button {
  min-width: min(360px, 82vw) !important;
}

.sentence-page .sentence-inline-confirm {
  margin-top: clamp(10px, 2dvh, 18px);
  width: min(360px, 82vw);
  min-height: clamp(64px, 9dvh, 82px);
  align-self: center;
}

.digit-page.ready.keypad-split-page,
.serial-page.keypad-split-page,
.orientation-number-page.keypad-split-page {
  grid-template-rows: minmax(92px, 0.3fr) minmax(0, 0.7fr) !important;
  padding-bottom: max(12px, env(safe-area-inset-bottom)) !important;
  overflow: visible !important;
}

.digit-page.ready.keypad-split-page .keypad-panel,
.serial-page.keypad-split-page .keypad-panel,
.orientation-number-page.keypad-split-page .keypad-panel {
  align-content: center !important;
  padding: clamp(4px, 0.9dvh, 10px) 0 max(10px, env(safe-area-inset-bottom)) !important;
}

.digit-page.ready.keypad-split-page .keypad-panel .keypad,
.serial-page.keypad-split-page .keypad-panel .keypad,
.orientation-number-page.keypad-split-page .keypad-panel .keypad {
  height: min(40dvh, 360px) !important;
  max-height: calc(100dvh - 340px) !important;
}

.digit-page.ready.keypad-split-page .keypad-delete,
.serial-page.keypad-split-page .keypad-delete,
.orientation-number-page.keypad-split-page .keypad-delete,
.digit-page.ready.keypad-split-page .keypad .confirm,
.serial-page.keypad-split-page .keypad .confirm,
.orientation-number-page.keypad-split-page .keypad .confirm {
  font-size: clamp(22px, 3vw, 32px) !important;
}

.orientation-choice-question-panel,
.orientation-number-page .keypad-question-panel,
.digit-question-panel,
.serial-page .keypad-question-panel {
  width: min(560px, 100%) !important;
}

.orientation-answer-box,
.orientation-choice-question-panel .weekday-answer-line,
.serial-page .serial-display,
.serial-page .serial-display.empty {
  width: min(520px, 100%) !important;
  min-height: clamp(76px, 11dvh, 102px) !important;
  box-sizing: border-box !important;
}

.date-input-with-units {
  min-height: clamp(76px, 11dvh, 102px) !important;
}

@media (orientation: portrait), (max-width: 760px) {
  .story-scene-screen:not(:has(.trail-guide-practice)) {
    --story-character-left: 50% !important;
    --story-dialog-left: 12px !important;
    --story-dialog-right: 12px !important;
  }

  .story-scene-screen:not(:has(.trail-guide-practice)) .story-character-stage {
    top: clamp(28px, 8dvh, 70px) !important;
    left: 50% !important;
    width: min(130px, 30vw) !important;
    transform: translateX(-50%) !important;
  }

  .story-scene-screen:not(:has(.trail-guide-practice)) .story-dialogue-box {
    top: clamp(180px, 32dvh, 260px) !important;
    left: 12px !important;
    right: 12px !important;
    width: fit-content !important;
    min-width: min(300px, calc(100vw - 24px)) !important;
    max-width: calc(100vw - 24px) !important;
    justify-self: center !important;
    margin-inline: auto !important;
    transform: none !important;
  }

  .story-scene-screen:not(:has(.trail-guide-practice)) .story-dialogue-box::before,
  .story-scene-screen:not(:has(.trail-guide-practice)) .story-dialogue-box::after {
    display: none !important;
  }

  .story-scene-screen:not(:has(.trail-guide-practice)) .story-choice-row {
    left: 12px !important;
    right: 12px !important;
  }

  .trail-guide-page:has(.trail-guide-practice).story-scene-screen {
    --trail-example-width: calc(100vw - 24px);
    grid-template-columns: minmax(0, 1fr) !important;
    grid-template-rows: auto auto minmax(0, auto) auto !important;
  }

  .trail-guide-page:has(.trail-guide-practice) .story-character-stage {
    grid-column: 1 !important;
    grid-row: 1 !important;
    justify-self: center !important;
    width: min(126px, 28vw) !important;
  }

  .trail-guide-page:has(.trail-guide-practice) .story-dialogue-box,
  .trail-guide-page:has(.trail-guide-practice) .story-extra-content,
  .trail-guide-page:has(.trail-guide-practice) .story-choice-row {
    grid-column: 1 !important;
  }

  .trail-guide-page:has(.trail-guide-practice) .story-dialogue-box {
    grid-row: 2 !important;
    justify-self: center !important;
  }

  .trail-guide-page:has(.trail-guide-practice) .story-extra-content {
    grid-row: 3 !important;
  }

  .trail-guide-page:has(.trail-guide-practice) .story-choice-row {
    grid-row: 4 !important;
  }
}

@media (orientation: landscape) and (max-height: 700px) {
  .digit-page.ready.keypad-split-page .keypad-panel .keypad,
  .serial-page.keypad-split-page .keypad-panel .keypad,
  .orientation-number-page.keypad-split-page .keypad-panel .keypad {
    height: min(36dvh, 292px) !important;
    max-height: calc(100dvh - 292px) !important;
    gap: clamp(7px, 1.4dvh, 11px) !important;
  }
}

/* Final QA pass: sidebar stays above task surfaces and all guide layouts center as one group. */
.global-menu-button {
  z-index: 11010 !important;
  pointer-events: auto !important;
}

.hidden-drawer {
  z-index: 11020 !important;
}

.admin-password-dialog {
  z-index: 11040 !important;
}

.story-scene-screen.story-screen--onboarding,
.story-scene-screen.story-screen--task-guide:not(:has(.trail-guide-practice)),
.story-scene-screen.story-screen--feedback {
  --story-character-width: clamp(138px, 15vw, 210px) !important;
  display: grid !important;
  grid-template-columns: minmax(118px, var(--story-character-width)) minmax(0, auto) !important;
  grid-template-rows: auto auto auto !important;
  align-content: center !important;
  align-items: center !important;
  justify-content: center !important;
  justify-items: stretch !important;
  gap: clamp(18px, 3dvh, 32px) clamp(18px, 3vw, 36px) !important;
  padding: clamp(18px, 3.2dvh, 34px) clamp(18px, 4vw, 48px) !important;
  overflow: hidden !important;
}

.story-scene-screen.story-screen--onboarding .story-character-stage,
.story-scene-screen.story-screen--task-guide:not(:has(.trail-guide-practice)) .story-character-stage,
.story-scene-screen.story-screen--feedback .story-character-stage,
.story-scene-screen.story-screen--onboarding .story-dialogue-box,
.story-scene-screen.story-screen--task-guide:not(:has(.trail-guide-practice)) .story-dialogue-box,
.story-scene-screen.story-screen--feedback .story-dialogue-box,
.story-scene-screen.story-screen--onboarding .story-extra-content,
.story-scene-screen.story-screen--task-guide:not(:has(.trail-guide-practice)) .story-extra-content,
.story-scene-screen.story-screen--feedback .story-extra-content,
.story-scene-screen.story-screen--onboarding .story-choice-row,
.story-scene-screen.story-screen--task-guide:not(:has(.trail-guide-practice)) .story-choice-row,
.story-scene-screen.story-screen--feedback .story-choice-row {
  position: static !important;
  inset: auto !important;
  transform: none !important;
}

.story-scene-screen.story-screen--onboarding .story-character-stage,
.story-scene-screen.story-screen--task-guide:not(:has(.trail-guide-practice)) .story-character-stage,
.story-scene-screen.story-screen--feedback .story-character-stage {
  grid-column: 1 !important;
  grid-row: 1 !important;
  width: var(--story-character-width) !important;
  align-self: center !important;
  justify-self: end !important;
}

.story-scene-screen.story-screen--onboarding .story-character-stage .guide-character,
.story-scene-screen.story-screen--task-guide:not(:has(.trail-guide-practice)) .story-character-stage .guide-character,
.story-scene-screen.story-screen--feedback .story-character-stage .guide-character,
.story-scene-screen.story-screen--onboarding .story-character-stage .character-container,
.story-scene-screen.story-screen--task-guide:not(:has(.trail-guide-practice)) .story-character-stage .character-container,
.story-scene-screen.story-screen--feedback .story-character-stage .character-container {
  width: var(--story-character-width) !important;
  max-height: min(42dvh, 310px) !important;
}

.story-scene-screen.story-screen--onboarding .story-dialogue-box,
.story-scene-screen.story-screen--task-guide:not(:has(.trail-guide-practice)) .story-dialogue-box,
.story-scene-screen.story-screen--feedback .story-dialogue-box {
  grid-column: 2 !important;
  grid-row: 1 !important;
  width: fit-content !important;
  min-width: min(300px, 100%) !important;
  max-width: 100% !important;
  height: auto !important;
  min-height: clamp(112px, 18dvh, 186px) !important;
  max-height: min(56dvh, 390px) !important;
  align-self: center !important;
  justify-self: start !important;
  padding: clamp(20px, 3dvh, 34px) clamp(26px, 4vw, 46px) !important;
  overflow: visible !important;
}

.story-scene-screen.story-screen--onboarding .story-dialogue-text,
.story-scene-screen.story-screen--task-guide:not(:has(.trail-guide-practice)) .story-dialogue-text,
.story-scene-screen.story-screen--feedback .story-dialogue-text {
  width: max-content !important;
  max-width: min(18em, 100%) !important;
  font-size: clamp(28px, 3.25vw, 44px) !important;
  line-height: 1.18 !important;
}

.story-scene-screen.story-screen--onboarding .story-extra-content,
.story-scene-screen.story-screen--task-guide:not(:has(.trail-guide-practice)) .story-extra-content,
.story-scene-screen.story-screen--feedback .story-extra-content {
  grid-column: 1 / -1 !important;
  grid-row: 2 !important;
  width: min(620px, calc(100vw - 36px)) !important;
  justify-self: center !important;
  align-self: center !important;
  margin: 0 !important;
  z-index: 4 !important;
}

.story-scene-screen.story-screen--onboarding .story-choice-row,
.story-scene-screen.story-screen--task-guide:not(:has(.trail-guide-practice)) .story-choice-row,
.story-scene-screen.story-screen--feedback .story-choice-row {
  grid-column: 1 / -1 !important;
  grid-row: 3 !important;
  width: 100% !important;
  min-width: 0 !important;
  justify-content: center !important;
  justify-self: center !important;
  align-self: center !important;
  z-index: 5 !important;
}

.story-scene-screen.story-screen--onboarding .story-action-bubble,
.story-scene-screen.story-screen--task-guide:not(:has(.trail-guide-practice)) .story-action-bubble,
.story-scene-screen.story-screen--feedback .story-action-bubble,
.story-scene-screen.story-screen--onboarding .story-status-bubble,
.story-scene-screen.story-screen--task-guide:not(:has(.trail-guide-practice)) .story-status-bubble,
.story-scene-screen.story-screen--feedback .story-status-bubble {
  min-width: min(340px, 86vw) !important;
}

.trail-guide-page:has(.trail-guide-practice).story-scene-screen {
  --story-character-width: clamp(138px, 15vw, 210px) !important;
  --trail-example-width: min(760px, calc(100vw - 320px)) !important;
  display: grid !important;
  grid-template-columns: minmax(118px, var(--story-character-width)) minmax(0, var(--trail-example-width)) !important;
  grid-template-rows: auto minmax(0, auto) auto !important;
  align-content: center !important;
  align-items: center !important;
  justify-content: center !important;
  justify-items: stretch !important;
  gap: clamp(12px, 2dvh, 22px) clamp(18px, 3vw, 36px) !important;
  padding: clamp(14px, 2.2dvh, 24px) clamp(18px, 4vw, 48px) !important;
  overflow: hidden !important;
}

.trail-guide-page:has(.trail-guide-practice) .story-character-stage,
.trail-guide-page:has(.trail-guide-practice) .story-dialogue-box,
.trail-guide-page:has(.trail-guide-practice) .story-extra-content,
.trail-guide-page:has(.trail-guide-practice) .story-choice-row {
  position: static !important;
  inset: auto !important;
  transform: none !important;
}

.trail-guide-page:has(.trail-guide-practice) .story-character-stage {
  grid-column: 1 !important;
  grid-row: 1 / 3 !important;
  width: var(--story-character-width) !important;
  align-self: center !important;
  justify-self: end !important;
}

.trail-guide-page:has(.trail-guide-practice) .story-character-stage .guide-character,
.trail-guide-page:has(.trail-guide-practice) .story-character-stage .character-container {
  width: var(--story-character-width) !important;
  max-height: min(42dvh, 310px) !important;
}

.trail-guide-page:has(.trail-guide-practice) .story-dialogue-box {
  grid-column: 2 !important;
  grid-row: 1 !important;
  width: fit-content !important;
  min-width: min(300px, 100%) !important;
  max-width: 100% !important;
  height: auto !important;
  min-height: clamp(96px, 15dvh, 148px) !important;
  max-height: none !important;
  align-self: end !important;
  justify-self: start !important;
  padding: clamp(16px, 2.2dvh, 24px) clamp(22px, 3vw, 34px) !important;
  overflow: visible !important;
}

.trail-guide-page:has(.trail-guide-practice) .story-dialogue-text {
  width: max-content !important;
  max-width: min(18em, 100%) !important;
  font-size: clamp(23px, 2.3vw, 34px) !important;
  line-height: 1.16 !important;
}

.trail-guide-page:has(.trail-guide-practice) .story-extra-content {
  grid-column: 2 !important;
  grid-row: 2 !important;
  width: 100% !important;
  max-width: 100% !important;
  align-self: start !important;
  justify-self: stretch !important;
  margin: 0 !important;
}

.trail-guide-page:has(.trail-guide-practice) .trail-guide-practice {
  width: 100% !important;
  margin: 0 !important;
}

.trail-guide-page:has(.trail-guide-practice) .trail-guide-board {
  height: clamp(168px, 31dvh, 270px) !important;
  min-height: 0 !important;
}

.trail-guide-page:has(.trail-guide-practice) .story-choice-row {
  grid-column: 1 / -1 !important;
  grid-row: 3 !important;
  width: 100% !important;
  justify-content: center !important;
  justify-self: center !important;
  align-self: center !important;
}

.hearing-summary-dialog {
  min-height: min(520px, calc(100dvh - 140px)) !important;
  align-items: center !important;
}

.hearing-summary-character {
  opacity: 0 !important;
  visibility: hidden !important;
  transform: translateY(8px) scale(0.98) !important;
  backface-visibility: hidden !important;
  will-change: opacity, transform !important;
  animation: hearingSummaryCharacterAppearStable 0.42s ease-out 0.32s forwards !important;
}

@keyframes hearingSummaryCharacterAppearStable {
  0% {
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px) scale(0.98);
  }
  1% {
    opacity: 0;
    visibility: visible;
    transform: translateY(8px) scale(0.98);
  }
  100% {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
  }
}

.weekday-answer-line {
  width: min(520px, 100%) !important;
  justify-self: center !important;
  justify-content: center !important;
}

.weekday-answer-line .orientation-answer-square {
  display: inline-grid !important;
  place-items: center !important;
  flex: 0 0 clamp(62px, 9vw, 86px) !important;
  line-height: 1 !important;
}

@media (orientation: portrait), (max-width: 760px) {
  .story-scene-screen.story-screen--onboarding,
  .story-scene-screen.story-screen--task-guide:not(:has(.trail-guide-practice)),
  .story-scene-screen.story-screen--feedback,
  .trail-guide-page:has(.trail-guide-practice).story-scene-screen {
    --story-character-width: min(132px, 30vw) !important;
    --trail-example-width: calc(100vw - 28px) !important;
    grid-template-columns: minmax(0, 1fr) !important;
    grid-template-rows: auto auto auto auto !important;
    align-content: center !important;
    justify-items: center !important;
    gap: clamp(10px, 2dvh, 18px) !important;
    padding: clamp(12px, 2dvh, 22px) 14px !important;
  }

  .story-scene-screen.story-screen--onboarding .story-character-stage,
  .story-scene-screen.story-screen--task-guide:not(:has(.trail-guide-practice)) .story-character-stage,
  .story-scene-screen.story-screen--feedback .story-character-stage,
  .trail-guide-page:has(.trail-guide-practice) .story-character-stage {
    grid-column: 1 !important;
    grid-row: 1 !important;
    width: var(--story-character-width) !important;
    justify-self: center !important;
  }

  .story-scene-screen.story-screen--onboarding .story-dialogue-box,
  .story-scene-screen.story-screen--task-guide:not(:has(.trail-guide-practice)) .story-dialogue-box,
  .story-scene-screen.story-screen--feedback .story-dialogue-box,
  .trail-guide-page:has(.trail-guide-practice) .story-dialogue-box {
    grid-column: 1 !important;
    grid-row: 2 !important;
    width: fit-content !important;
    min-width: min(292px, calc(100vw - 28px)) !important;
    max-width: calc(100vw - 28px) !important;
    justify-self: center !important;
    align-self: center !important;
    min-height: clamp(92px, 16dvh, 146px) !important;
    padding: clamp(18px, 2.6dvh, 26px) clamp(20px, 5vw, 30px) !important;
  }

  .story-scene-screen.story-screen--onboarding .story-dialogue-box::before,
  .story-scene-screen.story-screen--onboarding .story-dialogue-box::after,
  .story-scene-screen.story-screen--task-guide:not(:has(.trail-guide-practice)) .story-dialogue-box::before,
  .story-scene-screen.story-screen--task-guide:not(:has(.trail-guide-practice)) .story-dialogue-box::after,
  .story-scene-screen.story-screen--feedback .story-dialogue-box::before,
  .story-scene-screen.story-screen--feedback .story-dialogue-box::after,
  .trail-guide-page:has(.trail-guide-practice) .story-dialogue-box::before,
  .trail-guide-page:has(.trail-guide-practice) .story-dialogue-box::after {
    display: none !important;
  }

  .story-scene-screen.story-screen--onboarding .story-dialogue-text,
  .story-scene-screen.story-screen--task-guide:not(:has(.trail-guide-practice)) .story-dialogue-text,
  .story-scene-screen.story-screen--feedback .story-dialogue-text,
  .trail-guide-page:has(.trail-guide-practice) .story-dialogue-text {
    width: fit-content !important;
    max-width: 100% !important;
    font-size: clamp(25px, 6vw, 36px) !important;
  }

  .story-scene-screen.story-screen--onboarding .story-extra-content,
  .story-scene-screen.story-screen--task-guide:not(:has(.trail-guide-practice)) .story-extra-content,
  .story-scene-screen.story-screen--feedback .story-extra-content,
  .trail-guide-page:has(.trail-guide-practice) .story-extra-content {
    grid-column: 1 !important;
    grid-row: 3 !important;
    width: min(100%, calc(100vw - 28px)) !important;
  }

  .story-scene-screen.story-screen--onboarding .story-choice-row,
  .story-scene-screen.story-screen--task-guide:not(:has(.trail-guide-practice)) .story-choice-row,
  .story-scene-screen.story-screen--feedback .story-choice-row,
  .trail-guide-page:has(.trail-guide-practice) .story-choice-row {
    grid-column: 1 !important;
    grid-row: 4 !important;
  }

  .trail-guide-page:has(.trail-guide-practice) .trail-guide-board {
    height: clamp(150px, 28dvh, 230px) !important;
  }
}

@media (orientation: landscape) and (max-height: 620px) {
  .story-scene-screen.story-screen--onboarding,
  .story-scene-screen.story-screen--task-guide:not(:has(.trail-guide-practice)),
  .story-scene-screen.story-screen--feedback {
    --story-character-width: clamp(112px, 13vw, 160px) !important;
    grid-template-columns: minmax(104px, var(--story-character-width)) minmax(0, auto) !important;
    gap: clamp(10px, 2dvh, 18px) clamp(14px, 2.4vw, 28px) !important;
    padding-block: clamp(10px, 2dvh, 18px) !important;
  }

  .story-scene-screen.story-screen--onboarding .story-dialogue-box,
  .story-scene-screen.story-screen--task-guide:not(:has(.trail-guide-practice)) .story-dialogue-box,
  .story-scene-screen.story-screen--feedback .story-dialogue-box {
    min-height: clamp(88px, 21dvh, 130px) !important;
    max-height: 48dvh !important;
    padding: clamp(14px, 2.4dvh, 22px) clamp(20px, 3vw, 32px) !important;
  }

  .story-scene-screen.story-screen--onboarding .story-dialogue-text,
  .story-scene-screen.story-screen--task-guide:not(:has(.trail-guide-practice)) .story-dialogue-text,
  .story-scene-screen.story-screen--feedback .story-dialogue-text {
    font-size: clamp(24px, 3vw, 34px) !important;
  }

  .story-action-bubble,
  .story-status-bubble {
    min-height: clamp(58px, 10dvh, 72px) !important;
  }

  .trail-guide-page:has(.trail-guide-practice).story-scene-screen {
    --story-character-width: clamp(104px, 13vw, 150px) !important;
    --trail-example-width: min(640px, calc(100vw - 250px)) !important;
  }

  .trail-guide-page:has(.trail-guide-practice) .trail-guide-board {
    height: clamp(136px, 29dvh, 210px) !important;
  }
}

/* Final guide polish: keep speech bubbles proportional and center weekday orientation. */
.story-scene-screen.story-screen--onboarding .story-dialogue-box,
.story-scene-screen.story-screen--task-guide:not(:has(.trail-guide-practice)) .story-dialogue-box,
.story-scene-screen.story-screen--feedback .story-dialogue-box,
.trail-guide-page:has(.trail-guide-practice) .story-dialogue-box {
  box-sizing: border-box !important;
  position: relative !important;
  width: fit-content !important;
  min-width: min(260px, calc(100vw - 40px)) !important;
  max-width: min(680px, calc(100vw - var(--story-character-width, 160px) - 112px)) !important;
  min-height: clamp(86px, 13dvh, 136px) !important;
  padding: clamp(16px, 2.3dvh, 28px) clamp(22px, 3.1vw, 38px) !important;
}

.story-scene-screen.story-screen--onboarding .story-dialogue-text,
.story-scene-screen.story-screen--task-guide:not(:has(.trail-guide-practice)) .story-dialogue-text,
.story-scene-screen.story-screen--feedback .story-dialogue-text,
.trail-guide-page:has(.trail-guide-practice) .story-dialogue-text {
  width: fit-content !important;
  max-width: min(15em, 100%) !important;
}

.story-dialogue-box .story-next-triangle,
.hearing-summary-bubble .story-next-triangle {
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
}

.hearing-summary-bubble {
  position: relative !important;
  padding-bottom: clamp(30px, 5dvh, 48px) !important;
}

.hearing-summary-bubble .story-next-triangle {
  bottom: clamp(10px, 1.8dvh, 16px) !important;
}

.orientation-weekday-page.orientation-choice-page {
  grid-template-columns: minmax(0, 1fr) !important;
  grid-template-rows: minmax(96px, 0.38fr) minmax(0, 0.62fr) !important;
  justify-items: center !important;
  align-items: stretch !important;
}

.orientation-weekday-page .orientation-choice-question-panel,
.orientation-weekday-page .orientation-choice-option-panel {
  width: min(620px, 100%) !important;
  justify-self: center !important;
  justify-items: center !important;
}

.orientation-weekday-page .orientation-choice-question-panel {
  align-content: end !important;
}

.orientation-weekday-page .orientation-choice-option-panel {
  align-content: start !important;
}

.orientation-weekday-page .weekday-answer-line {
  width: fit-content !important;
  min-width: 0 !important;
  justify-self: center !important;
  margin-inline: auto !important;
}

.orientation-weekday-page .orientation-weekday-options {
  width: min(520px, 100%) !important;
  justify-content: center !important;
  justify-self: center !important;
}

.trail-guide-page:has(.trail-guide-practice) .story-dialogue-text {
  font-size: var(--story-dialogue-font-size) !important;
}

@media (orientation: portrait), (max-width: 760px) {
  .story-scene-screen.story-screen--onboarding .story-dialogue-box,
  .story-scene-screen.story-screen--task-guide:not(:has(.trail-guide-practice)) .story-dialogue-box,
  .story-scene-screen.story-screen--feedback .story-dialogue-box,
  .trail-guide-page:has(.trail-guide-practice) .story-dialogue-box {
    min-width: min(244px, calc(100vw - 28px)) !important;
    max-width: min(560px, calc(100vw - 28px)) !important;
    min-height: clamp(82px, 13dvh, 126px) !important;
    padding: clamp(15px, 2.2dvh, 24px) clamp(18px, 4.6vw, 28px) !important;
  }

  .story-scene-screen.story-screen--onboarding .story-dialogue-text,
  .story-scene-screen.story-screen--task-guide:not(:has(.trail-guide-practice)) .story-dialogue-text,
  .story-scene-screen.story-screen--feedback .story-dialogue-text,
  .trail-guide-page:has(.trail-guide-practice) .story-dialogue-text {
    max-width: min(13.5em, 100%) !important;
  }

  .orientation-weekday-page.orientation-choice-page {
    grid-template-rows: minmax(88px, 0.36fr) minmax(0, 0.64fr) !important;
  }
}

@media (orientation: landscape) and (max-height: 620px) {
  .story-scene-screen.story-screen--onboarding .story-dialogue-box,
  .story-scene-screen.story-screen--task-guide:not(:has(.trail-guide-practice)) .story-dialogue-box,
  .story-scene-screen.story-screen--feedback .story-dialogue-box,
  .trail-guide-page:has(.trail-guide-practice) .story-dialogue-box {
    min-height: clamp(78px, 18dvh, 112px) !important;
    padding: clamp(13px, 2dvh, 20px) clamp(18px, 2.6vw, 30px) !important;
  }
}

.hearing-intro-guide-page.story-scene-screen.story-screen--task-guide .story-dialogue-box {
  min-height: clamp(106px, 15dvh, 156px) !important;
  padding-bottom: clamp(30px, 4.2dvh, 44px) !important;
}

.hearing-intro-guide-page .story-next-triangle {
  bottom: clamp(8px, 1.5dvh, 14px) !important;
}

@media (orientation: landscape) and (max-height: 620px) {
  .hearing-intro-guide-page.story-scene-screen.story-screen--task-guide .story-dialogue-box {
    min-height: clamp(98px, 22dvh, 128px) !important;
    padding-bottom: clamp(28px, 5dvh, 38px) !important;
  }
}

/* Final keypad footprint: numeric-answer cards should match the full task card size. */
.task-page-village .digit-page.ready.keypad-split-page,
.task-page-village .serial-page.keypad-split-page,
.task-page-village .orientation-number-page.keypad-split-page {
  position: relative !important;
  display: grid !important;
  width: 100% !important;
  max-width: none !important;
  height: 100% !important;
  max-height: none !important;
  margin: 0 !important;
  box-sizing: border-box !important;
  grid-template-columns: minmax(0, 1fr) !important;
  grid-template-rows: minmax(112px, 0.34fr) minmax(0, 0.66fr) !important;
  align-content: stretch !important;
  align-items: stretch !important;
  justify-items: center !important;
  overflow: hidden !important;
}

.task-page-village .digit-page .keypad-question-panel,
.task-page-village .digit-page .keypad-panel,
.task-page-village .serial-page .keypad-question-panel,
.task-page-village .serial-page .keypad-panel,
.task-page-village .orientation-number-page .keypad-question-panel,
.task-page-village .orientation-number-page .keypad-panel {
  position: static !important;
  inset: auto !important;
  left: auto !important;
  top: auto !important;
  width: min(760px, 100%) !important;
  max-width: 100% !important;
  transform: none !important;
  justify-self: center !important;
}

.task-page-village .digit-page .keypad-question-panel,
.task-page-village .serial-page .keypad-question-panel,
.task-page-village .orientation-number-page .keypad-question-panel {
  align-self: end !important;
  align-content: end !important;
}

.task-page-village .digit-page .keypad-panel,
.task-page-village .serial-page .keypad-panel,
.task-page-village .orientation-number-page .keypad-panel {
  align-self: start !important;
  align-content: start !important;
}

.task-page-village .digit-page .keypad-panel .keypad,
.task-page-village .serial-page .keypad-panel .keypad,
.task-page-village .orientation-number-page .keypad-panel .keypad {
  width: min(520px, 100%) !important;
  height: min(39dvh, 350px) !important;
  max-height: calc(100dvh - 330px) !important;
}

/* Character stability: keep every person page visually still on tablets. */
.character-container--static {
  aspect-ratio: 641 / 900 !important;
  overflow: hidden !important;
  animation: none !important;
  contain: paint !important;
}

.character-container--static .character-static {
  display: block !important;
  width: 100% !important;
  height: 100% !important;
  object-fit: contain !important;
  pointer-events: none !important;
  user-select: none !important;
  -webkit-user-select: none !important;
  backface-visibility: hidden !important;
  transform: translateZ(0) !important;
}

.story-character-wrap,
.story-character-wrap.nod .character-container,
.story-character-wrap.encourage .character-container,
.story-character-wrap.nod .guide-character,
.story-character-wrap.encourage .guide-character,
.setup-welcome .character-container,
.hearing-summary-character .character-container {
  animation: none !important;
}

.setup-screen::before,
.setup-screen::after,
.setup-ambient-extra::before,
.setup-geo,
.floating-stars i {
  animation: none !important;
}

/* Numeric keypad polish: center the input + keypad group and give keys more height. */
.task-page-village .digit-page.ready.keypad-split-page,
.task-page-village .serial-page.keypad-split-page,
.task-page-village .orientation-number-page.keypad-split-page {
  grid-template-rows: auto auto !important;
  align-content: center !important;
  align-items: center !important;
  justify-content: center !important;
  gap: clamp(22px, 4dvh, 44px) !important;
  padding: clamp(30px, 5dvh, 56px) clamp(18px, 4vw, 44px) !important;
  overflow: hidden !important;
}

.task-page-village .digit-page .keypad-question-panel,
.task-page-village .serial-page .keypad-question-panel,
.task-page-village .orientation-number-page .keypad-question-panel,
.task-page-village .digit-page .keypad-panel,
.task-page-village .serial-page .keypad-panel,
.task-page-village .orientation-number-page .keypad-panel {
  height: auto !important;
  align-self: center !important;
  align-content: center !important;
}

.task-page-village .digit-page.ready.keypad-split-page .keypad-panel .digit-keypad.keypad,
.task-page-village .serial-page.keypad-split-page .keypad-panel .serial-keypad.keypad,
.task-page-village .orientation-number-page.keypad-split-page .keypad-panel .orientation-keypad.keypad,
.task-page-village .digit-page .keypad-panel .digit-keypad,
.task-page-village .serial-page .keypad-panel .serial-keypad,
.task-page-village .orientation-number-page .keypad-panel .orientation-keypad,
.task-page-village .digit-page .keypad-panel .keypad,
.task-page-village .serial-page .keypad-panel .keypad,
.task-page-village .orientation-number-page .keypad-panel .keypad {
  width: min(560px, 100%) !important;
  height: min(46dvh, 430px) !important;
  max-height: calc(100dvh - 300px) !important;
  grid-auto-rows: minmax(68px, 1fr) !important;
  gap: clamp(12px, 2dvh, 18px) !important;
}

.task-page-village .digit-page .keypad-panel .keypad button,
.task-page-village .serial-page .keypad-panel .keypad button,
.task-page-village .orientation-number-page .keypad-panel .keypad button,
.task-page-village .digit-page .keypad-panel .keypad-spacer,
.task-page-village .serial-page .keypad-panel .keypad-spacer,
.task-page-village .orientation-number-page .keypad-panel .keypad-spacer {
  min-height: 68px !important;
}

@media (orientation: landscape) and (max-height: 700px) {
  .task-page-village .digit-page.ready.keypad-split-page,
  .task-page-village .serial-page.keypad-split-page,
  .task-page-village .orientation-number-page.keypad-split-page {
    gap: clamp(14px, 3dvh, 24px) !important;
    padding-block: clamp(18px, 4dvh, 30px) !important;
  }

  .task-page-village .digit-page.ready.keypad-split-page .keypad-panel .digit-keypad.keypad,
  .task-page-village .serial-page.keypad-split-page .keypad-panel .serial-keypad.keypad,
  .task-page-village .orientation-number-page.keypad-split-page .keypad-panel .orientation-keypad.keypad,
  .task-page-village .digit-page .keypad-panel .digit-keypad,
  .task-page-village .serial-page .keypad-panel .serial-keypad,
  .task-page-village .orientation-number-page .keypad-panel .orientation-keypad,
  .task-page-village .digit-page .keypad-panel .keypad,
  .task-page-village .serial-page .keypad-panel .keypad,
  .task-page-village .orientation-number-page .keypad-panel .keypad {
    height: min(54dvh, 350px) !important;
    max-height: calc(100dvh - 210px) !important;
    grid-auto-rows: minmax(64px, 1fr) !important;
  }

  .task-page-village .digit-page .keypad-panel .keypad button,
  .task-page-village .serial-page .keypad-panel .keypad button,
  .task-page-village .orientation-number-page .keypad-panel .keypad button,
  .task-page-village .digit-page .keypad-panel .keypad-spacer,
  .task-page-village .serial-page .keypad-panel .keypad-spacer,
  .task-page-village .orientation-number-page .keypad-panel .keypad-spacer {
    min-height: 64px !important;
  }
}

/* Current QA overrides */
.story-character-stage .character-container,
.hearing-summary-character .character-container,
.setup-welcome .character-container {
  isolation: isolate !important;
  contain: paint !important;
  overflow: visible !important;
  backface-visibility: hidden !important;
  transform: translateZ(0) !important;
}

.guide-character-animated {
  display: block !important;
  aspect-ratio: 304 / 375 !important;
  object-fit: initial !important;
  overflow: visible !important;
  isolation: isolate !important;
}

.guide-character-animated .character-container {
  width: 100% !important;
  height: 100% !important;
  max-height: inherit !important;
  margin: 0 !important;
  filter: none !important;
  contain: paint !important;
}

.story-character-stage .character-container .character-base,
.setup-welcome .character-container .character-base,
.hearing-summary-character .character-container .character-base,
.guide-character-animated .character-container .character-base,
.character-eyes img,
.character-mouth img {
  backface-visibility: hidden !important;
  transform: translateZ(0) !important;
  will-change: auto !important;
}

.character-eyes {
  transform: translate3d(-50%, 0, 0) !important;
}

.character-mouth {
  transform: translate3d(-50%, 0, 0) !important;
}

.task-page-village .serial-page.keypad-split-page {
  display: grid !important;
  grid-template-rows: auto auto !important;
  align-content: center !important;
  justify-content: center !important;
  justify-items: center !important;
  gap: clamp(24px, 4.6dvh, 48px) !important;
  padding-block: clamp(44px, 7dvh, 78px) max(clamp(32px, 6dvh, 66px), env(safe-area-inset-bottom)) !important;
}

.task-page-village .serial-page.keypad-split-page .keypad-question-panel,
.task-page-village .serial-page.keypad-split-page .keypad-panel {
  position: static !important;
  inset: auto !important;
  width: min(760px, 100%) !important;
  margin: 0 auto !important;
  transform: none !important;
  justify-self: center !important;
}

.task-page-village .serial-page.keypad-split-page .keypad-question-panel {
  align-self: end !important;
  place-items: center !important;
}

.task-page-village .serial-page.keypad-split-page .keypad-panel {
  align-self: start !important;
}

.task-page-village .serial-page.keypad-split-page .serial-display,
.task-page-village .serial-page.keypad-split-page .serial-display.empty {
  position: static !important;
  left: auto !important;
  top: auto !important;
  width: min(560px, 100%) !important;
  min-height: clamp(82px, 12dvh, 112px) !important;
  margin: 0 auto !important;
  transform: none !important;
}

.task-page-village .serial-page.keypad-split-page .keypad-panel .serial-keypad.keypad,
.task-page-village .serial-page.keypad-split-page .keypad-panel .keypad {
  width: min(580px, 100%) !important;
  height: min(48dvh, 440px) !important;
  max-height: calc(100dvh - 300px) !important;
  grid-auto-rows: minmax(72px, 1fr) !important;
}

.task-page-village .serial-page.keypad-split-page .keypad-panel .keypad button,
.task-page-village .serial-page.keypad-split-page .keypad-panel .keypad-spacer {
  min-height: 72px !important;
}

.admin-toolbar .admin-action-button {
  border: 3px solid #d7e5dc !important;
  background: #ffffff !important;
  color: var(--leaf-dark) !important;
  box-shadow: 0 5px 0 #cddbd2, 0 12px 24px rgba(36, 52, 71, 0.08) !important;
  transition: background-color 120ms ease, color 120ms ease, border-color 120ms ease, box-shadow 120ms ease, transform 120ms ease !important;
}

.admin-toolbar .admin-action-button:active,
.admin-toolbar .admin-action-button.is-active {
  border-color: #4a7a4a !important;
  background: #5b8c5a !important;
  color: #ffffff !important;
  box-shadow: 0 3px 0 #3e6c3f, 0 10px 20px rgba(90, 140, 90, 0.22) !important;
  transform: translateY(2px) !important;
}

.admin-toolbar .admin-action-button[data-action="exportCsv"]:active,
.admin-toolbar .admin-action-button[data-action="exportCsv"].is-active {
  border-color: #1d4ed8 !important;
  background: #3b82f6 !important;
  box-shadow: 0 3px 0 #1d4ed8, 0 10px 20px rgba(59, 130, 246, 0.22) !important;
}

@media (orientation: landscape) and (max-height: 700px) {
  .task-page-village .serial-page.keypad-split-page {
    gap: clamp(16px, 3dvh, 28px) !important;
    padding-block: clamp(24px, 5dvh, 42px) max(clamp(18px, 4dvh, 32px), env(safe-area-inset-bottom)) !important;
  }

  .task-page-village .serial-page.keypad-split-page .serial-display,
  .task-page-village .serial-page.keypad-split-page .serial-display.empty {
    min-height: clamp(72px, 13dvh, 92px) !important;
  }

  .task-page-village .serial-page.keypad-split-page .keypad-panel .serial-keypad.keypad,
  .task-page-village .serial-page.keypad-split-page .keypad-panel .keypad {
    height: min(54dvh, 360px) !important;
    max-height: calc(100dvh - 210px) !important;
    grid-auto-rows: minmax(66px, 1fr) !important;
  }

  .task-page-village .serial-page.keypad-split-page .keypad-panel .keypad button,
  .task-page-village .serial-page.keypad-split-page .keypad-panel .keypad-spacer {
    min-height: 66px !important;
  }
}

/* Trail practice page: keep bubble and practice canvas aligned. */
.trail-guide-page:has(.trail-guide-practice).story-scene-screen {
  --trail-practice-width: min(760px, calc(100vw - 320px)) !important;
  grid-template-columns: minmax(118px, var(--story-character-width)) minmax(0, var(--trail-practice-width)) !important;
}

.trail-guide-page:has(.trail-guide-practice) .story-dialogue-box,
.trail-guide-page:has(.trail-guide-practice) .story-extra-content,
.trail-guide-page:has(.trail-guide-practice) .trail-guide-practice,
.trail-guide-page:has(.trail-guide-practice) .trail-guide-board {
  width: 100% !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
}

.trail-guide-page:has(.trail-guide-practice) .story-dialogue-box {
  justify-self: stretch !important;
}

.trail-guide-page:has(.trail-guide-practice) .trail-guide-practice {
  display: grid !important;
  grid-template-rows: minmax(0, 1fr) !important;
  gap: 0 !important;
}

.trail-guide-page:has(.trail-guide-practice) .trail-guide-practice strong {
  display: none !important;
}

@media (orientation: portrait), (max-width: 760px) {
  .trail-guide-page:has(.trail-guide-practice).story-scene-screen {
    --trail-practice-width: calc(100vw - 28px) !important;
  }
}

/* Current login QA: character left, form right, synced prompt typing. */
.setup-screen {
  height: 100dvh !important;
  min-height: 100dvh !important;
  max-height: 100dvh !important;
  overflow: hidden !important;
}

.setup-standalone {
  padding: 0 !important;
}

.setup-standalone .standalone-page-shell {
  width: 100vw !important;
  height: 100dvh !important;
}

.setup-panel {
  grid-template-columns: minmax(300px, 0.86fr) minmax(520px, 1.46fr) !important;
  box-sizing: border-box !important;
  width: min(1380px, calc(100vw - 32px)) !important;
  height: min(760px, calc(100dvh - 32px), calc(var(--app-height) - 32px)) !important;
  max-height: min(760px, calc(100dvh - 32px), calc(var(--app-height) - 32px)) !important;
  overflow: visible !important;
}

.setup-welcome {
  grid-column: 1 !important;
  grid-row: 1 !important;
  display: grid !important;
  justify-self: stretch !important;
}

.setup-left {
  grid-column: 2 !important;
  grid-row: 1 !important;
}

.setup-welcome-bubble {
  min-width: min(300px, 100%) !important;
  max-width: min(380px, 100%) !important;
  text-align: left !important;
  white-space: pre-line !important;
}

.setup-welcome-bubble .typewriter-text,
.setup-welcome-bubble .typewriter-measure,
.setup-welcome-bubble .typewriter-live {
  white-space: pre-line !important;
}

.setup-skip-login {
  right: max(34px, calc(env(safe-area-inset-right) + 30px)) !important;
  bottom: max(78px, calc(env(safe-area-inset-bottom) + 70px)) !important;
  max-width: calc(100vw - 72px) !important;
}

@media (orientation: portrait), (max-width: 760px) {
  .setup-panel {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .setup-left {
    grid-column: 1 !important;
  }

  .setup-welcome {
    display: none !important;
  }

  .setup-skip-login {
    right: max(28px, calc(env(safe-area-inset-right) + 24px)) !important;
  }
}

@media (orientation: landscape) and (max-height: 620px) {
  .setup-panel {
    grid-template-columns: minmax(240px, 0.78fr) minmax(500px, 1.5fr) !important;
  }

  .setup-welcome .character-container {
    width: min(230px, 22vw) !important;
  }

  .setup-welcome-bubble {
    max-width: min(340px, 100%) !important;
  }
}

.setup-duplicate-dialog,
.task-idle-dialog {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 24px;
}

.setup-duplicate-backdrop,
.task-idle-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(24, 35, 48, 0.34);
}

.setup-duplicate-panel,
.task-idle-panel {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 20px;
  justify-items: center;
  width: min(560px, 94vw);
  padding: clamp(26px, 4vw, 38px);
  border: 3px solid var(--leaf);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 22px 56px rgba(24, 35, 48, 0.24);
  text-align: center;
}

.setup-duplicate-panel h3,
.task-idle-panel h3 {
  margin: 0;
  color: var(--ink);
  font-size: clamp(28px, 4vw, 42px);
  font-weight: 1000;
  line-height: 1.16;
}

.setup-duplicate-panel p,
.task-idle-panel p {
  margin: 0;
  color: var(--muted);
  font-size: clamp(20px, 2.4vw, 28px);
  font-weight: 900;
  line-height: 1.28;
}

.setup-duplicate-actions,
.task-idle-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(150px, 1fr));
  gap: 14px;
  width: min(420px, 100%);
}

.setup-duplicate-actions.single {
  grid-template-columns: minmax(180px, 1fr);
  width: min(260px, 100%);
}

.setup-panel .setup-skip-login {
  position: fixed !important;
  top: auto !important;
  right: max(22px, calc(env(safe-area-inset-right) + 18px)) !important;
  bottom: max(22px, calc(env(safe-area-inset-bottom) + 18px)) !important;
  z-index: 70 !important;
  max-width: min(180px, calc(100vw - 44px)) !important;
  min-height: 36px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.86);
  color: rgba(49, 60, 72, 0.78);
  box-shadow: 0 6px 18px rgba(36, 52, 71, 0.12);
}

.cube-page.drawing-empty-canvas .task-canvas,
.clock-page.drawing-empty-canvas .task-canvas {
  border: 4px solid #f59e0b;
  border-radius: 12px;
  box-shadow: inset 0 2px 12px rgba(245, 158, 11, 0.14), 0 0 0 0 rgba(245, 158, 11, 0.28);
  animation: orangeCanvasPulse var(--attention-pulse-duration) ease-in-out infinite;
}

.cube-page.drawing-has-strokes .task-canvas,
.clock-page.drawing-has-strokes .task-canvas {
  border: 4px solid #f59e0b;
  border-radius: 12px;
  box-shadow: inset 0 2px 12px rgba(245, 158, 11, 0.12);
  animation: none;
}

.cube-page .task-canvas.locked,
.clock-page .task-canvas.locked {
  animation: none;
}

.drawing-canvas-hand-cue {
  position: absolute;
  left: 50%;
  top: 28%;
  z-index: 2;
  display: grid;
  place-items: center;
  width: clamp(58px, 7vw, 84px);
  height: clamp(58px, 7vw, 84px);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 10px 22px rgba(36, 52, 71, 0.18);
  font-size: clamp(38px, 5.4vw, 62px);
  line-height: 1;
  pointer-events: none;
  transform: translate(-50%, -50%);
  animation: idleCanvasHandTap var(--attention-pulse-duration) ease-in-out infinite;
}

.drawing-has-strokes .drawing-canvas-hand-cue {
  display: none;
}

.clock-time-reference strong {
  white-space: normal;
  font-size: clamp(36px, 4.8vw, 68px);
  line-height: 1.16;
}

.orientation-input-line,
.weekday-answer-line {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: clamp(10px, 1.8vw, 18px);
  width: 100%;
}

.orientation-input-prefix {
  color: var(--ink);
  font-size: clamp(30px, 4vw, 46px);
  font-weight: 1000;
  line-height: 1;
  white-space: nowrap;
}

.idle-answer-nudge .option:not(.picked),
.idle-answer-nudge .serial-display,
.idle-answer-nudge .year-digit-box,
.idle-answer-nudge .date-input-box,
.idle-answer-nudge .orientation-answer-box,
.idle-answer-nudge .orientation-answer-square,
.idle-answer-nudge .transcript-input,
.idle-answer-nudge .task-canvas,
.idle-answer-nudge .tap-button,
.idle-answer-nudge .sound-button {
  animation: idleAnswerFlash var(--attention-pulse-duration) ease-in-out infinite;
}

.idle-dialog-open > :not(.task-idle-dialog) .pulse,
.idle-dialog-open > :not(.task-idle-dialog) .answer-ready,
.idle-dialog-open > :not(.task-idle-dialog) .attention-nudge,
.idle-dialog-open > :not(.task-idle-dialog) .option,
.idle-dialog-open > :not(.task-idle-dialog) .serial-display,
.idle-dialog-open > :not(.task-idle-dialog) .year-digit-box,
.idle-dialog-open > :not(.task-idle-dialog) .date-input-box,
.idle-dialog-open > :not(.task-idle-dialog) .orientation-answer-box,
.idle-dialog-open > :not(.task-idle-dialog) .orientation-answer-square,
.idle-dialog-open > :not(.task-idle-dialog) .transcript-input,
.idle-dialog-open > :not(.task-idle-dialog) .task-canvas,
.idle-dialog-open > :not(.task-idle-dialog) .tap-button,
.idle-dialog-open > :not(.task-idle-dialog) .sound-button {
  animation: none !important;
}

#app:has(> .task-idle-dialog) > :not(.task-idle-dialog) .pulse,
#app:has(> .task-idle-dialog) > :not(.task-idle-dialog) .answer-ready,
#app:has(> .task-idle-dialog) > :not(.task-idle-dialog) .attention-nudge,
#app:has(> .task-idle-dialog) > :not(.task-idle-dialog) .option,
#app:has(> .task-idle-dialog) > :not(.task-idle-dialog) .tap-button,
#app:has(> .task-idle-dialog) > :not(.task-idle-dialog) .sound-button {
  animation: none !important;
}

.standalone-page-shell:has(> .task-idle-dialog) > :not(.task-idle-dialog) .pulse,
.standalone-page-shell:has(> .task-idle-dialog) > :not(.task-idle-dialog) .answer-ready,
.standalone-page-shell:has(> .task-idle-dialog) > :not(.task-idle-dialog) .attention-nudge,
.standalone-page-shell:has(> .task-idle-dialog) > :not(.task-idle-dialog) .story-action-bubble {
  animation: none !important;
}

.idle-confirm-target {
  position: relative;
  overflow: visible;
}

.idle-hand-cue {
  position: absolute;
  left: 50%;
  top: calc(100% + 12px);
  z-index: 2;
  display: grid;
  place-items: center;
  width: clamp(54px, 7vw, 76px);
  height: clamp(54px, 7vw, 76px);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 10px 22px rgba(36, 52, 71, 0.18);
  font-size: clamp(34px, 5vw, 54px);
  line-height: 1;
  pointer-events: none;
  transform: translate(-50%, 0);
  animation: idleButtonHandTap var(--attention-pulse-duration) ease-in-out infinite;
}

@keyframes orangeCanvasPulse {
  0%,
  100% {
    border-color: #f59e0b;
    box-shadow: inset 0 2px 12px rgba(245, 158, 11, 0.12), 0 0 0 0 rgba(245, 158, 11, 0.26);
  }
  50% {
    border-color: #fb923c;
    box-shadow: inset 0 2px 14px rgba(251, 146, 60, 0.22), 0 0 0 8px rgba(251, 146, 60, 0.14);
  }
}

@keyframes idleAnswerFlash {
  0%,
  100% {
    border-color: #f59e0b;
    box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.22);
  }
  50% {
    border-color: #fb923c;
    box-shadow: 0 0 0 8px rgba(251, 146, 60, 0.15);
  }
}

@keyframes idleButtonHandTap {
  0%,
  100% {
    transform: translate(-50%, 0) scale(1);
  }
  50% {
    transform: translate(-50%, 14%) scale(1.08);
  }
}

@keyframes idleCanvasHandTap {
  0%,
  100% {
    transform: translate(-50%, -50%) scale(1);
  }
  50% {
    transform: translate(-50%, -24%) scale(1.08);
  }
}
